Skip to content

Commit

Permalink
Update to Zig 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
joncinque committed Aug 24, 2024
1 parent 8095599 commit 44a2ca5
Show file tree
Hide file tree
Showing 7 changed files with 704 additions and 641 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and test hello-world program
on: [pull_request, push]

env:
SOLANA_ZIG_VERSION: v1.41
SOLANA_ZIG_VERSION: v1.43.0
SOLANA_ZIG_DIR: solana-zig

jobs:
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.76.0
toolchain: 1.78.0

- name: Install build deps
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
solana-zig
zig-cache/
zig-out/
.zig-cache/
15 changes: 12 additions & 3 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
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 = .ReleaseSmall;
const program = b.addSharedLibrary(.{
.name = "helloworld",
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});

// Adding required dependencies, link the program properly, and get a
// prepared modules
// 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 = .{ .path = "src/main.zig" },
.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);
Expand Down
14 changes: 7 additions & 7 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = "solana-helloworld-zig",
// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.12.0",
.version = "0.13.0",

// This field is optional.
// This is currently advisory only; Zig does not yet do anything
Expand All @@ -16,16 +16,16 @@
// internet connectivity.
.dependencies = .{
.base58 = .{
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.12.2.tar.gz",
.hash = "12203cf62befaa692c11ed82c1cea15ae6da153a87d89a969b006d99267fc4ba8626",
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.13.3.tar.gz",
.hash = "1220fd067bf167b9062cc29ccf715ff97643c2d3f8958beea863b6036876bb71bcb8",
},
.clap = .{
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.8.0.tar.gz",
.hash = "1220949d4e88864579067b6d4cdad6476c6176f27e782782c2c39b7f2c4817a10efb",
.url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.9.1.tar.gz",
.hash = "122062d301a203d003547b414237229b09a7980095061697349f8bef41be9c30266b",
},
.@"solana-program-sdk" = .{
.url = "https://github.com/joncinque/solana-sdk-zig/archive/refs/tags/v0.12.0.tar.gz",
.hash = "122027f10b77c99010365b20f2bb32314fccee9814deec30ac70258f6ec62654d859",
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.13.1.tar.gz",
.hash = "122030336f1257e3c0aa64243f5243f554b903c6b9ef3a91d48bfbe896c0c7d9b13b",
},
},

Expand Down
2 changes: 1 addition & 1 deletion install-solana-zig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if [[ -n $SOLANA_ZIG_VERSION ]]; then
solana_zig_version="$SOLANA_ZIG_VERSION"
else
solana_zig_version="v1.41"
solana_zig_version="v1.43.0"
fi
solana_zig_release_url="https://github.com/joncinque/solana-zig-bootstrap/releases/download/solana-$solana_zig_version"

Expand Down
Loading

0 comments on commit 44a2ca5

Please sign in to comment.