Skip to content

Commit

Permalink
Merge pull request #30 from nitanmarcel/0.13.0
Browse files Browse the repository at this point in the history
Fix building on 0.13.0 and above
  • Loading branch information
lassade authored Jun 12, 2024
2 parents b22872e + b8e1f4b commit 25ffa95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn build(b: *std.Build) void {
.name = "c2z",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
Expand Down Expand Up @@ -55,7 +55,7 @@ pub fn build(b: *std.Build) void {
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const test_cases = b.addTest(.{
.root_source_file = .{ .path = "./test_cases/tests.zig" },
.root_source_file = b.path("./test_cases/tests.zig"),
.target = target,
.optimize = optimize,
});
Expand All @@ -67,29 +67,29 @@ pub fn build(b: *std.Build) void {
.target = target,
.optimize = optimize,
});
lib.addIncludePath(.{ .path = "./test_cases/include" });
lib.addIncludePath(b.path("./test_cases/include"));
if (target.result.abi == .msvc) {
lib.linkLibC();
} else {
lib.linkLibCpp();
}
//lib.addCSourceFile("./test_cases/include/c002_cpp_structs.cpp", cflags);
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/include/c005_inheritance.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/include/c013_cpp_vector.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/include/c022_cpp_string.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/include/c023_cpp_nested_structs.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/include/c024_cpp_bitfields.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/include/c005_inheritance.cpp"), .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/include/c013_cpp_vector.cpp"), .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/include/c022_cpp_string.cpp"), .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/include/c023_cpp_nested_structs.cpp"), .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/include/c024_cpp_bitfields.cpp"), .flags = cflags });
//lib.addCSourceFile("./test_cases/c001_c_structs_glue.cpp", cflags);
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/c005_inheritance_glue.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/c009_enum_flags_glue.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/c011_index_this_glue.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/c013_cpp_vector_glue.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/c022_cpp_string_glue.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/c023_cpp_nested_structs_glue.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = .{ .path = "./test_cases/c024_cpp_bitfields_glue.cpp" }, .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/c005_inheritance_glue.cpp"), .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/c009_enum_flags_glue.cpp"), .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/c011_index_this_glue.cpp"), .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/c013_cpp_vector_glue.cpp"), .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/c022_cpp_string_glue.cpp"), .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/c023_cpp_nested_structs_glue.cpp"), .flags = cflags });
lib.addCSourceFile(.{ .file = b.path("./test_cases/c024_cpp_bitfields_glue.cpp"), .flags = cflags });
test_cases.linkLibrary(lib);

const cpp_mod = b.addModule("cpp", .{ .root_source_file = .{ .path = "src/cpp.zig" } });
const cpp_mod = b.addModule("cpp", .{ .root_source_file = b.path("src/cpp.zig") });
test_cases.root_module.addImport("cpp", cpp_mod);

const run_test_cases = b.addRunArtifact(test_cases);
Expand Down
4 changes: 2 additions & 2 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub fn main() !void {
try clang.append(file_path);
defer _ = clang.pop();

const astdump = try std.ChildProcess.run(.{
const astdump = try std.process.Child.run(.{
.allocator = allocator,
.argv = clang.items,
.max_output_bytes = 4 * 512 * 1024 * 1024,
Expand Down Expand Up @@ -168,7 +168,7 @@ pub fn main() !void {
try zfmt_args.append("fmt");
try zfmt_args.append(output_path.items);

var zfmt = std.ChildProcess.init(zfmt_args.items, allocator);
var zfmt = std.process.Child.init(zfmt_args.items, allocator);
zfmt.stderr_behavior = .Ignore;
zfmt.stdout_behavior = .Ignore;
_ = try zfmt.spawnAndWait();
Expand Down

0 comments on commit 25ffa95

Please sign in to comment.