zig/0001-Fedora-bootstrap-and-extra-build-flags-support.patch
2024-06-11 14:03:34 +02:00

60 lines
2.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aleksei Bavshin <alebastr89@gmail.org>
Date: Fri, 20 Oct 2023 04:49:46 +0000
Subject: [PATCH] Fedora: bootstrap and extra build flags support
- Allow passing ZIG_EXTRA_BUILD_FLAGS for stage3 build.
- Allow redefining ZIG_EXECUTABLE and short-circuiting to stage3 build
when using a prebuilt compiler from bootstrap package.
- Bump required CMake version to 3.14 to enable generator expression
expansion in `install(CODE ...)`.
Signed-off-by: Jan200101 <sentrycraft123@gmail.com>
---
CMakeLists.txt | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 22051f1902..06df068919 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -922,6 +922,9 @@ if(MSVC OR MINGW)
target_link_libraries(zig2 LINK_PUBLIC version)
endif()
+# Fedora customizations
+set(ZIG_EXTRA_BUILD_ARGS "" CACHE STRING "Extra flags for stage3 build")
+set(ZIG_EXECUTABLE "$<TARGET_FILE:zig2>" CACHE STRING "Compiler command to use for stage3 build")
# "-Dno-langref" and "-Dstd-docs=false" are hardcoded because they take too long to build.
# To obtain these two forms of documentation, run zig build against stage3 rather than stage2.
@@ -937,6 +940,8 @@ set(ZIG_BUILD_ARGS
-Dno-langref
-Dstd-docs=false
+
+ ${ZIG_EXTRA_BUILD_ARGS}
)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
@@ -976,17 +981,12 @@ set(ZIG2_WORKING_DIR "${PROJECT_SOURCE_DIR}")
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/stage3/bin/zig"
- COMMAND zig2 build --prefix "${PROJECT_BINARY_DIR}/stage3" ${ZIG_BUILD_ARGS}
+ COMMAND ${ZIG_EXECUTABLE} build --prefix "${PROJECT_BINARY_DIR}/stage3" ${ZIG_BUILD_ARGS}
COMMENT STATUS "Building stage3"
+ DEPENDS zigcpp
WORKING_DIRECTORY "${ZIG2_WORKING_DIR}"
)
-if(WIN32)
- set(ZIG_EXECUTABLE "${PROJECT_BINARY_DIR}/zig2.exe")
-else()
- set(ZIG_EXECUTABLE "${PROJECT_BINARY_DIR}/zig2")
-endif()
-
install(CODE "set(ZIG_EXECUTABLE \"${ZIG_EXECUTABLE}\")")
install(CODE "set(ZIG_BUILD_ARGS \"${ZIG_BUILD_ARGS}\")")
install(CODE "set(ZIG2_WORKING_DIR \"${ZIG2_WORKING_DIR}\")")