// コアライブラリと実行可能ファイルをビルドするためのビルド設定 const std = @import("std"); pub fn build(b: *std.Build) void { // ビルドコマンドのオプションからクロスコンパイル設定を取得する const target = b.standardTargetOptions(.{}); // ビルドコマンドのオプションから最適化に関する設定を取得する const optimize = b.standardOptimizeOption(.{}); // coreライブラリを定義 const core = b.addStaticLibrary(.{ .name = "hello", .root_source_file = b.path("src/core.zig"), .target = target, .optimize = optimize, }); // 実行ファイルを定義 const exe = b.addExecutable(.{ .name = "hello", .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, }); // 実行ファイルにコアライブラリをリンクさせる exe.linkLibrary(core); // installタスク(makeでいうallターゲット)に実行時ファイルのビルドを追加する b.installArtifact(exe); }