-
-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#465 change from defineCMacro to addCMacro #466
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@kassane - you want to review this change please Tested using this https://github.com/zigster64/zig-xlsxwriter/blob/fix-add-c-macro/build.zig.zon to build the zig lib using the above changes. So you will need to update the hash in your main lib. Thanks |
kassane
approved these changes
Dec 24, 2024
Nice contribution. This closes #465 If you want, you could extend the change, based on: suggestion patchdiff --git a/build.zig b/build.zig
index a4450916..c80f9df5 100644
--- a/build.zig
+++ b/build.zig
@@ -35,7 +35,7 @@ pub fn build(b: *std.Build) void {
}
if (tests)
lib.root_module.addCMacro("TESTING", "");
- lib.addCSourceFiles(.{
+ lib.root_module.addCSourceFiles(.{
.files = &.{
"src/vml.c",
"src/chartsheet.c",
@@ -69,7 +69,7 @@ pub fn build(b: *std.Build) void {
// minizip
if (minizip) {
- lib.addCSourceFiles(.{
+ lib.root_module.addCSourceFiles(.{
.files = switch (lib.rootModuleTarget().os.tag) {
.windows => minizip_src ++ [_][]const u8{
"third_party/minizip/iowin32.c",
@@ -86,31 +86,31 @@ pub fn build(b: *std.Build) void {
// md5
if (!md5)
- lib.addCSourceFile(.{
+ lib.root_module.addCSourceFile(.{
.file = b.path("third_party/md5/md5.c"),
.flags = cflags,
})
else
- lib.linkSystemLibrary("crypto");
+ lib.root_module.linkSystemLibrary("crypto", .{});
// dtoa
if (dtoa)
- lib.addCSourceFile(.{
+ lib.root_module.addCSourceFile(.{
.file = b.path("third_party/dtoa/emyg_dtoa.c"),
.flags = cflags,
});
// tmpfileplus
if (stdtmpfile)
- lib.addCSourceFile(.{
+ lib.root_module.addCSourceFile(.{
.file = b.path("third_party/tmpfileplus/tmpfileplus.c"),
.flags = cflags,
})
else
lib.root_module.addCMacro("USE_STANDARD_TMPFILE", "");
- lib.addIncludePath(b.path("include"));
- lib.addIncludePath(b.path("third_party"));
+ lib.root_module.addIncludePath(b.path("include"));
+ lib.root_module.addIncludePath(b.path("third_party"));
lib.linkLibC();
// get headers on include to zig-out/include
@@ -253,7 +253,7 @@ fn buildExe(b: *std.Build, info: BuildInfo) void {
.optimize = info.lib.root_module.optimize.?,
.target = info.lib.root_module.resolved_target.?,
});
- exe.addCSourceFile(.{
+ exe.root_module.addCSourceFile(.{
.file = b.path(info.path),
.flags = cflags,
});
@@ -284,19 +284,19 @@ fn buildTest(b: *std.Build, info: BuildInfo) void {
.target = info.lib.root_module.resolved_target.?,
});
exe.root_module.addCMacro("TESTING", "");
- exe.addCSourceFile(.{
+ exe.root_module.addCSourceFile(.{
.file = b.path(info.path),
.flags = cflags,
});
- exe.addCSourceFile(.{
+ exe.root_module.addCSourceFile(.{
.file = b.path("test/unit/test_all.c"),
.flags = cflags,
});
- exe.addIncludePath(b.path("test/unit"));
+ exe.root_module.addIncludePath(b.path("test/unit"));
for (info.lib.root_module.include_dirs.items) |include| {
exe.root_module.include_dirs.append(b.allocator, include) catch {};
}
- exe.linkLibrary(info.lib);
+ exe.root_module.linkLibrary(info.lib);
exe.linkLibC();
b.installArtifact(exe);
@@ -347,7 +347,7 @@ fn buildZlib(b: *std.Build, options: anytype) *std.Build.Step.Compile {
.optimize = options[1],
})) |zlib_path| {
libz.addIncludePath(zlib_path.path(""));
- libz.addCSourceFiles(.{
+ libz.root_module.addCSourceFiles(.{
.root = zlib_path.path(""),
.files = &.{
"adler32.c", build output ➜ libxlsxwriter git:(fix-add-c-macro) ✗ ~/zig/0.13.0/files/zig build --summary all
Build Summary: 5/5 steps succeeded
install success
└─ install xlsxwriter success
└─ zig build-lib xlsxwriter Debug native success 1s MaxRSS:145M
├─ zig build-lib z Debug native success 196ms MaxRSS:80M
└─ WriteFile zconf.h success
➜ libxlsxwriter git:(fix-add-c-macro) ✗ rm -fr .zig-cache/ zig-out/
➜ libxlsxwriter git:(fix-add-c-macro) ✗ ~/zig/master/files/zig version
0.14.0-dev.2546+0ff0bdb4a
➜ libxlsxwriter git:(fix-add-c-macro) ✗ ~/zig/master/files/zig build --summary all
Build Summary: 5/5 steps succeeded
install success
└─ install xlsxwriter success
└─ zig build-lib xlsxwriter Debug native success 1s MaxRSS:149M
├─ WriteFile zconf.h success
├─ zig build-lib z Debug native success 188ms MaxRSS:83M
└─ zig build-lib z Debug native (reused) cc: @jmcnamara |
Merged. Thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Small change to build.zig due to change in the zig build system, in the way it passes C Macros from the Zig build system to the target
defineCMacro() -> deprecated in favour of -> root_lib.addCMacro()
Recently deprecated & removed from the zig compiler
ziglang/zig@142471f
This change has no effect on libxlswriter itself - its a zig issue, no a libxlswriter issue
Tested - built using a patched zig-libxlswriter, and added to my app for end 2 end test to generate spreadsheets.