add ci build operations

pull/5476/head
Matthias L. Jugel 2018-01-13 11:25:22 +01:00
parent 829b04cb48
commit c968bc2f86
2 changed files with 39 additions and 9 deletions

View File

@ -11,16 +11,26 @@ SET(CMAKE_CROSSCOMPILING TRUE)
SET(CMAKE_C_COMPILER_WORKS TRUE) SET(CMAKE_C_COMPILER_WORKS TRUE)
SET(CMAKE_CXX_COMPILER_WORKS TRUE) SET(CMAKE_CXX_COMPILER_WORKS TRUE)
SET(CMAKE_ASM_COMPILER_INIT "{{asm}}") # force cmake compilers
SET(CMAKE_C_COMPILER_INIT "{{cc}}") SET(CMAKE_ASM_COMPILER "{{asm}}")
SET(CMAKE_CXX_COMPILER_INIT "{{cxx}}") SET(CMAKE_C_COMPILER "{{cc}}")
SET(ELF2BIN "{{elf2bin}}") SET(CMAKE_CXX_COMPILER "{{cxx}}")
SET(ELF2BIN "{{elf2bin}}")
{% if hex_files %} {% if hex_files %}
SET(SREC_CAT "srec_cat") SET(SREC_CAT "srec_cat")
{%- endif %} {%- endif %}
# if the environment does not specify build type, set to Debug
IF(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug"
CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF()
# here starts the project # here starts the project
PROJECT(cmake-{{name}} C CXX ASM) PROJECT(cmake-{{name}} C CXX ASM)
# uncomment below to have a verbose build process
#SET(CMAKE_VERBOSE_MAKEFILE ON) #SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(LD_SYS_LIBS "{%- block sys_libs -%} -Wl,--start-group {{ld_sys_libs|join(" ")}} {{libraries|join(" ")}} -Wl,--end-group {%- endblock -%}") SET(LD_SYS_LIBS "{%- block sys_libs -%} -Wl,--start-group {{ld_sys_libs|join(" ")}} {{libraries|join(" ")}} -Wl,--end-group {%- endblock -%}")

View File

@ -16,15 +16,14 @@ limitations under the License.
""" """
import re import re
import shutil import shutil
from os import remove from os import remove, getcwd, chdir, mkdir
from os.path import splitext, basename, exists from os.path import basename, exists
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from jinja2.exceptions import TemplateNotFound from jinja2.exceptions import TemplateNotFound
from tools.export.exporters import Exporter, apply_supported_whitelist from tools.export.exporters import Exporter, apply_supported_whitelist
from tools.targets import TARGET_MAP from tools.targets import TARGET_MAP
from tools.utils import NotSupportedException
class CMake(Exporter): class CMake(Exporter):
@ -126,14 +125,34 @@ class CMake(Exporter):
@staticmethod @staticmethod
def build(project_name, log_name="build_log.txt", cleanup=True): def build(project_name, log_name="build_log.txt", cleanup=True):
""" Build Make project """ """ Build Make project """
# > Make -j
cmd = ["make", "-j"] # change into our build directory
current_dir = getcwd()
if not exists("BUILD"):
mkdir("BUILD")
chdir("BUILD")
# > run cmake initial command
cmd = ["cmake", ".."]
# Build the project # Build the project
p = Popen(cmd, stdout=PIPE, stderr=PIPE) p = Popen(cmd, stdout=PIPE, stderr=PIPE)
out, err = p.communicate() out, err = p.communicate()
ret_code = p.returncode ret_code = p.returncode
if ret_code == 0:
# we create the cmake files inside BUILD, change into and run cmake
# > run make -j
cmd = ["make", "-j"]
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
ret_code = p.returncode
# go back to the original directory
chdir(current_dir)
out_string = "=" * 10 + "STDOUT" + "=" * 10 + "\n" out_string = "=" * 10 + "STDOUT" + "=" * 10 + "\n"
out_string += out out_string += out
out_string += "=" * 10 + "STDERR" + "=" * 10 + "\n" out_string += "=" * 10 + "STDERR" + "=" * 10 + "\n"
@ -161,6 +180,7 @@ class CMake(Exporter):
if exists('BUILD'): if exists('BUILD'):
shutil.rmtree('BUILD') shutil.rmtree('BUILD')
if ret_code != 0: if ret_code != 0:
# Seems like something went wrong. # Seems like something went wrong.
return -1 return -1