Compare commits
1 Commits
149d057403
...
98db66fa26
Author | SHA1 | Date | |
---|---|---|---|
98db66fa26 |
@ -1045,12 +1045,19 @@ target_compare = fn (a: Target, b: Target) u1
|
||||
return is_same_cpu and is_same_os;
|
||||
}
|
||||
|
||||
Definition = struct
|
||||
{
|
||||
name: []u8,
|
||||
value: []u8,
|
||||
}
|
||||
|
||||
CompileOptions = struct
|
||||
{
|
||||
content: []u8,
|
||||
path: []u8,
|
||||
executable: []u8,
|
||||
name: []u8,
|
||||
definitions: []Definition,
|
||||
objects: [][]u8,
|
||||
library_directories: [][]u8,
|
||||
library_names: [][]u8,
|
||||
@ -18201,6 +18208,38 @@ compile = fn (arena: &Arena, options: CompileOptions) void
|
||||
module.scope.types.first = base_type_allocation;
|
||||
module.scope.types.last = noreturn_type;
|
||||
|
||||
for (&definition: options.definitions)
|
||||
{
|
||||
>definition_global = new_global(&module);
|
||||
>definition_value = new_value(&module);
|
||||
>definition_storage = new_value(&module);
|
||||
|
||||
definition_value.& = {
|
||||
.content = {
|
||||
.string_literal = definition.value,
|
||||
},
|
||||
.id = .string_literal,
|
||||
zero,
|
||||
};
|
||||
|
||||
definition_storage.& = {
|
||||
.id = .global,
|
||||
zero,
|
||||
};
|
||||
|
||||
definition_global.& = {
|
||||
.variable = {
|
||||
.storage = definition_storage,
|
||||
.type = get_slice_type(&module, uint8(module)),
|
||||
.scope = &module.scope,
|
||||
.name = definition.name,
|
||||
zero,
|
||||
},
|
||||
.initial_value = definition_value,
|
||||
zero,
|
||||
};
|
||||
}
|
||||
|
||||
parse(&module);
|
||||
emit(&module);
|
||||
}
|
||||
@ -18269,6 +18308,12 @@ compile_file = fn (arena: &Arena, compile_options: CompileFile, envp: &&u8) []u8
|
||||
>file_path = path_absolute(arena, relative_file_path.pointer);
|
||||
>c_abi_object_path = ""; // TODO
|
||||
|
||||
>definitions: []Definition = zero;
|
||||
>cmake_prefix_path_definition: Definition = {
|
||||
.name = "CMAKE_PREFIX_PATH",
|
||||
.value = CMAKE_PREFIX_PATH,
|
||||
};
|
||||
|
||||
>objects = [ output_object_path ][..];
|
||||
>c_abi_library = "build/libc_abi.a";
|
||||
>llvm_bindings_library = "build/libllvm_bindings.a";
|
||||
@ -18282,9 +18327,11 @@ compile_file = fn (arena: &Arena, compile_options: CompileFile, envp: &&u8) []u8
|
||||
|
||||
if (is_compiler)
|
||||
{
|
||||
definitions = { .pointer = &cmake_prefix_path_definition, .length = 1 };
|
||||
|
||||
>builder: ArgumentBuilder = zero;
|
||||
|
||||
add_argument(&builder, arena_join_string(module.arena, [ CMAKE_PREFIX_PATH, "/bin/llvm-config"][..]);
|
||||
add_argument(&builder, arena_join_string(arena, [ CMAKE_PREFIX_PATH, "/bin/llvm-config"][..]));
|
||||
add_argument(&builder, "--libdir");
|
||||
add_argument(&builder, "--libs");
|
||||
add_argument(&builder, "--system-libs");
|
||||
@ -18397,6 +18444,7 @@ compile_file = fn (arena: &Arena, compile_options: CompileFile, envp: &&u8) []u8
|
||||
|
||||
>options: CompileOptions = {
|
||||
.executable = output_executable_path,
|
||||
.definitions = definitions,
|
||||
.objects = objects,
|
||||
.library_directories = library_directories,
|
||||
.library_names = library_names,
|
||||
|
@ -113,12 +113,17 @@ fn void compile(Arena* arena, Options options)
|
||||
{
|
||||
auto definition_global = new_global(&module);
|
||||
auto definition_value = new_value(&module);
|
||||
auto definition_storage = new_value(&module);
|
||||
*definition_value = {
|
||||
.string_literal = definition.value,
|
||||
.id = ValueId::string_literal,
|
||||
};
|
||||
*definition_storage = {
|
||||
.id = ValueId::global,
|
||||
};
|
||||
*definition_global = Global{
|
||||
.variable = {
|
||||
.storage = definition_storage,
|
||||
.initial_value = definition_value,
|
||||
.type = get_slice_type(&module, uint8(&module)),
|
||||
.scope = &module.scope,
|
||||
|
Loading…
x
Reference in New Issue
Block a user