gnunet-zig

GNUnet Bindings for Zig
Log | Files | Refs | README

build.zig (2248B)


      1 const std = @import("std");
      2 
      3 pub fn build(b: *std.Build) !void {
      4     const gnunet_prefix = b.option(
      5         []const u8,
      6         "gnunet-prefix",
      7         "Path to GNUnet",
      8     ) orelse "/usr/local";
      9     // FIXME parse the below with a separator?
     10     const additional_include_paths = b.option(
     11         []const u8,
     12         "additional-include-paths",
     13         "Path to additional includes",
     14     ) orelse "";
     15     const additional_lib_paths = b.option(
     16         []const u8,
     17         "additional-lib-paths",
     18         "Path to additional libs",
     19     ) orelse "";
     20     const target = b.standardTargetOptions(.{});
     21     const optimize = b.standardOptimizeOption(.{});
     22     const exe = b.addExecutable(.{
     23         .name = "gnunet-identity",
     24         .root_source_file = b.path("src/gnunet.zig"),
     25         .target = target,
     26         .optimize = optimize,
     27         .strip = false, // TODO make option
     28     });
     29     const svc_exe = b.addExecutable(.{
     30         .name = "gnunet-service-zig",
     31         .root_source_file = b.path("src/gnunet-service-zig.zig"),
     32         .target = target,
     33         .optimize = optimize,
     34         .strip = false, // TODO make option
     35     });
     36     // create our general purpose allocator
     37     var gpa = std.heap.GeneralPurposeAllocator(.{}){};
     38 
     39     // get an std.mem.Allocator from it
     40     const allocator = gpa.allocator();
     41     const gnunet_include_path = try std.fmt.allocPrint(allocator, "{s}/include", .{gnunet_prefix});
     42     const gnunet_lib_path = try std.fmt.allocPrint(allocator, "{s}/lib", .{gnunet_prefix});
     43     exe.addIncludePath(.{ .cwd_relative = gnunet_include_path });
     44     exe.addLibraryPath(.{ .cwd_relative = gnunet_lib_path });
     45     exe.addIncludePath(.{ .cwd_relative = additional_include_paths });
     46     exe.addLibraryPath(.{ .cwd_relative = additional_lib_paths });
     47     exe.linkSystemLibrary("gnunetutil");
     48     exe.linkSystemLibrary("gnunetidentity");
     49     b.installArtifact(exe);
     50     svc_exe.addIncludePath(.{ .cwd_relative = gnunet_include_path });
     51     svc_exe.addLibraryPath(.{ .cwd_relative = gnunet_lib_path });
     52     svc_exe.addIncludePath(.{ .cwd_relative = additional_include_paths });
     53     svc_exe.addLibraryPath(.{ .cwd_relative = additional_lib_paths });
     54     svc_exe.linkSystemLibrary("gnunetutil");
     55     b.installArtifact(svc_exe);
     56 }