mirror of https://github.com/ARMmbed/mbed-os.git
add ci build operations
parent
829b04cb48
commit
c968bc2f86
|
@ -11,16 +11,26 @@ SET(CMAKE_CROSSCOMPILING TRUE)
|
|||
SET(CMAKE_C_COMPILER_WORKS TRUE)
|
||||
SET(CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
|
||||
SET(CMAKE_ASM_COMPILER_INIT "{{asm}}")
|
||||
SET(CMAKE_C_COMPILER_INIT "{{cc}}")
|
||||
SET(CMAKE_CXX_COMPILER_INIT "{{cxx}}")
|
||||
SET(ELF2BIN "{{elf2bin}}")
|
||||
# force cmake compilers
|
||||
SET(CMAKE_ASM_COMPILER "{{asm}}")
|
||||
SET(CMAKE_C_COMPILER "{{cc}}")
|
||||
SET(CMAKE_CXX_COMPILER "{{cxx}}")
|
||||
SET(ELF2BIN "{{elf2bin}}")
|
||||
{% if hex_files %}
|
||||
SET(SREC_CAT "srec_cat")
|
||||
{%- 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
|
||||
PROJECT(cmake-{{name}} C CXX ASM)
|
||||
|
||||
# uncomment below to have a verbose build process
|
||||
#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 -%}")
|
||||
|
|
|
@ -16,15 +16,14 @@ limitations under the License.
|
|||
"""
|
||||
import re
|
||||
import shutil
|
||||
from os import remove
|
||||
from os.path import splitext, basename, exists
|
||||
from os import remove, getcwd, chdir, mkdir
|
||||
from os.path import basename, exists
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
|
||||
from tools.export.exporters import Exporter, apply_supported_whitelist
|
||||
from tools.targets import TARGET_MAP
|
||||
from tools.utils import NotSupportedException
|
||||
|
||||
|
||||
class CMake(Exporter):
|
||||
|
@ -126,14 +125,34 @@ class CMake(Exporter):
|
|||
@staticmethod
|
||||
def build(project_name, log_name="build_log.txt", cleanup=True):
|
||||
""" 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
|
||||
p = Popen(cmd, stdout=PIPE, stderr=PIPE)
|
||||
out, err = p.communicate()
|
||||
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 += out
|
||||
out_string += "=" * 10 + "STDERR" + "=" * 10 + "\n"
|
||||
|
@ -161,6 +180,7 @@ class CMake(Exporter):
|
|||
if exists('BUILD'):
|
||||
shutil.rmtree('BUILD')
|
||||
|
||||
|
||||
if ret_code != 0:
|
||||
# Seems like something went wrong.
|
||||
return -1
|
||||
|
|
Loading…
Reference in New Issue