Changeset View
Changeset View
Standalone View
Standalone View
contrib/teamcity/build-configurations.py
Show All 28 Lines | def __init__(self, script_root, config_file, build_name=None): | ||||
self.config_file = config_file | self.config_file = config_file | ||||
self.name = None | self.name = None | ||||
self.config = {} | self.config = {} | ||||
self.cmake_flags = [] | self.cmake_flags = [] | ||||
self.build_steps = [] | self.build_steps = [] | ||||
self.build_directory = None | self.build_directory = None | ||||
self.junit_reports_dir = None | self.junit_reports_dir = None | ||||
self.test_logs_dir = None | self.test_logs_dir = None | ||||
self.jobs = (os.cpu_count() or 0) + 1 | |||||
self.project_root = PurePath( | self.project_root = PurePath( | ||||
subprocess.run( | subprocess.run( | ||||
['git', 'rev-parse', '--show-toplevel'], | ['git', 'rev-parse', '--show-toplevel'], | ||||
capture_output=True, | capture_output=True, | ||||
check=True, | check=True, | ||||
encoding='utf-8', | encoding='utf-8', | ||||
text=True, | text=True, | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | def load(self, build_name): | ||||
# 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") | ||||
# We will provide the required environment variables | # We will provide the required environment variables | ||||
self.environment_variables = { | self.environment_variables = { | ||||
"BUILD_DIR": str(self.build_directory), | "BUILD_DIR": str(self.build_directory), | ||||
"CMAKE_PLATFORMS_DIR": self.project_root.joinpath("cmake", "platforms"), | "CMAKE_PLATFORMS_DIR": self.project_root.joinpath("cmake", "platforms"), | ||||
"THREADS": str(os.cpu_count() or 1), | "THREADS": str(self.jobs), | ||||
"TOPLEVEL": str(self.project_root), | "TOPLEVEL": str(self.project_root), | ||||
} | } | ||||
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 | ||||
# executable, it is the only thing to run. | # executable, it is the only thing to run. | ||||
# - By defining the configuration options and a list of target groups to | # - By defining the configuration options and a list of target groups to | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | def create_build_steps(self, artifact_dir): | ||||
"-DENABLE_JUNIT_REPORT=ON", | "-DENABLE_JUNIT_REPORT=ON", | ||||
]) | ]) | ||||
if self.config.get("Werror", False): | if self.config.get("Werror", False): | ||||
self.cmake_flags.extend([ | self.cmake_flags.extend([ | ||||
"-DCMAKE_C_FLAGS=-Werror", | "-DCMAKE_C_FLAGS=-Werror", | ||||
"-DCMAKE_CXX_FLAGS=-Werror", | "-DCMAKE_CXX_FLAGS=-Werror", | ||||
]) | ]) | ||||
# Some generator flags | # Get the generator, default to ninja | ||||
generator_flags = [] | generator = self.config.get("generator", {}) | ||||
if self.config.get("fail_fast", False): | generator_name = generator.get("name", "Ninja") | ||||
generator_flags.append("-k0") | generator_command = generator.get("command", "ninja") | ||||
generator_flags = generator.get("flags", ["-k0"]) | |||||
# Max out the jobs by default when the generator uses make | |||||
if generator_command == "make": | |||||
generator_flags.append("-j{}".format(self.jobs)) | |||||
# Handle cross build configuration | # Handle cross build configuration | ||||
cross_build = self.config.get("cross_build", None) | cross_build = self.config.get("cross_build", None) | ||||
if cross_build: | if cross_build: | ||||
static_depends = cross_build.get("static_depends", None) | static_depends = cross_build.get("static_depends", None) | ||||
toolchain = cross_build.get("toolchain", None) | toolchain = cross_build.get("toolchain", None) | ||||
emulator = cross_build.get("emulator", None) | emulator = cross_build.get("emulator", None) | ||||
Show All 24 Lines | def create_build_steps(self, artifact_dir): | ||||
"-DCMAKE_CROSSCOMPILING_EMULATOR={}".format( | "-DCMAKE_CROSSCOMPILING_EMULATOR={}".format( | ||||
shutil.which(emulator)) | shutil.which(emulator)) | ||||
) | ) | ||||
# Configure using cmake. | # Configure using cmake. | ||||
self.build_steps.append( | self.build_steps.append( | ||||
{ | { | ||||
"bin": "cmake", | "bin": "cmake", | ||||
# TODO: let the generator be configurable | "args": ["-G", generator_name, str(self.project_root)] + self.cmake_flags, | ||||
"args": ["-G", "Ninja", str(self.project_root)] + self.cmake_flags, | |||||
} | } | ||||
) | ) | ||||
for target_group in targets: | for target_group in targets: | ||||
self.build_steps.append( | self.build_steps.append( | ||||
{ | { | ||||
# TODO: let the generator be configurable | "bin": generator_command, | ||||
"bin": "ninja", | |||||
"args": generator_flags + target_group, | "args": generator_flags + target_group, | ||||
} | } | ||||
) | ) | ||||
def get(self, key, default): | def get(self, key, default): | ||||
return self.config.get(key, default) | return self.config.get(key, default) | ||||
▲ Show 20 Lines • Show All 277 Lines • Show Last 20 Lines |