Changeset View
Changeset View
Standalone View
Standalone View
contrib/teamcity/build-configurations.py
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | def load(self, build_name): | ||||
self.config = always_merger.merge(template_config, build) | self.config = always_merger.merge(template_config, build) | ||||
# Create the build directory as needed | # Create the build directory as needed | ||||
self.build_directory = Path( | self.build_directory = Path( | ||||
self.project_root.joinpath( | self.project_root.joinpath( | ||||
'abc-ci-builds', | 'abc-ci-builds', | ||||
self.name)) | self.name)) | ||||
self.build_directory.mkdir(exist_ok=True, parents=True) | |||||
# Define the junit and logs directories | # Define the junit and logs directories | ||||
self.junit_reports_dir = self.build_directory.joinpath("test/junit") | self.junit_reports_dir = self.build_directory.joinpath("test/junit") | ||||
self.test_logs_dir = self.build_directory.joinpath("test/log") | self.test_logs_dir = self.build_directory.joinpath("test/log") | ||||
def create_build_steps(self, artifact_dir): | def create_build_steps(self, artifact_dir): | ||||
# There are 2 possibilities to define the build steps: | # There are 2 possibilities to define the build steps: | ||||
# - By defining a script to run. If such a script is set and is | # - By defining a script to run. If such a script is set and is | ||||
Show All 28 Lines | def create_build_steps(self, artifact_dir): | ||||
if not targets: | if not targets: | ||||
raise AssertionError( | raise AssertionError( | ||||
"No build target has been provided for build {} and no script is defined, aborting".format( | "No build target has been provided for build {} and no script is defined, aborting".format( | ||||
self.name | self.name | ||||
) | ) | ||||
) | ) | ||||
# Some more flags for the build_cmake.sh script | # Some more flags for the build_cmake.sh script | ||||
build_cmake_flags = [] | |||||
if self.config.get("Werror", False): | |||||
build_cmake_flags.append("--Werror") | |||||
if self.config.get("junit", True): | |||||
build_cmake_flags.append("--junit") | |||||
if self.config.get("clang", False): | if self.config.get("clang", False): | ||||
build_cmake_flags.append("--clang") | self.cmake_flags.extend([ | ||||
"-DCMAKE_C_COMPILER=clang", | |||||
"-DCMAKE_CXX_COMPILER=clang++", | |||||
]) | |||||
if self.config.get("gcc", False): | |||||
self.cmake_flags.extend([ | |||||
"-DCMAKE_C_COMPILER=gcc", | |||||
"-DCMAKE_CXX_COMPILER=g++", | |||||
]) | |||||
if self.config.get("junit", True): | |||||
self.cmake_flags.extend([ | |||||
"-DENABLE_JUNIT_REPORT=ON", | |||||
]) | |||||
if self.config.get("Werror", False): | |||||
self.cmake_flags.extend([ | |||||
"-DCMAKE_C_FLAGS=-Werror", | |||||
"-DCMAKE_CXX_FLAGS=-Werror", | |||||
]) | |||||
# Some generator flags | # Some generator flags | ||||
generator_flags = [] | generator_flags = [] | ||||
if self.config.get("fail_fast", False): | if self.config.get("fail_fast", False): | ||||
generator_flags.append("-k0") | generator_flags.append("-k0") | ||||
# Handle cross build configuration | # Handle cross build configuration | ||||
cross_build = self.config.get("cross_build", None) | cross_build = self.config.get("cross_build", None) | ||||
Show All 25 Lines | def create_build_steps(self, artifact_dir): | ||||
) | ) | ||||
if emulator: | if emulator: | ||||
self.cmake_flags.append( | self.cmake_flags.append( | ||||
"-DCMAKE_CROSSCOMPILING_EMULATOR={}".format( | "-DCMAKE_CROSSCOMPILING_EMULATOR={}".format( | ||||
shutil.which(emulator)) | shutil.which(emulator)) | ||||
) | ) | ||||
# First call should use the build_cmake.sh script in order to run | # Configure using cmake. | ||||
# cmake. | |||||
self.build_steps.append( | self.build_steps.append( | ||||
{ | { | ||||
"bin": str(self.project_root.joinpath("contrib/devtools/build_cmake.sh")), | "bin": "cmake", | ||||
"args": targets[0] + build_cmake_flags, | # TODO: let the generator be configurable | ||||
"args": ["-G", "Ninja", str(self.project_root)] + self.cmake_flags, | |||||
} | } | ||||
) | ) | ||||
for target_group in targets[1:]: | for target_group in targets: | ||||
self.build_steps.append( | self.build_steps.append( | ||||
{ | { | ||||
# TODO: let the generator be configurable | # TODO: let the generator be configurable | ||||
"bin": "ninja", | "bin": "ninja", | ||||
"args": generator_flags + target_group, | "args": generator_flags + target_group, | ||||
} | } | ||||
) | ) | ||||
Show All 20 Lines | def __init__(self, configuration): | ||||
# Build 2 log files: | # Build 2 log files: | ||||
# - the full log will contain all unfiltered content | # - the full log will contain all unfiltered content | ||||
# - the clean log will contain the same filtered content as what is | # - the clean log will contain the same filtered content as what is | ||||
# printed to stdout. This filter is done in print_line_to_logs(). | # printed to stdout. This filter is done in print_line_to_logs(). | ||||
self.logs = {} | self.logs = {} | ||||
self.logs["clean_log"] = build_directory.joinpath( | self.logs["clean_log"] = build_directory.joinpath( | ||||
"build.clean.log") | "build.clean.log") | ||||
if self.logs["clean_log"].is_file(): | |||||
self.logs["clean_log"].unlink() | |||||
self.logs["full_log"] = build_directory.joinpath("build.full.log") | self.logs["full_log"] = build_directory.joinpath("build.full.log") | ||||
if self.logs["full_log"].is_file(): | |||||
self.logs["full_log"].unlink() | # Clean the build directory before any build step is run. | ||||
if self.configuration.build_directory.is_dir(): | |||||
shutil.rmtree(self.configuration.build_directory) | |||||
self.configuration.build_directory.mkdir(exist_ok=True, parents=True) | |||||
def copy_artifacts(self, artifacts): | def copy_artifacts(self, artifacts): | ||||
# Make sure the artifact directory always exists. It is created before | # Make sure the artifact directory always exists. It is created before | ||||
# the build is run (to let the build install things to it) but since we | # the build is run (to let the build install things to it) but since we | ||||
# have no control on what is being executed, it might very well be | # have no control on what is being executed, it might very well be | ||||
# deleted by the build as well. This can happen when the artifacts | # deleted by the build as well. This can happen when the artifacts | ||||
# are located in the build directory and the build calls git clean. | # are located in the build directory and the build calls git clean. | ||||
self.artifact_dir.mkdir(exist_ok=True) | self.artifact_dir.mkdir(exist_ok=True) | ||||
▲ Show 20 Lines • Show All 248 Lines • Show Last 20 Lines |