parent
d0d615d819
commit
e3b275fa47
|
@ -1326,7 +1326,7 @@ pub const LibExeObjStep = struct {
|
|||
zig_args.append("--ver-patch") catch unreachable;
|
||||
zig_args.append(builder.fmt("{}", self.version.patch)) catch unreachable;
|
||||
}
|
||||
if ((self.kind == Kind.Exe or self.kind == Kind.Test) and self.static) {
|
||||
if (self.static) {
|
||||
zig_args.append("--static") catch unreachable;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ pub fn addCases(cases: *tests.BuildExamplesContext) void {
|
|||
cases.addBuildFile("test/standalone/main_pkg_path/build.zig");
|
||||
cases.addBuildFile("example/shared_library/build.zig");
|
||||
cases.addBuildFile("example/mix_o_files/build.zig");
|
||||
cases.addBuildFile("test/standalone/static_c_lib/build.zig");
|
||||
if (builtin.os != builtin.Os.macosx) {
|
||||
// TODO https://github.com/ziglang/zig/issues/1126
|
||||
cases.addBuildFile("test/standalone/issue_339/build.zig");
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
const Builder = @import("std").build.Builder;
|
||||
|
||||
pub fn build(b: *Builder) void {
|
||||
const mode = b.standardReleaseOptions();
|
||||
|
||||
const foo = b.addStaticLibrary("foo", null);
|
||||
foo.addCSourceFile("foo.c", [][]const u8{});
|
||||
foo.setBuildMode(mode);
|
||||
foo.addIncludeDir(".");
|
||||
|
||||
const test_exe = b.addTest("foo.zig");
|
||||
test_exe.setBuildMode(mode);
|
||||
test_exe.linkLibrary(foo);
|
||||
test_exe.addIncludeDir(".");
|
||||
|
||||
const test_step = b.step("test", "Test it");
|
||||
test_step.dependOn(&test_exe.step);
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
#include "foo.h"
|
||||
uint32_t add(uint32_t a, uint32_t b) {
|
||||
return a + b;
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
#include <stdint.h>
|
||||
uint32_t add(uint32_t a, uint32_t b);
|
|
@ -0,0 +1,8 @@
|
|||
const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
const c = @cImport(@cInclude("foo.h"));
|
||||
|
||||
test "C add" {
|
||||
const result = c.add(1, 2);
|
||||
expect(result == 3);
|
||||
}
|
Loading…
Reference in New Issue