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,...@@ -6001,21 +6001,6 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
6001 }6001 }
6002 }6002 }
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
6019 // implicit [N]T to &const []const N6004 // implicit [N]T to &const []const N
6020 if (expected_type->id == TypeTableEntryIdPointer &&6005 if (expected_type->id == TypeTableEntryIdPointer &&
6021 expected_type->data.pointer.is_const &&6006 expected_type->data.pointer.is_const &&
std/build.zig+10-12
...@@ -85,7 +85,7 @@ pub const Builder = struct {...@@ -85,7 +85,7 @@ pub const Builder = struct {
85 var self = Builder {85 var self = Builder {
86 .zig_exe = zig_exe,86 .zig_exe = zig_exe,
87 .build_root = build_root,87 .build_root = build_root,
88 .cache_root = cache_root,88 .cache_root = %%os.path.relative(allocator, build_root, cache_root),
89 .verbose = false,89 .verbose = false,
90 .invalid_user_input = false,90 .invalid_user_input = false,
91 .allocator = allocator,91 .allocator = allocator,
...@@ -565,7 +565,7 @@ pub const Builder = struct {...@@ -565,7 +565,7 @@ pub const Builder = struct {
565 }565 }
566566
567 pub fn makePath(self: &Builder, path: []const u8) -> %void {567 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| {
569 %%io.stderr.printf("Unable to create path {}: {}\n", path, @errorName(err));569 %%io.stderr.printf("Unable to create path {}: {}\n", path, @errorName(err));
570 return err;570 return err;
571 };571 };
...@@ -824,8 +824,7 @@ pub const LibExeObjStep = struct {...@@ -824,8 +824,7 @@ pub const LibExeObjStep = struct {
824 test (self.output_path) |output_path| {824 test (self.output_path) |output_path| {
825 output_path825 output_path
826 } else {826 } else {
827 const wanted_path = %%os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename);827 %%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)
829 }828 }
830 }829 }
831830
...@@ -911,7 +910,7 @@ pub const LibExeObjStep = struct {...@@ -911,7 +910,7 @@ pub const LibExeObjStep = struct {
911 }910 }
912911
913 %%zig_args.append("--cache-dir");912 %%zig_args.append("--cache-dir");
914 %%zig_args.append(builder.cache_root);913 %%zig_args.append(builder.pathFromRoot(builder.cache_root));
915914
916 const output_path = builder.pathFromRoot(self.getOutputPath());915 const output_path = builder.pathFromRoot(self.getOutputPath());
917 %%zig_args.append("--output");916 %%zig_args.append("--output");
...@@ -1207,8 +1206,7 @@ pub const CLibExeObjStep = struct {...@@ -1207,8 +1206,7 @@ pub const CLibExeObjStep = struct {
1207 test (self.output_path) |output_path| {1206 test (self.output_path) |output_path| {
1208 output_path1207 output_path
1209 } else {1208 } else {
1210 const wanted_path = %%os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename);1209 %%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)
1212 }1210 }
1213 }1211 }
12141212
...@@ -1335,7 +1333,7 @@ pub const CLibExeObjStep = struct {...@@ -1335,7 +1333,7 @@ pub const CLibExeObjStep = struct {
1335 %return builder.makePath(cache_o_dir);1333 %return builder.makePath(cache_o_dir);
1336 const cache_o_file = builder.fmt("{}{}", cache_o_src, self.target.oFileExt());1334 const cache_o_file = builder.fmt("{}{}", cache_o_src, self.target.oFileExt());
1337 %%cc_args.append("-o");1335 %%cc_args.append("-o");
1338 %%cc_args.append(cache_o_file);1336 %%cc_args.append(builder.pathFromRoot(cache_o_file));
13391337
1340 self.appendCompileFlags(&cc_args);1338 self.appendCompileFlags(&cc_args);
13411339
...@@ -1382,7 +1380,7 @@ pub const CLibExeObjStep = struct {...@@ -1382,7 +1380,7 @@ pub const CLibExeObjStep = struct {
1382 }1380 }
13831381
1384 const rpath_arg = builder.fmt("-Wl,-rpath,{}",1382 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)));
1386 defer builder.allocator.free(rpath_arg);1384 defer builder.allocator.free(rpath_arg);
1387 %%cc_args.append(rpath_arg);1385 %%cc_args.append(rpath_arg);
13881386
...@@ -1411,7 +1409,7 @@ pub const CLibExeObjStep = struct {...@@ -1411,7 +1409,7 @@ pub const CLibExeObjStep = struct {
1411 %return builder.makePath(cache_o_dir);1409 %return builder.makePath(cache_o_dir);
1412 const cache_o_file = builder.fmt("{}{}", cache_o_src, self.target.oFileExt());1410 const cache_o_file = builder.fmt("{}{}", cache_o_src, self.target.oFileExt());
1413 %%cc_args.append("-o");1411 %%cc_args.append("-o");
1414 %%cc_args.append(cache_o_file);1412 %%cc_args.append(builder.pathFromRoot(cache_o_file));
14151413
1416 for (self.cflags.toSliceConst()) |cflag| {1414 for (self.cflags.toSliceConst()) |cflag| {
1417 %%cc_args.append(cflag);1415 %%cc_args.append(cflag);
...@@ -1424,7 +1422,7 @@ pub const CLibExeObjStep = struct {...@@ -1424,7 +1422,7 @@ pub const CLibExeObjStep = struct {
14241422
1425 %return builder.spawnChild(cc, cc_args.toSliceConst());1423 %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);
1428 }1426 }
14291427
1430 %%cc_args.resize(0);1428 %%cc_args.resize(0);
...@@ -1438,7 +1436,7 @@ pub const CLibExeObjStep = struct {...@@ -1438,7 +1436,7 @@ pub const CLibExeObjStep = struct {
1438 %%cc_args.append(output_path);1436 %%cc_args.append(output_path);
14391437
1440 const rpath_arg = builder.fmt("-Wl,-rpath,{}",1438 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)));
1442 defer builder.allocator.free(rpath_arg);1440 defer builder.allocator.free(rpath_arg);
1443 %%cc_args.append(rpath_arg);1441 %%cc_args.append(rpath_arg);
14441442
test/compile_errors.zig-1
...@@ -1630,5 +1630,4 @@ pub fn addCases(cases: &tests.CompileErrorContext) {...@@ -1630,5 +1630,4 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
1630 \\}1630 \\}
1631 ,1631 ,
1632 ".tmp_source.zig:4:12: error: function returns address of local variable");1632 ".tmp_source.zig:4:12: error: function returns address of local variable");
1633
1634}1633}
test/tests.zig+5-10
...@@ -345,7 +345,6 @@ pub const CompareOutputContext = struct {...@@ -345,7 +345,6 @@ pub const CompareOutputContext = struct {
345 const b = self.b;345 const b = self.b;
346346
347 const root_src = %%os.path.join(b.allocator, b.cache_root, case.sources.items[0].filename);347 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
350 switch (case.special) {349 switch (case.special) {
351 Special.Asm => {350 Special.Asm => {
...@@ -357,7 +356,6 @@ pub const CompareOutputContext = struct {...@@ -357,7 +356,6 @@ pub const CompareOutputContext = struct {
357356
358 const exe = b.addExecutable("test", null);357 const exe = b.addExecutable("test", null);
359 exe.addAssemblyFile(root_src);358 exe.addAssemblyFile(root_src);
360 exe.setOutputPath(exe_path);
361359
362 for (case.sources.toSliceConst()) |src_file| {360 for (case.sources.toSliceConst()) |src_file| {
363 const expanded_src_path = %%os.path.join(b.allocator, b.cache_root, src_file.filename);361 const expanded_src_path = %%os.path.join(b.allocator, b.cache_root, src_file.filename);
...@@ -365,7 +363,7 @@ pub const CompareOutputContext = struct {...@@ -365,7 +363,7 @@ pub const CompareOutputContext = struct {
365 exe.step.dependOn(&write_src.step);363 exe.step.dependOn(&write_src.step);
366 }364 }
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,
369 case.expected_output);367 case.expected_output);
370 run_and_cmp_output.step.dependOn(&exe.step);368 run_and_cmp_output.step.dependOn(&exe.step);
371369
...@@ -381,7 +379,6 @@ pub const CompareOutputContext = struct {...@@ -381,7 +379,6 @@ pub const CompareOutputContext = struct {
381 }379 }
382380
383 const exe = b.addExecutable("test", root_src);381 const exe = b.addExecutable("test", root_src);
384 exe.setOutputPath(exe_path);
385 exe.setBuildMode(mode);382 exe.setBuildMode(mode);
386 if (case.link_libc) {383 if (case.link_libc) {
387 exe.linkSystemLibrary("c");384 exe.linkSystemLibrary("c");
...@@ -393,23 +390,21 @@ pub const CompareOutputContext = struct {...@@ -393,23 +390,21 @@ pub const CompareOutputContext = struct {
393 exe.step.dependOn(&write_src.step);390 exe.step.dependOn(&write_src.step);
394 }391 }
395392
396 const run_and_cmp_output = RunCompareOutputStep.create(self, exe_path, annotated_case_name,393 const run_and_cmp_output = RunCompareOutputStep.create(self, exe.getOutputPath(),
397 case.expected_output);394 annotated_case_name, case.expected_output);
398 run_and_cmp_output.step.dependOn(&exe.step);395 run_and_cmp_output.step.dependOn(&exe.step);
399396
400 self.step.dependOn(&run_and_cmp_output.step);397 self.step.dependOn(&run_and_cmp_output.step);
401 }398 }
402 },399 },
403 Special.DebugSafety => {400 Special.DebugSafety => {
404 const obj_path = %%os.path.join(b.allocator, b.cache_root, "test.o");401 const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "safety {}", case.name);
405 const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "debug-safety {}", case.name);
406 test (self.test_filter) |filter| {402 test (self.test_filter) |filter| {
407 if (mem.indexOf(u8, annotated_case_name, filter) == null)403 if (mem.indexOf(u8, annotated_case_name, filter) == null)
408 return;404 return;
409 }405 }
410406
411 const exe = b.addExecutable("test", root_src);407 const exe = b.addExecutable("test", root_src);
412 exe.setOutputPath(exe_path);
413 if (case.link_libc) {408 if (case.link_libc) {
414 exe.linkSystemLibrary("c");409 exe.linkSystemLibrary("c");
415 }410 }
...@@ -420,7 +415,7 @@ pub const CompareOutputContext = struct {...@@ -420,7 +415,7 @@ pub const CompareOutputContext = struct {
420 exe.step.dependOn(&write_src.step);415 exe.step.dependOn(&write_src.step);
421 }416 }
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);
424 run_and_cmp_output.step.dependOn(&exe.step);419 run_and_cmp_output.step.dependOn(&exe.step);
425420
426 self.step.dependOn(&run_and_cmp_output.step);421 self.step.dependOn(&run_and_cmp_output.step);