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

build: orthonormalize the interface #2033

Merged
merged 3 commits into from
Jul 1, 2024
Merged

build: orthonormalize the interface #2033

merged 3 commits into from
Jul 1, 2024

Conversation

matklad
Copy link
Member

@matklad matklad commented Jun 19, 2024

Refactor build.zig to make the interface easier to remember and the
implementation somewhat easier to follow.

Many step names changed to follow step/ step:substep pattern, with
top-level step being the primary interface.

Main steps:

  • zig build builds TigerBeetle to ./src/tigerbeetle[.exe], no
    changes here.

  • zig build check quickly check for compilation errors. No changes
    here, but now we can introduce zig build vopr:check in a clean way.

  • zig build run run TigerBeetle, no changes here.

  • zig build scripts -- free-form release automation, no changes here.

  • zig build test, zig build test:unit, zig build test:integration,
    zig build test:fmt runs various tests.

  • zig build fuzz, zig build fuzz:build run or just build minor fuzzers

  • zig build vopr, zig build vopr:build run or just build the simulator

  • zig build client:{c,node,java,dotnet,go} -- build corresponding
    native libraries.

Odd steps which I'd love to get rid off, but which don't really fit
anywhere else:

  • zig build aof for running the aof utility
  • zig build clients:c:sample for checking C sample
  • zig build test:jni for running JNI tests. These have a dependency on
    JAVA_HOME, so they are not being run by default.

The main implementation change is that all build steps and options are
pre-declared at the top of the file, so you can see the entire interface
at a glance (got the idea from https://ziggit.dev/t/build-system-tricks/3531)

Closes: #1280

@matklad matklad force-pushed the matklad/build-better branch 2 times, most recently from 5b1d51f to f333e86 Compare June 20, 2024 12:51
@matklad
Copy link
Member Author

matklad commented Jun 20, 2024

Closes the remaining 80% of #1280

@matklad matklad force-pushed the matklad/build-better branch 3 times, most recently from d7b8c03 to 5501d85 Compare June 25, 2024 15:43
@matklad matklad changed the title simpler build.zig build: orthonormalize the interface Jun 25, 2024
@matklad matklad force-pushed the matklad/build-better branch 6 times, most recently from ac23cbc to a2b297d Compare June 25, 2024 16:40
@matklad matklad force-pushed the matklad/build-better branch 4 times, most recently from d3d639c to 78e554d Compare June 26, 2024 14:19
@matklad matklad marked this pull request as ready for review June 26, 2024 15:24
@matklad matklad requested a review from batiati June 26, 2024 15:24
build.zig Outdated
.clients_java = b.step("clients:java", "Build Java client shared library"),
.clients_node = b.step("clients:node", "Build Node client shared library"),
.fuzz = b.step("fuzz", "Run non-VOPR fuzzers"),
.fuzz_build = b.step("fuzz:build", "Run non-VOPR fuzzers"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/run/build

Refactor build.zig to make the interface easier to remember and the
implementation somewhat easier to follow.

Many step names changed to follow `step`/ `step:substep` pattern, with
top-level `step` being the primary interface.

Main steps:

* `zig build` builds TigerBeetle to `./src/tigerbeetle[.exe]`, no
  changes here.
* `zig build check` quickly check for compilation errors. No changes
  here, but now we can introduce `zig build vopr:check` in a clean way.
* `zig build run` run TigerBeetle, no changes here.

* `zig build scripts` -- free-form release automation, no changes here.

* `zig build test`, `zig build test:unit`, `zig build test:integration`,
  `zig build test:fmt` runs various tests.
* `zig build fuzz`, `zig build fuzz:build` run or just build minor fuzzers
* `zig build vopr`, `zig build vopr:build` run or just build the simulator

* `zig build client:{c,node,java,dotnet,go}` -- build corresponding
  native libraries.

Odd steps which I'd love to get rid off, but which don't really fit
anywhere else:

* `zig build aof` for running the aof utility
* `zig build clients:c:sample` for checking C sample
* `zig build test:jni` for running JNI tests. These have a dependency on
  JAVA_HOME, so they are _not_ being run by default.

The main implementation change is that all build steps and options are
pre-declared at the top of the file, so you can see the entire interface
at a glance (got the idea from https://ziggit.dev/t/build-system-tricks/3531)

Closes: #1280
This builds on top of #2044

* print generated file to stdout, to avoid the need to parse cli
  arguments. That's the UNIX way -- let the caller to redirect the
  output whenever they need it!
* Motivate why we need our own InstallStep, and rename it to CopyFile to
  avoid confusion with build-in install.
@matklad matklad added this pull request to the merge queue Jul 1, 2024
Merged via the queue into main with commit e1bbe61 Jul 1, 2024
25 checks passed
@matklad matklad deleted the matklad/build-better branch July 1, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rework build.zig and shorten our CI script
2 participants