From 2ca058efedbe09852f2fe565ac1cfe2ce582d7b1 Mon Sep 17 00:00:00 2001 From: Cory Alder Date: Sat, 3 Aug 2024 17:36:46 -0700 Subject: [PATCH] Fix build.zig for 0.12.1, and add running instructions to readme, detect inkscape layer names (#7) * Add selectors for inkscape svgs * Fix workflow and compile with zig 0.12.1 * Add running instructions to readme --------- Co-authored-by: Cory Alder --- .github/workflows/deploy.yml | 6 +++--- README.md | 8 ++++++++ native/build.zig | 7 +++++-- web/scripts/main.js | 16 ++++++++-------- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e088dc5..f15fa7d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,8 +27,8 @@ jobs: - name: Install Zig run: | - wget -q https://ziglang.org/builds/zig-linux-x86_64-0.12.0-dev.1830+779b8e259.tar.xz - tar -xf zig-linux-x86_64-0.12.0-dev.1830+779b8e259.tar.xz + wget -q https://ziglang.org/download/0.12.1/zig-linux-x86_64-0.12.1.tar.xz + tar -xf zig-linux-x86_64-0.12.1.tar.xz - uses: actions/setup-python@v4 with: @@ -41,7 +41,7 @@ jobs: - name: Build native working-directory: native run: | - ../zig-linux-x86_64-0.12.0-dev.1830+779b8e259/zig build -Doptimize=ReleaseFast + ../zig-linux-x86_64-0.12.1/zig build -Doptimize=ReleaseFast - name: Build web run: | diff --git a/README.md b/README.md index 306e141..c7fee50 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,14 @@ Gingerbread is a tool for converting vector artwork to KiCAD PCB files that live See https://gingerbread.wntr.dev for more information. +## Building & Running + +1. make sure you have python3 and zig (0.12.1) installed +2. build the native code in `native/` using `zig build` +3. make sure you have `jinja2` installed (`python3 -m pip install jinja2`) +4. run build.py in the root directory (`python3 build.py`) +5. this builds the site into `build/`, serve it using python `python3 -m http.server 8080 --bind 127.0.0.1 --directory ./build` and visit `http://127.0.0.1:8080/` to view the site + ## License and contributing Gingerbread is open source! Please take a chance to read the [LICENSE](LICENSE.md) file. diff --git a/native/build.zig b/native/build.zig index 8f6f9e9..ecdf431 100644 --- a/native/build.zig +++ b/native/build.zig @@ -1,7 +1,10 @@ const std = @import("std"); pub fn build(b: *std.Build) void { - const target: std.zig.CrossTarget = .{ .cpu_arch = .wasm32, .os_tag = .wasi }; + const target = b.resolveTargetQuery(.{ + .cpu_arch = .wasm32, + .os_tag = .wasi, + }); const optimize = b.standardOptimizeOption(.{}); const libpotrace = b.addStaticLibrary(.{ @@ -48,11 +51,11 @@ pub fn build(b: *std.Build) void { .version = .{ .major = 1, .minor = 0, .patch = 0 }, .target = target, .optimize = optimize, + .strip = true }); libgingerbread.entry = .disabled; libgingerbread.rdynamic = true; libgingerbread.wasi_exec_model = std.builtin.WasiExecModel.reactor; - libgingerbread.strip = false; libgingerbread.linkLibC(); libgingerbread.linkLibrary(libpotrace); libgingerbread.linkLibrary(libclipper2); diff --git a/web/scripts/main.js b/web/scripts/main.js index 3de196b..28932dc 100644 --- a/web/scripts/main.js +++ b/web/scripts/main.js @@ -23,20 +23,20 @@ class Design { { name: "Drill", type: "drill", - selector: "#Drill, #Drills", + selector: "#Drill, #Drills, [*|label=\"Drills\"]", color: "Fuchsia", }, { name: "FSilkS", type: "raster", - selector: "#FSilkS, #F\\.SilkS", + selector: "#FSilkS, #F\\.SilkS, [*|label=\"F\\.SilkS\"]", color: "white", number: 3, }, { name: "FMask", type: "raster", - selector: "#FMask, #F\\.Mask", + selector: "#FMask, #F\\.Mask, [*|label=\"F\\.Mask\"]", color: "black", is_mask: true, number: 5, @@ -44,21 +44,21 @@ class Design { { name: "FCu", type: "raster", - selector: "#FCu, #F\\.Cu", + selector: "#FCu, #F\\.Cu, [*|label=\"F\\.Cu\"]", color: "gold", number: 1, }, { name: "BCu", type: "raster", - selector: "#BCu, #B\\.Cu", + selector: "#BCu, #B\\.Cu, [*|label=\"B\\.Cu\"]", color: "gold", number: 2, }, { name: "BMask", type: "raster", - selector: "#BMask, #B\\.Mask", + selector: "#BMask, #B\\.Mask, [*|label=\"B\\.Mask\"]", color: "black", is_mask: true, number: 6, @@ -66,14 +66,14 @@ class Design { { name: "BSilkS", type: "raster", - selector: "#BSilkS, #B\\.SilkS", + selector: "#BSilkS, #B\\.SilkS, [*|label=\"B\\.SilkS\"]", color: "white", number: 4, }, { name: "EdgeCuts", type: "vector", - selector: "#EdgeCuts, #Edge\\.Cuts", + selector: "#EdgeCuts, #Edge\\.Cuts, [*|label=\"Edge\\.Cuts\"]", color: "PeachPuff", force_color: true, number: 7,