mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 16:45:27 +00:00
caddbbc315
build.zig: add a 'compile' step to compile the self-hosted compiler without installing it. Compilation: set cache mode to whole when using the LLVM backend and --enable-cache is passed. This makes `zig build` act the same as it does with stage1. Upside is that a second invocation of `zig build` on an unmodified source tree will avoid redoing the compilation again. Downside is that it will proliferate more garbage in the project-local cache (same as stage1). This can eventually be fixed when Zig's incremental compilation is more robust; we can go back to having LLVM use CacheMode.incremental and rely on it detecting no changes and avoiding doing the flush() step.
28 lines
783 B
CMake
28 lines
783 B
CMake
set(ZIG_INSTALL_ARGS build ${ZIG_BUILD_ARGS} --prefix "${CMAKE_INSTALL_PREFIX}")
|
|
execute_process(
|
|
COMMAND "${ZIG_EXECUTABLE}" ${ZIG_INSTALL_ARGS}
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
RESULT_VARIABLE _result)
|
|
|
|
if(_result)
|
|
message("::")
|
|
message(":: ERROR: ${_result}")
|
|
message(":: (execute_process)")
|
|
|
|
list(JOIN ZIG_INSTALL_ARGS " " s_INSTALL_LIBSTAGE2_ARGS)
|
|
message("::")
|
|
message(":: argv: ${ZIG_EXECUTABLE} ${s_INSTALL_LIBSTAGE2_ARGS}")
|
|
|
|
set(_args ${ZIG_EXECUTABLE} ${ZIG_INSTALL_ARGS})
|
|
list(LENGTH _args _len)
|
|
math(EXPR _len "${_len} - 1")
|
|
message("::")
|
|
foreach(_i RANGE 0 ${_len})
|
|
list(GET _args ${_i} _arg)
|
|
message(":: argv[${_i}]: ${_arg}")
|
|
endforeach()
|
|
|
|
message("::")
|
|
message(FATAL_ERROR)
|
|
endif()
|