Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmanaged and Aligned variants #8

Merged
merged 4 commits into from
May 8, 2024
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/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Setup Zig
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.12.0
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
docs/
zig-cache/
zig-out/
kcov-out
6 changes: 4 additions & 2 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
coverage: clean
zig build test
kcov --include-pattern=src/main.zig,src/tests.zig kcov-out zig-cache/o/**/test
zig build test -Doptimize=Debug
kcov --include-pattern=src/root.zig,src/tests.zig kcov-out zig-cache/o/**/test

docs:
zig build
xdg-open http://localhost:3000/
bun run docs/index.ts

test:
zig test src/tests.zig
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/Aandreba/zigrc/tests.yml)
[![Docs](https://img.shields.io/badge/docs-zig-blue)](https://aandreba.github.io/zigrc/)
[![Docs](https://img.shields.io/badge/docs-zig-blue)](https://aandreba.github.io/zigrc/#zig-rc.main)

# zigrc

Expand Down
12 changes: 6 additions & 6 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn build_v10(b: *std.build.Builder) void {
const coverage = b.option(bool, "coverage", "Generate test coverage") orelse false;

// Docs
const docs = b.addStaticLibrary("zig-rc", "src/main.zig");
const docs = b.addStaticLibrary("zig-rc", "src/root.zig");
docs.emit_docs = .emit;
docs.setBuildMode(mode);
docs.install();
Expand All @@ -39,7 +39,7 @@ fn build_v10(b: *std.build.Builder) void {
if (coverage) {
main_tests.setExecCmd(&[_]?[]const u8{
"kcov",
"--include-pattern=src/main.zig,src/tests.zig",
"--include-pattern=src/root.zig,src/tests.zig",
"kcov-out",
null, // to get zig to use the --test-cmd-bin flag
});
Expand Down Expand Up @@ -72,7 +72,7 @@ fn build_v11(b: *std.Build) void {
// Docs
const docs = b.addStaticLibrary(.{
.name = "zig-rc",
.root_source_file = std.build.LazyPath.relative("src/main.zig"),
.root_source_file = std.build.LazyPath.relative("src/root.zig"),
.target = target,
.optimize = optimize,
});
Expand All @@ -96,7 +96,7 @@ fn build_v11(b: *std.Build) void {
if (coverage) {
main_tests.setExecCmd(&[_]?[]const u8{
"kcov",
"--include-pattern=src/main.zig,src/tests.zig",
"--include-pattern=src/root.zig,src/tests.zig",
"kcov-out",
null, // to get zig to use the --test-cmd-bin flag
});
Expand Down Expand Up @@ -131,7 +131,7 @@ fn build_v12(b: *std.Build) void {
// Docs
const docs = b.addStaticLibrary(.{
.name = "zig-rc",
.root_source_file = b.path("src/main.zig"),
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
Expand All @@ -155,7 +155,7 @@ fn build_v12(b: *std.Build) void {
if (coverage) {
main_tests.setExecCmd(&[_]?[]const u8{
"kcov",
"--include-pattern=src/main.zig,src/tests.zig",
"--include-pattern=src/root.zig,src/tests.zig",
"kcov-out",
null, // to get zig to use the --test-cmd-bin flag
});
Expand Down
61 changes: 61 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.{
.name = "zigrc",
// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.5.0",

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

// 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 = .{
// See `zig fetch --save <url>` for a command-line interface for adding dependencies.
//.example = .{
// // When updating this field to a new URL, be sure to delete the corresponding
// // `hash`, otherwise you are communicating that you expect to find the old hash at
// // the new URL.
// .url = "https://example.com/foo.tar.gz",
//
// // This is computed from the file contents of the directory of files that is
// // obtained after fetching `url` and applying the inclusion rules given by
// // `paths`.
// //
// // This field is the source of truth; packages do not come from a `url`; they
// // come from a `hash`. `url` is just one of many possible mirrors for how to
// // obtain a package matching this `hash`.
// //
// // Uses the [multihash](https://multiformats.io/multihash/) format.
// .hash = "...",
//
// // When this is provided, the package is found in a directory relative to the
// // build root. In this case the package's hash is irrelevant and therefore not
// // computed. This field and `url` are mutually exclusive.
// .path = "foo",

// // When this is set to `true`, a package is declared to be lazily
// // fetched. This makes the dependency only get fetched if it is
// // actually used.
// .lazy = false,
//},
},

// Specifies the set of files and directories that are included in this package.
// Only files and directories listed here are included in the `hash` that
// is computed for this package.
// Paths are relative to the build root. Use the empty string (`""`) to refer to
// the build root itself.
// A directory listed here means that all files within, recursively, are included.
.paths = .{
"build.zig",
"build.zig.zon",
"src",
"LICENSE",
"README.md",
},
}
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
bun.lockb
9 changes: 9 additions & 0 deletions docs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const server = Bun.serve({
fetch(req) {
const url = new URL(req.url);
const path = url.pathname === "/" ? "/index.html" : url.pathname;
return new Response(Bun.file(`./zig-out/docs${path}`));
},
});

console.log(`Server started at ${server.port}`);
11 changes: 11 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "docs",
"module": "index.ts",
"type": "module",
"devDependencies": {
"bun-types": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
25 changes: 25 additions & 0 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
// add Bun type definitions
"types": ["bun-types"],

// enable latest features
"lib": ["esnext"],
"module": "esnext",
"target": "esnext",

"moduleResolution": "bundler",
"noEmit": true,
"allowImportingTsExtensions": true,
"moduleDetection": "force",

"jsx": "react-jsx", // support JSX
"allowJs": true, // allow importing `.js` from `.ts`
"esModuleInterop": true, // allow default imports for CommonJS modules

// best practices
"strict": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
}
}
2 changes: 1 addition & 1 deletion src/example.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const std = @import("std");
const rc = @import("main.zig");
const rc = @import("root.zig");

const Thread = std.Thread;
const Mutex = Thread.Mutex;
Expand Down
Loading