Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build library and test programs
name: Main

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
- 'main'

env:
SOLANA_ZIG_VERSION: v1.47.0
SOLANA_ZIG_VERSION: v1.52.0
SOLANA_ZIG_DIR: solana-zig

jobs:
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.84.1
toolchain: 1.86.0

# took the workaround from https://github.com/sfackler/rust-openssl/issues/2149
- name: Set Perl environment variables
Expand Down
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ You can run the convenience script in this repo to download the compiler to
1. Add this package to your project:

```console
zig fetch --save https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.0.tar.gz
zig fetch --save https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.17.0.tar.gz
```

2. (Optional) if you want to generate a keypair during building, you'll also
need to install base58 and clap:

```console
zig fetch --save https://github.com/joncinque/base58-zig/archive/refs/tags/v0.14.0.tar.gz
zig fetch --save https://github.com/Hejsil/zig-clap/archive/refs/tags/0.10.0.tar.gz
zig fetch --save https://github.com/joncinque/base58-zig/archive/refs/tags/v0.15.0.tar.gz
zig fetch --save https://github.com/Hejsil/zig-clap/archive/refs/tags/0.11.0.tar.gz
```

3. In your build.zig, add the modules that you want one by one, or use the
Expand All @@ -64,13 +64,18 @@ pub fn build(b: *std.build.Builder) !void {
const target = b.resolveTargetQuery(solana.sbf_target);
// Choose the optimization. `.ReleaseFast` gives optimized CU usage
const optimize = .ReleaseFast;
// Create a module for your program
const mod = b.addModule("my_program", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
// Define your program as a shared library
const program = b.addSharedLibrary(.{
const program = b.addLibrary(.{
.name = "program_name",
.linkage = .dynamic,
// Give the root of your program, where the entrypoint is defined
.root_source_file = b.path("src/main.zig"),
.optimize = optimize,
.target = target,
.root_module = mod,
});
// Use the `buildProgram` helper to create the solana-sdk module, and link
// the program properly.
Expand All @@ -86,7 +91,7 @@ pub fn build(b: *std.build.Builder) !void {
// them with `zig build test` with this step included
const test_step = b.step("test", "Run unit tests");
const lib_unit_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.root_module = mod,
});
lib_unit_tests.root_module.addImport("solana_program_sdk", solana_mod);
const run_unit_tests = b.addRunArtifact(lib_unit_tests);
Expand All @@ -99,7 +104,7 @@ pub fn build(b: *std.build.Builder) !void {
```zig
const solana = @import("solana_program_sdk");

export fn entrypoint(_: [*]u8) callconv(.C) u64 {
export fn entrypoint(_: [*]u8) callconv(.c) u64 {
solana.print("Hello world!", .{});
return 0;
}
Expand Down
12 changes: 2 additions & 10 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});

// Export self as a module
const solana_mod = b.addModule("solana_program_sdk", .{ .root_source_file = b.path("src/root.zig") });

const lib = b.addStaticLibrary(.{
.name = "solana_program_sdk",
const solana_mod = b.addModule("solana_program_sdk", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
Expand All @@ -19,15 +16,10 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});
const base58_mod = base58_dep.module("base58");
lib.root_module.addImport("base58", base58_mod);
solana_mod.addImport("base58", base58_mod);

b.installArtifact(lib);

const lib_unit_tests = b.addTest(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.root_module = solana_mod,
});

lib_unit_tests.root_module.addImport("base58", base58_mod);
Expand Down
8 changes: 4 additions & 4 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.{
.fingerprint = 0xdc47aff950fd68c0,
.name = .solana_program_sdk,
.version = "0.16.3",
.minimum_zig_version = "0.14.0",
.version = "0.17.0",
.minimum_zig_version = "0.15.0",

// This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`.
Expand All @@ -11,8 +11,8 @@
// internet connectivity.
.dependencies = .{
.base58 = .{
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.14.0.tar.gz",
.hash = "base58-0.14.0-6-CZm81qAAD4JCRHgewcNh8FS0pmnk7-OmwUkosaFKvg",
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.15.0.tar.gz",
.hash = "base58-0.15.0-6-CZmwVpAAAxqof6REya9G_XyHL1fTqUsAcsZ-J1IHMF",
},
},
.paths = .{
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.47.0"
solana_zig_version="v1.52.0"
fi
solana_zig_release_url="https://github.com/joncinque/solana-zig-bootstrap/releases/download/solana-$solana_zig_version"

Expand Down
Loading