mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 00:08:56 +00:00
parent
d03fcc73fc
commit
c0b774fbc6
@ -1,6 +1,5 @@
|
||||
* add CLI support for a way to pass extra flags to c source files
|
||||
* musl
|
||||
* support rpaths in ELF linker code
|
||||
* musl
|
||||
* implement proper parsing of LLD stderr/stdout and exposing compile errors
|
||||
* tests passing with -Dskip-non-native
|
||||
* windows CUSTOMBUILD : error : unable to build compiler_rt: FileNotFound [D:\a\1\s\build\zig_install_lib_files.vcxproj]
|
||||
|
||||
@ -1947,6 +1947,7 @@ pub const LibExeObjStep = struct {
|
||||
|
||||
if (self.root_src) |root_src| try zig_args.append(root_src.getPath(builder));
|
||||
|
||||
var prev_has_extra_flags = false;
|
||||
for (self.link_objects.span()) |link_object| {
|
||||
switch (link_object) {
|
||||
.StaticPath => |static_path| {
|
||||
@ -1979,12 +1980,26 @@ pub const LibExeObjStep = struct {
|
||||
try zig_args.append(name);
|
||||
},
|
||||
.AssemblyFile => |asm_file| {
|
||||
if (prev_has_extra_flags) {
|
||||
try zig_args.append("-extra-cflags");
|
||||
try zig_args.append("--");
|
||||
prev_has_extra_flags = false;
|
||||
}
|
||||
try zig_args.append(asm_file.getPath(builder));
|
||||
},
|
||||
.CSourceFile => |c_source_file| {
|
||||
try zig_args.append("--c-source");
|
||||
for (c_source_file.args) |arg| {
|
||||
try zig_args.append(arg);
|
||||
if (c_source_file.args.len == 0) {
|
||||
if (prev_has_extra_flags) {
|
||||
try zig_args.append("-cflags");
|
||||
try zig_args.append("--");
|
||||
prev_has_extra_flags = false;
|
||||
}
|
||||
} else {
|
||||
try zig_args.append("-cflags");
|
||||
for (c_source_file.args) |arg| {
|
||||
try zig_args.append(arg);
|
||||
}
|
||||
try zig_args.append("--");
|
||||
}
|
||||
try zig_args.append(c_source_file.source.getPath(builder));
|
||||
},
|
||||
|
||||
18
src/main.zig
18
src/main.zig
@ -244,6 +244,7 @@ const usage_build_generic =
|
||||
\\ -I[dir] Add directory to include search path
|
||||
\\ -D[macro]=[value] Define C [macro] to [value] (1 if [value] omitted)
|
||||
\\ --libc [file] Provide a file which specifies libc paths
|
||||
\\ -cflags [flags] -- Set extra flags for the next positional C source files
|
||||
\\
|
||||
\\Link Options:
|
||||
\\ -l[lib], --library [lib] Link against system library
|
||||
@ -376,6 +377,9 @@ pub fn buildOutputType(
|
||||
var clang_argv = std.ArrayList([]const u8).init(gpa);
|
||||
defer clang_argv.deinit();
|
||||
|
||||
var extra_cflags = std.ArrayList([]const u8).init(gpa);
|
||||
defer extra_cflags.deinit();
|
||||
|
||||
var lld_argv = std.ArrayList([]const u8).init(gpa);
|
||||
defer lld_argv.deinit();
|
||||
|
||||
@ -469,6 +473,14 @@ pub fn buildOutputType(
|
||||
if (i + 1 >= args.len) fatal("expected parameter after {}", .{arg});
|
||||
i += 1;
|
||||
main_pkg_path = args[i];
|
||||
} else if (mem.eql(u8, arg, "-cflags")) {
|
||||
extra_cflags.shrinkRetainingCapacity(0);
|
||||
while (true) {
|
||||
i += 1;
|
||||
if (i + 1 >= args.len) fatal("expected -- after -cflags", .{});
|
||||
if (mem.eql(u8, args[i], "--")) break;
|
||||
try extra_cflags.append(args[i]);
|
||||
}
|
||||
} else if (mem.eql(u8, arg, "--color")) {
|
||||
if (i + 1 >= args.len) {
|
||||
fatal("expected [auto|on|off] after --color", .{});
|
||||
@ -713,8 +725,10 @@ pub fn buildOutputType(
|
||||
try link_objects.append(arg);
|
||||
},
|
||||
.assembly, .c, .cpp, .h, .ll, .bc => {
|
||||
// TODO a way to pass extra flags on the CLI
|
||||
try c_source_files.append(.{ .src_path = arg });
|
||||
try c_source_files.append(.{
|
||||
.src_path = arg,
|
||||
.extra_flags = try arena.dupe([]const u8, extra_cflags.items),
|
||||
});
|
||||
},
|
||||
.shared_library => {
|
||||
fatal("linking against dynamic libraries not yet supported", .{});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user