diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml new file mode 100644 index 0000000000..aa669ea2a2 --- /dev/null +++ b/.github/workflows/artifacts.yml @@ -0,0 +1,67 @@ +name: Deploy release artifacts + +on: + push: + branches: + - master + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +jobs: + deploy: + if: github.repository_owner == 'zigtools' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # required to resolve the version string + + - uses: goto-bus-stop/setup-zig@v2 + with: + version: master + + - run: zig env + + - name: Build artifacts + run: | + mkdir -p artifacts/master + + zig build release -Dcpu=baseline -Doptimize=ReleaseSafe --prefix artifacts/master --summary all + + zls_version=$(artifacts/master/x86_64-linux/zls --version) + mkdir -p "artifacts/$zls_version/" + cp -r artifacts/master/* "artifacts/$zls_version/" + + wget https://zigtools-releases.nyc3.digitaloceanspaces.com/zls/index.json + + cp index.json artifacts/old-index.json + + for file in artifacts/master/*; do + targets+=("${file#artifacts/master/}") + done + + jq \ + --arg targets "${targets[*]}" \ + --arg zig_version "$(zig version)" \ + --arg zls_version "$(artifacts/master/x86_64-linux/zls --version)" \ + --arg zls_minimum_build_version "$(artifacts/master/x86_64-linux/zls --minimum-build-version)" \ + '.latest = $zls_version | .versions[$zls_version] = { + "date": now | todateiso8601, + "builtWithZigVersion": $zig_version, + "zlsVersion": $zls_version, + "zlsMinimumBuildVersion": $zls_minimum_build_version, + "commit": "${{ github.sha }}", + "targets": ($targets / " "), + }' index.json > artifacts/index.json + + - uses: BetaHuhn/do-spaces-action@v2 + with: + access_key: ${{ secrets.DO_SPACES_ACCESS_KEY }} + secret_key: ${{ secrets.DO_SPACES_SECRET_KEY }} + space_name: zigtools-releases + space_region: nyc3 + source: artifacts/ + out_dir: zls/ diff --git a/.github/workflows/build_runner.yml b/.github/workflows/build_runner.yml index 386e570401..abc7c4c96f 100644 --- a/.github/workflows/build_runner.yml +++ b/.github/workflows/build_runner.yml @@ -5,12 +5,8 @@ on: paths: - ".github/workflows/build_runner.yml" - "src/build_runner/**" - pull_request: - paths: - - ".github/workflows/build_runner.yml" - - "src/build_runner/**" schedule: - - cron: '0 0 * * *' + - cron: "0 0 * * *" workflow_dispatch: jobs: @@ -27,9 +23,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 + uses: actions/checkout@v4 - name: Grab zig uses: goto-bus-stop/setup-zig@v2 diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 08b68e85f8..b31f3896c5 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,26 +1,20 @@ name: Code Coverage -on: [push, pull_request] +on: + push: jobs: coverage: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - submodules: true + - uses: actions/checkout@v4 - uses: goto-bus-stop/setup-zig@v2 with: version: master - - run: zig version - run: zig env - - name: Build - run: zig build - - name: Install kcov run: | wget https://github.com/SimonKagstrom/kcov/releases/download/v42/kcov-amd64.tar.gz @@ -29,13 +23,12 @@ jobs: - name: Run Tests with kcov run: | kcov --version - zig build test -Dgenerate_coverage - + zig build test -Dgenerate_coverage --summary all + - name: Upload to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - directory: zig-out/kcov/kcov-merged + directory: zig-out/coverage/kcov-merged fail_ci_if_error: true verbose: true - diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 165ef1b34f..46ecd3ce25 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -55,25 +55,24 @@ jobs: - run: zig env - name: Checkout zig - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: zig repository: "ziglang/zig" - fetch-depth: 0 - name: Checkout zls (non-PR) if: github.event_name != 'pull_request_target' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - path: zls fetch-depth: 0 + path: zls - name: Checkout zls (PR) if: github.event_name == 'pull_request_target' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - path: zls fetch-depth: 0 + path: zls ref: "refs/pull/${{ github.event.number }}/merge" - name: Build zls @@ -83,11 +82,10 @@ jobs: zig build - name: Checkout sus - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: sus repository: "zigtools/sus" - fetch-depth: 0 - name: Build sus run: | @@ -117,6 +115,3 @@ jobs: space_region: nyc3 source: sus/saved_logs/ out_dir: ${{ github.event.pull_request.head.repo.full_name || github.repository }}/${{ github.head_ref || github.ref_name }}/${{ github.event.pull_request.head.sha || github.sha }} - - - \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 70db94c965..4dcc94a132 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,153 +1,30 @@ -name: CI - -on: - push: - paths: - - ".github/workflows/main.yml" - - "**.zig" - - "build.zig.zon" - pull_request: - paths: - - ".github/workflows/main.yml" - - "**.zig" - - "build.zig.zon" - schedule: - - cron: "0 0 * * *" - workflow_dispatch: - -jobs: - build: - if: github.repository_owner == 'zigtools' - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: goto-bus-stop/setup-zig@v2 - with: - version: master - - - name: Get Zig version - id: zig_version - run: echo "zig_version=$(zig version)" >> $GITHUB_OUTPUT - - - run: zig env - - - name: Run zig fmt - run: zig fmt --check . - - - name: Build - run: zig build - - - name: Get ZLS version and mimimum build version - id: zls_version - run: | - echo "zls_version=$(./zig-out/bin/zls --version)" >> $GITHUB_OUTPUT - echo "zls_minimum_build_version=$(./zig-out/bin/zls --minimum-build-version)" >> $GITHUB_OUTPUT - - - name: Run Tests - run: zig build test - - - name: Build artifacts - if: ${{ matrix.os == 'ubuntu-latest' }} - run: | - declare -a targets=("x86_64-windows" "x86_64-linux" "x86_64-macos" "x86-windows" "x86-linux" "aarch64-linux" "aarch64-macos" "wasm32-wasi") - mkdir -p "artifacts/${{ steps.zls_version.outputs.zls_version }}/" - - for target in "${targets[@]}"; do - mkdir -p artifacts/${{ steps.zls_version.outputs.zls_version }}/$target - - echo "Building target ${target}..." - if [ "${GITHUB_REF##*/}" == "master" ]; then - echo "Building safe" - zig build -Dtarget=${target} -Dcpu=baseline -Doptimize=ReleaseSafe --prefix artifacts/${{ steps.zls_version.outputs.zls_version }}/${target}/ - else - echo "Building debug as action is not running on master" - zig build -Dtarget=${target} -Dcpu=baseline --prefix artifacts/${{ steps.zls_version.outputs.zls_version }}/${target}/ - fi - - mv artifacts/${{ steps.zls_version.outputs.zls_version }}/${target}/bin/* artifacts/${{ steps.zls_version.outputs.zls_version }}/${target} - rmdir artifacts/${{ steps.zls_version.outputs.zls_version }}/${target}/bin - done - - wget https://zigtools-releases.nyc3.digitaloceanspaces.com/zls/index.json - - cp index.json artifacts/old-index.json - - jq --arg targets "${targets[*]}" '.latest = "${{ steps.zls_version.outputs.zls_version }}" | .versions["${{ steps.zls_version.outputs.zls_version }}"] = { - "date": now | todateiso8601, - "builtWithZigVersion": "${{ steps.zig_version.outputs.zig_version }}", - "zlsVersion": "${{ steps.zls_version.outputs.zls_version }}", - "zlsMinimumBuildVersion": "${{ steps.zls_version.outputs.zls_minimum_build_version }}", - "commit": "${{ github.sha }}", - "targets": ($targets / " "), - }' index.json > artifacts/index.json - - - name: Upload x86_64-windows artifact - if: ${{ matrix.os == 'ubuntu-latest' }} - uses: actions/upload-artifact@v3 - with: - name: zls-x86_64-windows - path: artifacts/${{ steps.zls_version.outputs.zls_version }}/x86_64-windows/ - - - name: Upload x86_64-linux artifact - if: ${{ matrix.os == 'ubuntu-latest' }} - uses: actions/upload-artifact@v3 - with: - name: zls-x86_64-linux - path: artifacts/${{ steps.zls_version.outputs.zls_version }}/x86_64-linux/ - - - name: Upload x86_64-macos artifact - if: ${{ matrix.os == 'ubuntu-latest' }} - uses: actions/upload-artifact@v3 - with: - name: zls-x86_64-macos - path: artifacts/${{ steps.zls_version.outputs.zls_version }}/x86_64-macos/ - - - name: Upload x86-windows artifact - if: ${{ matrix.os == 'ubuntu-latest' }} - uses: actions/upload-artifact@v3 - with: - name: zls-x86-windows - path: artifacts/${{ steps.zls_version.outputs.zls_version }}/x86-windows/ - - - name: Upload x86-linux artifact - if: ${{ matrix.os == 'ubuntu-latest' }} - uses: actions/upload-artifact@v3 - with: - name: zls-x86-linux - path: artifacts/${{ steps.zls_version.outputs.zls_version }}/x86-linux/ - - - name: Upload aarch64-linux artifact - if: ${{ matrix.os == 'ubuntu-latest' }} - uses: actions/upload-artifact@v3 - with: - name: zls-aarch64-linux - path: artifacts/${{ steps.zls_version.outputs.zls_version }}/aarch64-linux/ - - - name: Upload aarch64-macos artifact - if: ${{ matrix.os == 'ubuntu-latest' }} - uses: actions/upload-artifact@v3 - with: - name: zls-aarch64-macos - path: artifacts/${{ steps.zls_version.outputs.zls_version }}/aarch64-macos/ - - - name: Upload wasm32-wasi artifact - if: ${{ matrix.os == 'ubuntu-latest' }} - uses: actions/upload-artifact@v3 - with: - name: zls-wasm32-wasi - path: artifacts/${{ steps.zls_version.outputs.zls_version }}/wasm32-wasi/ - - - uses: BetaHuhn/do-spaces-action@v2 - if: ${{ matrix.os == 'ubuntu-latest' && github.ref == 'refs/heads/master' }} - with: - access_key: ${{ secrets.DO_SPACES_ACCESS_KEY }} - secret_key: ${{ secrets.DO_SPACES_SECRET_KEY }} - space_name: zigtools-releases - space_region: nyc3 - source: artifacts/ - out_dir: zls/ +name: CI + +on: + push: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + build: + if: github.repository_owner == 'zigtools' + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - uses: goto-bus-stop/setup-zig@v2 + with: + version: master + + - run: zig env + + - name: Run zig fmt + run: zig fmt --check . + + - name: Run Tests + run: zig build test --summary all diff --git a/build.zig b/build.zig index 6c5a275d5d..4e3931caf5 100644 --- a/build.zig +++ b/build.zig @@ -38,67 +38,29 @@ pub fn build(b: *Build) !void { const single_threaded = b.option(bool, "single-threaded", "Build a single threaded Executable"); const pie = b.option(bool, "pie", "Build a Position Independent Executable"); const enable_tracy = b.option(bool, "enable_tracy", "Whether tracy should be enabled.") orelse false; + const enable_tracy_allocation = b.option(bool, "enable_tracy_allocation", "Enable using TracyAllocator to monitor allocations.") orelse enable_tracy; + const enable_tracy_callstack = b.option(bool, "enable_tracy_callstack", "Enable callstack graphs.") orelse enable_tracy; const coverage = b.option(bool, "generate_coverage", "Generate coverage data with kcov") orelse false; - const coverage_output_dir = b.option([]const u8, "coverage_output_dir", "Output directory for coverage data") orelse b.pathJoin(&.{ b.install_prefix, "kcov" }); const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter"); const data_version = b.option([]const u8, "data_version", "The Zig version your compiler is.") orelse "master"; const data_version_path = b.option([]const u8, "version_data_path", "Manually specify zig language reference file"); const override_version_data_file_path = b.option([]const u8, "version_data_file_path", "Relative path to version data file (if none, will be named with timestamp)"); const use_llvm = b.option(bool, "use_llvm", "Use Zig's llvm code backend"); - const version_string = v: { - const version_string = b.fmt("{d}.{d}.{d}", .{ zls_version.major, zls_version.minor, zls_version.patch }); - const build_root_path = b.build_root.path orelse "."; + const version_string = getVersion(b); - var code: u8 = undefined; - const git_describe_untrimmed = b.runAllowFail(&[_][]const u8{ - "git", "-C", build_root_path, "describe", "--match", "*.*.*", "--tags", - }, &code, .Ignore) catch break :v version_string; - - const git_describe = std.mem.trim(u8, git_describe_untrimmed, " \n\r"); - - switch (std.mem.count(u8, git_describe, "-")) { - 0 => { - // Tagged release version (e.g. 0.10.0). - std.debug.assert(std.mem.eql(u8, git_describe, version_string)); // tagged release must match version string - break :v version_string; - }, - 2 => { - // Untagged development build (e.g. 0.10.0-dev.216+34ce200). - var it = std.mem.splitScalar(u8, git_describe, '-'); - const tagged_ancestor = it.first(); - const commit_height = it.next().?; - const commit_id = it.next().?; - - const ancestor_ver = try std.SemanticVersion.parse(tagged_ancestor); - std.debug.assert(zls_version.order(ancestor_ver) == .gt); // zls version must be greater than its previous version - std.debug.assert(std.mem.startsWith(u8, commit_id, "g")); // commit hash is prefixed with a 'g' - - break :v b.fmt("{s}-dev.{s}+{s}", .{ version_string, commit_height, commit_id[1..] }); - }, - else => { - std.debug.print("Unexpected 'git describe' output: '{s}'\n", .{git_describe}); - std.process.exit(1); - }, - } - }; + const build_options = b.addOptions(); + const build_options_module = build_options.createModule(); + build_options.addOption([]const u8, "version_string", version_string); + build_options.addOption(std.SemanticVersion, "version", try std.SemanticVersion.parse(version_string)); + build_options.addOption([]const u8, "min_zig_string", min_zig_string); const exe_options = b.addOptions(); + const exe_options_module = exe_options.createModule(); exe_options.addOption(std.log.Level, "log_level", b.option(std.log.Level, "log_level", "The Log Level to be used.") orelse .info); - exe_options.addOption(bool, "enable_tracy", enable_tracy); - exe_options.addOption(bool, "enable_tracy_allocation", b.option(bool, "enable_tracy_allocation", "Enable using TracyAllocator to monitor allocations.") orelse enable_tracy); - exe_options.addOption(bool, "enable_tracy_callstack", b.option(bool, "enable_tracy_callstack", "Enable callstack graphs.") orelse enable_tracy); exe_options.addOption(bool, "enable_failing_allocator", b.option(bool, "enable_failing_allocator", "Whether to use a randomly failing allocator.") orelse false); exe_options.addOption(u32, "enable_failing_allocator_likelihood", b.option(u32, "enable_failing_allocator_likelihood", "The chance that an allocation will fail is `1/likelihood`") orelse 256); exe_options.addOption(bool, "use_gpa", b.option(bool, "use_gpa", "Good for debugging") orelse (optimize == .Debug)); - exe_options.addOption([]const u8, "version_string", version_string); - exe_options.addOption(std.SemanticVersion, "version", try std.SemanticVersion.parse(version_string)); - exe_options.addOption([]const u8, "min_zig_string", min_zig_string); - - const build_options = b.addOptions(); - const build_options_module = build_options.createModule(); - build_options.addOption([]const u8, "version_string", version_string); - build_options.addOption(std.SemanticVersion, "version", try std.SemanticVersion.parse(version_string)); const global_cache_path = try b.cache_root.join(b.allocator, &.{"zls"}); b.cache_root.handle.makePath(global_cache_path) catch |err| { @@ -110,48 +72,15 @@ pub fn build(b: *Build) !void { test_options.addOption([]const u8, "zig_exe_path", b.graph.zig_exe); test_options.addOption([]const u8, "global_cache_path", global_cache_path); - const exe_options_module = exe_options.createModule(); const known_folders_module = b.dependency("known_folders", .{}).module("known-folders"); const diffz_module = b.dependency("diffz", .{}).module("diffz"); - - const exe = b.addExecutable(.{ - .name = "zls", - .root_source_file = .{ .path = "src/main.zig" }, + const tracy_module = getTracyModule(b, .{ .target = target, .optimize = optimize, - .single_threaded = single_threaded, + .enable = enable_tracy, + .enable_allocation = enable_tracy_allocation, + .enable_callstack = enable_tracy_callstack, }); - exe.use_llvm = use_llvm; - exe.use_lld = use_llvm; - exe.pie = pie; - b.installArtifact(exe); - - exe.root_module.addImport("build_options", exe_options_module); - exe.root_module.addImport("known-folders", known_folders_module); - exe.root_module.addImport("diffz", diffz_module); - - if (enable_tracy) { - const client_cpp = "src/tracy/public/TracyClient.cpp"; - - // On mingw, we need to opt into windows 7+ to get some features required by tracy. - const tracy_c_flags: []const []const u8 = if (target.result.isMinGW()) - &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" } - else - &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" }; - - exe.addIncludePath(.{ .path = "src/tracy" }); - exe.addCSourceFile(.{ - .file = .{ .path = client_cpp }, - .flags = tracy_c_flags, - }); - exe.linkLibCpp(); - exe.linkLibC(); - - if (target.result.os.tag == .windows) { - exe.linkSystemLibrary("dbghelp"); - exe.linkSystemLibrary("ws2_32"); - } - } const gen_exe = b.addExecutable(.{ .name = "zls_gen", @@ -194,50 +123,105 @@ pub fn build(b: *Build) !void { else gen_version_data_cmd.addOutputFileArg(version_data_file_name); const version_data_module = b.addModule("version_data", .{ .root_source_file = version_data_path }); - exe.root_module.addImport("version_data", version_data_module); const zls_module = b.addModule("zls", .{ .root_source_file = .{ .path = "src/zls.zig" }, .imports = &.{ .{ .name = "known-folders", .module = known_folders_module }, .{ .name = "diffz", .module = diffz_module }, + .{ .name = "tracy", .module = tracy_module }, .{ .name = "build_options", .module = build_options_module }, .{ .name = "version_data", .module = version_data_module }, }, }); + const targets: []const std.Target.Query = &.{ + .{ .cpu_arch = .x86_64, .os_tag = .windows }, + .{ .cpu_arch = .x86_64, .os_tag = .linux }, + .{ .cpu_arch = .x86_64, .os_tag = .macos }, + .{ .cpu_arch = .x86, .os_tag = .windows }, + .{ .cpu_arch = .x86, .os_tag = .linux }, + .{ .cpu_arch = .aarch64, .os_tag = .linux }, + .{ .cpu_arch = .aarch64, .os_tag = .macos }, + .{ .cpu_arch = .wasm32, .os_tag = .wasi }, + }; + + const release_step = b.step("release", "Build all release binaries"); + + for (targets) |target_query| { + const exe = b.addExecutable(.{ + .name = "zls", + .root_source_file = .{ .path = "src/main.zig" }, + .target = b.resolveTargetQuery(target_query), + .optimize = optimize, + .single_threaded = single_threaded, + .use_llvm = use_llvm, + .use_lld = use_llvm, + }); + exe.pie = pie; + exe.root_module.addImport("exe_options", exe_options_module); + exe.root_module.addImport("tracy", tracy_module); + exe.root_module.addImport("known-folders", known_folders_module); + exe.root_module.addImport("zls", zls_module); + + const target_output = b.addInstallArtifact(exe, .{ + .dest_dir = .{ + .override = .{ + .custom = try target_query.zigTriple(b.allocator), + }, + }, + }); + release_step.dependOn(&target_output.step); + } + + const exe = b.addExecutable(.{ + .name = "zls", + .root_source_file = .{ .path = "src/main.zig" }, + .target = target, + .optimize = optimize, + .single_threaded = single_threaded, + .use_llvm = use_llvm, + .use_lld = use_llvm, + }); + exe.pie = pie; + exe.root_module.addImport("exe_options", exe_options_module); + exe.root_module.addImport("tracy", tracy_module); + exe.root_module.addImport("known-folders", known_folders_module); + exe.root_module.addImport("zls", zls_module); + b.installArtifact(exe); + const test_step = b.step("test", "Run all the tests"); test_step.dependOn(b.getInstallStep()); - var tests = b.addTest(.{ + const tests = b.addTest(.{ .root_source_file = .{ .path = "tests/tests.zig" }, .target = target, .optimize = optimize, .filter = test_filter, .single_threaded = single_threaded, + .use_llvm = use_llvm, + .use_lld = use_llvm, }); - tests.use_llvm = use_llvm; - tests.use_lld = use_llvm; tests.root_module.addImport("zls", zls_module); - tests.root_module.addImport("build_options", build_options_module); tests.root_module.addImport("test_options", test_options_module); test_step.dependOn(&b.addRunArtifact(tests).step); - var src_tests = b.addTest(.{ + const src_tests = b.addTest(.{ .root_source_file = .{ .path = "src/zls.zig" }, .target = target, .optimize = optimize, .filter = test_filter, .single_threaded = single_threaded, + .use_llvm = use_llvm, + .use_lld = use_llvm, }); - src_tests.use_llvm = use_llvm; - src_tests.use_lld = use_llvm; src_tests.root_module.addImport("build_options", build_options_module); src_tests.root_module.addImport("test_options", test_options_module); test_step.dependOn(&b.addRunArtifact(src_tests).step); if (coverage) { + const coverage_output_dir = b.makeTempPath(); const include_pattern = b.fmt("--include-pattern=/src", .{}); const exclude_pattern = b.fmt("--exclude-pattern=/src/stage2", .{}); const args = &[_]std.Build.Step.Run.Arg{ @@ -248,25 +232,115 @@ pub fn build(b: *Build) !void { .{ .bytes = b.dupe(coverage_output_dir) }, }; - var tests_run = b.addRunArtifact(tests); - var src_tests_run = b.addRunArtifact(src_tests); + const tests_run = b.addRunArtifact(tests); + const src_tests_run = b.addRunArtifact(src_tests); tests_run.has_side_effects = true; src_tests_run.has_side_effects = true; tests_run.argv.insertSlice(0, args) catch @panic("OOM"); src_tests_run.argv.insertSlice(0, args) catch @panic("OOM"); - var merge_step = std.Build.Step.Run.create(b, "merge kcov"); + const merge_step = std.Build.Step.Run.create(b, "merge kcov"); merge_step.has_side_effects = true; merge_step.addArgs(&.{ "kcov", "--merge", - coverage_output_dir, + b.pathJoin(&.{ coverage_output_dir, "output" }), b.pathJoin(&.{ coverage_output_dir, "test" }), }); - merge_step.step.dependOn(&b.addRemoveDirTree(coverage_output_dir).step); merge_step.step.dependOn(&tests_run.step); merge_step.step.dependOn(&src_tests_run.step); - test_step.dependOn(&merge_step.step); + + const install_coverage = b.addInstallDirectory(.{ + .source_dir = .{ .path = b.pathJoin(&.{ coverage_output_dir, "output" }) }, + .install_dir = .{ .custom = "coverage" }, + .install_subdir = "", + }); + install_coverage.step.dependOn(&merge_step.step); + test_step.dependOn(&install_coverage.step); + } +} + +fn getVersion(b: *Build) []const u8 { + const version_string = b.fmt("{d}.{d}.{d}", .{ zls_version.major, zls_version.minor, zls_version.patch }); + const build_root_path = b.build_root.path orelse "."; + + var code: u8 = undefined; + const git_describe_untrimmed = b.runAllowFail(&[_][]const u8{ + "git", "-C", build_root_path, "describe", "--match", "*.*.*", "--tags", + }, &code, .Ignore) catch return version_string; + + const git_describe = std.mem.trim(u8, git_describe_untrimmed, " \n\r"); + + switch (std.mem.count(u8, git_describe, "-")) { + 0 => { + // Tagged release version (e.g. 0.10.0). + std.debug.assert(std.mem.eql(u8, git_describe, version_string)); // tagged release must match version string + return version_string; + }, + 2 => { + // Untagged development build (e.g. 0.10.0-dev.216+34ce200). + var it = std.mem.splitScalar(u8, git_describe, '-'); + const tagged_ancestor = it.first(); + const commit_height = it.next().?; + const commit_id = it.next().?; + + const ancestor_ver = std.SemanticVersion.parse(tagged_ancestor) catch unreachable; + std.debug.assert(zls_version.order(ancestor_ver) == .gt); // zls version must be greater than its previous version + std.debug.assert(std.mem.startsWith(u8, commit_id, "g")); // commit hash is prefixed with a 'g' + + return b.fmt("{s}-dev.{s}+{s}", .{ version_string, commit_height, commit_id[1..] }); + }, + else => { + std.debug.print("Unexpected 'git describe' output: '{s}'\n", .{git_describe}); + std.process.exit(1); + }, + } +} + +fn getTracyModule( + b: *Build, + options: struct { + target: Build.ResolvedTarget, + optimize: std.builtin.OptimizeMode, + enable: bool, + enable_allocation: bool, + enable_callstack: bool, + }, +) *Build.Module { + const tracy_options = b.addOptions(); + tracy_options.addOption(bool, "enable", options.enable); + tracy_options.addOption(bool, "enable_allocation", options.enable and options.enable_allocation); + tracy_options.addOption(bool, "enable_callstack", options.enable and options.enable_callstack); + + const tracy_module = b.addModule("tracy", .{ + .root_source_file = .{ .path = "src/tracy.zig" }, + .target = options.target, + .optimize = options.optimize, + }); + tracy_module.addImport("options", tracy_options.createModule()); + if (!options.enable) return tracy_module; + tracy_module.link_libc = true; + tracy_module.link_libcpp = true; + + const client_cpp = "src/tracy/public/TracyClient.cpp"; + + // On mingw, we need to opt into windows 7+ to get some features required by tracy. + const tracy_c_flags: []const []const u8 = if (options.target.result.isMinGW()) + &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined", "-D_WIN32_WINNT=0x601" } + else + &[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" }; + + tracy_module.addIncludePath(.{ .path = "src/tracy" }); + tracy_module.addCSourceFile(.{ + .file = .{ .path = client_cpp }, + .flags = tracy_c_flags, + }); + + if (options.target.result.os.tag == .windows) { + tracy_module.linkSystemLibrary("dbghelp", .{}); + tracy_module.linkSystemLibrary("ws2_32", .{}); } + + return tracy_module; } diff --git a/flake.lock b/flake.lock index 82242b0f0c..4b14781cc6 100644 --- a/flake.lock +++ b/flake.lock @@ -72,22 +72,22 @@ "langref": { "flake": false, "locked": { - "narHash": "sha256-mYdDCBdNEIeMbavdhSo8qXqW+3fqPC8BAich7W3umrI=", + "narHash": "sha256-94broSBethRhPJr0G9no4TPyB8ee6BQ/hHK1QnLPln0=", "type": "file", - "url": "https://raw.githubusercontent.com/ziglang/zig/63bd2bff12992aef0ce23ae4b344e9cb5d65f05d/doc/langref.html.in" + "url": "https://raw.githubusercontent.com/ziglang/zig/54bbc73f8502fe073d385361ddb34a43d12eec39/doc/langref.html.in" }, "original": { "type": "file", - "url": "https://raw.githubusercontent.com/ziglang/zig/63bd2bff12992aef0ce23ae4b344e9cb5d65f05d/doc/langref.html.in" + "url": "https://raw.githubusercontent.com/ziglang/zig/54bbc73f8502fe073d385361ddb34a43d12eec39/doc/langref.html.in" } }, "nixpkgs": { "locked": { - "lastModified": 1707588924, - "narHash": "sha256-0e1ce6X5ghapv6cAF9rxLZKeNyFHHXsLbGxN2cQQE8U=", + "lastModified": 1707743206, + "narHash": "sha256-AehgH64b28yKobC/DAWYZWkJBxL/vP83vkY+ag2Hhy4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "10b813040df67c4039086db0f6eaf65c536886c6", + "rev": "2d627a2a704708673e56346fcb13d25344b8eaf3", "type": "github" }, "original": { @@ -130,11 +130,11 @@ ] }, "locked": { - "lastModified": 1707611073, - "narHash": "sha256-sMsxVKXP5TLcaVMNlRZ7KlDsYGwDdJAMtY0DKmb+7fQ=", + "lastModified": 1707783766, + "narHash": "sha256-kD90pK+KAzr3UrohYRqE7fWUaEg4Mv3rk1IhubiHFUM=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "aa4edff6f53e64443ca77e8d9ffe866f29e5b3d4", + "rev": "06f4507d05f90a54409a5206fcfba5966eea0c03", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 5cfe2dd0ad..b759f44c3b 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,7 @@ flake-utils.url = "github:numtide/flake-utils"; - langref.url = "https://raw.githubusercontent.com/ziglang/zig/63bd2bff12992aef0ce23ae4b344e9cb5d65f05d/doc/langref.html.in"; + langref.url = "https://raw.githubusercontent.com/ziglang/zig/54bbc73f8502fe073d385361ddb34a43d12eec39/doc/langref.html.in"; langref.flake = false; }; diff --git a/src/DocumentScope.zig b/src/DocumentScope.zig index 42e7e85a54..23f9b2cc0e 100644 --- a/src/DocumentScope.zig +++ b/src/DocumentScope.zig @@ -1,7 +1,7 @@ const std = @import("std"); const ast = @import("ast.zig"); const Ast = std.zig.Ast; -const tracy = @import("tracy.zig"); +const tracy = @import("tracy"); const offsets = @import("offsets.zig"); const Analyser = @import("analysis.zig"); const Declaration = Analyser.Declaration; diff --git a/src/DocumentStore.zig b/src/DocumentStore.zig index fbff1a339f..deb6e53a5f 100644 --- a/src/DocumentStore.zig +++ b/src/DocumentStore.zig @@ -7,7 +7,7 @@ const log = std.log.scoped(.zls_store); const Ast = std.zig.Ast; const BuildAssociatedConfig = @import("BuildAssociatedConfig.zig"); const BuildConfig = @import("build_runner/BuildConfig.zig"); -const tracy = @import("tracy.zig"); +const tracy = @import("tracy"); const Config = @import("Config.zig"); const ZigVersionWrapper = @import("ZigVersionWrapper.zig"); const translate_c = @import("translate_c.zig"); diff --git a/src/Server.zig b/src/Server.zig index 7d8def25ed..ae2b9ad0dd 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -11,7 +11,7 @@ const Analyser = @import("analysis.zig"); const ast = @import("ast.zig"); const offsets = @import("offsets.zig"); const Ast = std.zig.Ast; -const tracy = @import("tracy.zig"); +const tracy = @import("tracy"); const diff = @import("diff.zig"); const ComptimeInterpreter = @import("ComptimeInterpreter.zig"); const InternPool = @import("analyser/analyser.zig").InternPool; diff --git a/src/analysis.zig b/src/analysis.zig index 2e4efd1b32..1eeb350480 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -5,7 +5,7 @@ const offsets = @import("offsets.zig"); const URI = @import("uri.zig"); const log = std.log.scoped(.zls_analysis); const ast = @import("ast.zig"); -const tracy = @import("tracy.zig"); +const tracy = @import("tracy"); const ComptimeInterpreter = @import("ComptimeInterpreter.zig"); const InternPool = ComptimeInterpreter.InternPool; const references = @import("features/references.zig"); diff --git a/src/configuration.zig b/src/configuration.zig index e83e10a893..ed651ce226 100644 --- a/src/configuration.zig +++ b/src/configuration.zig @@ -2,7 +2,7 @@ const std = @import("std"); const builtin = @import("builtin"); const ZigVersionWrapper = @import("ZigVersionWrapper.zig"); -const tracy = @import("tracy.zig"); +const tracy = @import("tracy"); const known_folders = @import("known-folders"); const Config = @import("Config.zig"); diff --git a/src/diff.zig b/src/diff.zig index cbc8952879..7b3a095a4f 100644 --- a/src/diff.zig +++ b/src/diff.zig @@ -1,7 +1,7 @@ const std = @import("std"); const types = @import("lsp.zig"); const offsets = @import("offsets.zig"); -const tracy = @import("tracy.zig"); +const tracy = @import("tracy"); const DiffMatchPatch = @import("diffz"); const dmp = DiffMatchPatch{ diff --git a/src/features/code_actions.zig b/src/features/code_actions.zig index 74723ec7e6..9b44b51b5b 100644 --- a/src/features/code_actions.zig +++ b/src/features/code_actions.zig @@ -6,7 +6,7 @@ const Analyser = @import("../analysis.zig"); const ast = @import("../ast.zig"); const types = @import("../lsp.zig"); const offsets = @import("../offsets.zig"); -const tracy = @import("../tracy.zig"); +const tracy = @import("tracy"); pub const Builder = struct { arena: std.mem.Allocator, diff --git a/src/features/completions.zig b/src/features/completions.zig index 2434efd2b1..d804f03e10 100644 --- a/src/features/completions.zig +++ b/src/features/completions.zig @@ -9,7 +9,7 @@ const types = @import("../lsp.zig"); const Analyser = @import("../analysis.zig"); const ast = @import("../ast.zig"); const offsets = @import("../offsets.zig"); -const tracy = @import("../tracy.zig"); +const tracy = @import("tracy"); const URI = @import("../uri.zig"); const DocumentScope = @import("../DocumentScope.zig"); const analyser_completions = @import("../analyser/completions.zig"); @@ -670,7 +670,7 @@ fn kindToSortScore(kind: types.CompletionItemKind) ?[]const u8 { .Variable => "2_", .Field => "3_", - .Function => "4_", + .Function, .Method => "4_", .Keyword, .Snippet, .EnumMember => "5_", @@ -683,7 +683,7 @@ fn kindToSortScore(kind: types.CompletionItemKind) ?[]const u8 { => "6_", else => { - log.debug(@typeName(types.CompletionItemKind) ++ "{s} has no sort score specified!", .{@tagName(kind)}); + log.debug(@typeName(types.CompletionItemKind) ++ ".{s} has no sort score specified!", .{@tagName(kind)}); return null; }, }; diff --git a/src/features/diagnostics.zig b/src/features/diagnostics.zig index 34ff301dc3..2612f917b5 100644 --- a/src/features/diagnostics.zig +++ b/src/features/diagnostics.zig @@ -12,7 +12,7 @@ const ast = @import("../ast.zig"); const offsets = @import("../offsets.zig"); const URI = @import("../uri.zig"); const code_actions = @import("code_actions.zig"); -const tracy = @import("../tracy.zig"); +const tracy = @import("tracy"); const Module = @import("../stage2/Module.zig"); const Zir = @import("../stage2/Zir.zig"); diff --git a/src/features/document_symbol.zig b/src/features/document_symbol.zig index 35a50f0c27..2e1d9bf9af 100644 --- a/src/features/document_symbol.zig +++ b/src/features/document_symbol.zig @@ -6,7 +6,7 @@ const types = @import("../lsp.zig"); const offsets = @import("../offsets.zig"); const ast = @import("../ast.zig"); const analysis = @import("../analysis.zig"); -const tracy = @import("../tracy.zig"); +const tracy = @import("tracy"); const Symbol = struct { name: []const u8, diff --git a/src/features/folding_range.zig b/src/features/folding_range.zig index cd02606a69..655aa4b8c8 100644 --- a/src/features/folding_range.zig +++ b/src/features/folding_range.zig @@ -4,7 +4,7 @@ const Ast = std.zig.Ast; const ast = @import("../ast.zig"); const types = @import("../lsp.zig"); const offsets = @import("../offsets.zig"); -const tracy = @import("../tracy.zig"); +const tracy = @import("tracy"); const FoldingRange = struct { loc: offsets.Loc, diff --git a/src/features/goto.zig b/src/features/goto.zig index 23d7134eb4..9849618055 100644 --- a/src/features/goto.zig +++ b/src/features/goto.zig @@ -7,7 +7,7 @@ const ast = @import("../ast.zig"); const types = @import("../lsp.zig"); const offsets = @import("../offsets.zig"); const URI = @import("../uri.zig"); -const tracy = @import("../tracy.zig"); +const tracy = @import("tracy"); const Analyser = @import("../analysis.zig"); const DocumentStore = @import("../DocumentStore.zig"); diff --git a/src/features/hover.zig b/src/features/hover.zig index 587e2ebf00..1f38d09c6e 100644 --- a/src/features/hover.zig +++ b/src/features/hover.zig @@ -6,7 +6,7 @@ const ast = @import("../ast.zig"); const types = @import("../lsp.zig"); const offsets = @import("../offsets.zig"); const URI = @import("../uri.zig"); -const tracy = @import("../tracy.zig"); +const tracy = @import("tracy"); const Analyser = @import("../analysis.zig"); const DocumentStore = @import("../DocumentStore.zig"); diff --git a/src/features/inlay_hints.zig b/src/features/inlay_hints.zig index efba03a96e..c6e27b1b21 100644 --- a/src/features/inlay_hints.zig +++ b/src/features/inlay_hints.zig @@ -7,7 +7,7 @@ const DocumentStore = @import("../DocumentStore.zig"); const Analyser = @import("../analysis.zig"); const types = @import("../lsp.zig"); const offsets = @import("../offsets.zig"); -const tracy = @import("../tracy.zig"); +const tracy = @import("tracy"); const ast = @import("../ast.zig"); const Config = @import("../Config.zig"); diff --git a/src/features/references.zig b/src/features/references.zig index c167731725..2b10cef664 100644 --- a/src/features/references.zig +++ b/src/features/references.zig @@ -8,7 +8,7 @@ const Analyser = @import("../analysis.zig"); const types = @import("../lsp.zig"); const offsets = @import("../offsets.zig"); const ast = @import("../ast.zig"); -const tracy = @import("../tracy.zig"); +const tracy = @import("tracy"); fn labelReferences( allocator: std.mem.Allocator, diff --git a/src/main.zig b/src/main.zig index 7702bec35c..fbba797388 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,21 +1,17 @@ const std = @import("std"); const zig_builtin = @import("builtin"); -const build_options = @import("build_options"); -const tracy = @import("tracy.zig"); +const zls = @import("zls"); +const exe_options = @import("exe_options"); + +const tracy = @import("tracy"); const known_folders = @import("known-folders"); -const Config = @import("Config.zig"); -const configuration = @import("configuration.zig"); -const Server = @import("Server.zig"); -const Header = @import("Header.zig"); -const Transport = @import("Transport.zig"); -const debug = @import("debug.zig"); const binned_allocator = @import("binned_allocator.zig"); const logger = std.log.scoped(.zls_main); var actual_log_level: std.log.Level = switch (zig_builtin.mode) { .Debug => .debug, - else => @enumFromInt(@intFromEnum(build_options.log_level)), // temporary fix to build failing on release-safe due to a Zig bug + else => @enumFromInt(@intFromEnum(exe_options.log_level)), // temporary fix to build failing on release-safe due to a Zig bug }; fn logFn( @@ -45,7 +41,7 @@ pub const std_options = std.Options{ .logFn = logFn, }; -fn getRecordFile(config: Config) ?std.fs.File { +fn getRecordFile(config: zls.Config) ?std.fs.File { if (!config.record_session) return null; if (config.record_session_path) |record_path| { @@ -62,7 +58,7 @@ fn getRecordFile(config: Config) ?std.fs.File { } } -fn getReplayFile(config: Config) ?std.fs.File { +fn getReplayFile(config: zls.Config) ?std.fs.File { const replay_path = config.replay_session_path orelse config.record_session_path orelse return null; if (std.fs.openFileAbsolute(replay_path, .{})) |file| { @@ -78,8 +74,8 @@ fn getReplayFile(config: Config) ?std.fs.File { /// when replaying we read this message and replace the current config fn updateConfig( allocator: std.mem.Allocator, - transport: *Transport, - config: *configuration.ConfigWithPath, + transport: *zls.Transport, + config: *zls.configuration.ConfigWithPath, record_file: ?std.fs.File, replay_file: ?std.fs.File, ) !void { @@ -94,7 +90,7 @@ fn updateConfig( defer buffer.deinit(allocator); try std.json.stringify(cfg, .{}, buffer.writer(allocator)); - var header = Header{ .content_length = buffer.items.len }; + var header = zls.Header{ .content_length = buffer.items.len }; try header.write(file.writer()); try file.writeAll(buffer.items); } @@ -104,7 +100,7 @@ fn updateConfig( defer allocator.free(json_message); const new_config = try std.json.parseFromSlice( - Config, + zls.Config, allocator, json_message, .{ .allocate = .alloc_always }, @@ -232,11 +228,11 @@ fn parseArgs(allocator: std.mem.Allocator) !ParseArgsResult { return result; } if (specified.get(.version)) { - try stdout.writeAll(build_options.version_string ++ "\n"); + try stdout.writeAll(zls.build_options.version_string ++ "\n"); return result; } if (specified.get(.@"minimum-build-version")) { - try stdout.writeAll(build_options.min_zig_string ++ "\n"); + try stdout.writeAll(zls.build_options.min_zig_string ++ "\n"); return result; } if (specified.get(.@"compiler-version")) { @@ -255,7 +251,7 @@ fn parseArgs(allocator: std.mem.Allocator) !ParseArgsResult { std.debug.assert(result.config_path != null); } if (specified.get(.@"show-config-path")) { - var new_config = try configuration.getConfig(allocator, result.config_path); + var new_config = try zls.configuration.getConfig(allocator, result.config_path); defer new_config.deinit(allocator); if (new_config.config_path) |path| { @@ -286,13 +282,13 @@ const stack_frames = switch (zig_builtin.mode) { }; pub fn main() !void { - var allocator_state = if (build_options.use_gpa) + var allocator_state = if (exe_options.use_gpa) std.heap.GeneralPurposeAllocator(.{ .stack_trace_frames = stack_frames }){} else binned_allocator.BinnedAllocator(.{}){}; defer { - if (build_options.use_gpa) + if (exe_options.use_gpa) std.debug.assert(allocator_state.deinit() == .ok) else allocator_state.deinit(); @@ -301,8 +297,8 @@ pub fn main() !void { var tracy_state = if (tracy.enable_allocation) tracy.tracyAllocator(allocator_state.allocator()) else void{}; const inner_allocator: std.mem.Allocator = if (tracy.enable_allocation) tracy_state.allocator() else allocator_state.allocator(); - var failing_allocator_state = if (build_options.enable_failing_allocator) debug.FailingAllocator.init(inner_allocator, build_options.enable_failing_allocator_likelihood) else void{}; - const allocator: std.mem.Allocator = if (build_options.enable_failing_allocator) failing_allocator_state.allocator() else inner_allocator; + var failing_allocator_state = if (exe_options.enable_failing_allocator) zls.debug.FailingAllocator.init(inner_allocator, exe_options.enable_failing_allocator_likelihood) else void{}; + const allocator: std.mem.Allocator = if (exe_options.enable_failing_allocator) failing_allocator_state.allocator() else inner_allocator; const result = try parseArgs(allocator); defer allocator.free(result.zls_exe_path); @@ -312,9 +308,9 @@ pub fn main() !void { .exit => return, } - logger.info("Starting ZLS {s} @ '{s}'", .{ build_options.version_string, result.zls_exe_path }); + logger.info("Starting ZLS {s} @ '{s}'", .{ zls.build_options.version_string, result.zls_exe_path }); - var config = try configuration.getConfig(allocator, result.config_path); + var config = try zls.configuration.getConfig(allocator, result.config_path); defer config.deinit(allocator); if (result.replay_enabled and config.config.record_session_path == null) { @@ -332,7 +328,7 @@ pub fn main() !void { const replay_file = if (result.replay_enabled) getReplayFile(config.config) else null; defer if (replay_file) |file| file.close(); - var transport = Transport.init( + var transport = zls.Transport.init( if (replay_file) |file| file.reader() else std.io.getStdIn().reader(), std.io.getStdOut().writer(), ); @@ -341,7 +337,7 @@ pub fn main() !void { try updateConfig(allocator, &transport, &config, record_file, replay_file); - const server = try Server.create(allocator); + const server = try zls.Server.create(allocator); defer server.destroy(); try server.updateConfiguration2(config.config); server.recording_enabled = record_file != null; diff --git a/src/stage2/AstGen.zig b/src/stage2/AstGen.zig index 908358892a..850b81c5db 100644 --- a/src/stage2/AstGen.zig +++ b/src/stage2/AstGen.zig @@ -22,7 +22,7 @@ const isPrimitive = std.zig.primitives.isPrimitive; const Zir = @import("Zir.zig"); const refToIndex = Zir.refToIndex; const indexToRef = Zir.indexToRef; -const trace = @import("../tracy.zig").trace; +const trace = @import("tracy").trace; const BuiltinFn = @import("BuiltinFn.zig"); const AstRlAnnotate = @import("AstRlAnnotate.zig"); diff --git a/src/tracy.zig b/src/tracy.zig index ec9a7f3764..d7afd74775 100644 --- a/src/tracy.zig +++ b/src/tracy.zig @@ -25,11 +25,11 @@ const std = @import("std"); const builtin = @import("builtin"); -const build_options = @import("build_options"); +const options = @import("options"); -pub const enable = if (builtin.is_test) false else build_options.enable_tracy; -pub const enable_allocation = enable and build_options.enable_tracy_allocation; -pub const enable_callstack = enable and build_options.enable_tracy_callstack; +pub const enable = if (builtin.is_test) false else options.enable; +pub const enable_allocation = enable and options.enable_allocation; +pub const enable_callstack = enable and options.enable_callstack; // TODO: make this configurable const callstack_depth = 10; diff --git a/src/translate_c.zig b/src/translate_c.zig index f4d658e83f..f6f7b12569 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -3,7 +3,7 @@ const zig_builtin = @import("builtin"); const builtin = @import("builtin"); const Config = @import("Config.zig"); const ast = @import("ast.zig"); -const tracy = @import("tracy.zig"); +const tracy = @import("tracy"); const Ast = std.zig.Ast; const URI = @import("uri.zig"); const ZCS = @import("ZigCompileServer.zig"); diff --git a/src/zls.zig b/src/zls.zig index 5c6e47f156..d07362ca3f 100644 --- a/src/zls.zig +++ b/src/zls.zig @@ -1,6 +1,8 @@ //! Used by tests as a package, can be used by tools such as //! zigbot9001 to take advantage of zls' tools +pub const build_options = @import("build_options"); + pub const ast = @import("ast.zig"); pub const Analyser = @import("analysis.zig"); pub const Header = @import("Header.zig"); @@ -9,6 +11,7 @@ pub const offsets = @import("offsets.zig"); pub const Config = @import("Config.zig"); pub const Server = @import("Server.zig"); pub const translate_c = @import("translate_c.zig"); +pub const Transport = @import("Transport.zig"); pub const types = @import("lsp.zig"); pub const URI = @import("uri.zig"); pub const DocumentStore = @import("DocumentStore.zig");