Skip to content

Commit

Permalink
Start of using zig to orchestrate the build
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianReeves committed May 25, 2024
1 parent 511c4fc commit 6f3402c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
20 changes: 17 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
# Node, Bun, and Deno Related
package-lock.json
node_modules/

# IDE Related
.idea/
.fake
.ionide

.vscode/
package-lock.json
node_modules/


# Elm related
elm-stuff/

# Zig related
zig-cache/
zig-out/

# Build Artifacts
out/

24 changes: 24 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
const run_tool = b.option(JavascriptRunTool, "js-runtool", "JavaScript run tool, such as npx or bun.") orelse JavascriptRunTool.bunx;

// Setup verification step for the elm package
const verify_elm_package = b.step("verify-elm-package", "Verify that the finos/morphir Elm package is valid and okay to publish.");
const check_elm_docs = b.step("check-elm-docs", "Check that the Elm package documentation is in a valid state.");

const elm_make_docs = switch (run_tool) {
JavascriptRunTool.bunx => b.addSystemCommand(&.{ "bunx", "elm", "make" }),
JavascriptRunTool.npx => b.addSystemCommand(&.{ "npx", "elm", "make" }),
};
elm_make_docs.addArg("--docs");

const elm_docs_output = elm_make_docs.addOutputFileArg("docs.json");

check_elm_docs
.dependOn(&b.addInstallFileWithDir(elm_docs_output, .prefix, b.pathJoin(&.{ "elm-out/finos/morphir", "docs.json" })).step);

verify_elm_package.dependOn(check_elm_docs);
}

const JavascriptRunTool = enum { bunx, npx };
Binary file modified bun.lockb
Binary file not shown.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"apps/js-cli"
],
"scripts": {
"build:elm-package":"elm make"
"build:verify-elm-package": "zig build verify-elm-package --summary all",
"build:check-elm-docs": "zig build check-elm-docs --summary all",
"postinstall": "elm-tooling install"
},
"devDependencies": {
"elm-tooling": "^1.15.1"
}
}
}

0 comments on commit 6f3402c

Please sign in to comment.