authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-05-03 16:00:51-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-05-03 16:13:57-04:00
log6756c27ca48f65c7f21b7a4365ff7a80069d2441
tree02421041aafc483e0fc9611ce194104bc49fd587
parent6f66691214a0709d913d15772e7b130ede7977c9

zig build: cache_root is relative to build_root


4 files changed, 15 insertions(+), 38 deletions(-)

src/ir.cpp-15
......@@ -6001,21 +6001,6 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
60016001 }
60026002 }
60036003
6004 //// implicit [N]T to %[]const T
6005 //if (expected_type->id == TypeTableEntryIdErrorUnion &&
6006 // is_slice(expected_type->data.error.child_type) &&
6007 // actual_type->id == TypeTableEntryIdArray)
6008 //{
6009 // TypeTableEntry *ptr_type =
6010 // expected_type->data.error.child_type->data.structure.fields[slice_ptr_index].type_entry;
6011 // assert(ptr_type->id == TypeTableEntryIdPointer);
6012 // if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
6013 // types_match_const_cast_only(ptr_type->data.pointer.child_type, actual_type->data.array.child_type))
6014 // {
6015 // return ImplicitCastMatchResultYes;
6016 // }
6017 //}
6018
60196004 // implicit [N]T to &const []const N
60206005 if (expected_type->id == TypeTableEntryIdPointer &&
60216006 expected_type->data.pointer.is_const &&
std/build.zig+10-12
......@@ -85,7 +85,7 @@ pub const Builder = struct {
8585 var self = Builder {
8686 .zig_exe = zig_exe,
8787 .build_root = build_root,
88 .cache_root = cache_root,
88 .cache_root = %%os.path.relative(allocator, build_root, cache_root),
8989 .verbose = false,
9090 .invalid_user_input = false,
9191 .allocator = allocator,
......@@ -565,7 +565,7 @@ pub const Builder = struct {
565565 }
566566
567567 pub fn makePath(self: &Builder, path: []const u8) -> %void {
568 os.makePath(self.allocator, path) %% |err| {
568 os.makePath(self.allocator, self.pathFromRoot(path)) %% |err| {
569569 %%io.stderr.printf("Unable to create path {}: {}\n", path, @errorName(err));
570570 return err;
571571 };
......@@ -824,8 +824,7 @@ pub const LibExeObjStep = struct {
824824 test (self.output_path) |output_path| {
825825 output_path
826826 } else {
827 const wanted_path = %%os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename);
828 %%os.path.relative(self.builder.allocator, self.builder.build_root, wanted_path)
827 %%os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename)
829828 }
830829 }
831830
......@@ -911,7 +910,7 @@ pub const LibExeObjStep = struct {
911910 }
912911
913912 %%zig_args.append("--cache-dir");
914 %%zig_args.append(builder.cache_root);
913 %%zig_args.append(builder.pathFromRoot(builder.cache_root));
915914
916915 const output_path = builder.pathFromRoot(self.getOutputPath());
917916 %%zig_args.append("--output");
......@@ -1207,8 +1206,7 @@ pub const CLibExeObjStep = struct {
12071206 test (self.output_path) |output_path| {
12081207 output_path
12091208 } else {
1210 const wanted_path = %%os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename);
1211 %%os.path.relative(self.builder.allocator, self.builder.build_root, wanted_path)
1209 %%os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename)
12121210 }
12131211 }
12141212
......@@ -1335,7 +1333,7 @@ pub const CLibExeObjStep = struct {
13351333 %return builder.makePath(cache_o_dir);
13361334 const cache_o_file = builder.fmt("{}{}", cache_o_src, self.target.oFileExt());
13371335 %%cc_args.append("-o");
1338 %%cc_args.append(cache_o_file);
1336 %%cc_args.append(builder.pathFromRoot(cache_o_file));
13391337
13401338 self.appendCompileFlags(&cc_args);
13411339
......@@ -1382,7 +1380,7 @@ pub const CLibExeObjStep = struct {
13821380 }
13831381
13841382 const rpath_arg = builder.fmt("-Wl,-rpath,{}",
1385 %%os.path.real(builder.allocator, builder.cache_root));
1383 %%os.path.real(builder.allocator, builder.pathFromRoot(builder.cache_root)));
13861384 defer builder.allocator.free(rpath_arg);
13871385 %%cc_args.append(rpath_arg);
13881386
......@@ -1411,7 +1409,7 @@ pub const CLibExeObjStep = struct {
14111409 %return builder.makePath(cache_o_dir);
14121410 const cache_o_file = builder.fmt("{}{}", cache_o_src, self.target.oFileExt());
14131411 %%cc_args.append("-o");
1414 %%cc_args.append(cache_o_file);
1412 %%cc_args.append(builder.pathFromRoot(cache_o_file));
14151413
14161414 for (self.cflags.toSliceConst()) |cflag| {
14171415 %%cc_args.append(cflag);
......@@ -1424,7 +1422,7 @@ pub const CLibExeObjStep = struct {
14241422
14251423 %return builder.spawnChild(cc, cc_args.toSliceConst());
14261424
1427 %%self.object_files.append(%%os.path.relative(builder.allocator, builder.build_root, cache_o_file));
1425 %%self.object_files.append(cache_o_file);
14281426 }
14291427
14301428 %%cc_args.resize(0);
......@@ -1438,7 +1436,7 @@ pub const CLibExeObjStep = struct {
14381436 %%cc_args.append(output_path);
14391437
14401438 const rpath_arg = builder.fmt("-Wl,-rpath,{}",
1441 %%os.path.real(builder.allocator, builder.cache_root));
1439 %%os.path.real(builder.allocator, builder.pathFromRoot(builder.cache_root)));
14421440 defer builder.allocator.free(rpath_arg);
14431441 %%cc_args.append(rpath_arg);
14441442
test/compile_errors.zig-1
......@@ -1630,5 +1630,4 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
16301630 \\}
16311631 ,
16321632 ".tmp_source.zig:4:12: error: function returns address of local variable");
1633
16341633}
test/tests.zig+5-10
......@@ -345,7 +345,6 @@ pub const CompareOutputContext = struct {
345345 const b = self.b;
346346
347347 const root_src = %%os.path.join(b.allocator, b.cache_root, case.sources.items[0].filename);
348 const exe_path = %%os.path.join(b.allocator, b.cache_root, "test");
349348
350349 switch (case.special) {
351350 Special.Asm => {
......@@ -357,7 +356,6 @@ pub const CompareOutputContext = struct {
357356
358357 const exe = b.addExecutable("test", null);
359358 exe.addAssemblyFile(root_src);
360 exe.setOutputPath(exe_path);
361359
362360 for (case.sources.toSliceConst()) |src_file| {
363361 const expanded_src_path = %%os.path.join(b.allocator, b.cache_root, src_file.filename);
......@@ -365,7 +363,7 @@ pub const CompareOutputContext = struct {
365363 exe.step.dependOn(&write_src.step);
366364 }
367365
368 const run_and_cmp_output = RunCompareOutputStep.create(self, exe_path, annotated_case_name,
366 const run_and_cmp_output = RunCompareOutputStep.create(self, exe.getOutputPath(), annotated_case_name,
369367 case.expected_output);
370368 run_and_cmp_output.step.dependOn(&exe.step);
371369
......@@ -381,7 +379,6 @@ pub const CompareOutputContext = struct {
381379 }
382380
383381 const exe = b.addExecutable("test", root_src);
384 exe.setOutputPath(exe_path);
385382 exe.setBuildMode(mode);
386383 if (case.link_libc) {
387384 exe.linkSystemLibrary("c");
......@@ -393,23 +390,21 @@ pub const CompareOutputContext = struct {
393390 exe.step.dependOn(&write_src.step);
394391 }
395392
396 const run_and_cmp_output = RunCompareOutputStep.create(self, exe_path, annotated_case_name,
397 case.expected_output);
393 const run_and_cmp_output = RunCompareOutputStep.create(self, exe.getOutputPath(),
394 annotated_case_name, case.expected_output);
398395 run_and_cmp_output.step.dependOn(&exe.step);
399396
400397 self.step.dependOn(&run_and_cmp_output.step);
401398 }
402399 },
403400 Special.DebugSafety => {
404 const obj_path = %%os.path.join(b.allocator, b.cache_root, "test.o");
405 const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "debug-safety {}", case.name);
401 const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "safety {}", case.name);
406402 test (self.test_filter) |filter| {
407403 if (mem.indexOf(u8, annotated_case_name, filter) == null)
408404 return;
409405 }
410406
411407 const exe = b.addExecutable("test", root_src);
412 exe.setOutputPath(exe_path);
413408 if (case.link_libc) {
414409 exe.linkSystemLibrary("c");
415410 }
......@@ -420,7 +415,7 @@ pub const CompareOutputContext = struct {
420415 exe.step.dependOn(&write_src.step);
421416 }
422417
423 const run_and_cmp_output = DebugSafetyRunStep.create(self, exe_path, annotated_case_name);
418 const run_and_cmp_output = DebugSafetyRunStep.create(self, exe.getOutputPath(), annotated_case_name);
424419 run_and_cmp_output.step.dependOn(&exe.step);
425420
426421 self.step.dependOn(&run_and_cmp_output.step);