| author | |
| committer | |
| log | e0a1466bd842f23983bb4a175bd16b005001a3f9 |
| tree | 2e1504f8e526a4b7783cd390a9e54f427045ca92 |
| parent | 2031989d981f05dca9d2b0da0bfcfb67f0333dac |
3 files changed, 40 insertions(+), 5 deletions(-)
build.zig+12-5| ... | ... | @@ -80,9 +80,12 @@ fn dependOnLib(lib_exe_obj: &std.build.LibExeObjStep, dep: &const LibraryDep) { |
| 80 | 80 | for (dep.libdirs.toSliceConst()) |lib_dir| { |
| 81 | 81 | lib_exe_obj.addLibPath(lib_dir); |
| 82 | 82 | } |
| 83 | for (dep.libs.toSliceConst()) |lib| { | |
| 83 | for (dep.system_libs.toSliceConst()) |lib| { | |
| 84 | 84 | lib_exe_obj.linkSystemLibrary(lib); |
| 85 | 85 | } |
| 86 | for (dep.libs.toSliceConst()) |lib| { | |
| 87 | lib_exe_obj.addObjectFile(lib); | |
| 88 | } | |
| 86 | 89 | for (dep.includes.toSliceConst()) |include_path| { |
| 87 | 90 | lib_exe_obj.addIncludeDir(include_path); |
| 88 | 91 | } |
| ... | ... | @@ -91,6 +94,7 @@ fn dependOnLib(lib_exe_obj: &std.build.LibExeObjStep, dep: &const LibraryDep) { |
| 91 | 94 | const LibraryDep = struct { |
| 92 | 95 | libdirs: ArrayList([]const u8), |
| 93 | 96 | libs: ArrayList([]const u8), |
| 97 | system_libs: ArrayList([]const u8), | |
| 94 | 98 | includes: ArrayList([]const u8), |
| 95 | 99 | }; |
| 96 | 100 | |
| ... | ... | @@ -98,11 +102,11 @@ fn findLLVM(b: &Builder) -> ?LibraryDep { |
| 98 | 102 | const llvm_config_exe = b.findProgram( |
| 99 | 103 | [][]const u8{"llvm-config-5.0", "llvm-config"}, |
| 100 | 104 | [][]const u8{ |
| 101 | "/usr/local/opt/llvm@5/bin", | |
| 102 | "/mingw64/bin", | |
| 105 | "C:/Libraries/llvm-5.0.0/bin", | |
| 103 | 106 | "/c/msys64/mingw64/bin", |
| 104 | 107 | "c:/msys64/mingw64/bin", |
| 105 | "C:/Libraries/llvm-5.0.0/bin", | |
| 108 | "/usr/local/opt/llvm@5/bin", | |
| 109 | "/mingw64/bin", | |
| 106 | 110 | }) %% |err| |
| 107 | 111 | { |
| 108 | 112 | warn("unable to find llvm-config: {}\n", err); |
| ... | ... | @@ -114,6 +118,7 @@ fn findLLVM(b: &Builder) -> ?LibraryDep { |
| 114 | 118 | |
| 115 | 119 | var result = LibraryDep { |
| 116 | 120 | .libs = ArrayList([]const u8).init(b.allocator), |
| 121 | .system_libs = ArrayList([]const u8).init(b.allocator), | |
| 117 | 122 | .includes = ArrayList([]const u8).init(b.allocator), |
| 118 | 123 | .libdirs = ArrayList([]const u8).init(b.allocator), |
| 119 | 124 | }; |
| ... | ... | @@ -121,7 +126,9 @@ fn findLLVM(b: &Builder) -> ?LibraryDep { |
| 121 | 126 | var it = mem.split(libs_output, " \n"); |
| 122 | 127 | while (it.next()) |lib_arg| { |
| 123 | 128 | if (mem.startsWith(u8, lib_arg, "-l")) { |
| 124 | %%result.libs.append(lib_arg[2..]); | |
| 129 | %%result.system_libs.append(lib_arg[2..]); | |
| 130 | } else { | |
| 131 | %%result.libs.append(lib_arg); | |
| 125 | 132 | } |
| 126 | 133 | } |
| 127 | 134 | } |
std/build.zig+21| ... | ... | @@ -47,6 +47,7 @@ pub const Builder = struct { |
| 47 | 47 | env_map: BufMap, |
| 48 | 48 | top_level_steps: ArrayList(&TopLevelStep), |
| 49 | 49 | prefix: []const u8, |
| 50 | search_prefixes: ArrayList([]const u8), | |
| 50 | 51 | lib_dir: []const u8, |
| 51 | 52 | exe_dir: []const u8, |
| 52 | 53 | installed_files: ArrayList([]const u8), |
| ... | ... | @@ -114,6 +115,7 @@ pub const Builder = struct { |
| 114 | 115 | .default_step = undefined, |
| 115 | 116 | .env_map = %%os.getEnvMap(allocator), |
| 116 | 117 | .prefix = undefined, |
| 118 | .search_prefixes = ArrayList([]const u8).init(allocator), | |
| 117 | 119 | .lib_dir = undefined, |
| 118 | 120 | .exe_dir = undefined, |
| 119 | 121 | .installed_files = ArrayList([]const u8).init(allocator), |
| ... | ... | @@ -671,7 +673,22 @@ pub const Builder = struct { |
| 671 | 673 | } |
| 672 | 674 | |
| 673 | 675 | pub fn findProgram(self: &Builder, names: []const []const u8, paths: []const []const u8) -> %[]const u8 { |
| 676 | // TODO report error for ambiguous situations | |
| 674 | 677 | const exe_extension = (Target { .Native = {}}).exeFileExt(); |
| 678 | for (self.search_prefixes.toSliceConst()) |search_prefix| { | |
| 679 | for (names) |name| { | |
| 680 | if (os.path.isAbsolute(name)) { | |
| 681 | return name; | |
| 682 | } | |
| 683 | const full_path = %return os.path.join(self.allocator, search_prefix, "bin", | |
| 684 | self.fmt("{}{}", name, exe_extension)); | |
| 685 | if (os.path.real(self.allocator, full_path)) |real_path| { | |
| 686 | return real_path; | |
| 687 | } else |_| { | |
| 688 | continue; | |
| 689 | } | |
| 690 | } | |
| 691 | } | |
| 675 | 692 | if (self.env_map.get("PATH")) |PATH| { |
| 676 | 693 | for (names) |name| { |
| 677 | 694 | if (os.path.isAbsolute(name)) { |
| ... | ... | @@ -727,6 +744,10 @@ pub const Builder = struct { |
| 727 | 744 | }, |
| 728 | 745 | } |
| 729 | 746 | } |
| 747 | ||
| 748 | pub fn addSearchPrefix(self: &Builder, search_prefix: []const u8) { | |
| 749 | %%self.search_prefixes.append(search_prefix); | |
| 750 | } | |
| 730 | 751 | }; |
| 731 | 752 | |
| 732 | 753 | const Version = struct { |
std/special/build_runner.zig+7| ... | ... | @@ -84,6 +84,12 @@ pub fn main() -> %void { |
| 84 | 84 | warn("Expected argument after --prefix\n\n"); |
| 85 | 85 | return usageAndErr(&builder, false, %return stderr_stream); |
| 86 | 86 | }); |
| 87 | } else if (mem.eql(u8, arg, "--search-prefix")) { | |
| 88 | const search_prefix = %return unwrapArg(arg_it.next(allocator) ?? { | |
| 89 | warn("Expected argument after --search-prefix\n\n"); | |
| 90 | return usageAndErr(&builder, false, %return stderr_stream); | |
| 91 | }); | |
| 92 | builder.addSearchPrefix(search_prefix); | |
| 87 | 93 | } else if (mem.eql(u8, arg, "--verbose-tokenize")) { |
| 88 | 94 | builder.verbose_tokenize = true; |
| 89 | 95 | } else if (mem.eql(u8, arg, "--verbose-ast")) { |
| ... | ... | @@ -145,6 +151,7 @@ fn usage(builder: &Builder, already_ran_build: bool, out_stream: &io.OutStream) |
| 145 | 151 | \\ --help Print this help and exit |
| 146 | 152 | \\ --verbose Print commands before executing them |
| 147 | 153 | \\ --prefix [path] Override default install prefix |
| 154 | \\ --search-prefix [path] Add a path to look for binaries, libraries, headers | |
| 148 | 155 | \\ |
| 149 | 156 | \\Project-Specific Options: |
| 150 | 157 | \\ |