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
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
branches: [main]

env:
ZIG_VERSION: 0.14.1
ZIG_VERSION: 0.15.2

jobs:
build:
Expand Down
19 changes: 7 additions & 12 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const peerid_dep = b.dependency("peer_id", .{
.target = target,
.optimize = optimize,
});
const peerid_module = peerid_dep.module("peer-id");

// Create the module
const root_module = b.addModule("multiformats-zig", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
root_module.addImport("peer-id", peerid_module);

// Create the library
const lib = b.addLibrary(.{
Expand All @@ -32,8 +25,6 @@ pub fn build(b: *std.Build) void {
// Test setup
const lib_unit_tests = b.addTest(.{
.root_module = root_module,
.target = target,
.optimize = optimize,
});

const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
Expand All @@ -49,12 +40,16 @@ fn setupBenchmarks(b: *std.Build, target: std.Build.ResolvedTarget, optimize: st
const method_option = b.option([]const u8, "method", "method of Base action") orelse "encode";
const code_option = b.option([]const u8, "code", "code of the Base type") orelse "";

const benchmark = b.addExecutable(.{
.name = bench_name,
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = b.fmt("src/{s}.zig", .{bench_name}) } },
const bench_module = b.createModule(.{
.root_source_file = b.path(b.fmt("src/{s}.zig", .{bench_name})),
.target = target,
.optimize = optimize,
});

const benchmark = b.addExecutable(.{
.name = bench_name,
.root_module = bench_module,
});
const run_benchmark = b.addRunArtifact(benchmark);
run_benchmark.addArgs(&.{ "--period", period_option });
run_benchmark.addArgs(&.{ "--times", times_option });
Expand Down
29 changes: 2 additions & 27 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,41 +1,16 @@
.{
// This is the default name used by packages depending on this one. For
// example, when a user runs `zig fetch --save <url>`, this field is used
// as the key in the `dependencies` table. Although the user can choose a
// different name, most users will stick with this provided value.
//
// It is redundant to include "zig" in this name because it is already
// within the Zig package namespace.
.name = .zmultiformats,

.fingerprint = 0x8fb7678286dc3bca,

// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.1.0",

// This field is optional.
// This is currently advisory only; Zig does not yet do anything
// with this value.
//.minimum_zig_version = "0.11.0",
.minimum_zig_version = "0.15.2",

// This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`.
// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
// Once all dependencies are fetched, `zig build` no longer requires
// internet connectivity.
.dependencies = .{
.peer_id = .{
.url = "git+https://github.com/blockblaz/peer-id#2066600a1b9e0196dc35722f8ce544a3ca44fad6",
.hash = "peer_id-0.0.0-IgmND5VeAACon_XsphKZcYuOFn7SgmpBluBi2ieRFDya",
},
},
.dependencies = .{},
.paths = .{
"build.zig",
"build.zig.zon",
"src",
// For example...
//"LICENSE",
//"README.md",
},
}
12 changes: 6 additions & 6 deletions src/generate.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub fn main() !void {
const csv_content = try fs.cwd().readFileAlloc(allocator, "src/spec/multicodec/table.csv", 1024 * 1024);
defer allocator.free(csv_content);

var codecs = std.ArrayList(Codec).init(allocator);
defer codecs.deinit();
var codecs: std.ArrayList(Codec) = .{};
defer codecs.deinit(allocator);

// Parse CSV
var lines = std.mem.splitSequence(u8, csv_content, "\n");
Expand All @@ -39,7 +39,7 @@ pub fn main() !void {

const code = try std.fmt.parseInt(i32, std.mem.trim(u8, code_str, " "), 0);

try codecs.append(.{
try codecs.append(allocator, .{
.name = name,
.tag = tag,
.code = code,
Expand Down Expand Up @@ -83,12 +83,12 @@ pub fn main() !void {
}

// Convert to sorted array
var tag_keys = std.ArrayList([]const u8).init(allocator);
defer tag_keys.deinit();
var tag_keys: std.ArrayList([]const u8) = .{};
defer tag_keys.deinit(allocator);

var tag_iter = tags.keyIterator();
while (tag_iter.next()) |tag| {
try tag_keys.append(tag.*);
try tag_keys.append(allocator, tag.*);
}

// Sort tags alphabetically
Expand Down
Loading