Ability to set CMAKE_PREFIX_PATH from env vars
All checks were successful
CI / ci (Release, ubuntu-latest) (pull_request) Successful in 29s
CI / ci (Release-assertions, ubuntu-latest) (pull_request) Successful in 34s
CI / ci (Release, ubuntu-latest) (push) Successful in 30s
CI / ci (Release-assertions, ubuntu-latest) (push) Successful in 40s
CI / ci (Debug, ubuntu-latest) (push) Successful in 8m0s
CI / release (ubuntu-latest) (push) Successful in 7s

This commit is contained in:
David Gonzalez Martin 2025-06-24 21:56:46 -06:00
parent 57edde0823
commit 9508cd7275
4 changed files with 29 additions and 0 deletions

View File

@ -77,6 +77,8 @@ O = bits u32
[extern] memcpy = fn [cc(c)] (destination: &u8, source: &u8, byte_count: u64) &u8;
[extern] exit = fn [cc(c)] (exit_code: int) noreturn;
[extern] getenv = fn [cc(c)] (env: &u8) &u8;
[extern] realpath = fn [cc(c)] (source_path: &u8, resolved_path: &u8) &u8;
[extern] mkdir = fn [cc(c)] (path: &u8, mode: mode_t) int;
@ -18356,6 +18358,16 @@ compile_file = fn (arena: &Arena, compile_options: CompileFile, envp: &&u8) []u8
.value = CMAKE_PREFIX_PATH,
};
if (is_compiler)
{
>cmake_prefix_path_cstr = getenv("CMAKE_PREFIX_PATH");
if (cmake_prefix_path_cstr)
{
>cmake_prefix_path_value = c_string_to_slice(cmake_prefix_path_cstr);
cmake_prefix_path_definition.value = cmake_prefix_path_value;
}
}
>objects = [ output_object_path ][..];
>c_abi_library = "build/libc_abi.a";
>llvm_bindings_library = "build/libllvm_bindings.a";

View File

@ -221,6 +221,16 @@ fn String compile_file(Arena* arena, Compile options)
.value = cmake_prefix_path,
};
if (is_compiler)
{
auto cmake_prefix_path_cstr = os_get_environment_variable("CMAKE_PREFIX_PATH");
if (cmake_prefix_path_cstr)
{
auto cmake_prefix_path_string = c_string_to_slice(cmake_prefix_path_cstr);
cmake_prefix_path_definition.value = cmake_prefix_path_string;
}
}
String objects[] = {
output_object_path,
};

View File

@ -225,3 +225,9 @@ Execution os_execute(Arena* arena, Slice<char* const> arguments, Slice<char* con
return execution;
}
extern "C" char* getenv(const char*);
char* os_get_environment_variable(const char* env)
{
return getenv(env);
}

View File

@ -719,3 +719,4 @@ struct Execution
};
Execution os_execute(Arena* arena, Slice<char* const> arguments, Slice<char* const> environment, ExecuteOptions options);
char* os_get_environment_variable(const char* env);