-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.zig
34 lines (29 loc) · 1.16 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const std = @import("std");
const solana = @import("solana-program-sdk");
const base58 = @import("base58");
pub fn build(b: *std.Build) !void {
// Be sure to specify a solana target
const target = b.resolveTargetQuery(solana.sbf_target);
const optimize = .ReleaseFast;
const program = b.addSharedLibrary(.{
.name = "helloworld",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
// Adding required dependencies, link the program properly, and get a
// prepared solana-program module
const solana_mod = solana.buildProgram(b, program, target, optimize);
// Install the program artifact
b.installArtifact(program);
// Optional: generate a keypair for the program
base58.generateProgramKeypair(b, program);
// Run unit tests
const test_step = b.step("test", "Run unit tests");
const lib_unit_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
});
lib_unit_tests.root_module.addImport("solana-program-sdk", solana_mod);
const run_unit_tests = b.addRunArtifact(lib_unit_tests);
test_step.dependOn(&run_unit_tests.step);
}