| ... | ... | @@ -814,6 +814,7 @@ pub const LibExeObjStep = struct { |
| 814 | 814 | out_h_filename: []const u8, |
| 815 | 815 | assembly_files: ArrayList([]const u8), |
| 816 | 816 | packages: ArrayList(Pkg), |
| 817 | build_options_contents: std.Buffer, |
| 817 | 818 | |
| 818 | 819 | // C only stuff |
| 819 | 820 | source_files: ArrayList([]const u8), |
| ... | ... | @@ -905,6 +906,7 @@ pub const LibExeObjStep = struct { |
| 905 | 906 | .lib_paths = ArrayList([]const u8).init(builder.allocator), |
| 906 | 907 | .object_src = undefined, |
| 907 | 908 | .disable_libc = true, |
| 909 | .build_options_contents = std.Buffer.initSize(builder.allocator, 0) catch unreachable, |
| 908 | 910 | }; |
| 909 | 911 | self.computeOutFileNames(); |
| 910 | 912 | return self; |
| ... | ... | @@ -945,6 +947,7 @@ pub const LibExeObjStep = struct { |
| 945 | 947 | .out_h_filename = undefined, |
| 946 | 948 | .assembly_files = undefined, |
| 947 | 949 | .packages = undefined, |
| 950 | .build_options_contents = undefined, |
| 948 | 951 | }; |
| 949 | 952 | self.computeOutFileNames(); |
| 950 | 953 | return self; |
| ... | ... | @@ -1096,6 +1099,12 @@ pub const LibExeObjStep = struct { |
| 1096 | 1099 | self.include_dirs.append(self.builder.cache_root) catch unreachable; |
| 1097 | 1100 | } |
| 1098 | 1101 | |
| 1102 | pub fn addBuildOption(self: *LibExeObjStep, comptime T: type, name: []const u8, value: T) void { |
| 1103 | assert(self.is_zig); |
| 1104 | const out = &std.io.BufferOutStream.init(&self.build_options_contents).stream; |
| 1105 | out.print("pub const {} = {};\n", name, value) catch unreachable; |
| 1106 | } |
| 1107 | |
| 1099 | 1108 | pub fn addIncludeDir(self: *LibExeObjStep, path: []const u8) void { |
| 1100 | 1109 | self.include_dirs.append(path) catch unreachable; |
| 1101 | 1110 | } |
| ... | ... | @@ -1155,6 +1164,15 @@ pub const LibExeObjStep = struct { |
| 1155 | 1164 | zig_args.append(builder.pathFromRoot(root_src)) catch unreachable; |
| 1156 | 1165 | } |
| 1157 | 1166 | |
| 1167 | if (self.build_options_contents.len() > 0) { |
| 1168 | const build_options_file = try os.path.join(builder.allocator, builder.cache_root, builder.fmt("{}_build_options.zig", self.name)); |
| 1169 | try std.io.writeFile(builder.allocator, build_options_file, self.build_options_contents.toSliceConst()); |
| 1170 | try zig_args.append("--pkg-begin"); |
| 1171 | try zig_args.append("build_options"); |
| 1172 | try zig_args.append(builder.pathFromRoot(build_options_file)); |
| 1173 | try zig_args.append("--pkg-end"); |
| 1174 | } |
| 1175 | |
| 1158 | 1176 | for (self.object_files.toSliceConst()) |object_file| { |
| 1159 | 1177 | zig_args.append("--object") catch unreachable; |
| 1160 | 1178 | zig_args.append(builder.pathFromRoot(object_file)) catch unreachable; |