zig build: cache_root is relative to build_root

This commit is contained in:
Andrew Kelley 2017-05-03 16:00:51 -04:00
parent 6f66691214
commit 6756c27ca4
4 changed files with 15 additions and 38 deletions

View File

@ -6001,21 +6001,6 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
}
}
//// implicit [N]T to %[]const T
//if (expected_type->id == TypeTableEntryIdErrorUnion &&
// is_slice(expected_type->data.error.child_type) &&
// actual_type->id == TypeTableEntryIdArray)
//{
// TypeTableEntry *ptr_type =
// expected_type->data.error.child_type->data.structure.fields[slice_ptr_index].type_entry;
// assert(ptr_type->id == TypeTableEntryIdPointer);
// if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) &&
// types_match_const_cast_only(ptr_type->data.pointer.child_type, actual_type->data.array.child_type))
// {
// return ImplicitCastMatchResultYes;
// }
//}
// implicit [N]T to &const []const N
if (expected_type->id == TypeTableEntryIdPointer &&
expected_type->data.pointer.is_const &&

View File

@ -85,7 +85,7 @@ pub const Builder = struct {
var self = Builder {
.zig_exe = zig_exe,
.build_root = build_root,
.cache_root = cache_root,
.cache_root = %%os.path.relative(allocator, build_root, cache_root),
.verbose = false,
.invalid_user_input = false,
.allocator = allocator,
@ -565,7 +565,7 @@ pub const Builder = struct {
}
pub fn makePath(self: &Builder, path: []const u8) -> %void {
os.makePath(self.allocator, path) %% |err| {
os.makePath(self.allocator, self.pathFromRoot(path)) %% |err| {
%%io.stderr.printf("Unable to create path {}: {}\n", path, @errorName(err));
return err;
};
@ -824,8 +824,7 @@ pub const LibExeObjStep = struct {
test (self.output_path) |output_path| {
output_path
} else {
const wanted_path = %%os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename);
%%os.path.relative(self.builder.allocator, self.builder.build_root, wanted_path)
%%os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename)
}
}
@ -911,7 +910,7 @@ pub const LibExeObjStep = struct {
}
%%zig_args.append("--cache-dir");
%%zig_args.append(builder.cache_root);
%%zig_args.append(builder.pathFromRoot(builder.cache_root));
const output_path = builder.pathFromRoot(self.getOutputPath());
%%zig_args.append("--output");
@ -1207,8 +1206,7 @@ pub const CLibExeObjStep = struct {
test (self.output_path) |output_path| {
output_path
} else {
const wanted_path = %%os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename);
%%os.path.relative(self.builder.allocator, self.builder.build_root, wanted_path)
%%os.path.join(self.builder.allocator, self.builder.cache_root, self.out_filename)
}
}
@ -1335,7 +1333,7 @@ pub const CLibExeObjStep = struct {
%return builder.makePath(cache_o_dir);
const cache_o_file = builder.fmt("{}{}", cache_o_src, self.target.oFileExt());
%%cc_args.append("-o");
%%cc_args.append(cache_o_file);
%%cc_args.append(builder.pathFromRoot(cache_o_file));
self.appendCompileFlags(&cc_args);
@ -1382,7 +1380,7 @@ pub const CLibExeObjStep = struct {
}
const rpath_arg = builder.fmt("-Wl,-rpath,{}",
%%os.path.real(builder.allocator, builder.cache_root));
%%os.path.real(builder.allocator, builder.pathFromRoot(builder.cache_root)));
defer builder.allocator.free(rpath_arg);
%%cc_args.append(rpath_arg);
@ -1411,7 +1409,7 @@ pub const CLibExeObjStep = struct {
%return builder.makePath(cache_o_dir);
const cache_o_file = builder.fmt("{}{}", cache_o_src, self.target.oFileExt());
%%cc_args.append("-o");
%%cc_args.append(cache_o_file);
%%cc_args.append(builder.pathFromRoot(cache_o_file));
for (self.cflags.toSliceConst()) |cflag| {
%%cc_args.append(cflag);
@ -1424,7 +1422,7 @@ pub const CLibExeObjStep = struct {
%return builder.spawnChild(cc, cc_args.toSliceConst());
%%self.object_files.append(%%os.path.relative(builder.allocator, builder.build_root, cache_o_file));
%%self.object_files.append(cache_o_file);
}
%%cc_args.resize(0);
@ -1438,7 +1436,7 @@ pub const CLibExeObjStep = struct {
%%cc_args.append(output_path);
const rpath_arg = builder.fmt("-Wl,-rpath,{}",
%%os.path.real(builder.allocator, builder.cache_root));
%%os.path.real(builder.allocator, builder.pathFromRoot(builder.cache_root)));
defer builder.allocator.free(rpath_arg);
%%cc_args.append(rpath_arg);

View File

@ -1630,5 +1630,4 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
\\}
,
".tmp_source.zig:4:12: error: function returns address of local variable");
}

View File

@ -345,7 +345,6 @@ pub const CompareOutputContext = struct {
const b = self.b;
const root_src = %%os.path.join(b.allocator, b.cache_root, case.sources.items[0].filename);
const exe_path = %%os.path.join(b.allocator, b.cache_root, "test");
switch (case.special) {
Special.Asm => {
@ -357,7 +356,6 @@ pub const CompareOutputContext = struct {
const exe = b.addExecutable("test", null);
exe.addAssemblyFile(root_src);
exe.setOutputPath(exe_path);
for (case.sources.toSliceConst()) |src_file| {
const expanded_src_path = %%os.path.join(b.allocator, b.cache_root, src_file.filename);
@ -365,7 +363,7 @@ pub const CompareOutputContext = struct {
exe.step.dependOn(&write_src.step);
}
const run_and_cmp_output = RunCompareOutputStep.create(self, exe_path, annotated_case_name,
const run_and_cmp_output = RunCompareOutputStep.create(self, exe.getOutputPath(), annotated_case_name,
case.expected_output);
run_and_cmp_output.step.dependOn(&exe.step);
@ -381,7 +379,6 @@ pub const CompareOutputContext = struct {
}
const exe = b.addExecutable("test", root_src);
exe.setOutputPath(exe_path);
exe.setBuildMode(mode);
if (case.link_libc) {
exe.linkSystemLibrary("c");
@ -393,23 +390,21 @@ pub const CompareOutputContext = struct {
exe.step.dependOn(&write_src.step);
}
const run_and_cmp_output = RunCompareOutputStep.create(self, exe_path, annotated_case_name,
case.expected_output);
const run_and_cmp_output = RunCompareOutputStep.create(self, exe.getOutputPath(),
annotated_case_name, case.expected_output);
run_and_cmp_output.step.dependOn(&exe.step);
self.step.dependOn(&run_and_cmp_output.step);
}
},
Special.DebugSafety => {
const obj_path = %%os.path.join(b.allocator, b.cache_root, "test.o");
const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "debug-safety {}", case.name);
const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "safety {}", case.name);
test (self.test_filter) |filter| {
if (mem.indexOf(u8, annotated_case_name, filter) == null)
return;
}
const exe = b.addExecutable("test", root_src);
exe.setOutputPath(exe_path);
if (case.link_libc) {
exe.linkSystemLibrary("c");
}
@ -420,7 +415,7 @@ pub const CompareOutputContext = struct {
exe.step.dependOn(&write_src.step);
}
const run_and_cmp_output = DebugSafetyRunStep.create(self, exe_path, annotated_case_name);
const run_and_cmp_output = DebugSafetyRunStep.create(self, exe.getOutputPath(), annotated_case_name);
run_and_cmp_output.step.dependOn(&exe.step);
self.step.dependOn(&run_and_cmp_output.step);