Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Enr CI

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

env:
ZIG_VERSION: 0.14.1

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Zig
uses: korandoru/setup-zig@v1
with:
zig-version: 0.14.1

- name: Formatting
run: zig fmt --check --color on .

- name: Unit testing
run: zig build test --summary all

- name: Building
run: zig build -Doptimize=ReleaseSafe
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,49 @@
# enr
About Ethereum Node Records (ENR)
Ethereum Node Records (ENR) utility in Zig.

## Prerequisites

- Zig 0.14.1

## Building

To build the project, run the following command in the root directory of the project:

```bash
zig build -Doptimize=ReleaseSafe
```

## Running Tests

To run the tests, run the following command in the root directory of the project:

```bash
zig build test --summary all
```

## Docs

To generate documentation for the project, run the following command in the root directory of the project:

```bash
zig build docs
```

# Usage

Update `build.zig.zon`:

```sh
zig fetch --save git+https://github.com/blockblaz/enr
```

In your `build.zig`:

```zig
const enr_dep = b.dependency("zig_enr", .{
.target = target,
.optimize = optimize,
});
const enr_module = enr_dep.module("zig-enr");
root_module.addImport("zig-enr", enr_module);
```
45 changes: 45 additions & 0 deletions build.zig
Comment thread
GrapeBaBa marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const std = @import("std");

pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});

const optimize = b.standardOptimizeOption(.{});

const discv5 = b.dependency("discv5", .{});

const enr_mod = discv5.module("enr");

const lib_mod = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});

lib_mod.addImport("enr", enr_mod);

try b.modules.put(b.dupe("zig-enr"), lib_mod);
const lib = b.addLibrary(.{
.linkage = .static,
.name = "enr",
.root_module = lib_mod,
});

b.installArtifact(lib);

const lib_unit_tests = b.addTest(.{
.root_module = lib_mod,
});

const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);

const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);

const install_docs = b.addInstallDirectory(.{
.source_dir = lib.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs",
});
const docs_step = b.step("docs", "Generate documentation");
docs_step.dependOn(&install_docs.step);
}
23 changes: 23 additions & 0 deletions build.zig.zon
Comment thread
GrapeBaBa marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.{
.name = .zig_enr,

.version = "0.0.0",

.fingerprint = 0x499ae5d25c594f6a,

.minimum_zig_version = "0.14.1",

.dependencies = .{
.discv5 = .{
.url = "git+https://github.com/blockblaz/zig-discv5#31f46b3b5e5b25a68638bb320545b74c642c6caa",
.hash = "discv5-0.1.0-fkJduLBkAQBQHUJxdOEqCR2YMKfF1lNhaLM_FgonkFRW",
},
},
.paths = .{
"build.zig",
"build.zig.zon",
"src",
"LICENSE",
"README.md",
},
}
Loading