Skip to content

Commit

Permalink
update the way we pass definitions to cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-sevostianov-sc committed Jan 17, 2023
1 parent 182f685 commit 77b3ec5
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 19 deletions.
4 changes: 2 additions & 2 deletions launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 3.17.0)
set (CMAKE_SYSTEM_VERSION 6.1 CACHE TYPE INTERNAL FORCE)
project (launcher C)
add_definitions(-DGUI -DWIN32_LEAN_AND_MEAN)
add_executable(launcher ../../launcher.c)
add_definitions(-DGUI=${GUI} -DWIN32_LEAN_AND_MEAN)
add_executable(launcher ../launcher.c)
Binary file modified setuptools/cli-32.exe
Binary file not shown.
Binary file modified setuptools/cli-64.exe
Binary file not shown.
Binary file modified setuptools/cli-arm64.exe
Binary file not shown.
Binary file modified setuptools/cli.exe
Binary file not shown.
Binary file modified setuptools/gui-32.exe
Binary file not shown.
Binary file modified setuptools/gui-64.exe
Binary file not shown.
Binary file modified setuptools/gui-arm64.exe
Binary file not shown.
Binary file modified setuptools/gui.exe
Binary file not shown.
24 changes: 7 additions & 17 deletions tools/build_launchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
GUI = {"cli": 0, "gui": 1}
BUILD_PLATFORMS = ["Win32", "x64", "arm64"]
REPO_ROOT = Path(__file__).parent.parent.resolve()
LAUNCHER_PROJECT_ROOT = REPO_ROOT / "launcher"
LAUNCHER_CMAKE_PROJECT = REPO_ROOT / "launcher"
MSBUILD_OUT_DIR = REPO_ROOT / "setuptools"
"""
Might be modified to visual studio that currently installed on the machine.
Expand Down Expand Up @@ -54,9 +54,9 @@ def get_executable_name(name, platform: str):
return f"{name}-{platform}"


def generate_cmake_project(cmake, build_arena, cmake_project_path, platform):
def generate_cmake_project(cmake, build_arena, cmake_project_path, platform, is_gui):
subprocess.check_call(f'{cmake} -G "{VISUAL_STUDIO_VERSION}" -A "{platform}"'
f' {cmake_project_path}', cwd=build_arena, shell=True)
f' {cmake_project_path} -DGUI={is_gui}', cwd=build_arena, shell=True)


def build_cmake_project_with_msbuild(msbuild, build_arena, msbuild_parameters):
Expand Down Expand Up @@ -96,7 +96,7 @@ def get_msbuild():
'-products * -requires Microsoft.Component.'
'MSBuild -find MSBuild\\**\\Bin\\MSBuild.exe',
shell=True, encoding="utf-8").strip()
if msbuild_path is "":
if msbuild_path == "":
raise
except Exception:
raise Exception("Ensure that Visual Studio is installed correctly")
Expand All @@ -107,28 +107,18 @@ def main():
msbuild = f'"{get_msbuild()}"'

build_arena = REPO_ROOT / "build-arena"
launcher_project_in_arena = build_arena / "launcher"
for platform in BUILD_PLATFORMS:
for target in BUILD_TARGETS:
print(f"Building {target} for {platform}")
if build_arena.exists():
shutil.rmtree(build_arena)
build_arena.mkdir()

# Since MSBuild does not allow to pass compile definitions we modify them
# per target in CMakeLists.txt
shutil.copytree(REPO_ROOT / LAUNCHER_PROJECT_ROOT,
launcher_project_in_arena)
cmake_lists = launcher_project_in_arena / "CMakeLists.txt"
modified_definition = cmake_lists.read_text(encoding="utf-8") \
.replace("GUI",
f"GUI={GUI[target]}")
cmake_lists.write_text(modified_definition)

generate_cmake_project(cmake,
build_arena,
(build_arena / "launcher").resolve(),
platform)
LAUNCHER_CMAKE_PROJECT,
platform,
GUI[target])

build_params = f"/t:build " \
f"/property:Configuration=Release " \
Expand Down

0 comments on commit 77b3ec5

Please sign in to comment.