Skip to content

Commit

Permalink
Build constellation metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mjoerussell committed Jan 19, 2024
1 parent ff04c46 commit 27957ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- id: create-artifact
name: Bundle package
run:
tar -cvf one-night.tar server/zig-out/bin/zig-server web/dist web/assets web/styles web/index.html
tar -cvf one-night.tar night-math/zig-out/const_meta.json server/zig-out/bin/zig-server web/dist web/assets web/styles web/index.html
- name: Upload Bundle
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -63,6 +63,7 @@ jobs:
run: |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} <<< '
tar -xf one-night.tar
kill $(lsof -t -i:8080)
cd server
nohup ./zig-out/bin/zig-server > logs.out &
'
13 changes: 11 additions & 2 deletions night-math/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ pub fn build(b: *Build) !void {
.output = "const_data.bin",
.import_name = "const_data",
},
.{
.arg = "--metadata",
.input = .{ .dir = "../data/constellations/iau" },
.output = "const_meta.json",
},
});

// Install the artifact in a custom directory - will be emitted in web/dist/wasm
Expand Down Expand Up @@ -84,7 +89,7 @@ const DataConfig = struct {
arg: []const u8,
input: Input,
output: []const u8,
import_name: []const u8,
import_name: ?[]const u8 = null,
};

fn generateStarData(b: *Build, main_exe: *Build.Step.Compile, generator_exe: *Build.Step.Compile, data_configs: []const DataConfig) void {
Expand All @@ -98,6 +103,10 @@ fn generateStarData(b: *Build, main_exe: *Build.Step.Compile, generator_exe: *Bu
}

const output = run_data_gen.addOutputFileArg(config.output);
main_exe.root_module.addAnonymousImport(config.import_name, .{ .root_source_file = output });
if (config.import_name) |import_name| {
main_exe.root_module.addAnonymousImport(import_name, .{ .root_source_file = output });
} else {
b.getInstallStep().dependOn(&b.addInstallFileWithDir(output, .prefix, config.output).step);
}
}
}
2 changes: 1 addition & 1 deletion server/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const http = tortie.http;

var static_files = [_]StaticFile{
StaticFile.init("../web/index.html", .{ .path = "/" }),
StaticFile.init("const_meta.json", .{ .path = "/constellations/meta", .content_type = "application/json" }),
StaticFile.init("../night-math/zig-out/const_meta.json", .{ .path = "/constellations/meta", .content_type = "application/json" }),
StaticFile.init("../web/styles/main.css", .{ .relative_to = "../web" }),
StaticFile.init("../web/dist/bundle.js", .{ .relative_to = "../web", .compress = true }),
StaticFile.init("../web/dist/bundle.js.map", .{ .relative_to = "../web", .compress = true }),
Expand Down

0 comments on commit 27957ae

Please sign in to comment.