11// SPDX-License-Identifier: PMPL-1.0-or-later
22// ECHIDNA Zig FFI Build Configuration
3+ // Compatible with Zig 0.14+/0.15+
34
45const std = @import ("std" );
56
@@ -8,58 +9,51 @@ pub fn build(b: *std.Build) void {
89 const optimize = b .standardOptimizeOption (.{});
910
1011 // Build shared library for FFI
11- const lib = b .addSharedLibrary (.{
12+ const lib = b .addLibrary (.{
1213 .name = "echidna_chapel_ffi" ,
13- .root_source_file = b .path ("chapel_bridge.zig" ),
14- .target = target ,
15- .optimize = optimize ,
14+ .root_module = b .createModule (.{
15+ .root_source_file = b .path ("chapel_bridge.zig" ),
16+ .target = target ,
17+ .optimize = optimize ,
18+ .link_libc = true ,
19+ }),
20+ .linkage = .dynamic ,
1621 });
17-
18- // Link with C (required for Chapel interop)
19- lib .linkLibC ();
20-
21- // Set version
22- lib .version = .{ .major = 1 , .minor = 0 , .patch = 0 };
22+ // Chapel C headers are in the same directory
23+ lib .root_module .addIncludePath (b .path ("." ));
2324
2425 // Install artifacts
2526 b .installArtifact (lib );
2627
2728 // Static library (alternative)
28- const lib_static = b .addStaticLibrary (.{
29+ const lib_static = b .addLibrary (.{
2930 .name = "echidna_chapel_ffi" ,
30- .root_source_file = b .path ("chapel_bridge.zig" ),
31- .target = target ,
32- .optimize = optimize ,
31+ .root_module = b .createModule (.{
32+ .root_source_file = b .path ("chapel_bridge.zig" ),
33+ .target = target ,
34+ .optimize = optimize ,
35+ .link_libc = true ,
36+ }),
37+ .linkage = .static ,
3338 });
39+ lib_static .root_module .addIncludePath (b .path ("." ));
3440
35- lib_static .linkLibC ();
3641 b .installArtifact (lib_static );
3742
38- // Unit tests
43+ // Unit tests (link against stubs when Chapel not available)
3944 const lib_tests = b .addTest (.{
40- .root_source_file = b .path ("chapel_bridge.zig" ),
41- .target = target ,
42- .optimize = optimize ,
45+ .root_module = b .createModule (.{
46+ .root_source_file = b .path ("chapel_bridge.zig" ),
47+ .target = target ,
48+ .optimize = optimize ,
49+ .link_libc = true ,
50+ }),
4351 });
44-
45- lib_tests .linkLibC ( );
52+ lib_tests . root_module . addIncludePath ( b . path ( "." ));
53+ lib_tests .addCSourceFile (.{ . file = b . path ( "chapel_stubs.c" ) } );
4654
4755 const run_lib_tests = b .addRunArtifact (lib_tests );
4856
4957 const test_step = b .step ("test" , "Run FFI tests" );
5058 test_step .dependOn (& run_lib_tests .step );
51-
52- // Documentation
53- const docs = b .addTest (.{
54- .root_source_file = b .path ("chapel_bridge.zig" ),
55- .target = target ,
56- .optimize = .Debug ,
57- });
58-
59- const docs_step = b .step ("docs" , "Generate documentation" );
60- docs_step .dependOn (& b .addInstallDirectory (.{
61- .source_dir = docs .getEmittedDocs (),
62- .install_dir = .prefix ,
63- .install_subdir = "docs" ,
64- }).step );
6559}
0 commit comments