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

add Message type #15

Merged
merged 2 commits into from
Mar 27, 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
10 changes: 4 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@ jobs:

- run: zig env

- run: zig build

- name: Build artifacts
- name: zig build test
run: |
wget https://raw.githubusercontent.com/microsoft/vscode-languageserver-node/main/protocol/metaModel.json
zig build run -- metaModel.json artifacts/lsp.zig
zig build test

- run: zig fmt --ast-check --check artifacts/lsp.zig
- run: zig fmt --ast-check --check zig-out/artifacts/lsp.zig

- name: Upload artifacts
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v2
with:
name: builds
path: artifacts/*
path: zig-out/artifacts/*
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Zig LSP codegen from the newly released, official metamodel! This actually good

1. `git clone`
2. Plop `metaModel.json` in this cloned repo. A copy can be found [here](https://github.com/microsoft/vscode-languageserver-node/blob/main/protocol/metaModel.json).
3. `zig build run -- metaModel.json lsp.zig`
4. Tada! You should now have a `lsp.zig` file that can be used to your heart's content! Enjoy :)
3. `zig build`
4. Tada! You should now have a `zig-out/artifacts/lsp.zig` file that can be used to your heart's content! Enjoy :)
20 changes: 12 additions & 8 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const meta_model_path = b.option([]const u8, "meta-model", "Specify path to the metaMode.json") orelse "metaModel.json";

const exe = b.addExecutable(.{
.name = "zig-lsp-codegen",
.root_source_file = .{ .path = "src/main.zig" },
Expand All @@ -12,15 +14,16 @@ pub fn build(b: *std.Build) void {
});
b.installArtifact(exe);

const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());

if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_codegen = b.addRunArtifact(exe);
run_codegen.addFileArg(.{ .cwd_relative = meta_model_path });
const lsp_output_path = run_codegen.addOutputFileArg("lsp.zig");

const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const lsp_module = b.addModule("lsp", .{
.root_source_file = lsp_output_path,
.target = target,
.optimize = optimize,
});
b.getInstallStep().dependOn(&b.addInstallFile(lsp_output_path, "artifacts/lsp.zig").step);

const test_step = b.step("test", "Run all the tests");
test_step.dependOn(b.getInstallStep());
Expand All @@ -30,6 +33,7 @@ pub fn build(b: *std.Build) void {
.target = target,
.optimize = optimize,
});
tests.root_module.addImport("lsp", lsp_module);

test_step.dependOn(&b.addRunArtifact(tests).step);
}
Loading
Loading