tigerbeetle 0.0.40 → 0.17.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +0 -25
- data/README.md +670 -80
- data/docs/migration.md +201 -0
- data/sig/tigerbeetle.rbs +271 -0
- data/src/ext/tigerbeetle/extconf.rb +47 -0
- data/src/ext/tigerbeetle/lib/aarch64-linux-gnu.2.27/libtb_client.so +0 -0
- data/src/ext/tigerbeetle/lib/aarch64-linux-musl/libtb_client.so +0 -0
- data/src/ext/tigerbeetle/lib/aarch64-macos/libtb_client.dylib +0 -0
- data/src/ext/tigerbeetle/lib/x86_64-linux-gnu.2.27/libtb_client.so +0 -0
- data/src/ext/tigerbeetle/lib/x86_64-linux-musl/libtb_client.so +0 -0
- data/src/ext/tigerbeetle/lib/x86_64-macos/libtb_client.dylib +0 -0
- data/src/ext/tigerbeetle/lib/x86_64-windows/tb_client.dll +0 -0
- data/src/ext/tigerbeetle/rb_tb_gen.h +458 -0
- data/{ext/tb_client/tigerbeetle/src/clients/rust/assets → src/ext/tigerbeetle}/tb_client.h +18 -16
- data/src/ext/tigerbeetle/tigerbeetle.c +310 -0
- data/src/tigerbeetle/bindings.rb +347 -0
- data/src/tigerbeetle/client.rb +129 -0
- data/src/tigerbeetle/completion_dispatcher.rb +108 -0
- data/src/tigerbeetle/id.rb +40 -0
- data/src/tigerbeetle/tb.rb +3 -0
- data/src/tigerbeetle/version.rb +3 -0
- data/src/tigerbeetle.rb +39 -0
- metadata +33 -350
- data/CHANGELOG.md +0 -162
- data/ext/tb_client/extconf.rb +0 -41
- data/ext/tb_client/tigerbeetle/LICENSE +0 -177
- data/ext/tb_client/tigerbeetle/build.zig +0 -2296
- data/ext/tb_client/tigerbeetle/src/aof.zig +0 -1000
- data/ext/tb_client/tigerbeetle/src/build/fetch.zig +0 -112
- data/ext/tb_client/tigerbeetle/src/build_multiversion.zig +0 -808
- data/ext/tb_client/tigerbeetle/src/cdc/amqp/protocol.zig +0 -1283
- data/ext/tb_client/tigerbeetle/src/cdc/amqp/spec.zig +0 -1704
- data/ext/tb_client/tigerbeetle/src/cdc/amqp/types.zig +0 -341
- data/ext/tb_client/tigerbeetle/src/cdc/amqp.zig +0 -1450
- data/ext/tb_client/tigerbeetle/src/cdc/runner.zig +0 -1659
- data/ext/tb_client/tigerbeetle/src/clients/c/samples/main.c +0 -406
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/context.zig +0 -1092
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/echo_client.zig +0 -286
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/packet.zig +0 -158
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/signal.zig +0 -229
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client/signal_fuzz.zig +0 -110
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client.h +0 -386
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client.zig +0 -34
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client_exports.zig +0 -281
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client_header.zig +0 -312
- data/ext/tb_client/tigerbeetle/src/clients/c/tb_client_header_test.zig +0 -138
- data/ext/tb_client/tigerbeetle/src/clients/c/test.zig +0 -466
- data/ext/tb_client/tigerbeetle/src/clients/docs_samples.zig +0 -157
- data/ext/tb_client/tigerbeetle/src/clients/docs_types.zig +0 -90
- data/ext/tb_client/tigerbeetle/src/clients/dotnet/ci.zig +0 -203
- data/ext/tb_client/tigerbeetle/src/clients/dotnet/docs.zig +0 -79
- data/ext/tb_client/tigerbeetle/src/clients/dotnet/dotnet_bindings.zig +0 -542
- data/ext/tb_client/tigerbeetle/src/clients/go/ci.zig +0 -109
- data/ext/tb_client/tigerbeetle/src/clients/go/docs.zig +0 -86
- data/ext/tb_client/tigerbeetle/src/clients/go/go_bindings.zig +0 -370
- data/ext/tb_client/tigerbeetle/src/clients/go/pkg/native/tb_client.h +0 -386
- data/ext/tb_client/tigerbeetle/src/clients/java/ci.zig +0 -167
- data/ext/tb_client/tigerbeetle/src/clients/java/docs.zig +0 -126
- data/ext/tb_client/tigerbeetle/src/clients/java/java_bindings.zig +0 -996
- data/ext/tb_client/tigerbeetle/src/clients/java/src/client.zig +0 -748
- data/ext/tb_client/tigerbeetle/src/clients/java/src/jni.zig +0 -3238
- data/ext/tb_client/tigerbeetle/src/clients/java/src/jni_tests.zig +0 -1718
- data/ext/tb_client/tigerbeetle/src/clients/java/src/jni_thread_cleaner.zig +0 -190
- data/ext/tb_client/tigerbeetle/src/clients/node/ci.zig +0 -104
- data/ext/tb_client/tigerbeetle/src/clients/node/docs.zig +0 -75
- data/ext/tb_client/tigerbeetle/src/clients/node/node.zig +0 -522
- data/ext/tb_client/tigerbeetle/src/clients/node/node_bindings.zig +0 -267
- data/ext/tb_client/tigerbeetle/src/clients/node/src/c.zig +0 -3
- data/ext/tb_client/tigerbeetle/src/clients/node/src/translate.zig +0 -379
- data/ext/tb_client/tigerbeetle/src/clients/python/ci.zig +0 -131
- data/ext/tb_client/tigerbeetle/src/clients/python/docs.zig +0 -63
- data/ext/tb_client/tigerbeetle/src/clients/python/python_bindings.zig +0 -588
- data/ext/tb_client/tigerbeetle/src/clients/rust/ci.zig +0 -73
- data/ext/tb_client/tigerbeetle/src/clients/rust/docs.zig +0 -106
- data/ext/tb_client/tigerbeetle/src/clients/rust/rust_bindings.zig +0 -305
- data/ext/tb_client/tigerbeetle/src/config.zig +0 -296
- data/ext/tb_client/tigerbeetle/src/constants.zig +0 -790
- data/ext/tb_client/tigerbeetle/src/copyhound.zig +0 -202
- data/ext/tb_client/tigerbeetle/src/counting_allocator.zig +0 -72
- data/ext/tb_client/tigerbeetle/src/direction.zig +0 -120
- data/ext/tb_client/tigerbeetle/src/docs_website/build.zig +0 -158
- data/ext/tb_client/tigerbeetle/src/docs_website/src/content.zig +0 -156
- data/ext/tb_client/tigerbeetle/src/docs_website/src/docs.zig +0 -252
- data/ext/tb_client/tigerbeetle/src/docs_website/src/file_checker.zig +0 -313
- data/ext/tb_client/tigerbeetle/src/docs_website/src/html.zig +0 -87
- data/ext/tb_client/tigerbeetle/src/docs_website/src/page_writer.zig +0 -63
- data/ext/tb_client/tigerbeetle/src/docs_website/src/redirects.zig +0 -47
- data/ext/tb_client/tigerbeetle/src/docs_website/src/search_index_writer.zig +0 -28
- data/ext/tb_client/tigerbeetle/src/docs_website/src/service_worker_writer.zig +0 -61
- data/ext/tb_client/tigerbeetle/src/docs_website/src/single_page_writer.zig +0 -169
- data/ext/tb_client/tigerbeetle/src/docs_website/src/website.zig +0 -46
- data/ext/tb_client/tigerbeetle/src/ewah.zig +0 -445
- data/ext/tb_client/tigerbeetle/src/ewah_benchmark.zig +0 -128
- data/ext/tb_client/tigerbeetle/src/ewah_fuzz.zig +0 -171
- data/ext/tb_client/tigerbeetle/src/fuzz_tests.zig +0 -179
- data/ext/tb_client/tigerbeetle/src/integration_tests.zig +0 -662
- data/ext/tb_client/tigerbeetle/src/io/common.zig +0 -155
- data/ext/tb_client/tigerbeetle/src/io/darwin.zig +0 -1093
- data/ext/tb_client/tigerbeetle/src/io/linux.zig +0 -1880
- data/ext/tb_client/tigerbeetle/src/io/test.zig +0 -1005
- data/ext/tb_client/tigerbeetle/src/io/windows.zig +0 -1598
- data/ext/tb_client/tigerbeetle/src/io.zig +0 -34
- data/ext/tb_client/tigerbeetle/src/iops.zig +0 -134
- data/ext/tb_client/tigerbeetle/src/list.zig +0 -236
- data/ext/tb_client/tigerbeetle/src/lsm/binary_search.zig +0 -848
- data/ext/tb_client/tigerbeetle/src/lsm/binary_search_benchmark.zig +0 -179
- data/ext/tb_client/tigerbeetle/src/lsm/cache_map.zig +0 -424
- data/ext/tb_client/tigerbeetle/src/lsm/cache_map_fuzz.zig +0 -420
- data/ext/tb_client/tigerbeetle/src/lsm/compaction.zig +0 -2114
- data/ext/tb_client/tigerbeetle/src/lsm/composite_key.zig +0 -185
- data/ext/tb_client/tigerbeetle/src/lsm/forest.zig +0 -1146
- data/ext/tb_client/tigerbeetle/src/lsm/forest_fuzz.zig +0 -1102
- data/ext/tb_client/tigerbeetle/src/lsm/forest_table_iterator.zig +0 -200
- data/ext/tb_client/tigerbeetle/src/lsm/groove.zig +0 -1495
- data/ext/tb_client/tigerbeetle/src/lsm/k_way_merge.zig +0 -739
- data/ext/tb_client/tigerbeetle/src/lsm/k_way_merge_benchmark.zig +0 -166
- data/ext/tb_client/tigerbeetle/src/lsm/manifest.zig +0 -754
- data/ext/tb_client/tigerbeetle/src/lsm/manifest_level.zig +0 -1294
- data/ext/tb_client/tigerbeetle/src/lsm/manifest_level_fuzz.zig +0 -510
- data/ext/tb_client/tigerbeetle/src/lsm/manifest_log.zig +0 -1241
- data/ext/tb_client/tigerbeetle/src/lsm/manifest_log_fuzz.zig +0 -628
- data/ext/tb_client/tigerbeetle/src/lsm/node_pool.zig +0 -247
- data/ext/tb_client/tigerbeetle/src/lsm/scan_buffer.zig +0 -116
- data/ext/tb_client/tigerbeetle/src/lsm/scan_builder.zig +0 -543
- data/ext/tb_client/tigerbeetle/src/lsm/scan_fuzz.zig +0 -938
- data/ext/tb_client/tigerbeetle/src/lsm/scan_lookup.zig +0 -293
- data/ext/tb_client/tigerbeetle/src/lsm/scan_merge.zig +0 -359
- data/ext/tb_client/tigerbeetle/src/lsm/scan_range.zig +0 -99
- data/ext/tb_client/tigerbeetle/src/lsm/scan_state.zig +0 -17
- data/ext/tb_client/tigerbeetle/src/lsm/scan_tree.zig +0 -962
- data/ext/tb_client/tigerbeetle/src/lsm/schema.zig +0 -617
- data/ext/tb_client/tigerbeetle/src/lsm/scratch_memory.zig +0 -84
- data/ext/tb_client/tigerbeetle/src/lsm/segmented_array.zig +0 -1500
- data/ext/tb_client/tigerbeetle/src/lsm/segmented_array_benchmark.zig +0 -149
- data/ext/tb_client/tigerbeetle/src/lsm/segmented_array_fuzz.zig +0 -7
- data/ext/tb_client/tigerbeetle/src/lsm/set_associative_cache.zig +0 -865
- data/ext/tb_client/tigerbeetle/src/lsm/table.zig +0 -607
- data/ext/tb_client/tigerbeetle/src/lsm/table_memory.zig +0 -843
- data/ext/tb_client/tigerbeetle/src/lsm/table_value_iterator.zig +0 -90
- data/ext/tb_client/tigerbeetle/src/lsm/timestamp_range.zig +0 -40
- data/ext/tb_client/tigerbeetle/src/lsm/tree.zig +0 -629
- data/ext/tb_client/tigerbeetle/src/lsm/tree_fuzz.zig +0 -933
- data/ext/tb_client/tigerbeetle/src/lsm/zig_zag_merge.zig +0 -534
- data/ext/tb_client/tigerbeetle/src/message_buffer.zig +0 -469
- data/ext/tb_client/tigerbeetle/src/message_bus.zig +0 -1219
- data/ext/tb_client/tigerbeetle/src/message_bus_fuzz.zig +0 -936
- data/ext/tb_client/tigerbeetle/src/message_pool.zig +0 -343
- data/ext/tb_client/tigerbeetle/src/multiversion.zig +0 -2195
- data/ext/tb_client/tigerbeetle/src/queue.zig +0 -390
- data/ext/tb_client/tigerbeetle/src/repl/completion.zig +0 -201
- data/ext/tb_client/tigerbeetle/src/repl/parser.zig +0 -1356
- data/ext/tb_client/tigerbeetle/src/repl/terminal.zig +0 -496
- data/ext/tb_client/tigerbeetle/src/repl.zig +0 -1034
- data/ext/tb_client/tigerbeetle/src/scripts/amqp.zig +0 -973
- data/ext/tb_client/tigerbeetle/src/scripts/cfo.zig +0 -1866
- data/ext/tb_client/tigerbeetle/src/scripts/changelog.zig +0 -304
- data/ext/tb_client/tigerbeetle/src/scripts/ci.zig +0 -227
- data/ext/tb_client/tigerbeetle/src/scripts/client_readmes.zig +0 -658
- data/ext/tb_client/tigerbeetle/src/scripts/devhub.zig +0 -466
- data/ext/tb_client/tigerbeetle/src/scripts/release.zig +0 -1058
- data/ext/tb_client/tigerbeetle/src/scripts.zig +0 -105
- data/ext/tb_client/tigerbeetle/src/shell.zig +0 -1195
- data/ext/tb_client/tigerbeetle/src/stack.zig +0 -260
- data/ext/tb_client/tigerbeetle/src/state_machine/auditor.zig +0 -911
- data/ext/tb_client/tigerbeetle/src/state_machine/workload.zig +0 -2079
- data/ext/tb_client/tigerbeetle/src/state_machine.zig +0 -4872
- data/ext/tb_client/tigerbeetle/src/state_machine_fuzz.zig +0 -288
- data/ext/tb_client/tigerbeetle/src/state_machine_tests.zig +0 -3128
- data/ext/tb_client/tigerbeetle/src/static_allocator.zig +0 -82
- data/ext/tb_client/tigerbeetle/src/stdx/bit_set.zig +0 -157
- data/ext/tb_client/tigerbeetle/src/stdx/bounded_array.zig +0 -292
- data/ext/tb_client/tigerbeetle/src/stdx/debug.zig +0 -65
- data/ext/tb_client/tigerbeetle/src/stdx/flags.zig +0 -1414
- data/ext/tb_client/tigerbeetle/src/stdx/huge_page_allocator.zig +0 -115
- data/ext/tb_client/tigerbeetle/src/stdx/mlock.zig +0 -92
- data/ext/tb_client/tigerbeetle/src/stdx/prng.zig +0 -677
- data/ext/tb_client/tigerbeetle/src/stdx/radix.zig +0 -336
- data/ext/tb_client/tigerbeetle/src/stdx/ring_buffer.zig +0 -511
- data/ext/tb_client/tigerbeetle/src/stdx/sort_test.zig +0 -112
- data/ext/tb_client/tigerbeetle/src/stdx/stdx.zig +0 -1163
- data/ext/tb_client/tigerbeetle/src/stdx/testing/low_level_hash_vectors.zig +0 -142
- data/ext/tb_client/tigerbeetle/src/stdx/testing/snaptest.zig +0 -361
- data/ext/tb_client/tigerbeetle/src/stdx/time_units.zig +0 -275
- data/ext/tb_client/tigerbeetle/src/stdx/unshare.zig +0 -295
- data/ext/tb_client/tigerbeetle/src/stdx/vendored/aegis.zig +0 -436
- data/ext/tb_client/tigerbeetle/src/stdx/windows.zig +0 -48
- data/ext/tb_client/tigerbeetle/src/stdx/zipfian.zig +0 -402
- data/ext/tb_client/tigerbeetle/src/storage.zig +0 -489
- data/ext/tb_client/tigerbeetle/src/storage_fuzz.zig +0 -180
- data/ext/tb_client/tigerbeetle/src/testing/bench.zig +0 -146
- data/ext/tb_client/tigerbeetle/src/testing/cluster/grid_checker.zig +0 -53
- data/ext/tb_client/tigerbeetle/src/testing/cluster/journal_checker.zig +0 -61
- data/ext/tb_client/tigerbeetle/src/testing/cluster/manifest_checker.zig +0 -76
- data/ext/tb_client/tigerbeetle/src/testing/cluster/message_bus.zig +0 -110
- data/ext/tb_client/tigerbeetle/src/testing/cluster/network.zig +0 -412
- data/ext/tb_client/tigerbeetle/src/testing/cluster/state_checker.zig +0 -331
- data/ext/tb_client/tigerbeetle/src/testing/cluster/storage_checker.zig +0 -458
- data/ext/tb_client/tigerbeetle/src/testing/cluster.zig +0 -1198
- data/ext/tb_client/tigerbeetle/src/testing/exhaustigen.zig +0 -128
- data/ext/tb_client/tigerbeetle/src/testing/fixtures.zig +0 -181
- data/ext/tb_client/tigerbeetle/src/testing/fuzz.zig +0 -144
- data/ext/tb_client/tigerbeetle/src/testing/id.zig +0 -97
- data/ext/tb_client/tigerbeetle/src/testing/io.zig +0 -317
- data/ext/tb_client/tigerbeetle/src/testing/marks.zig +0 -126
- data/ext/tb_client/tigerbeetle/src/testing/packet_simulator.zig +0 -533
- data/ext/tb_client/tigerbeetle/src/testing/reply_sequence.zig +0 -154
- data/ext/tb_client/tigerbeetle/src/testing/state_machine.zig +0 -389
- data/ext/tb_client/tigerbeetle/src/testing/storage.zig +0 -1247
- data/ext/tb_client/tigerbeetle/src/testing/table.zig +0 -249
- data/ext/tb_client/tigerbeetle/src/testing/time.zig +0 -98
- data/ext/tb_client/tigerbeetle/src/testing/tmp_tigerbeetle.zig +0 -212
- data/ext/tb_client/tigerbeetle/src/testing/vortex/constants.zig +0 -26
- data/ext/tb_client/tigerbeetle/src/testing/vortex/faulty_network.zig +0 -579
- data/ext/tb_client/tigerbeetle/src/testing/vortex/java_driver/ci.zig +0 -39
- data/ext/tb_client/tigerbeetle/src/testing/vortex/logged_process.zig +0 -214
- data/ext/tb_client/tigerbeetle/src/testing/vortex/rust_driver/ci.zig +0 -34
- data/ext/tb_client/tigerbeetle/src/testing/vortex/supervisor.zig +0 -785
- data/ext/tb_client/tigerbeetle/src/testing/vortex/workload.zig +0 -543
- data/ext/tb_client/tigerbeetle/src/testing/vortex/zig_driver.zig +0 -181
- data/ext/tb_client/tigerbeetle/src/tidy.zig +0 -1449
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/benchmark_driver.zig +0 -227
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/benchmark_load.zig +0 -1069
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/cli.zig +0 -1422
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/inspect.zig +0 -1658
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/inspect_integrity.zig +0 -518
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/libtb_client.zig +0 -36
- data/ext/tb_client/tigerbeetle/src/tigerbeetle/main.zig +0 -646
- data/ext/tb_client/tigerbeetle/src/tigerbeetle.zig +0 -958
- data/ext/tb_client/tigerbeetle/src/time.zig +0 -236
- data/ext/tb_client/tigerbeetle/src/trace/event.zig +0 -745
- data/ext/tb_client/tigerbeetle/src/trace/statsd.zig +0 -462
- data/ext/tb_client/tigerbeetle/src/trace.zig +0 -556
- data/ext/tb_client/tigerbeetle/src/unit_tests.zig +0 -321
- data/ext/tb_client/tigerbeetle/src/vopr.zig +0 -1785
- data/ext/tb_client/tigerbeetle/src/vortex.zig +0 -101
- data/ext/tb_client/tigerbeetle/src/vsr/checkpoint_trailer.zig +0 -473
- data/ext/tb_client/tigerbeetle/src/vsr/checksum.zig +0 -208
- data/ext/tb_client/tigerbeetle/src/vsr/checksum_benchmark.zig +0 -43
- data/ext/tb_client/tigerbeetle/src/vsr/client.zig +0 -768
- data/ext/tb_client/tigerbeetle/src/vsr/client_replies.zig +0 -532
- data/ext/tb_client/tigerbeetle/src/vsr/client_sessions.zig +0 -338
- data/ext/tb_client/tigerbeetle/src/vsr/clock.zig +0 -1019
- data/ext/tb_client/tigerbeetle/src/vsr/fault_detector.zig +0 -279
- data/ext/tb_client/tigerbeetle/src/vsr/free_set.zig +0 -1381
- data/ext/tb_client/tigerbeetle/src/vsr/free_set_fuzz.zig +0 -315
- data/ext/tb_client/tigerbeetle/src/vsr/grid.zig +0 -1460
- data/ext/tb_client/tigerbeetle/src/vsr/grid_blocks_missing.zig +0 -757
- data/ext/tb_client/tigerbeetle/src/vsr/grid_scrubber.zig +0 -797
- data/ext/tb_client/tigerbeetle/src/vsr/journal.zig +0 -2586
- data/ext/tb_client/tigerbeetle/src/vsr/marzullo.zig +0 -308
- data/ext/tb_client/tigerbeetle/src/vsr/message_header.zig +0 -1777
- data/ext/tb_client/tigerbeetle/src/vsr/multi_batch.zig +0 -715
- data/ext/tb_client/tigerbeetle/src/vsr/multi_batch_fuzz.zig +0 -185
- data/ext/tb_client/tigerbeetle/src/vsr/repair_budget.zig +0 -333
- data/ext/tb_client/tigerbeetle/src/vsr/replica.zig +0 -12356
- data/ext/tb_client/tigerbeetle/src/vsr/replica_format.zig +0 -416
- data/ext/tb_client/tigerbeetle/src/vsr/replica_reformat.zig +0 -165
- data/ext/tb_client/tigerbeetle/src/vsr/replica_test.zig +0 -2928
- data/ext/tb_client/tigerbeetle/src/vsr/routing.zig +0 -1075
- data/ext/tb_client/tigerbeetle/src/vsr/superblock.zig +0 -1603
- data/ext/tb_client/tigerbeetle/src/vsr/superblock_fuzz.zig +0 -484
- data/ext/tb_client/tigerbeetle/src/vsr/superblock_quorums.zig +0 -405
- data/ext/tb_client/tigerbeetle/src/vsr/superblock_quorums_fuzz.zig +0 -355
- data/ext/tb_client/tigerbeetle/src/vsr/sync.zig +0 -29
- data/ext/tb_client/tigerbeetle/src/vsr.zig +0 -1727
- data/lib/tb_client/shared_lib.rb +0 -66
- data/lib/tb_client.rb +0 -282
- data/lib/tigerbeetle/account.rb +0 -38
- data/lib/tigerbeetle/account_balance.rb +0 -23
- data/lib/tigerbeetle/account_filter.rb +0 -31
- data/lib/tigerbeetle/atomic_counter.rb +0 -14
- data/lib/tigerbeetle/client.rb +0 -214
- data/lib/tigerbeetle/converters/account.rb +0 -63
- data/lib/tigerbeetle/converters/account_balance.rb +0 -31
- data/lib/tigerbeetle/converters/account_filter.rb +0 -32
- data/lib/tigerbeetle/converters/base.rb +0 -35
- data/lib/tigerbeetle/converters/create_accounts_result.rb +0 -21
- data/lib/tigerbeetle/converters/create_transfers_result.rb +0 -21
- data/lib/tigerbeetle/converters/query_filter.rb +0 -33
- data/lib/tigerbeetle/converters/time.rb +0 -23
- data/lib/tigerbeetle/converters/transfer.rb +0 -64
- data/lib/tigerbeetle/converters/uint_128.rb +0 -24
- data/lib/tigerbeetle/converters.rb +0 -12
- data/lib/tigerbeetle/error.rb +0 -4
- data/lib/tigerbeetle/id.rb +0 -30
- data/lib/tigerbeetle/platforms.rb +0 -9
- data/lib/tigerbeetle/query_filter.rb +0 -31
- data/lib/tigerbeetle/request.rb +0 -7
- data/lib/tigerbeetle/transfer.rb +0 -40
- data/lib/tigerbeetle/version.rb +0 -4
- data/lib/tigerbeetle.rb +0 -13
- data/tigerbeetle.gemspec +0 -60
|
@@ -1,2296 +0,0 @@
|
|
|
1
|
-
const std = @import("std");
|
|
2
|
-
const builtin = @import("builtin");
|
|
3
|
-
// NB: Don't import anything from `./src` to keep compile times low.
|
|
4
|
-
|
|
5
|
-
const assert = std.debug.assert;
|
|
6
|
-
const Query = std.Target.Query;
|
|
7
|
-
|
|
8
|
-
const VoprStateMachine = enum { testing, accounting };
|
|
9
|
-
const VoprLog = enum { short, full };
|
|
10
|
-
|
|
11
|
-
// TigerBeetle binary requires certain CPU feature and supports a closed set of CPUs. Here, we
|
|
12
|
-
// specify exactly which features the binary needs.
|
|
13
|
-
fn resolve_target(b: *std.Build, target_requested: ?[]const u8) !std.Build.ResolvedTarget {
|
|
14
|
-
const target_host = @tagName(builtin.target.cpu.arch) ++ "-" ++ @tagName(builtin.target.os.tag);
|
|
15
|
-
const target = target_requested orelse target_host;
|
|
16
|
-
const triples = .{
|
|
17
|
-
"aarch64-linux",
|
|
18
|
-
"aarch64-macos",
|
|
19
|
-
"x86_64-linux",
|
|
20
|
-
"x86_64-macos",
|
|
21
|
-
"x86_64-windows",
|
|
22
|
-
};
|
|
23
|
-
const cpus = .{
|
|
24
|
-
"baseline+aes+neon",
|
|
25
|
-
"baseline+aes+neon",
|
|
26
|
-
"x86_64_v3+aes",
|
|
27
|
-
"x86_64_v3+aes",
|
|
28
|
-
"x86_64_v3+aes",
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const arch_os, const cpu = inline for (triples, cpus) |triple, cpu| {
|
|
32
|
-
if (std.mem.eql(u8, target, triple)) break .{ triple, cpu };
|
|
33
|
-
} else {
|
|
34
|
-
std.log.err("unsupported target: '{s}'", .{target});
|
|
35
|
-
return error.UnsupportedTarget;
|
|
36
|
-
};
|
|
37
|
-
const query = try Query.parse(.{
|
|
38
|
-
.arch_os_abi = arch_os,
|
|
39
|
-
.cpu_features = cpu,
|
|
40
|
-
});
|
|
41
|
-
return b.resolveTargetQuery(query);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const zig_version = std.SemanticVersion{
|
|
45
|
-
.major = 0,
|
|
46
|
-
.minor = 14,
|
|
47
|
-
.patch = 1,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
comptime {
|
|
51
|
-
// Compare versions while allowing different pre/patch metadata.
|
|
52
|
-
const zig_version_eq = zig_version.major == builtin.zig_version.major and
|
|
53
|
-
zig_version.minor == builtin.zig_version.minor and
|
|
54
|
-
(zig_version.patch == builtin.zig_version.patch);
|
|
55
|
-
if (!zig_version_eq) {
|
|
56
|
-
@compileError(std.fmt.comptimePrint(
|
|
57
|
-
"unsupported zig version: expected {}, found {}",
|
|
58
|
-
.{ zig_version, builtin.zig_version },
|
|
59
|
-
));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
pub fn build(b: *std.Build) !void {
|
|
64
|
-
// A compile error stack trace of 10 is arbitrary in size but helps with debugging.
|
|
65
|
-
b.reference_trace = 10;
|
|
66
|
-
|
|
67
|
-
// Top-level steps you can invoke on the command line.
|
|
68
|
-
const build_steps = .{
|
|
69
|
-
.aof = b.step("aof", "Run TigerBeetle AOF Utility"),
|
|
70
|
-
.check = b.step("check", "Check if TigerBeetle compiles"),
|
|
71
|
-
.clients_c = b.step("clients:c", "Build C client library"),
|
|
72
|
-
.clients_c_sample = b.step("clients:c:sample", "Build C client sample"),
|
|
73
|
-
.clients_dotnet = b.step("clients:dotnet", "Build dotnet client shared library"),
|
|
74
|
-
.clients_rust = b.step("clients:rust", "Build Rust client shared library"),
|
|
75
|
-
.clients_go = b.step("clients:go", "Build Go client shared library"),
|
|
76
|
-
.clients_java = b.step("clients:java", "Build Java client shared library"),
|
|
77
|
-
.clients_node = b.step("clients:node", "Build Node client shared library"),
|
|
78
|
-
.clients_python = b.step("clients:python", "Build Python client library"),
|
|
79
|
-
.docs = b.step("docs", "Build docs"),
|
|
80
|
-
.fuzz = b.step("fuzz", "Run non-VOPR fuzzers"),
|
|
81
|
-
.fuzz_build = b.step("fuzz:build", "Build non-VOPR fuzzers"),
|
|
82
|
-
.run = b.step("run", "Run TigerBeetle"),
|
|
83
|
-
.ci = b.step("ci", "Run the full suite of CI checks"),
|
|
84
|
-
.scripts = b.step("scripts", "Free form automation scripts"),
|
|
85
|
-
.scripts_build = b.step("scripts:build", "Build automation scripts"),
|
|
86
|
-
.vortex = b.step("vortex", "Full system tests with pluggable client drivers"),
|
|
87
|
-
.vortex_build = b.step("vortex:build", "Build the Vortex"),
|
|
88
|
-
.vortex_driver_zig_build = b.step("vortex:driver:zig", "Build the Vortex Zig driver"),
|
|
89
|
-
.@"test" = b.step("test", "Run all tests"),
|
|
90
|
-
.test_fmt = b.step("test:fmt", "Check formatting"),
|
|
91
|
-
.test_integration = b.step("test:integration", "Run integration tests"),
|
|
92
|
-
.test_integration_build = b.step("test:integration:build", "Build integration tests"),
|
|
93
|
-
.test_unit = b.step("test:unit", "Run unit tests"),
|
|
94
|
-
.test_unit_build = b.step("test:unit:build", "Build unit tests"),
|
|
95
|
-
.test_jni = b.step("test:jni", "Run Java JNI tests"),
|
|
96
|
-
.vopr = b.step("vopr", "Run the VOPR"),
|
|
97
|
-
.vopr_build = b.step("vopr:build", "Build the VOPR"),
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const mode = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseSafe });
|
|
101
|
-
|
|
102
|
-
// Build options passed with `-D` flags.
|
|
103
|
-
const build_options = .{
|
|
104
|
-
.target = b.option([]const u8, "target", "The CPU architecture and OS to build for"),
|
|
105
|
-
.multiversion = b.option(
|
|
106
|
-
[]const u8,
|
|
107
|
-
"multiversion",
|
|
108
|
-
"Past version to include for upgrades (\"latest\" or \"x.y.z\")",
|
|
109
|
-
),
|
|
110
|
-
.multiversion_file = b.option(
|
|
111
|
-
[]const u8,
|
|
112
|
-
"multiversion-file",
|
|
113
|
-
"Past version to include for upgrades (local binary file)",
|
|
114
|
-
),
|
|
115
|
-
.config_verify = b.option(bool, "config_verify", "Enable extra assertions.") orelse
|
|
116
|
-
// If `config_verify` isn't set, disable it for `release` builds; otherwise, enable it.
|
|
117
|
-
(mode == .Debug),
|
|
118
|
-
.config_release = b.option([]const u8, "config-release", "Release triple."),
|
|
119
|
-
.config_release_client_min = b.option(
|
|
120
|
-
[]const u8,
|
|
121
|
-
"config-release-client-min",
|
|
122
|
-
"Minimum client release triple.",
|
|
123
|
-
),
|
|
124
|
-
.emit_llvm_ir = b.option(bool, "emit-llvm-ir", "Emit LLVM IR (.ll file)") orelse false,
|
|
125
|
-
// The "tigerbeetle version" command includes the build-time commit hash.
|
|
126
|
-
.git_commit = b.option(
|
|
127
|
-
[]const u8,
|
|
128
|
-
"git-commit",
|
|
129
|
-
"The git commit revision of the source code.",
|
|
130
|
-
) orelse std.mem.trimRight(u8, b.run(&.{ "git", "rev-parse", "--verify", "HEAD" }), "\n"),
|
|
131
|
-
.vopr_state_machine = b.option(
|
|
132
|
-
VoprStateMachine,
|
|
133
|
-
"vopr-state-machine",
|
|
134
|
-
"State machine.",
|
|
135
|
-
) orelse .accounting,
|
|
136
|
-
.vopr_log = b.option(
|
|
137
|
-
VoprLog,
|
|
138
|
-
"vopr-log",
|
|
139
|
-
"Log only state transitions (short) or everything (full).",
|
|
140
|
-
) orelse .short,
|
|
141
|
-
.llvm_objcopy = b.option(
|
|
142
|
-
[]const u8,
|
|
143
|
-
"llvm-objcopy",
|
|
144
|
-
"Use this llvm-objcopy instead of downloading one",
|
|
145
|
-
),
|
|
146
|
-
.print_exe = b.option(
|
|
147
|
-
bool,
|
|
148
|
-
"print-exe",
|
|
149
|
-
"Build tasks print the path of the executable",
|
|
150
|
-
) orelse false,
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
if (build_options.config_release == null and build_options.config_release_client_min != null) {
|
|
154
|
-
@panic("must set config-release if setting config-release-client-min");
|
|
155
|
-
}
|
|
156
|
-
if (build_options.config_release_client_min == null and build_options.config_release != null) {
|
|
157
|
-
@panic("must set config-release-client-min if setting config-release");
|
|
158
|
-
}
|
|
159
|
-
assert((build_options.config_release == null) ==
|
|
160
|
-
(build_options.config_release_client_min == null));
|
|
161
|
-
|
|
162
|
-
const target = try resolve_target(b, build_options.target);
|
|
163
|
-
const stdx_module = b.addModule("stdx", .{ .root_source_file = b.path("src/stdx/stdx.zig") });
|
|
164
|
-
|
|
165
|
-
assert(build_options.git_commit.len == 40);
|
|
166
|
-
const vsr_options, const vsr_module = build_vsr_module(b, .{
|
|
167
|
-
.stdx_module = stdx_module,
|
|
168
|
-
.git_commit = build_options.git_commit[0..40].*,
|
|
169
|
-
.config_verify = build_options.config_verify,
|
|
170
|
-
.config_release = build_options.config_release orelse "65535.0.0",
|
|
171
|
-
.config_release_client_min = build_options.config_release_client_min orelse "0.16.4",
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// For integration tests and vortex, we build an independent copy of TigerBeetle with "real"
|
|
175
|
-
// config and multiversioning.
|
|
176
|
-
const vsr_options_test, const vsr_module_test = build_vsr_module(b, .{
|
|
177
|
-
.stdx_module = stdx_module,
|
|
178
|
-
.git_commit = "bee71e0000000000000000000000000000bee71e".*, // Beetle-hash!
|
|
179
|
-
.config_verify = true,
|
|
180
|
-
.config_release = "65535.0.0",
|
|
181
|
-
.config_release_client_min = "0.16.4",
|
|
182
|
-
});
|
|
183
|
-
const tigerbeetle_test_previous = download_release(b, "latest", target, mode);
|
|
184
|
-
const tigerbeetle_test = build_tigerbeetle_executable_multiversion(b, .{
|
|
185
|
-
.stdx_module = stdx_module,
|
|
186
|
-
.vsr_module = vsr_module_test,
|
|
187
|
-
.vsr_options = vsr_options_test,
|
|
188
|
-
.llvm_objcopy = build_options.llvm_objcopy,
|
|
189
|
-
.tigerbeetle_previous = tigerbeetle_test_previous,
|
|
190
|
-
.target = target,
|
|
191
|
-
.mode = mode,
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
const tb_client = build_tb_client(b, .{
|
|
195
|
-
.vsr_module = vsr_module,
|
|
196
|
-
.vsr_options = vsr_options,
|
|
197
|
-
.mode = mode,
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
// zig build check
|
|
201
|
-
build_check(b, build_steps.check, .{
|
|
202
|
-
.stdx_module = stdx_module,
|
|
203
|
-
.vsr_module = vsr_module,
|
|
204
|
-
.target = target,
|
|
205
|
-
.mode = mode,
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// zig build, zig build run
|
|
209
|
-
build_tigerbeetle(b, .{
|
|
210
|
-
.run = build_steps.run,
|
|
211
|
-
.install = b.getInstallStep(),
|
|
212
|
-
}, .{
|
|
213
|
-
.stdx_module = stdx_module,
|
|
214
|
-
.vsr_module = vsr_module,
|
|
215
|
-
.vsr_options = vsr_options,
|
|
216
|
-
.llvm_objcopy = build_options.llvm_objcopy,
|
|
217
|
-
.target = target,
|
|
218
|
-
.mode = mode,
|
|
219
|
-
.emit_llvm_ir = build_options.emit_llvm_ir,
|
|
220
|
-
.multiversion = build_options.multiversion,
|
|
221
|
-
.multiversion_file = build_options.multiversion_file,
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
// zig build aof
|
|
225
|
-
build_aof(b, build_steps.aof, .{
|
|
226
|
-
.stdx_module = stdx_module,
|
|
227
|
-
.vsr_options = vsr_options,
|
|
228
|
-
.target = target,
|
|
229
|
-
.mode = mode,
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
// zig build vortex:drivers:zig
|
|
233
|
-
const vortex_driver_zig = build_vortex_driver_zig(b, .{
|
|
234
|
-
.vortex_driver_zig_build = build_steps.vortex_driver_zig_build,
|
|
235
|
-
}, .{
|
|
236
|
-
.stdx_module = stdx_module,
|
|
237
|
-
.tb_client_header = tb_client.header,
|
|
238
|
-
.vsr_module_test = vsr_module_test,
|
|
239
|
-
.vsr_options_test = vsr_options_test,
|
|
240
|
-
.target = target,
|
|
241
|
-
.mode = mode,
|
|
242
|
-
.print_exe = build_options.print_exe,
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// zig build test -- "test filter"
|
|
246
|
-
try build_test(b, .{
|
|
247
|
-
.test_unit = build_steps.test_unit,
|
|
248
|
-
.test_unit_build = build_steps.test_unit_build,
|
|
249
|
-
.test_integration = build_steps.test_integration,
|
|
250
|
-
.test_integration_build = build_steps.test_integration_build,
|
|
251
|
-
.test_fmt = build_steps.test_fmt,
|
|
252
|
-
.@"test" = build_steps.@"test",
|
|
253
|
-
}, .{
|
|
254
|
-
.stdx_module = stdx_module,
|
|
255
|
-
.llvm_objcopy = build_options.llvm_objcopy,
|
|
256
|
-
.tb_client_header = tb_client.header,
|
|
257
|
-
.target = target,
|
|
258
|
-
.mode = mode,
|
|
259
|
-
.vsr_module_test = vsr_module_test,
|
|
260
|
-
.vsr_options_test = vsr_options_test,
|
|
261
|
-
.tigerbeetle_test = tigerbeetle_test,
|
|
262
|
-
.tigerbeetle_test_previous = tigerbeetle_test_previous,
|
|
263
|
-
.vortex_driver_zig = vortex_driver_zig,
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// zig build test:jni
|
|
267
|
-
try build_test_jni(b, build_steps.test_jni, .{
|
|
268
|
-
.target = target,
|
|
269
|
-
.mode = mode,
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
// zig build vopr -- 42
|
|
273
|
-
build_vopr(b, .{
|
|
274
|
-
.vopr_build = build_steps.vopr_build,
|
|
275
|
-
.vopr_run = build_steps.vopr,
|
|
276
|
-
}, .{
|
|
277
|
-
.stdx_module = stdx_module,
|
|
278
|
-
.vsr_options_test = vsr_options_test,
|
|
279
|
-
.target = target,
|
|
280
|
-
.mode = mode,
|
|
281
|
-
.print_exe = build_options.print_exe,
|
|
282
|
-
.vopr_state_machine = build_options.vopr_state_machine,
|
|
283
|
-
.vopr_log = build_options.vopr_log,
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
// zig build fuzz -- --events-max=100 lsm_tree 123
|
|
287
|
-
build_fuzz(b, .{
|
|
288
|
-
.fuzz = build_steps.fuzz,
|
|
289
|
-
.fuzz_build = build_steps.fuzz_build,
|
|
290
|
-
}, .{
|
|
291
|
-
.stdx_module = stdx_module,
|
|
292
|
-
.vsr_options_test = vsr_options_test,
|
|
293
|
-
.target = target,
|
|
294
|
-
.mode = mode,
|
|
295
|
-
.print_exe = build_options.print_exe,
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
// zig build scripts -- ci --language=java
|
|
299
|
-
const scripts = build_scripts(b, .{
|
|
300
|
-
.scripts = build_steps.scripts,
|
|
301
|
-
.scripts_build = build_steps.scripts_build,
|
|
302
|
-
}, .{
|
|
303
|
-
.stdx_module = stdx_module,
|
|
304
|
-
.vsr_options = vsr_options,
|
|
305
|
-
.target = target,
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
// zig build vortex -- supervisor --replica-count=3 --test-duration=1m
|
|
309
|
-
build_vortex(b, .{
|
|
310
|
-
.vortex_build = build_steps.vortex_build,
|
|
311
|
-
.vortex_run = build_steps.vortex,
|
|
312
|
-
}, .{
|
|
313
|
-
.stdx_module = stdx_module,
|
|
314
|
-
.vsr_module_test = vsr_module_test,
|
|
315
|
-
.vsr_options_test = vsr_options_test,
|
|
316
|
-
.target = target,
|
|
317
|
-
.mode = mode,
|
|
318
|
-
.print_exe = build_options.print_exe,
|
|
319
|
-
.tigerbeetle_test = tigerbeetle_test,
|
|
320
|
-
.tigerbeetle_test_previous = tigerbeetle_test_previous,
|
|
321
|
-
.vortex_driver_zig = vortex_driver_zig,
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
// zig build clients:$lang
|
|
325
|
-
build_rust_client(b, build_steps.clients_rust, .{
|
|
326
|
-
.vsr_module = vsr_module,
|
|
327
|
-
.vsr_options = vsr_options,
|
|
328
|
-
.tb_client_header = tb_client.header,
|
|
329
|
-
.mode = mode,
|
|
330
|
-
});
|
|
331
|
-
build_go_client(b, build_steps.clients_go, .{
|
|
332
|
-
.vsr_module = vsr_module,
|
|
333
|
-
.vsr_options = vsr_options,
|
|
334
|
-
.tb_client_header = tb_client.header,
|
|
335
|
-
.mode = mode,
|
|
336
|
-
});
|
|
337
|
-
build_java_client(b, build_steps.clients_java, .{
|
|
338
|
-
.vsr_module = vsr_module,
|
|
339
|
-
.vsr_options = vsr_options,
|
|
340
|
-
.mode = mode,
|
|
341
|
-
});
|
|
342
|
-
build_dotnet_client(b, build_steps.clients_dotnet, .{
|
|
343
|
-
.vsr_module = vsr_module,
|
|
344
|
-
.vsr_options = vsr_options,
|
|
345
|
-
.tb_client = tb_client,
|
|
346
|
-
.mode = mode,
|
|
347
|
-
});
|
|
348
|
-
build_node_client(b, build_steps.clients_node, .{
|
|
349
|
-
.vsr_module = vsr_module,
|
|
350
|
-
.vsr_options = vsr_options,
|
|
351
|
-
.mode = mode,
|
|
352
|
-
});
|
|
353
|
-
build_python_client(b, build_steps.clients_python, .{
|
|
354
|
-
.vsr_module = vsr_module,
|
|
355
|
-
.vsr_options = vsr_options,
|
|
356
|
-
.tb_client = tb_client,
|
|
357
|
-
.mode = mode,
|
|
358
|
-
});
|
|
359
|
-
build_c_client(b, build_steps.clients_c, .{
|
|
360
|
-
.vsr_module = vsr_module,
|
|
361
|
-
.vsr_options = vsr_options,
|
|
362
|
-
.tb_client_header = tb_client.header,
|
|
363
|
-
.mode = mode,
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
// zig build clients:c:sample
|
|
367
|
-
build_clients_c_sample(b, build_steps.clients_c_sample, .{
|
|
368
|
-
.vsr_module = vsr_module,
|
|
369
|
-
.vsr_options = vsr_options,
|
|
370
|
-
.target = target,
|
|
371
|
-
.mode = mode,
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
// zig build docs
|
|
375
|
-
build_steps.docs.dependOn(blk: {
|
|
376
|
-
const nested_build = b.addSystemCommand(&.{ b.graph.zig_exe, "build" });
|
|
377
|
-
nested_build.setCwd(b.path("./src/docs_website/"));
|
|
378
|
-
break :blk &nested_build.step;
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
// zig build ci
|
|
382
|
-
build_ci(b, build_steps.ci, .{
|
|
383
|
-
.scripts = scripts,
|
|
384
|
-
.git_commit = build_options.git_commit,
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
fn build_vsr_module(b: *std.Build, options: struct {
|
|
389
|
-
stdx_module: *std.Build.Module,
|
|
390
|
-
git_commit: [40]u8,
|
|
391
|
-
config_verify: bool,
|
|
392
|
-
config_release: []const u8,
|
|
393
|
-
config_release_client_min: []const u8,
|
|
394
|
-
}) struct { *std.Build.Step.Options, *std.Build.Module } {
|
|
395
|
-
// Ideally, we would return _just_ the module here, and keep options an implementation detail.
|
|
396
|
-
// However, currently Zig makes it awkward to provide multiple entry points for a module:
|
|
397
|
-
// https://ziggit.dev/t/suggested-project-layout-for-multiple-entry-point-for-zig-0-12/4219
|
|
398
|
-
//
|
|
399
|
-
// For this reason, we have to return options as well, so that other entry points can
|
|
400
|
-
// essentially re-create identical module.
|
|
401
|
-
const vsr_options = b.addOptions();
|
|
402
|
-
vsr_options.addOption(?[40]u8, "git_commit", options.git_commit[0..40].*);
|
|
403
|
-
vsr_options.addOption(bool, "config_verify", options.config_verify);
|
|
404
|
-
vsr_options.addOption([]const u8, "release", options.config_release);
|
|
405
|
-
vsr_options.addOption([]const u8, "release_client_min", options.config_release_client_min);
|
|
406
|
-
|
|
407
|
-
const vsr_module = b.createModule(.{
|
|
408
|
-
.root_source_file = b.path("src/vsr.zig"),
|
|
409
|
-
});
|
|
410
|
-
vsr_module.addImport("stdx", options.stdx_module);
|
|
411
|
-
vsr_module.addOptions("vsr_options", vsr_options);
|
|
412
|
-
|
|
413
|
-
return .{ vsr_options, vsr_module };
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
/// This is what is called by CI infrastructure, but you can also use it locally. In particular,
|
|
417
|
-
///
|
|
418
|
-
/// ./zig/zig build ci
|
|
419
|
-
///
|
|
420
|
-
/// is useful to run locally to get a set of somewhat comprehensive checks without needing many
|
|
421
|
-
/// external dependencies.
|
|
422
|
-
///
|
|
423
|
-
/// Various CI machines pass filters to select a subset of checks:
|
|
424
|
-
///
|
|
425
|
-
/// ./zig/zig build ci -- all
|
|
426
|
-
fn build_ci(
|
|
427
|
-
b: *std.Build,
|
|
428
|
-
step_ci: *std.Build.Step,
|
|
429
|
-
options: struct {
|
|
430
|
-
scripts: *std.Build.Step.Compile,
|
|
431
|
-
git_commit: []const u8,
|
|
432
|
-
},
|
|
433
|
-
) void {
|
|
434
|
-
const CIMode = enum {
|
|
435
|
-
smoke, // Quickly check formatting and such.
|
|
436
|
-
@"test", // Main test suite, excluding VOPR and clients.
|
|
437
|
-
fuzz, // Smoke tests for fuzzers and VOPR.
|
|
438
|
-
aof, // Dedicated test for AOF, which is somewhat slow to run.
|
|
439
|
-
|
|
440
|
-
clients, // Tests for all language clients below.
|
|
441
|
-
dotnet,
|
|
442
|
-
go,
|
|
443
|
-
rust,
|
|
444
|
-
java,
|
|
445
|
-
node,
|
|
446
|
-
python,
|
|
447
|
-
|
|
448
|
-
devhub, // Things that run on known-good commit on main branch after merge.
|
|
449
|
-
@"devhub-dry-run",
|
|
450
|
-
amqp,
|
|
451
|
-
default, // smoke + test + building Zig parts of clients.
|
|
452
|
-
all,
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
const mode: CIMode = if (b.args) |args| mode: {
|
|
456
|
-
if (args.len != 1) {
|
|
457
|
-
step_ci.dependOn(&b.addFail("invalid CIMode").step);
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
if (std.meta.stringToEnum(CIMode, args[0])) |m| {
|
|
461
|
-
break :mode m;
|
|
462
|
-
} else {
|
|
463
|
-
step_ci.dependOn(&b.addFail("invalid CIMode").step);
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
} else .default;
|
|
467
|
-
|
|
468
|
-
const all = mode == .all;
|
|
469
|
-
const default = all or mode == .default;
|
|
470
|
-
|
|
471
|
-
if (default or mode == .smoke) {
|
|
472
|
-
build_ci_step(b, step_ci, .{"test:fmt"});
|
|
473
|
-
build_ci_step(b, step_ci, .{"check"});
|
|
474
|
-
|
|
475
|
-
const build_docs = b.addSystemCommand(&.{ b.graph.zig_exe, "build" });
|
|
476
|
-
build_docs.has_side_effects = true;
|
|
477
|
-
build_docs.cwd = b.path("./src/docs_website");
|
|
478
|
-
step_ci.dependOn(&build_docs.step);
|
|
479
|
-
}
|
|
480
|
-
if (default or mode == .@"test") {
|
|
481
|
-
build_ci_step(b, step_ci, .{"test"});
|
|
482
|
-
build_ci_step(b, step_ci, .{ "fuzz", "--", "smoke" });
|
|
483
|
-
build_ci_step(b, step_ci, .{"clients:c:sample"});
|
|
484
|
-
build_ci_script(b, step_ci, options.scripts, &.{"--help"});
|
|
485
|
-
}
|
|
486
|
-
if (default or mode == .fuzz) {
|
|
487
|
-
build_ci_step(b, step_ci, .{ "fuzz", "--", "smoke" });
|
|
488
|
-
inline for (.{ "testing", "accounting" }) |state_machine| {
|
|
489
|
-
build_ci_step(b, step_ci, .{
|
|
490
|
-
"vopr",
|
|
491
|
-
"-Dvopr-state-machine=" ++ state_machine,
|
|
492
|
-
"-Drelease",
|
|
493
|
-
"--",
|
|
494
|
-
options.git_commit,
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
if (default or mode == .amqp) {
|
|
499
|
-
// Smoke test the AMQP integration.
|
|
500
|
-
build_ci_script(b, step_ci, options.scripts, &.{
|
|
501
|
-
"amqp",
|
|
502
|
-
"--transfer-count=100",
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
if (all or mode == .aof) {
|
|
507
|
-
const aof = b.addSystemCommand(&.{"./.github/ci/test_aof.sh"});
|
|
508
|
-
hide_stderr(aof);
|
|
509
|
-
step_ci.dependOn(&aof.step);
|
|
510
|
-
}
|
|
511
|
-
inline for (&.{ CIMode.dotnet, .go, .rust, .java, .node, .python }) |language| {
|
|
512
|
-
if (default or mode == .clients or mode == language) {
|
|
513
|
-
// Client tests expect vortex to exist.
|
|
514
|
-
build_ci_step(b, step_ci, .{"vortex:build"});
|
|
515
|
-
build_ci_step(b, step_ci, .{"clients:" ++ @tagName(language)});
|
|
516
|
-
}
|
|
517
|
-
if (all or mode == .clients or mode == language) {
|
|
518
|
-
build_ci_script(b, step_ci, options.scripts, &.{
|
|
519
|
-
"ci",
|
|
520
|
-
"--language=" ++ @tagName(language),
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
if (all or mode == .@"devhub-dry-run") {
|
|
526
|
-
build_ci_script(b, step_ci, options.scripts, &.{
|
|
527
|
-
"devhub",
|
|
528
|
-
b.fmt("--sha={s}", .{options.git_commit}),
|
|
529
|
-
"--skip-kcov",
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
if (mode == .devhub) {
|
|
533
|
-
build_ci_script(b, step_ci, options.scripts, &.{
|
|
534
|
-
"devhub",
|
|
535
|
-
b.fmt("--sha={s}", .{options.git_commit}),
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
fn build_ci_step(
|
|
541
|
-
b: *std.Build,
|
|
542
|
-
step_ci: *std.Build.Step,
|
|
543
|
-
command: anytype,
|
|
544
|
-
) void {
|
|
545
|
-
const argv = .{ b.graph.zig_exe, "build" } ++ command;
|
|
546
|
-
const system_command = b.addSystemCommand(&argv);
|
|
547
|
-
const name = std.mem.join(b.allocator, " ", &command) catch @panic("OOM");
|
|
548
|
-
system_command.setName(name);
|
|
549
|
-
hide_stderr(system_command);
|
|
550
|
-
step_ci.dependOn(&system_command.step);
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
fn build_ci_script(
|
|
554
|
-
b: *std.Build,
|
|
555
|
-
step_ci: *std.Build.Step,
|
|
556
|
-
scripts: *std.Build.Step.Compile,
|
|
557
|
-
argv: []const []const u8,
|
|
558
|
-
) void {
|
|
559
|
-
const run_artifact = b.addRunArtifact(scripts);
|
|
560
|
-
run_artifact.addArgs(argv);
|
|
561
|
-
run_artifact.setEnvironmentVariable("ZIG_EXE", b.graph.zig_exe);
|
|
562
|
-
hide_stderr(run_artifact);
|
|
563
|
-
step_ci.dependOn(&run_artifact.step);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// Hide step's stderr unless it fails, to prevent zig build ci output being dominated by VOPR logs.
|
|
567
|
-
// Sadly, this requires "overriding" Build.Step.Run make function.
|
|
568
|
-
fn hide_stderr(run: *std.Build.Step.Run) void {
|
|
569
|
-
const b = run.step.owner;
|
|
570
|
-
|
|
571
|
-
run.addCheck(.{ .expect_term = .{ .Exited = 0 } });
|
|
572
|
-
run.has_side_effects = true;
|
|
573
|
-
|
|
574
|
-
const override = struct {
|
|
575
|
-
var global_map: std.AutoHashMapUnmanaged(usize, std.Build.Step.MakeFn) = .{};
|
|
576
|
-
|
|
577
|
-
fn make(step: *std.Build.Step, options: std.Build.Step.MakeOptions) anyerror!void {
|
|
578
|
-
const original = global_map.get(@intFromPtr(step)).?;
|
|
579
|
-
try original(step, options);
|
|
580
|
-
assert(step.result_error_msgs.items.len == 0);
|
|
581
|
-
step.result_stderr = "";
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
|
-
|
|
585
|
-
const original = run.step.makeFn;
|
|
586
|
-
override.global_map.put(b.allocator, @intFromPtr(&run.step), original) catch @panic("OOM");
|
|
587
|
-
run.step.makeFn = &override.make;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
// Run a tigerbeetle build without running codegen and waiting for llvm
|
|
591
|
-
// see <https://github.com/ziglang/zig/commit/5c0181841081170a118d8e50af2a09f5006f59e1>
|
|
592
|
-
// how it's supposed to work.
|
|
593
|
-
// In short, codegen only runs if zig build sees a dependency on the binary output of
|
|
594
|
-
// the step. So we duplicate the build definition so that it doesn't get polluted by
|
|
595
|
-
// b.installArtifact.
|
|
596
|
-
// TODO(zig): https://github.com/ziglang/zig/issues/18877
|
|
597
|
-
fn build_check(
|
|
598
|
-
b: *std.Build,
|
|
599
|
-
step_check: *std.Build.Step,
|
|
600
|
-
options: struct {
|
|
601
|
-
stdx_module: *std.Build.Module,
|
|
602
|
-
vsr_module: *std.Build.Module,
|
|
603
|
-
target: std.Build.ResolvedTarget,
|
|
604
|
-
mode: std.builtin.OptimizeMode,
|
|
605
|
-
},
|
|
606
|
-
) void {
|
|
607
|
-
const tigerbeetle = b.addExecutable(.{
|
|
608
|
-
.name = "tigerbeetle",
|
|
609
|
-
.root_module = b.createModule(.{
|
|
610
|
-
.root_source_file = b.path("src/tigerbeetle/main.zig"),
|
|
611
|
-
.target = options.target,
|
|
612
|
-
.optimize = options.mode,
|
|
613
|
-
}),
|
|
614
|
-
});
|
|
615
|
-
tigerbeetle.root_module.addImport("stdx", options.stdx_module);
|
|
616
|
-
tigerbeetle.root_module.addImport("vsr", options.vsr_module);
|
|
617
|
-
step_check.dependOn(&tigerbeetle.step);
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
fn build_tigerbeetle(
|
|
621
|
-
b: *std.Build,
|
|
622
|
-
steps: struct {
|
|
623
|
-
run: *std.Build.Step,
|
|
624
|
-
install: *std.Build.Step,
|
|
625
|
-
},
|
|
626
|
-
options: struct {
|
|
627
|
-
stdx_module: *std.Build.Module,
|
|
628
|
-
vsr_module: *std.Build.Module,
|
|
629
|
-
vsr_options: *std.Build.Step.Options,
|
|
630
|
-
llvm_objcopy: ?[]const u8,
|
|
631
|
-
target: std.Build.ResolvedTarget,
|
|
632
|
-
mode: std.builtin.OptimizeMode,
|
|
633
|
-
multiversion: ?[]const u8,
|
|
634
|
-
multiversion_file: ?[]const u8,
|
|
635
|
-
emit_llvm_ir: bool,
|
|
636
|
-
},
|
|
637
|
-
) void {
|
|
638
|
-
const multiversion_file: ?std.Build.LazyPath = if (options.multiversion_file) |path|
|
|
639
|
-
.{ .cwd_relative = path }
|
|
640
|
-
else if (options.multiversion) |version_past|
|
|
641
|
-
download_release(b, version_past, options.target, options.mode)
|
|
642
|
-
else
|
|
643
|
-
null;
|
|
644
|
-
|
|
645
|
-
const tigerbeetle_bin = if (multiversion_file) |multiversion_lazy_path| bin: {
|
|
646
|
-
assert(!options.emit_llvm_ir);
|
|
647
|
-
break :bin build_tigerbeetle_executable_multiversion(b, .{
|
|
648
|
-
.stdx_module = options.stdx_module,
|
|
649
|
-
.vsr_module = options.vsr_module,
|
|
650
|
-
.vsr_options = options.vsr_options,
|
|
651
|
-
.llvm_objcopy = options.llvm_objcopy,
|
|
652
|
-
.tigerbeetle_previous = multiversion_lazy_path,
|
|
653
|
-
.target = options.target,
|
|
654
|
-
.mode = options.mode,
|
|
655
|
-
});
|
|
656
|
-
} else bin: {
|
|
657
|
-
const tigerbeetle_exe = build_tigerbeetle_executable(b, .{
|
|
658
|
-
.vsr_module = options.vsr_module,
|
|
659
|
-
.vsr_options = options.vsr_options,
|
|
660
|
-
.target = options.target,
|
|
661
|
-
.mode = options.mode,
|
|
662
|
-
});
|
|
663
|
-
if (options.emit_llvm_ir) {
|
|
664
|
-
steps.install.dependOn(&b.addInstallBinFile(
|
|
665
|
-
tigerbeetle_exe.getEmittedLlvmIr(),
|
|
666
|
-
"tigerbeetle.ll",
|
|
667
|
-
).step);
|
|
668
|
-
}
|
|
669
|
-
break :bin tigerbeetle_exe.getEmittedBin();
|
|
670
|
-
};
|
|
671
|
-
|
|
672
|
-
const out_filename = if (options.target.result.os.tag == .windows)
|
|
673
|
-
"tigerbeetle.exe"
|
|
674
|
-
else
|
|
675
|
-
"tigerbeetle";
|
|
676
|
-
|
|
677
|
-
steps.install.dependOn(&b.addInstallBinFile(tigerbeetle_bin, out_filename).step);
|
|
678
|
-
// "zig build install" moves the server executable to the root folder:
|
|
679
|
-
steps.install.dependOn(&b.addInstallFile(
|
|
680
|
-
tigerbeetle_bin,
|
|
681
|
-
b.pathJoin(&.{ "../", out_filename }),
|
|
682
|
-
).step);
|
|
683
|
-
|
|
684
|
-
const run_cmd = std.Build.Step.Run.create(b, b.fmt("run tigerbeetle", .{}));
|
|
685
|
-
run_cmd.addFileArg(tigerbeetle_bin);
|
|
686
|
-
if (b.args) |args| run_cmd.addArgs(args);
|
|
687
|
-
steps.run.dependOn(&run_cmd.step);
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
fn build_tigerbeetle_executable(b: *std.Build, options: struct {
|
|
691
|
-
vsr_module: *std.Build.Module,
|
|
692
|
-
vsr_options: *std.Build.Step.Options,
|
|
693
|
-
target: std.Build.ResolvedTarget,
|
|
694
|
-
mode: std.builtin.OptimizeMode,
|
|
695
|
-
}) *std.Build.Step.Compile {
|
|
696
|
-
const root_module = b.createModule(.{
|
|
697
|
-
.root_source_file = b.path("src/tigerbeetle/main.zig"),
|
|
698
|
-
.target = options.target,
|
|
699
|
-
.optimize = options.mode,
|
|
700
|
-
});
|
|
701
|
-
root_module.addImport("vsr", options.vsr_module);
|
|
702
|
-
root_module.addOptions("vsr_options", options.vsr_options);
|
|
703
|
-
if (options.mode == .ReleaseSafe) strip_root_module(root_module);
|
|
704
|
-
|
|
705
|
-
const tigerbeetle = b.addExecutable(.{
|
|
706
|
-
.name = "tigerbeetle",
|
|
707
|
-
.root_module = root_module,
|
|
708
|
-
});
|
|
709
|
-
|
|
710
|
-
return tigerbeetle;
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
fn build_tigerbeetle_executable_multiversion(b: *std.Build, options: struct {
|
|
714
|
-
stdx_module: *std.Build.Module,
|
|
715
|
-
vsr_module: *std.Build.Module,
|
|
716
|
-
vsr_options: *std.Build.Step.Options,
|
|
717
|
-
llvm_objcopy: ?[]const u8,
|
|
718
|
-
tigerbeetle_previous: std.Build.LazyPath,
|
|
719
|
-
target: std.Build.ResolvedTarget,
|
|
720
|
-
mode: std.builtin.OptimizeMode,
|
|
721
|
-
}) std.Build.LazyPath {
|
|
722
|
-
// build_multiversion a custom step that would take care of packing several releases into one
|
|
723
|
-
const build_multiversion_exe = b.addExecutable(.{
|
|
724
|
-
.name = "build_multiversion",
|
|
725
|
-
.root_module = b.createModule(.{
|
|
726
|
-
.root_source_file = b.path("src/build_multiversion.zig"),
|
|
727
|
-
// Enable aes extensions for vsr.checksum on the host.
|
|
728
|
-
.target = resolve_target(b, null) catch @panic("unsupported host"),
|
|
729
|
-
}),
|
|
730
|
-
});
|
|
731
|
-
build_multiversion_exe.root_module.addImport("stdx", options.stdx_module);
|
|
732
|
-
// Ideally, we should pass `vsr_options` here at runtime. Making them comptime
|
|
733
|
-
// parameters is inelegant, but practical!
|
|
734
|
-
build_multiversion_exe.root_module.addOptions("vsr_options", options.vsr_options);
|
|
735
|
-
|
|
736
|
-
const build_multiversion = b.addRunArtifact(build_multiversion_exe);
|
|
737
|
-
if (options.llvm_objcopy) |path| {
|
|
738
|
-
build_multiversion.addArg(b.fmt("--llvm-objcopy={s}", .{path}));
|
|
739
|
-
} else {
|
|
740
|
-
build_multiversion.addPrefixedFileArg(
|
|
741
|
-
"--llvm-objcopy=",
|
|
742
|
-
build_tigerbeetle_executable_get_objcopy(b),
|
|
743
|
-
);
|
|
744
|
-
}
|
|
745
|
-
if (options.target.result.os.tag == .macos) {
|
|
746
|
-
build_multiversion.addArg("--target=macos");
|
|
747
|
-
inline for (.{ "x86_64", "aarch64" }, .{ "x86-64", "aarch64" }) |arch, flag| {
|
|
748
|
-
build_multiversion.addPrefixedFileArg(
|
|
749
|
-
"--tigerbeetle-current-" ++ flag ++ "=",
|
|
750
|
-
build_tigerbeetle_executable(b, .{
|
|
751
|
-
.vsr_module = options.vsr_module,
|
|
752
|
-
.vsr_options = options.vsr_options,
|
|
753
|
-
.target = resolve_target(b, arch ++ "-macos") catch unreachable,
|
|
754
|
-
.mode = options.mode,
|
|
755
|
-
}).getEmittedBin(),
|
|
756
|
-
);
|
|
757
|
-
}
|
|
758
|
-
} else {
|
|
759
|
-
build_multiversion.addArg(b.fmt("--target={s}-{s}", .{
|
|
760
|
-
@tagName(options.target.result.cpu.arch),
|
|
761
|
-
@tagName(options.target.result.os.tag),
|
|
762
|
-
}));
|
|
763
|
-
build_multiversion.addPrefixedFileArg(
|
|
764
|
-
"--tigerbeetle-current=",
|
|
765
|
-
build_tigerbeetle_executable(b, .{
|
|
766
|
-
.vsr_module = options.vsr_module,
|
|
767
|
-
.vsr_options = options.vsr_options,
|
|
768
|
-
.target = options.target,
|
|
769
|
-
.mode = options.mode,
|
|
770
|
-
}).getEmittedBin(),
|
|
771
|
-
);
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
if (options.mode == .Debug) {
|
|
775
|
-
build_multiversion.addArg("--debug");
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
build_multiversion.addPrefixedFileArg("--tigerbeetle-past=", options.tigerbeetle_previous);
|
|
779
|
-
build_multiversion.addArg(b.fmt(
|
|
780
|
-
"--tmp={s}",
|
|
781
|
-
.{b.cache_root.join(b.allocator, &.{"tmp"}) catch @panic("OOM")},
|
|
782
|
-
));
|
|
783
|
-
const basename = if (options.target.result.os.tag == .windows)
|
|
784
|
-
"tigerbeetle.exe"
|
|
785
|
-
else
|
|
786
|
-
"tigerbeetle";
|
|
787
|
-
return build_multiversion.addPrefixedOutputFileArg("--output=", basename);
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
// Downloads a pre-build llvm-objcopy from <https://github.com/tigerbeetle/dependencies>.
|
|
791
|
-
fn build_tigerbeetle_executable_get_objcopy(b: *std.Build) std.Build.LazyPath {
|
|
792
|
-
switch (b.graph.host.result.os.tag) {
|
|
793
|
-
.linux => {
|
|
794
|
-
switch (b.graph.host.result.cpu.arch) {
|
|
795
|
-
.x86_64 => {
|
|
796
|
-
return fetch(b, .{
|
|
797
|
-
.url = "https://github.com/tigerbeetle/dependencies/releases/download/" ++
|
|
798
|
-
"18.1.8/llvm-objcopy-x86_64-linux.zip",
|
|
799
|
-
.file_name = "llvm-objcopy",
|
|
800
|
-
.hash = "N-V-__8AAFCWcgAxBPUOMe_uJrFGfQ2Ri_SsbNp77pPYZdAe",
|
|
801
|
-
});
|
|
802
|
-
},
|
|
803
|
-
.aarch64 => {
|
|
804
|
-
return fetch(b, .{
|
|
805
|
-
.url = "https://github.com/tigerbeetle/dependencies/releases/download/" ++
|
|
806
|
-
"18.1.8/llvm-objcopy-aarch64-linux.zip",
|
|
807
|
-
.file_name = "llvm-objcopy",
|
|
808
|
-
.hash = "N-V-__8AAIgJcQAG--KvT2zb1yNrlRtNEo3pW3aIgoppmbT-",
|
|
809
|
-
});
|
|
810
|
-
},
|
|
811
|
-
else => @panic("unsupported arch"),
|
|
812
|
-
}
|
|
813
|
-
},
|
|
814
|
-
.windows => {
|
|
815
|
-
assert(b.graph.host.result.cpu.arch == .x86_64);
|
|
816
|
-
return fetch(b, .{
|
|
817
|
-
.url = "https://github.com/tigerbeetle/dependencies/releases/download/" ++
|
|
818
|
-
"18.1.8/llvm-objcopy-x86_64-windows.zip",
|
|
819
|
-
.file_name = "llvm-objcopy.exe",
|
|
820
|
-
.hash = "N-V-__8AAADuPABpdHRgl3oetSEQ6yq8i5kq9XJC73JDFtMH",
|
|
821
|
-
});
|
|
822
|
-
},
|
|
823
|
-
.macos => {
|
|
824
|
-
// TODO: this assert triggers, but the macOS tests on x86_64 work...?
|
|
825
|
-
// assert(b.graph.host.result.cpu.arch == .aarch64);
|
|
826
|
-
return fetch(b, .{
|
|
827
|
-
.url = "https://github.com/tigerbeetle/dependencies/releases/download/" ++
|
|
828
|
-
"18.1.8/llvm-objcopy-aarch64-macos.zip",
|
|
829
|
-
.file_name = "llvm-objcopy",
|
|
830
|
-
.hash = "N-V-__8AAFAsVgArdRpU50gjJhqaAUSXsTemKo2A9rCaewUV",
|
|
831
|
-
});
|
|
832
|
-
},
|
|
833
|
-
else => @panic("unsupported host"),
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
fn build_aof(
|
|
838
|
-
b: *std.Build,
|
|
839
|
-
step_aof: *std.Build.Step,
|
|
840
|
-
options: struct {
|
|
841
|
-
stdx_module: *std.Build.Module,
|
|
842
|
-
vsr_options: *std.Build.Step.Options,
|
|
843
|
-
target: std.Build.ResolvedTarget,
|
|
844
|
-
mode: std.builtin.OptimizeMode,
|
|
845
|
-
},
|
|
846
|
-
) void {
|
|
847
|
-
const aof = b.addExecutable(.{
|
|
848
|
-
.name = "aof",
|
|
849
|
-
.root_module = b.createModule(.{
|
|
850
|
-
.root_source_file = b.path("src/aof.zig"),
|
|
851
|
-
.target = options.target,
|
|
852
|
-
.optimize = options.mode,
|
|
853
|
-
}),
|
|
854
|
-
});
|
|
855
|
-
aof.root_module.addImport("stdx", options.stdx_module);
|
|
856
|
-
aof.root_module.addOptions("vsr_options", options.vsr_options);
|
|
857
|
-
const run_cmd = b.addRunArtifact(aof);
|
|
858
|
-
if (b.args) |args| run_cmd.addArgs(args);
|
|
859
|
-
step_aof.dependOn(&run_cmd.step);
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
fn build_test(
|
|
863
|
-
b: *std.Build,
|
|
864
|
-
steps: struct {
|
|
865
|
-
test_unit: *std.Build.Step,
|
|
866
|
-
test_unit_build: *std.Build.Step,
|
|
867
|
-
test_integration: *std.Build.Step,
|
|
868
|
-
test_integration_build: *std.Build.Step,
|
|
869
|
-
test_fmt: *std.Build.Step,
|
|
870
|
-
@"test": *std.Build.Step,
|
|
871
|
-
},
|
|
872
|
-
options: struct {
|
|
873
|
-
llvm_objcopy: ?[]const u8,
|
|
874
|
-
stdx_module: *std.Build.Module,
|
|
875
|
-
tb_client_header: std.Build.LazyPath,
|
|
876
|
-
target: std.Build.ResolvedTarget,
|
|
877
|
-
mode: std.builtin.OptimizeMode,
|
|
878
|
-
vsr_module_test: *std.Build.Module,
|
|
879
|
-
vsr_options_test: *std.Build.Step.Options,
|
|
880
|
-
tigerbeetle_test: std.Build.LazyPath,
|
|
881
|
-
tigerbeetle_test_previous: std.Build.LazyPath,
|
|
882
|
-
vortex_driver_zig: std.Build.LazyPath,
|
|
883
|
-
},
|
|
884
|
-
) !void {
|
|
885
|
-
const test_options = b.addOptions();
|
|
886
|
-
// Benchmark run in two modes.
|
|
887
|
-
// - ./zig/zig build test
|
|
888
|
-
// - ./zig/zig build -Drelease test -- "benchmark: name"
|
|
889
|
-
// The former uses small parameter values and is silent.
|
|
890
|
-
// The latter is the real benchmark, which prints the output.
|
|
891
|
-
test_options.addOption(bool, "benchmark", for (b.args orelse &.{}) |arg| {
|
|
892
|
-
if (std.mem.indexOf(u8, arg, "benchmark") != null) break true;
|
|
893
|
-
} else false);
|
|
894
|
-
|
|
895
|
-
const stdx_unit_tests = b.addTest(.{
|
|
896
|
-
.name = "test-stdx",
|
|
897
|
-
.root_module = b.createModule(.{
|
|
898
|
-
.root_source_file = b.path("src/stdx/stdx.zig"),
|
|
899
|
-
.target = options.target,
|
|
900
|
-
.optimize = options.mode,
|
|
901
|
-
}),
|
|
902
|
-
.filters = b.args orelse &.{},
|
|
903
|
-
});
|
|
904
|
-
const unit_tests = b.addTest(.{
|
|
905
|
-
.name = "test-unit",
|
|
906
|
-
.root_module = b.createModule(.{
|
|
907
|
-
.root_source_file = b.path("src/unit_tests.zig"),
|
|
908
|
-
.target = options.target,
|
|
909
|
-
.optimize = options.mode,
|
|
910
|
-
}),
|
|
911
|
-
.filters = b.args orelse &.{},
|
|
912
|
-
});
|
|
913
|
-
unit_tests.root_module.addImport("stdx", options.stdx_module);
|
|
914
|
-
unit_tests.root_module.addOptions("vsr_options", options.vsr_options_test);
|
|
915
|
-
unit_tests.root_module.addOptions("test_options", test_options);
|
|
916
|
-
|
|
917
|
-
steps.test_unit_build.dependOn(&b.addInstallArtifact(stdx_unit_tests, .{}).step);
|
|
918
|
-
steps.test_unit_build.dependOn(&b.addInstallArtifact(unit_tests, .{}).step);
|
|
919
|
-
|
|
920
|
-
const run_stdx_unit_tests = b.addRunArtifact(stdx_unit_tests);
|
|
921
|
-
const run_unit_tests = b.addRunArtifact(unit_tests);
|
|
922
|
-
run_stdx_unit_tests.setEnvironmentVariable("ZIG_EXE", b.graph.zig_exe);
|
|
923
|
-
run_unit_tests.setEnvironmentVariable("ZIG_EXE", b.graph.zig_exe);
|
|
924
|
-
if (b.args != null) { // Don't cache test results if running a specific test.
|
|
925
|
-
run_stdx_unit_tests.has_side_effects = true;
|
|
926
|
-
run_unit_tests.has_side_effects = true;
|
|
927
|
-
}
|
|
928
|
-
steps.test_unit.dependOn(&run_stdx_unit_tests.step);
|
|
929
|
-
steps.test_unit.dependOn(&run_unit_tests.step);
|
|
930
|
-
|
|
931
|
-
run_unit_tests.setCwd(b.path("."));
|
|
932
|
-
|
|
933
|
-
build_test_integration(b, .{
|
|
934
|
-
.test_integration = steps.test_integration,
|
|
935
|
-
.test_integration_build = steps.test_integration_build,
|
|
936
|
-
}, .{
|
|
937
|
-
.tb_client_header = options.tb_client_header,
|
|
938
|
-
.llvm_objcopy = options.llvm_objcopy,
|
|
939
|
-
.stdx_module = options.stdx_module,
|
|
940
|
-
.target = options.target,
|
|
941
|
-
.mode = options.mode,
|
|
942
|
-
.vsr_module_test = options.vsr_module_test,
|
|
943
|
-
.vsr_options_test = options.vsr_options_test,
|
|
944
|
-
.tigerbeetle_test = options.tigerbeetle_test,
|
|
945
|
-
.tigerbeetle_test_previous = options.tigerbeetle_test_previous,
|
|
946
|
-
.vortex_driver_zig = options.vortex_driver_zig,
|
|
947
|
-
});
|
|
948
|
-
|
|
949
|
-
const run_fmt = b.addFmt(.{ .paths = &.{"."}, .check = true });
|
|
950
|
-
steps.test_fmt.dependOn(&run_fmt.step);
|
|
951
|
-
|
|
952
|
-
steps.@"test".dependOn(&run_stdx_unit_tests.step);
|
|
953
|
-
steps.@"test".dependOn(&run_unit_tests.step);
|
|
954
|
-
if (b.args == null) {
|
|
955
|
-
steps.@"test".dependOn(steps.test_integration);
|
|
956
|
-
steps.@"test".dependOn(steps.test_fmt);
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
fn build_test_integration(
|
|
961
|
-
b: *std.Build,
|
|
962
|
-
steps: struct {
|
|
963
|
-
test_integration: *std.Build.Step,
|
|
964
|
-
test_integration_build: *std.Build.Step,
|
|
965
|
-
},
|
|
966
|
-
options: struct {
|
|
967
|
-
tb_client_header: std.Build.LazyPath,
|
|
968
|
-
llvm_objcopy: ?[]const u8,
|
|
969
|
-
stdx_module: *std.Build.Module,
|
|
970
|
-
target: std.Build.ResolvedTarget,
|
|
971
|
-
mode: std.builtin.OptimizeMode,
|
|
972
|
-
vsr_module_test: *std.Build.Module,
|
|
973
|
-
vsr_options_test: *std.Build.Step.Options,
|
|
974
|
-
tigerbeetle_test: std.Build.LazyPath,
|
|
975
|
-
tigerbeetle_test_previous: std.Build.LazyPath,
|
|
976
|
-
vortex_driver_zig: std.Build.LazyPath,
|
|
977
|
-
},
|
|
978
|
-
) void {
|
|
979
|
-
const vortex = build_vortex_executable(b, .{
|
|
980
|
-
.stdx_module = options.stdx_module,
|
|
981
|
-
.target = options.target,
|
|
982
|
-
.mode = options.mode,
|
|
983
|
-
.vsr_module_test = options.vsr_module_test,
|
|
984
|
-
.vsr_options_test = options.vsr_options_test,
|
|
985
|
-
.tigerbeetle_test = options.tigerbeetle_test,
|
|
986
|
-
.tigerbeetle_test_previous = options.tigerbeetle_test_previous,
|
|
987
|
-
.vortex_driver_zig = options.vortex_driver_zig,
|
|
988
|
-
});
|
|
989
|
-
const vortex_artifact = b.addInstallArtifact(vortex, .{});
|
|
990
|
-
|
|
991
|
-
const integration_tests_options = b.addOptions();
|
|
992
|
-
integration_tests_options.addOptionPath("tigerbeetle_exe", options.tigerbeetle_test);
|
|
993
|
-
integration_tests_options.addOptionPath(
|
|
994
|
-
"tigerbeetle_exe_past",
|
|
995
|
-
options.tigerbeetle_test_previous,
|
|
996
|
-
);
|
|
997
|
-
integration_tests_options.addOptionPath("vortex_exe", vortex_artifact.emitted_bin.?);
|
|
998
|
-
const integration_tests = b.addTest(.{
|
|
999
|
-
.name = "test-integration",
|
|
1000
|
-
.root_module = b.createModule(.{
|
|
1001
|
-
.root_source_file = b.path("src/integration_tests.zig"),
|
|
1002
|
-
.target = options.target,
|
|
1003
|
-
.optimize = options.mode,
|
|
1004
|
-
}),
|
|
1005
|
-
.filters = b.args orelse &.{},
|
|
1006
|
-
});
|
|
1007
|
-
integration_tests.root_module.addImport("stdx", options.stdx_module);
|
|
1008
|
-
integration_tests.root_module.addOptions("vsr_options", options.vsr_options_test);
|
|
1009
|
-
integration_tests.root_module.addOptions("test_options", integration_tests_options);
|
|
1010
|
-
integration_tests.addIncludePath(options.tb_client_header.dirname());
|
|
1011
|
-
steps.test_integration_build.dependOn(&b.addInstallArtifact(integration_tests, .{}).step);
|
|
1012
|
-
|
|
1013
|
-
const run_integration_tests = b.addRunArtifact(integration_tests);
|
|
1014
|
-
if (b.args != null) { // Don't cache test results if running a specific test.
|
|
1015
|
-
run_integration_tests.has_side_effects = true;
|
|
1016
|
-
}
|
|
1017
|
-
run_integration_tests.has_side_effects = true;
|
|
1018
|
-
steps.test_integration.dependOn(&run_integration_tests.step);
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
fn build_test_jni(
|
|
1022
|
-
b: *std.Build,
|
|
1023
|
-
step_test_jni: *std.Build.Step,
|
|
1024
|
-
options: struct {
|
|
1025
|
-
target: std.Build.ResolvedTarget,
|
|
1026
|
-
mode: std.builtin.OptimizeMode,
|
|
1027
|
-
},
|
|
1028
|
-
) !void {
|
|
1029
|
-
const java_home = b.graph.env_map.get("JAVA_HOME") orelse {
|
|
1030
|
-
step_test_jni.dependOn(&b.addFail(
|
|
1031
|
-
"can't build jni tests tests, JAVA_HOME is not set",
|
|
1032
|
-
).step);
|
|
1033
|
-
return;
|
|
1034
|
-
};
|
|
1035
|
-
|
|
1036
|
-
// JNI test require JVM to be present, and are _not_ run as a part of `zig build test`.
|
|
1037
|
-
// We need libjvm.so both at build time and at a runtime, so use `FailStep` when that is not
|
|
1038
|
-
// available.
|
|
1039
|
-
const libjvm_path = b.pathJoin(&.{
|
|
1040
|
-
java_home,
|
|
1041
|
-
if (builtin.os.tag == .windows) "/lib" else "/lib/server",
|
|
1042
|
-
});
|
|
1043
|
-
|
|
1044
|
-
const tests = b.addTest(.{
|
|
1045
|
-
.root_module = b.createModule(.{
|
|
1046
|
-
.root_source_file = b.path("src/clients/java/src/jni_tests.zig"),
|
|
1047
|
-
.target = options.target,
|
|
1048
|
-
// TODO(zig): The function `JNI_CreateJavaVM` tries to detect
|
|
1049
|
-
// the stack size and causes a SEGV that is handled by Zig's panic handler.
|
|
1050
|
-
// https://bugzilla.redhat.com/show_bug.cgi?id=1572811#c7
|
|
1051
|
-
//
|
|
1052
|
-
// The workaround is to run the tests in "ReleaseFast" mode.
|
|
1053
|
-
.optimize = if (builtin.os.tag == .windows) .ReleaseFast else options.mode,
|
|
1054
|
-
}),
|
|
1055
|
-
});
|
|
1056
|
-
tests.linkLibC();
|
|
1057
|
-
|
|
1058
|
-
tests.linkSystemLibrary("jvm");
|
|
1059
|
-
tests.addLibraryPath(.{ .cwd_relative = libjvm_path });
|
|
1060
|
-
if (builtin.os.tag == .linux) {
|
|
1061
|
-
// On Linux, detects the abi by calling `ldd` to check if
|
|
1062
|
-
// the libjvm.so is linked against libc or musl.
|
|
1063
|
-
// It's reasonable to assume that ldd will be present.
|
|
1064
|
-
var exit_code: u8 = undefined;
|
|
1065
|
-
const stderr_behavior = .Ignore;
|
|
1066
|
-
const ldd_result = try b.runAllowFail(
|
|
1067
|
-
&.{ "ldd", b.pathJoin(&.{ libjvm_path, "libjvm.so" }) },
|
|
1068
|
-
&exit_code,
|
|
1069
|
-
stderr_behavior,
|
|
1070
|
-
);
|
|
1071
|
-
|
|
1072
|
-
if (std.mem.indexOf(u8, ldd_result, "musl") != null) {
|
|
1073
|
-
tests.root_module.resolved_target.?.query.abi = .musl;
|
|
1074
|
-
tests.root_module.resolved_target.?.result.abi = .musl;
|
|
1075
|
-
} else if (std.mem.indexOf(u8, ldd_result, "libc") != null) {
|
|
1076
|
-
tests.root_module.resolved_target.?.query.abi = .gnu;
|
|
1077
|
-
tests.root_module.resolved_target.?.result.abi = .gnu;
|
|
1078
|
-
} else {
|
|
1079
|
-
std.log.err("{s}", .{ldd_result});
|
|
1080
|
-
return error.JavaAbiUnrecognized;
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
switch (builtin.os.tag) {
|
|
1085
|
-
.windows => set_windows_dll(b.allocator, java_home),
|
|
1086
|
-
.macos => try b.graph.env_map.put("DYLD_LIBRARY_PATH", libjvm_path),
|
|
1087
|
-
.linux => try b.graph.env_map.put("LD_LIBRARY_PATH", libjvm_path),
|
|
1088
|
-
else => unreachable,
|
|
1089
|
-
}
|
|
1090
|
-
|
|
1091
|
-
step_test_jni.dependOn(&b.addRunArtifact(tests).step);
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
fn build_vopr(
|
|
1095
|
-
b: *std.Build,
|
|
1096
|
-
steps: struct {
|
|
1097
|
-
vopr_build: *std.Build.Step,
|
|
1098
|
-
vopr_run: *std.Build.Step,
|
|
1099
|
-
},
|
|
1100
|
-
options: struct {
|
|
1101
|
-
stdx_module: *std.Build.Module,
|
|
1102
|
-
vsr_options_test: *std.Build.Step.Options,
|
|
1103
|
-
target: std.Build.ResolvedTarget,
|
|
1104
|
-
mode: std.builtin.OptimizeMode,
|
|
1105
|
-
print_exe: bool,
|
|
1106
|
-
vopr_state_machine: VoprStateMachine,
|
|
1107
|
-
vopr_log: VoprLog,
|
|
1108
|
-
},
|
|
1109
|
-
) void {
|
|
1110
|
-
const vopr_options = b.addOptions();
|
|
1111
|
-
|
|
1112
|
-
vopr_options.addOption(VoprStateMachine, "state_machine", options.vopr_state_machine);
|
|
1113
|
-
vopr_options.addOption(VoprLog, "log", options.vopr_log);
|
|
1114
|
-
|
|
1115
|
-
const vopr = b.addExecutable(.{
|
|
1116
|
-
.name = "vopr",
|
|
1117
|
-
.root_module = b.createModule(.{
|
|
1118
|
-
.root_source_file = b.path("src/vopr.zig"),
|
|
1119
|
-
.target = options.target,
|
|
1120
|
-
// When running without a SEED, default to release.
|
|
1121
|
-
.optimize = if (b.args == null) .ReleaseSafe else options.mode,
|
|
1122
|
-
}),
|
|
1123
|
-
});
|
|
1124
|
-
vopr.stack_size = 4 * MiB;
|
|
1125
|
-
vopr.root_module.addImport("stdx", options.stdx_module);
|
|
1126
|
-
vopr.root_module.addOptions("vsr_options", options.vsr_options_test);
|
|
1127
|
-
vopr.root_module.addOptions("vsr_vopr_options", vopr_options);
|
|
1128
|
-
// Ensure that we get stack traces even in release builds.
|
|
1129
|
-
vopr.root_module.omit_frame_pointer = false;
|
|
1130
|
-
steps.vopr_build.dependOn(print_or_install(b, vopr, options.print_exe));
|
|
1131
|
-
|
|
1132
|
-
const run_cmd = b.addRunArtifact(vopr);
|
|
1133
|
-
if (b.args) |args| run_cmd.addArgs(args);
|
|
1134
|
-
steps.vopr_run.dependOn(&run_cmd.step);
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
fn build_fuzz(
|
|
1138
|
-
b: *std.Build,
|
|
1139
|
-
steps: struct {
|
|
1140
|
-
fuzz: *std.Build.Step,
|
|
1141
|
-
fuzz_build: *std.Build.Step,
|
|
1142
|
-
},
|
|
1143
|
-
options: struct {
|
|
1144
|
-
stdx_module: *std.Build.Module,
|
|
1145
|
-
vsr_options_test: *std.Build.Step.Options,
|
|
1146
|
-
target: std.Build.ResolvedTarget,
|
|
1147
|
-
mode: std.builtin.OptimizeMode,
|
|
1148
|
-
print_exe: bool,
|
|
1149
|
-
},
|
|
1150
|
-
) void {
|
|
1151
|
-
const fuzz_exe = b.addExecutable(.{
|
|
1152
|
-
.name = "fuzz",
|
|
1153
|
-
.root_module = b.createModule(.{
|
|
1154
|
-
.root_source_file = b.path("src/fuzz_tests.zig"),
|
|
1155
|
-
.target = options.target,
|
|
1156
|
-
.optimize = options.mode,
|
|
1157
|
-
}),
|
|
1158
|
-
});
|
|
1159
|
-
fuzz_exe.stack_size = 4 * MiB;
|
|
1160
|
-
fuzz_exe.root_module.addImport("stdx", options.stdx_module);
|
|
1161
|
-
fuzz_exe.root_module.addOptions("vsr_options", options.vsr_options_test);
|
|
1162
|
-
fuzz_exe.root_module.omit_frame_pointer = false;
|
|
1163
|
-
steps.fuzz_build.dependOn(print_or_install(b, fuzz_exe, options.print_exe));
|
|
1164
|
-
|
|
1165
|
-
const fuzz_run = b.addRunArtifact(fuzz_exe);
|
|
1166
|
-
if (b.args) |args| fuzz_run.addArgs(args);
|
|
1167
|
-
steps.fuzz.dependOn(&fuzz_run.step);
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
fn build_scripts(
|
|
1171
|
-
b: *std.Build,
|
|
1172
|
-
steps: struct {
|
|
1173
|
-
scripts: *std.Build.Step,
|
|
1174
|
-
scripts_build: *std.Build.Step,
|
|
1175
|
-
},
|
|
1176
|
-
options: struct {
|
|
1177
|
-
stdx_module: *std.Build.Module,
|
|
1178
|
-
vsr_options: *std.Build.Step.Options,
|
|
1179
|
-
target: std.Build.ResolvedTarget,
|
|
1180
|
-
},
|
|
1181
|
-
) *std.Build.Step.Compile {
|
|
1182
|
-
const scripts_exe = b.addExecutable(.{
|
|
1183
|
-
.name = "scripts",
|
|
1184
|
-
.root_module = b.createModule(.{
|
|
1185
|
-
.root_source_file = b.path("src/scripts.zig"),
|
|
1186
|
-
.target = options.target,
|
|
1187
|
-
.optimize = .Debug,
|
|
1188
|
-
}),
|
|
1189
|
-
});
|
|
1190
|
-
scripts_exe.root_module.addImport("stdx", options.stdx_module);
|
|
1191
|
-
scripts_exe.root_module.addOptions("vsr_options", options.vsr_options);
|
|
1192
|
-
steps.scripts_build.dependOn(
|
|
1193
|
-
&b.addInstallArtifact(scripts_exe, .{}).step,
|
|
1194
|
-
);
|
|
1195
|
-
|
|
1196
|
-
const scripts_run = b.addRunArtifact(scripts_exe);
|
|
1197
|
-
scripts_run.setEnvironmentVariable("ZIG_EXE", b.graph.zig_exe);
|
|
1198
|
-
if (b.args) |args| scripts_run.addArgs(args);
|
|
1199
|
-
steps.scripts.dependOn(&scripts_run.step);
|
|
1200
|
-
|
|
1201
|
-
return scripts_exe;
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
fn build_vortex(
|
|
1205
|
-
b: *std.Build,
|
|
1206
|
-
steps: struct {
|
|
1207
|
-
vortex_build: *std.Build.Step,
|
|
1208
|
-
vortex_run: *std.Build.Step,
|
|
1209
|
-
},
|
|
1210
|
-
options: struct {
|
|
1211
|
-
stdx_module: *std.Build.Module,
|
|
1212
|
-
vsr_module_test: *std.Build.Module,
|
|
1213
|
-
vsr_options_test: *std.Build.Step.Options,
|
|
1214
|
-
target: std.Build.ResolvedTarget,
|
|
1215
|
-
mode: std.builtin.OptimizeMode,
|
|
1216
|
-
tigerbeetle_test: std.Build.LazyPath,
|
|
1217
|
-
tigerbeetle_test_previous: std.Build.LazyPath,
|
|
1218
|
-
vortex_driver_zig: std.Build.LazyPath,
|
|
1219
|
-
print_exe: bool,
|
|
1220
|
-
},
|
|
1221
|
-
) void {
|
|
1222
|
-
const vortex = build_vortex_executable(b, .{
|
|
1223
|
-
.stdx_module = options.stdx_module,
|
|
1224
|
-
.vsr_module_test = options.vsr_module_test,
|
|
1225
|
-
.vsr_options_test = options.vsr_options_test,
|
|
1226
|
-
.target = options.target,
|
|
1227
|
-
.mode = options.mode,
|
|
1228
|
-
.tigerbeetle_test = options.tigerbeetle_test,
|
|
1229
|
-
.tigerbeetle_test_previous = options.tigerbeetle_test_previous,
|
|
1230
|
-
.vortex_driver_zig = options.vortex_driver_zig,
|
|
1231
|
-
});
|
|
1232
|
-
|
|
1233
|
-
const install_step = print_or_install(b, vortex, options.print_exe);
|
|
1234
|
-
steps.vortex_build.dependOn(install_step);
|
|
1235
|
-
|
|
1236
|
-
const run_cmd = b.addRunArtifact(vortex);
|
|
1237
|
-
if (b.args) |args| run_cmd.addArgs(args);
|
|
1238
|
-
steps.vortex_run.dependOn(&run_cmd.step);
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
fn build_vortex_executable(
|
|
1242
|
-
b: *std.Build,
|
|
1243
|
-
options: struct {
|
|
1244
|
-
stdx_module: *std.Build.Module,
|
|
1245
|
-
vsr_module_test: *std.Build.Module,
|
|
1246
|
-
vsr_options_test: *std.Build.Step.Options,
|
|
1247
|
-
target: std.Build.ResolvedTarget,
|
|
1248
|
-
mode: std.builtin.OptimizeMode,
|
|
1249
|
-
tigerbeetle_test: std.Build.LazyPath,
|
|
1250
|
-
tigerbeetle_test_previous: std.Build.LazyPath,
|
|
1251
|
-
vortex_driver_zig: std.Build.LazyPath,
|
|
1252
|
-
},
|
|
1253
|
-
) *std.Build.Step.Compile {
|
|
1254
|
-
const vortex_options = b.addOptions();
|
|
1255
|
-
vortex_options.addOptionPath("tigerbeetle_exe", options.tigerbeetle_test);
|
|
1256
|
-
vortex_options.addOptionPath("driver_exe", options.vortex_driver_zig);
|
|
1257
|
-
|
|
1258
|
-
const vortex = b.addExecutable(.{
|
|
1259
|
-
.name = "vortex",
|
|
1260
|
-
.root_module = b.createModule(.{
|
|
1261
|
-
.root_source_file = b.path("src/vortex.zig"),
|
|
1262
|
-
.omit_frame_pointer = false,
|
|
1263
|
-
.target = options.target,
|
|
1264
|
-
.optimize = options.mode,
|
|
1265
|
-
}),
|
|
1266
|
-
});
|
|
1267
|
-
vortex.root_module.addImport("stdx", options.stdx_module);
|
|
1268
|
-
vortex.root_module.addOptions("vsr_options", options.vsr_options_test);
|
|
1269
|
-
vortex.root_module.addOptions("vortex_options", vortex_options);
|
|
1270
|
-
return vortex;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
fn build_vortex_driver_zig(
|
|
1274
|
-
b: *std.Build,
|
|
1275
|
-
steps: struct {
|
|
1276
|
-
vortex_driver_zig_build: *std.Build.Step,
|
|
1277
|
-
},
|
|
1278
|
-
options: struct {
|
|
1279
|
-
tb_client_header: std.Build.LazyPath,
|
|
1280
|
-
stdx_module: *std.Build.Module,
|
|
1281
|
-
vsr_module_test: *std.Build.Module,
|
|
1282
|
-
vsr_options_test: *std.Build.Step.Options,
|
|
1283
|
-
target: std.Build.ResolvedTarget,
|
|
1284
|
-
mode: std.builtin.OptimizeMode,
|
|
1285
|
-
print_exe: bool,
|
|
1286
|
-
},
|
|
1287
|
-
) std.Build.LazyPath {
|
|
1288
|
-
const tb_client = b.addLibrary(.{
|
|
1289
|
-
.name = "tb_client",
|
|
1290
|
-
.linkage = .static,
|
|
1291
|
-
.root_module = b.createModule(.{
|
|
1292
|
-
.root_source_file = b.path("src/tigerbeetle/libtb_client.zig"),
|
|
1293
|
-
.target = options.target,
|
|
1294
|
-
.optimize = options.mode,
|
|
1295
|
-
}),
|
|
1296
|
-
});
|
|
1297
|
-
tb_client.linkLibC();
|
|
1298
|
-
tb_client.pie = true;
|
|
1299
|
-
tb_client.bundle_compiler_rt = true;
|
|
1300
|
-
tb_client.root_module.addImport("vsr", options.vsr_module_test);
|
|
1301
|
-
tb_client.root_module.addOptions("vsr_options", options.vsr_options_test);
|
|
1302
|
-
if (options.target.result.os.tag == .windows) {
|
|
1303
|
-
tb_client.linkSystemLibrary("ws2_32");
|
|
1304
|
-
tb_client.linkSystemLibrary("advapi32");
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
const vortex_driver = b.addExecutable(.{
|
|
1308
|
-
.name = "vortex-driver-zig",
|
|
1309
|
-
.root_module = b.createModule(.{
|
|
1310
|
-
.root_source_file = b.path("src/testing/vortex/zig_driver.zig"),
|
|
1311
|
-
.omit_frame_pointer = false,
|
|
1312
|
-
.target = options.target,
|
|
1313
|
-
.optimize = options.mode,
|
|
1314
|
-
}),
|
|
1315
|
-
});
|
|
1316
|
-
vortex_driver.linkLibC();
|
|
1317
|
-
vortex_driver.linkLibrary(tb_client);
|
|
1318
|
-
vortex_driver.addIncludePath(options.tb_client_header.dirname());
|
|
1319
|
-
vortex_driver.root_module.addImport("stdx", options.stdx_module);
|
|
1320
|
-
vortex_driver.root_module.addImport("vsr", options.vsr_module_test);
|
|
1321
|
-
|
|
1322
|
-
const install_step = print_or_install(b, vortex_driver, options.print_exe);
|
|
1323
|
-
steps.vortex_driver_zig_build.dependOn(install_step);
|
|
1324
|
-
return vortex_driver.getEmittedBin();
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
// TigerBeetle clients ship as precompiled binaries and support this closed set of targets:
|
|
1328
|
-
const Platform = enum {
|
|
1329
|
-
@"aarch64-linux-gnu.2.27",
|
|
1330
|
-
@"aarch64-linux-musl",
|
|
1331
|
-
@"aarch64-macos",
|
|
1332
|
-
@"x86_64-linux-gnu.2.27",
|
|
1333
|
-
@"x86_64-linux-musl",
|
|
1334
|
-
@"x86_64-macos",
|
|
1335
|
-
@"x86_64-windows",
|
|
1336
|
-
|
|
1337
|
-
const all: []const Platform = std.enums.values(Platform);
|
|
1338
|
-
|
|
1339
|
-
pub fn target(platform: Platform) []const u8 {
|
|
1340
|
-
return @tagName(platform);
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
pub fn target_no_glibc_version(platform: Platform) []const u8 {
|
|
1344
|
-
if (std.mem.endsWith(u8, platform.target(), "gnu.2.27")) {
|
|
1345
|
-
return platform.target()[0 .. platform.target().len - ".2.27".len];
|
|
1346
|
-
}
|
|
1347
|
-
assert(std.mem.indexOf(u8, platform.target(), "gnu") == null);
|
|
1348
|
-
return platform.target();
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
pub fn target_resolved(platform: Platform, b: *std.Build) std.Build.ResolvedTarget {
|
|
1352
|
-
const query = Query.parse(.{
|
|
1353
|
-
.arch_os_abi = platform.target(),
|
|
1354
|
-
.cpu_features = platform.cpu_features(),
|
|
1355
|
-
}) catch unreachable;
|
|
1356
|
-
return b.resolveTargetQuery(query);
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
pub fn cpu_features(platform: Platform) []const u8 {
|
|
1360
|
-
return switch (platform) {
|
|
1361
|
-
.@"aarch64-linux-gnu.2.27",
|
|
1362
|
-
.@"aarch64-linux-musl",
|
|
1363
|
-
.@"aarch64-macos",
|
|
1364
|
-
=> "baseline+aes+neon",
|
|
1365
|
-
|
|
1366
|
-
.@"x86_64-linux-gnu.2.27",
|
|
1367
|
-
.@"x86_64-linux-musl",
|
|
1368
|
-
.@"x86_64-macos",
|
|
1369
|
-
.@"x86_64-windows",
|
|
1370
|
-
=> "x86_64_v3+aes",
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
pub fn dotnet_RID(platform: Platform) []const u8 {
|
|
1375
|
-
return switch (platform) {
|
|
1376
|
-
.@"aarch64-linux-gnu.2.27" => "linux-arm64",
|
|
1377
|
-
.@"aarch64-linux-musl" => "linux-musl-arm64",
|
|
1378
|
-
.@"aarch64-macos" => "osx-arm64",
|
|
1379
|
-
|
|
1380
|
-
.@"x86_64-linux-gnu.2.27" => "linux-x64",
|
|
1381
|
-
.@"x86_64-linux-musl" => "linux-musl-x64",
|
|
1382
|
-
.@"x86_64-macos" => "osx-x64",
|
|
1383
|
-
.@"x86_64-windows" => "win-x64",
|
|
1384
|
-
};
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
pub fn go_target(platform: Platform) []const u8 {
|
|
1388
|
-
return switch (platform) {
|
|
1389
|
-
// Go statically links musl.
|
|
1390
|
-
.@"aarch64-linux-gnu.2.27", .@"x86_64-linux-gnu.2.27" => unreachable,
|
|
1391
|
-
.@"aarch64-linux-musl" => "aarch64-linux",
|
|
1392
|
-
.@"x86_64-linux-musl" => "x86_64-linux",
|
|
1393
|
-
|
|
1394
|
-
.@"aarch64-macos",
|
|
1395
|
-
.@"x86_64-macos",
|
|
1396
|
-
.@"x86_64-windows",
|
|
1397
|
-
=> platform.target(),
|
|
1398
|
-
};
|
|
1399
|
-
}
|
|
1400
|
-
};
|
|
1401
|
-
|
|
1402
|
-
/// Produces a directory with tb_client precompiled as dynamic libraries
|
|
1403
|
-
/// for all platforms we support. These precompiled libraries are then
|
|
1404
|
-
/// redistributed with our language clients.
|
|
1405
|
-
const TBClientPrebuilt = struct {
|
|
1406
|
-
header: std.Build.LazyPath,
|
|
1407
|
-
all_platforms: std.Build.LazyPath,
|
|
1408
|
-
per_platform: []PerPlatform,
|
|
1409
|
-
|
|
1410
|
-
const PerPlatform = struct {
|
|
1411
|
-
platform: Platform,
|
|
1412
|
-
file_name: []const u8,
|
|
1413
|
-
lazy_path: std.Build.LazyPath,
|
|
1414
|
-
};
|
|
1415
|
-
};
|
|
1416
|
-
|
|
1417
|
-
fn build_tb_client(
|
|
1418
|
-
b: *std.Build,
|
|
1419
|
-
options: struct {
|
|
1420
|
-
vsr_module: *std.Build.Module,
|
|
1421
|
-
vsr_options: *std.Build.Step.Options,
|
|
1422
|
-
mode: std.builtin.OptimizeMode,
|
|
1423
|
-
},
|
|
1424
|
-
) TBClientPrebuilt {
|
|
1425
|
-
var per_platform: std.ArrayListUnmanaged(TBClientPrebuilt.PerPlatform) = .empty;
|
|
1426
|
-
const all_platforms = b.addWriteFiles();
|
|
1427
|
-
for (Platform.all) |platform| {
|
|
1428
|
-
const resolved_target = platform.target_resolved(b);
|
|
1429
|
-
|
|
1430
|
-
const root_module = b.createModule(.{
|
|
1431
|
-
.root_source_file = b.path("src/tigerbeetle/libtb_client.zig"),
|
|
1432
|
-
.target = resolved_target,
|
|
1433
|
-
.optimize = options.mode,
|
|
1434
|
-
});
|
|
1435
|
-
root_module.addImport("vsr", options.vsr_module);
|
|
1436
|
-
root_module.addOptions("vsr_options", options.vsr_options);
|
|
1437
|
-
if (options.mode == .ReleaseSafe) strip_root_module(root_module);
|
|
1438
|
-
|
|
1439
|
-
const shared_lib = b.addLibrary(.{
|
|
1440
|
-
.name = "tb_client",
|
|
1441
|
-
.linkage = .dynamic,
|
|
1442
|
-
.root_module = root_module,
|
|
1443
|
-
});
|
|
1444
|
-
shared_lib.linkLibC();
|
|
1445
|
-
if (resolved_target.result.os.tag == .windows) {
|
|
1446
|
-
shared_lib.linkSystemLibrary("ws2_32");
|
|
1447
|
-
shared_lib.linkSystemLibrary("advapi32");
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
per_platform.append(b.allocator, .{
|
|
1451
|
-
.platform = platform,
|
|
1452
|
-
.file_name = shared_lib.out_filename,
|
|
1453
|
-
.lazy_path = all_platforms.addCopyFile(
|
|
1454
|
-
shared_lib.getEmittedBin(),
|
|
1455
|
-
b.pathJoin(&.{ platform.target(), shared_lib.out_filename }),
|
|
1456
|
-
),
|
|
1457
|
-
}) catch @panic("OOM");
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
const tb_client_header_generator = b.addExecutable(.{
|
|
1461
|
-
.name = "tb_client_header",
|
|
1462
|
-
.root_module = b.createModule(.{
|
|
1463
|
-
.root_source_file = b.path("src/clients/c/tb_client_header.zig"),
|
|
1464
|
-
.target = b.graph.host,
|
|
1465
|
-
}),
|
|
1466
|
-
});
|
|
1467
|
-
tb_client_header_generator.root_module.addImport("vsr", options.vsr_module);
|
|
1468
|
-
tb_client_header_generator.root_module.addOptions("vsr_options", options.vsr_options);
|
|
1469
|
-
const header = Generated.file(b, .{
|
|
1470
|
-
.generator = tb_client_header_generator,
|
|
1471
|
-
.path = "./src/clients/c/tb_client.h",
|
|
1472
|
-
});
|
|
1473
|
-
|
|
1474
|
-
return .{
|
|
1475
|
-
.header = header.path,
|
|
1476
|
-
.all_platforms = all_platforms.getDirectory(),
|
|
1477
|
-
.per_platform = per_platform.items,
|
|
1478
|
-
};
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
fn build_rust_client(
|
|
1482
|
-
b: *std.Build,
|
|
1483
|
-
step_clients_rust: *std.Build.Step,
|
|
1484
|
-
options: struct {
|
|
1485
|
-
vsr_module: *std.Build.Module,
|
|
1486
|
-
vsr_options: *std.Build.Step.Options,
|
|
1487
|
-
tb_client_header: std.Build.LazyPath,
|
|
1488
|
-
mode: std.builtin.OptimizeMode,
|
|
1489
|
-
},
|
|
1490
|
-
) void {
|
|
1491
|
-
// The Rust test suite runs tigerbeetle directly. This ensures it is available.
|
|
1492
|
-
step_clients_rust.dependOn(b.getInstallStep());
|
|
1493
|
-
|
|
1494
|
-
// Copy the generated header file to the Rust client assets directory:
|
|
1495
|
-
const tb_client_header_copy = Generated.file_copy(b, .{
|
|
1496
|
-
.from = options.tb_client_header,
|
|
1497
|
-
.path = "./src/clients/rust/assets/tb_client.h",
|
|
1498
|
-
});
|
|
1499
|
-
step_clients_rust.dependOn(&tb_client_header_copy.step);
|
|
1500
|
-
|
|
1501
|
-
for (Platform.all) |platform| {
|
|
1502
|
-
const resolved_target = platform.target_resolved(b);
|
|
1503
|
-
|
|
1504
|
-
const root_module = b.createModule(.{
|
|
1505
|
-
.root_source_file = b.path("src/tigerbeetle/libtb_client.zig"),
|
|
1506
|
-
.target = resolved_target,
|
|
1507
|
-
.optimize = options.mode,
|
|
1508
|
-
});
|
|
1509
|
-
root_module.addImport("vsr", options.vsr_module);
|
|
1510
|
-
root_module.addOptions("vsr_options", options.vsr_options);
|
|
1511
|
-
if (options.mode == .ReleaseSafe) strip_root_module(root_module);
|
|
1512
|
-
|
|
1513
|
-
const static_lib = b.addLibrary(.{
|
|
1514
|
-
.name = "tb_client",
|
|
1515
|
-
.linkage = .static,
|
|
1516
|
-
.root_module = root_module,
|
|
1517
|
-
});
|
|
1518
|
-
static_lib.bundle_compiler_rt = true;
|
|
1519
|
-
static_lib.pie = true;
|
|
1520
|
-
static_lib.linkLibC();
|
|
1521
|
-
|
|
1522
|
-
step_clients_rust.dependOn(&b.addInstallFile(static_lib.getEmittedBin(), b.pathJoin(&.{
|
|
1523
|
-
"../src/clients/rust/assets/lib/",
|
|
1524
|
-
platform.target(),
|
|
1525
|
-
static_lib.out_filename,
|
|
1526
|
-
})).step);
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
const rust_bindings_generator = b.addExecutable(.{
|
|
1530
|
-
.name = "rust_bindings",
|
|
1531
|
-
.root_module = b.createModule(.{
|
|
1532
|
-
.root_source_file = b.path("src/clients/rust/rust_bindings.zig"),
|
|
1533
|
-
.target = b.graph.host,
|
|
1534
|
-
}),
|
|
1535
|
-
});
|
|
1536
|
-
rust_bindings_generator.root_module.addImport("vsr", options.vsr_module);
|
|
1537
|
-
rust_bindings_generator.root_module.addOptions("vsr_options", options.vsr_options);
|
|
1538
|
-
const bindings = Generated.file(b, .{
|
|
1539
|
-
.generator = rust_bindings_generator,
|
|
1540
|
-
.path = "./src/clients/rust/src/tb_client.rs",
|
|
1541
|
-
});
|
|
1542
|
-
|
|
1543
|
-
step_clients_rust.dependOn(&bindings.step);
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
fn build_go_client(
|
|
1547
|
-
b: *std.Build,
|
|
1548
|
-
step_clients_go: *std.Build.Step,
|
|
1549
|
-
options: struct {
|
|
1550
|
-
vsr_module: *std.Build.Module,
|
|
1551
|
-
vsr_options: *std.Build.Step.Options,
|
|
1552
|
-
tb_client_header: std.Build.LazyPath,
|
|
1553
|
-
mode: std.builtin.OptimizeMode,
|
|
1554
|
-
},
|
|
1555
|
-
) void {
|
|
1556
|
-
// Updates the generated header file:
|
|
1557
|
-
const tb_client_header_copy = Generated.file_copy(b, .{
|
|
1558
|
-
.from = options.tb_client_header,
|
|
1559
|
-
.path = "./src/clients/go/pkg/native/tb_client.h",
|
|
1560
|
-
});
|
|
1561
|
-
|
|
1562
|
-
const go_bindings_generator = b.addExecutable(.{
|
|
1563
|
-
.name = "go_bindings",
|
|
1564
|
-
.root_module = b.createModule(.{
|
|
1565
|
-
.root_source_file = b.path("src/clients/go/go_bindings.zig"),
|
|
1566
|
-
.target = b.graph.host,
|
|
1567
|
-
}),
|
|
1568
|
-
});
|
|
1569
|
-
go_bindings_generator.root_module.addImport("vsr", options.vsr_module);
|
|
1570
|
-
go_bindings_generator.root_module.addOptions("vsr_options", options.vsr_options);
|
|
1571
|
-
go_bindings_generator.step.dependOn(&tb_client_header_copy.step);
|
|
1572
|
-
const bindings = Generated.file(b, .{
|
|
1573
|
-
.generator = go_bindings_generator,
|
|
1574
|
-
.path = "./src/clients/go/pkg/types/bindings.go",
|
|
1575
|
-
});
|
|
1576
|
-
|
|
1577
|
-
for (Platform.all) |platform| {
|
|
1578
|
-
// We don't need the linux-gnu builds.
|
|
1579
|
-
if (platform == .@"aarch64-linux-gnu.2.27" or platform == .@"x86_64-linux-gnu.2.27") {
|
|
1580
|
-
continue;
|
|
1581
|
-
}
|
|
1582
|
-
|
|
1583
|
-
const resolved_target = platform.target_resolved(b);
|
|
1584
|
-
|
|
1585
|
-
const root_module = b.createModule(.{
|
|
1586
|
-
.root_source_file = b.path("src/tigerbeetle/libtb_client.zig"),
|
|
1587
|
-
.target = resolved_target,
|
|
1588
|
-
.optimize = options.mode,
|
|
1589
|
-
.stack_protector = false,
|
|
1590
|
-
});
|
|
1591
|
-
root_module.addImport("vsr", options.vsr_module);
|
|
1592
|
-
root_module.addOptions("vsr_options", options.vsr_options);
|
|
1593
|
-
if (options.mode == .ReleaseSafe) strip_root_module(root_module);
|
|
1594
|
-
|
|
1595
|
-
const lib = b.addLibrary(.{
|
|
1596
|
-
.name = "tb_client",
|
|
1597
|
-
.linkage = .static,
|
|
1598
|
-
.root_module = root_module,
|
|
1599
|
-
});
|
|
1600
|
-
lib.linkLibC();
|
|
1601
|
-
lib.pie = true;
|
|
1602
|
-
lib.bundle_compiler_rt = true;
|
|
1603
|
-
lib.step.dependOn(&bindings.step);
|
|
1604
|
-
|
|
1605
|
-
const file_name: []const u8, const extension: []const u8 = cut: {
|
|
1606
|
-
assert(std.mem.count(u8, lib.out_lib_filename, ".") == 1);
|
|
1607
|
-
var it = std.mem.splitScalar(u8, lib.out_lib_filename, '.');
|
|
1608
|
-
defer assert(it.next() == null);
|
|
1609
|
-
break :cut .{ it.next().?, it.next().? };
|
|
1610
|
-
};
|
|
1611
|
-
|
|
1612
|
-
// NB: New way to do lib.setOutputDir(). The ../ is important to escape zig-cache/.
|
|
1613
|
-
step_clients_go.dependOn(&b.addInstallFile(
|
|
1614
|
-
lib.getEmittedBin(),
|
|
1615
|
-
b.fmt("../src/clients/go/pkg/native/{s}_{s}.{s}", .{
|
|
1616
|
-
file_name,
|
|
1617
|
-
platform.go_target(),
|
|
1618
|
-
extension,
|
|
1619
|
-
}),
|
|
1620
|
-
).step);
|
|
1621
|
-
}
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
fn build_java_client(
|
|
1625
|
-
b: *std.Build,
|
|
1626
|
-
step_clients_java: *std.Build.Step,
|
|
1627
|
-
options: struct {
|
|
1628
|
-
vsr_module: *std.Build.Module,
|
|
1629
|
-
vsr_options: *std.Build.Step.Options,
|
|
1630
|
-
mode: std.builtin.OptimizeMode,
|
|
1631
|
-
},
|
|
1632
|
-
) void {
|
|
1633
|
-
const java_bindings_generator = b.addExecutable(.{
|
|
1634
|
-
.name = "java_bindings",
|
|
1635
|
-
.root_module = b.createModule(.{
|
|
1636
|
-
.root_source_file = b.path("src/clients/java/java_bindings.zig"),
|
|
1637
|
-
.target = b.graph.host,
|
|
1638
|
-
}),
|
|
1639
|
-
});
|
|
1640
|
-
java_bindings_generator.root_module.addImport("vsr", options.vsr_module);
|
|
1641
|
-
java_bindings_generator.root_module.addOptions("vsr_options", options.vsr_options);
|
|
1642
|
-
const bindings = Generated.directory(b, .{
|
|
1643
|
-
.generator = java_bindings_generator,
|
|
1644
|
-
.path = "./src/clients/java/src/main/java/com/tigerbeetle/",
|
|
1645
|
-
});
|
|
1646
|
-
|
|
1647
|
-
for (Platform.all) |platform| {
|
|
1648
|
-
const resolved_target = platform.target_resolved(b);
|
|
1649
|
-
|
|
1650
|
-
const root_module = b.createModule(.{
|
|
1651
|
-
.root_source_file = b.path("src/clients/java/src/client.zig"),
|
|
1652
|
-
.target = resolved_target,
|
|
1653
|
-
.optimize = options.mode,
|
|
1654
|
-
});
|
|
1655
|
-
root_module.addImport("vsr", options.vsr_module);
|
|
1656
|
-
root_module.addOptions("vsr_options", options.vsr_options);
|
|
1657
|
-
if (options.mode == .ReleaseSafe) strip_root_module(root_module);
|
|
1658
|
-
|
|
1659
|
-
const lib = b.addLibrary(.{
|
|
1660
|
-
.name = "tb_jniclient",
|
|
1661
|
-
.linkage = .dynamic,
|
|
1662
|
-
.root_module = root_module,
|
|
1663
|
-
});
|
|
1664
|
-
lib.linkLibC();
|
|
1665
|
-
if (resolved_target.result.os.tag == .windows) {
|
|
1666
|
-
lib.linkSystemLibrary("ws2_32");
|
|
1667
|
-
lib.linkSystemLibrary("advapi32");
|
|
1668
|
-
}
|
|
1669
|
-
lib.step.dependOn(&bindings.step);
|
|
1670
|
-
|
|
1671
|
-
// NB: New way to do lib.setOutputDir(). The ../ is important to escape zig-cache/.
|
|
1672
|
-
step_clients_java.dependOn(&b.addInstallFile(lib.getEmittedBin(), b.pathJoin(&.{
|
|
1673
|
-
"../src/clients/java/src/main/resources/lib/",
|
|
1674
|
-
platform.target_no_glibc_version(),
|
|
1675
|
-
lib.out_filename,
|
|
1676
|
-
})).step);
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
fn build_dotnet_client(
|
|
1681
|
-
b: *std.Build,
|
|
1682
|
-
step_clients_dotnet: *std.Build.Step,
|
|
1683
|
-
options: struct {
|
|
1684
|
-
vsr_module: *std.Build.Module,
|
|
1685
|
-
vsr_options: *std.Build.Step.Options,
|
|
1686
|
-
tb_client: TBClientPrebuilt,
|
|
1687
|
-
mode: std.builtin.OptimizeMode,
|
|
1688
|
-
},
|
|
1689
|
-
) void {
|
|
1690
|
-
const dotnet_bindings_generator = b.addExecutable(.{
|
|
1691
|
-
.name = "dotnet_bindings",
|
|
1692
|
-
.root_module = b.createModule(.{
|
|
1693
|
-
.root_source_file = b.path("src/clients/dotnet/dotnet_bindings.zig"),
|
|
1694
|
-
.target = b.graph.host,
|
|
1695
|
-
}),
|
|
1696
|
-
});
|
|
1697
|
-
dotnet_bindings_generator.root_module.addImport("vsr", options.vsr_module);
|
|
1698
|
-
dotnet_bindings_generator.root_module.addOptions("vsr_options", options.vsr_options);
|
|
1699
|
-
const bindings = Generated.file(b, .{
|
|
1700
|
-
.generator = dotnet_bindings_generator,
|
|
1701
|
-
.path = "./src/clients/dotnet/TigerBeetle/Bindings.cs",
|
|
1702
|
-
});
|
|
1703
|
-
|
|
1704
|
-
step_clients_dotnet.dependOn(&bindings.step);
|
|
1705
|
-
for (options.tb_client.per_platform) |platform| {
|
|
1706
|
-
step_clients_dotnet.dependOn(&b.addInstallFile(platform.lazy_path, b.pathJoin(&.{
|
|
1707
|
-
"../src/clients/dotnet/TigerBeetle/runtimes/",
|
|
1708
|
-
platform.platform.dotnet_RID(),
|
|
1709
|
-
"native",
|
|
1710
|
-
platform.file_name,
|
|
1711
|
-
})).step);
|
|
1712
|
-
}
|
|
1713
|
-
}
|
|
1714
|
-
|
|
1715
|
-
fn build_node_client(
|
|
1716
|
-
b: *std.Build,
|
|
1717
|
-
step_clients_node: *std.Build.Step,
|
|
1718
|
-
options: struct {
|
|
1719
|
-
vsr_module: *std.Build.Module,
|
|
1720
|
-
vsr_options: *std.Build.Step.Options,
|
|
1721
|
-
mode: std.builtin.OptimizeMode,
|
|
1722
|
-
},
|
|
1723
|
-
) void {
|
|
1724
|
-
const node_bindings_generator = b.addExecutable(.{
|
|
1725
|
-
.name = "node_bindings",
|
|
1726
|
-
.root_module = b.createModule(.{
|
|
1727
|
-
.root_source_file = b.path("src/clients/node/node_bindings.zig"),
|
|
1728
|
-
.target = b.graph.host,
|
|
1729
|
-
}),
|
|
1730
|
-
});
|
|
1731
|
-
node_bindings_generator.root_module.addImport("vsr", options.vsr_module);
|
|
1732
|
-
node_bindings_generator.root_module.addOptions("vsr_options", options.vsr_options);
|
|
1733
|
-
const bindings = Generated.file(b, .{
|
|
1734
|
-
.generator = node_bindings_generator,
|
|
1735
|
-
.path = "./src/clients/node/src/bindings.ts",
|
|
1736
|
-
});
|
|
1737
|
-
|
|
1738
|
-
// Run `npm install` to get access to node headers.
|
|
1739
|
-
var npm_install = b.addSystemCommand(&.{ "npm", "install" });
|
|
1740
|
-
npm_install.cwd = b.path("./src/clients/node");
|
|
1741
|
-
|
|
1742
|
-
// For windows, compile a set of all symbols that could be exported by node and write it to a
|
|
1743
|
-
// `.def` file for `zig dlltool` to generate a `.lib` file from.
|
|
1744
|
-
var write_def_file = b.addSystemCommand(&.{
|
|
1745
|
-
"node", "--eval",
|
|
1746
|
-
\\const headers = require('node-api-headers')
|
|
1747
|
-
\\
|
|
1748
|
-
\\const allSymbols = new Set()
|
|
1749
|
-
\\for (const ver of Object.values(headers.symbols)) {
|
|
1750
|
-
\\ for (const sym of ver.node_api_symbols) {
|
|
1751
|
-
\\ allSymbols.add(sym)
|
|
1752
|
-
\\ }
|
|
1753
|
-
\\ for (const sym of ver.js_native_api_symbols) {
|
|
1754
|
-
\\ allSymbols.add(sym)
|
|
1755
|
-
\\ }
|
|
1756
|
-
\\}
|
|
1757
|
-
\\
|
|
1758
|
-
\\process.stdout.write('EXPORTS\n ' + Array.from(allSymbols).join('\n '))
|
|
1759
|
-
});
|
|
1760
|
-
write_def_file.cwd = b.path("./src/clients/node");
|
|
1761
|
-
write_def_file.step.dependOn(&npm_install.step);
|
|
1762
|
-
|
|
1763
|
-
var run_dll_tool = b.addSystemCommand(&.{
|
|
1764
|
-
b.graph.zig_exe, "dlltool",
|
|
1765
|
-
"-m", "i386:x86-64",
|
|
1766
|
-
"-D", "node.exe",
|
|
1767
|
-
"-l", "node.lib",
|
|
1768
|
-
"-d",
|
|
1769
|
-
});
|
|
1770
|
-
run_dll_tool.addFileArg(write_def_file.captureStdOut());
|
|
1771
|
-
run_dll_tool.cwd = b.path("./src/clients/node");
|
|
1772
|
-
|
|
1773
|
-
for (Platform.all) |platform| {
|
|
1774
|
-
const resolved_target = platform.target_resolved(b);
|
|
1775
|
-
|
|
1776
|
-
const root_module = b.createModule(.{
|
|
1777
|
-
.root_source_file = b.path("src/clients/node/node.zig"),
|
|
1778
|
-
.target = resolved_target,
|
|
1779
|
-
.optimize = options.mode,
|
|
1780
|
-
});
|
|
1781
|
-
root_module.addImport("vsr", options.vsr_module);
|
|
1782
|
-
root_module.addOptions("vsr_options", options.vsr_options);
|
|
1783
|
-
if (options.mode == .ReleaseSafe) strip_root_module(root_module);
|
|
1784
|
-
|
|
1785
|
-
const lib = b.addLibrary(.{
|
|
1786
|
-
.name = "tb_nodeclient",
|
|
1787
|
-
.linkage = .dynamic,
|
|
1788
|
-
.root_module = root_module,
|
|
1789
|
-
});
|
|
1790
|
-
lib.linkLibC();
|
|
1791
|
-
|
|
1792
|
-
lib.step.dependOn(&npm_install.step);
|
|
1793
|
-
lib.addSystemIncludePath(b.path("src/clients/node/node_modules/node-api-headers/include"));
|
|
1794
|
-
lib.linker_allow_shlib_undefined = true;
|
|
1795
|
-
|
|
1796
|
-
if (resolved_target.result.os.tag == .windows) {
|
|
1797
|
-
lib.linkSystemLibrary("ws2_32");
|
|
1798
|
-
lib.linkSystemLibrary("advapi32");
|
|
1799
|
-
|
|
1800
|
-
lib.step.dependOn(&run_dll_tool.step);
|
|
1801
|
-
lib.addLibraryPath(b.path("src/clients/node"));
|
|
1802
|
-
lib.linkSystemLibrary("node");
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
lib.step.dependOn(&bindings.step);
|
|
1806
|
-
step_clients_node.dependOn(&b.addInstallFile(lib.getEmittedBin(), b.pathJoin(&.{
|
|
1807
|
-
"../src/clients/node/dist/bin",
|
|
1808
|
-
platform.target_no_glibc_version(),
|
|
1809
|
-
"/client.node",
|
|
1810
|
-
})).step);
|
|
1811
|
-
}
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
fn build_python_client(
|
|
1815
|
-
b: *std.Build,
|
|
1816
|
-
step_clients_python: *std.Build.Step,
|
|
1817
|
-
options: struct {
|
|
1818
|
-
vsr_module: *std.Build.Module,
|
|
1819
|
-
vsr_options: *std.Build.Step.Options,
|
|
1820
|
-
tb_client: TBClientPrebuilt,
|
|
1821
|
-
mode: std.builtin.OptimizeMode,
|
|
1822
|
-
},
|
|
1823
|
-
) void {
|
|
1824
|
-
const python_bindings_generator = b.addExecutable(.{
|
|
1825
|
-
.name = "python_bindings",
|
|
1826
|
-
.root_module = b.createModule(.{
|
|
1827
|
-
.root_source_file = b.path("src/clients/python/python_bindings.zig"),
|
|
1828
|
-
.target = b.graph.host,
|
|
1829
|
-
}),
|
|
1830
|
-
});
|
|
1831
|
-
python_bindings_generator.root_module.addImport("vsr", options.vsr_module);
|
|
1832
|
-
python_bindings_generator.root_module.addOptions("vsr_options", options.vsr_options);
|
|
1833
|
-
const bindings = Generated.file(b, .{
|
|
1834
|
-
.generator = python_bindings_generator,
|
|
1835
|
-
.path = "./src/clients/python/src/tigerbeetle/bindings.py",
|
|
1836
|
-
});
|
|
1837
|
-
step_clients_python.dependOn(&bindings.step);
|
|
1838
|
-
|
|
1839
|
-
step_clients_python.dependOn(&b.addInstallDirectory(.{
|
|
1840
|
-
.source_dir = options.tb_client.all_platforms,
|
|
1841
|
-
.install_dir = .prefix,
|
|
1842
|
-
.install_subdir = "../src/clients/python/src/tigerbeetle/lib/",
|
|
1843
|
-
}).step);
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
fn build_c_client(
|
|
1847
|
-
b: *std.Build,
|
|
1848
|
-
step_clients_c: *std.Build.Step,
|
|
1849
|
-
options: struct {
|
|
1850
|
-
vsr_module: *std.Build.Module,
|
|
1851
|
-
vsr_options: *std.Build.Step.Options,
|
|
1852
|
-
tb_client_header: std.Build.LazyPath,
|
|
1853
|
-
mode: std.builtin.OptimizeMode,
|
|
1854
|
-
},
|
|
1855
|
-
) void {
|
|
1856
|
-
options.tb_client_header.addStepDependencies(step_clients_c);
|
|
1857
|
-
|
|
1858
|
-
for (Platform.all) |platform| {
|
|
1859
|
-
const resolved_target = platform.target_resolved(b);
|
|
1860
|
-
|
|
1861
|
-
const root_module = b.createModule(.{
|
|
1862
|
-
.root_source_file = b.path("src/tigerbeetle/libtb_client.zig"),
|
|
1863
|
-
.target = resolved_target,
|
|
1864
|
-
.optimize = options.mode,
|
|
1865
|
-
});
|
|
1866
|
-
root_module.addImport("vsr", options.vsr_module);
|
|
1867
|
-
root_module.addOptions("vsr_options", options.vsr_options);
|
|
1868
|
-
if (options.mode == .ReleaseSafe) strip_root_module(root_module);
|
|
1869
|
-
|
|
1870
|
-
const shared_lib = b.addLibrary(.{
|
|
1871
|
-
.name = "tb_client",
|
|
1872
|
-
.linkage = .dynamic,
|
|
1873
|
-
.root_module = root_module,
|
|
1874
|
-
});
|
|
1875
|
-
|
|
1876
|
-
const static_lib = b.addLibrary(.{
|
|
1877
|
-
.name = "tb_client",
|
|
1878
|
-
.linkage = .static,
|
|
1879
|
-
.root_module = root_module,
|
|
1880
|
-
});
|
|
1881
|
-
static_lib.bundle_compiler_rt = true;
|
|
1882
|
-
static_lib.pie = true;
|
|
1883
|
-
|
|
1884
|
-
for ([_]*std.Build.Step.Compile{ shared_lib, static_lib }) |lib| {
|
|
1885
|
-
lib.linkLibC();
|
|
1886
|
-
if (resolved_target.result.os.tag == .windows) {
|
|
1887
|
-
lib.linkSystemLibrary("ws2_32");
|
|
1888
|
-
lib.linkSystemLibrary("advapi32");
|
|
1889
|
-
}
|
|
1890
|
-
|
|
1891
|
-
step_clients_c.dependOn(&b.addInstallFile(lib.getEmittedBin(), b.pathJoin(&.{
|
|
1892
|
-
"../src/clients/c/lib/",
|
|
1893
|
-
platform.target(),
|
|
1894
|
-
lib.out_filename,
|
|
1895
|
-
})).step);
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
fn build_clients_c_sample(
|
|
1901
|
-
b: *std.Build,
|
|
1902
|
-
step_clients_c_sample: *std.Build.Step,
|
|
1903
|
-
options: struct {
|
|
1904
|
-
vsr_module: *std.Build.Module,
|
|
1905
|
-
vsr_options: *std.Build.Step.Options,
|
|
1906
|
-
target: std.Build.ResolvedTarget,
|
|
1907
|
-
mode: std.builtin.OptimizeMode,
|
|
1908
|
-
},
|
|
1909
|
-
) void {
|
|
1910
|
-
const static_lib = b.addLibrary(.{
|
|
1911
|
-
.name = "tb_client",
|
|
1912
|
-
.linkage = .static,
|
|
1913
|
-
.root_module = b.createModule(.{
|
|
1914
|
-
.root_source_file = b.path("src/tigerbeetle/libtb_client.zig"),
|
|
1915
|
-
.target = options.target,
|
|
1916
|
-
.optimize = options.mode,
|
|
1917
|
-
}),
|
|
1918
|
-
});
|
|
1919
|
-
static_lib.linkLibC();
|
|
1920
|
-
static_lib.pie = true;
|
|
1921
|
-
static_lib.bundle_compiler_rt = true;
|
|
1922
|
-
static_lib.root_module.addImport("vsr", options.vsr_module);
|
|
1923
|
-
static_lib.root_module.addOptions("vsr_options", options.vsr_options);
|
|
1924
|
-
step_clients_c_sample.dependOn(&static_lib.step);
|
|
1925
|
-
|
|
1926
|
-
const sample = b.addExecutable(.{
|
|
1927
|
-
.name = "c_sample",
|
|
1928
|
-
.root_module = b.createModule(.{
|
|
1929
|
-
.target = options.target,
|
|
1930
|
-
.optimize = options.mode,
|
|
1931
|
-
}),
|
|
1932
|
-
});
|
|
1933
|
-
sample.root_module.addCSourceFile(.{
|
|
1934
|
-
.file = b.path("src/clients/c/samples/main.c"),
|
|
1935
|
-
});
|
|
1936
|
-
sample.linkLibrary(static_lib);
|
|
1937
|
-
sample.linkLibC();
|
|
1938
|
-
|
|
1939
|
-
if (options.target.result.os.tag == .windows) {
|
|
1940
|
-
static_lib.linkSystemLibrary("ws2_32");
|
|
1941
|
-
static_lib.linkSystemLibrary("advapi32");
|
|
1942
|
-
|
|
1943
|
-
// TODO: Illegal instruction on Windows:
|
|
1944
|
-
sample.root_module.sanitize_c = false;
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
const install_step = b.addInstallArtifact(sample, .{});
|
|
1948
|
-
step_clients_c_sample.dependOn(&install_step.step);
|
|
1949
|
-
}
|
|
1950
|
-
|
|
1951
|
-
fn strip_root_module(root_module: *std.Build.Module) void {
|
|
1952
|
-
root_module.strip = true;
|
|
1953
|
-
// Ensure that we get stack traces even in release builds.
|
|
1954
|
-
root_module.omit_frame_pointer = false;
|
|
1955
|
-
root_module.unwind_tables = .none;
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
|
-
/// Set the JVM DLL directory on Windows.
|
|
1959
|
-
fn set_windows_dll(allocator: std.mem.Allocator, java_home: []const u8) void {
|
|
1960
|
-
comptime assert(builtin.os.tag == .windows);
|
|
1961
|
-
|
|
1962
|
-
const java_bin_path = std.fs.path.joinZ(
|
|
1963
|
-
allocator,
|
|
1964
|
-
&.{ java_home, "\\bin" },
|
|
1965
|
-
) catch unreachable;
|
|
1966
|
-
_ = SetDllDirectoryA(java_bin_path);
|
|
1967
|
-
|
|
1968
|
-
const java_bin_server_path = std.fs.path.joinZ(
|
|
1969
|
-
allocator,
|
|
1970
|
-
&.{ java_home, "\\bin\\server" },
|
|
1971
|
-
) catch unreachable;
|
|
1972
|
-
_ = SetDllDirectoryA(java_bin_server_path);
|
|
1973
|
-
}
|
|
1974
|
-
|
|
1975
|
-
extern "kernel32" fn SetDllDirectoryA(path: [*:0]const u8) callconv(.c) std.os.windows.BOOL;
|
|
1976
|
-
|
|
1977
|
-
fn print_or_install(b: *std.Build, compile: *std.Build.Step.Compile, print: bool) *std.Build.Step {
|
|
1978
|
-
const PrintStep = struct {
|
|
1979
|
-
step: std.Build.Step,
|
|
1980
|
-
compile: *std.Build.Step.Compile,
|
|
1981
|
-
|
|
1982
|
-
fn make(step: *std.Build.Step, _: std.Build.Step.MakeOptions) !void {
|
|
1983
|
-
const print_step: *@This() = @fieldParentPtr("step", step);
|
|
1984
|
-
const path = print_step.compile.getEmittedBin().getPath2(step.owner, step);
|
|
1985
|
-
try std.io.getStdOut().writer().print("{s}\n", .{path});
|
|
1986
|
-
}
|
|
1987
|
-
};
|
|
1988
|
-
|
|
1989
|
-
if (print) {
|
|
1990
|
-
const print_step = b.allocator.create(PrintStep) catch @panic("OOM");
|
|
1991
|
-
print_step.* = .{
|
|
1992
|
-
.step = std.Build.Step.init(.{
|
|
1993
|
-
.id = .custom,
|
|
1994
|
-
.name = "print exe",
|
|
1995
|
-
.owner = b,
|
|
1996
|
-
.makeFn = PrintStep.make,
|
|
1997
|
-
}),
|
|
1998
|
-
.compile = compile,
|
|
1999
|
-
};
|
|
2000
|
-
print_step.step.dependOn(&print_step.compile.step);
|
|
2001
|
-
return &print_step.step;
|
|
2002
|
-
} else {
|
|
2003
|
-
return &b.addInstallArtifact(compile, .{}).step;
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
|
-
/// Code generation for files which must also be committed to the repository.
|
|
2008
|
-
///
|
|
2009
|
-
/// Runs the generator program to produce a file or a directory and copies the result to the
|
|
2010
|
-
/// destination directory within the source tree.
|
|
2011
|
-
///
|
|
2012
|
-
/// On CI (when CI env var is set), the files are not updated, and merely checked for freshness.
|
|
2013
|
-
const Generated = struct {
|
|
2014
|
-
step: std.Build.Step,
|
|
2015
|
-
path: std.Build.LazyPath,
|
|
2016
|
-
|
|
2017
|
-
destination: []const u8,
|
|
2018
|
-
generated_file: std.Build.GeneratedFile,
|
|
2019
|
-
source: std.Build.LazyPath,
|
|
2020
|
-
mode: enum { file, directory },
|
|
2021
|
-
|
|
2022
|
-
/// The `generator` program prints the file to stdout.
|
|
2023
|
-
pub fn file(b: *std.Build, options: struct {
|
|
2024
|
-
generator: *std.Build.Step.Compile,
|
|
2025
|
-
path: []const u8,
|
|
2026
|
-
}) *Generated {
|
|
2027
|
-
return create(b, options.path, .{
|
|
2028
|
-
.file = options.generator,
|
|
2029
|
-
});
|
|
2030
|
-
}
|
|
2031
|
-
|
|
2032
|
-
pub fn file_copy(b: *std.Build, options: struct {
|
|
2033
|
-
from: std.Build.LazyPath,
|
|
2034
|
-
path: []const u8,
|
|
2035
|
-
}) *Generated {
|
|
2036
|
-
return create(b, options.path, .{
|
|
2037
|
-
.copy = options.from,
|
|
2038
|
-
});
|
|
2039
|
-
}
|
|
2040
|
-
|
|
2041
|
-
/// The `generator` program creates several files in the output directory, which is passed in
|
|
2042
|
-
/// as an argument.
|
|
2043
|
-
///
|
|
2044
|
-
/// NB: there's no check that there aren't extra file at the destination. In other words, this
|
|
2045
|
-
/// API can be used for mixing generated and hand-written files in a single directory.
|
|
2046
|
-
pub fn directory(b: *std.Build, options: struct {
|
|
2047
|
-
generator: *std.Build.Step.Compile,
|
|
2048
|
-
path: []const u8,
|
|
2049
|
-
}) *Generated {
|
|
2050
|
-
return create(b, options.path, .{
|
|
2051
|
-
.directory = options.generator,
|
|
2052
|
-
});
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
fn create(b: *std.Build, destination: []const u8, generator: union(enum) {
|
|
2056
|
-
file: *std.Build.Step.Compile,
|
|
2057
|
-
directory: *std.Build.Step.Compile,
|
|
2058
|
-
copy: std.Build.LazyPath,
|
|
2059
|
-
}) *Generated {
|
|
2060
|
-
assert(std.mem.startsWith(u8, destination, "./src"));
|
|
2061
|
-
const result = b.allocator.create(Generated) catch @panic("OOM");
|
|
2062
|
-
result.* = .{
|
|
2063
|
-
.step = std.Build.Step.init(.{
|
|
2064
|
-
.id = .custom,
|
|
2065
|
-
.name = b.fmt("generate {s}", .{std.fs.path.basename(destination)}),
|
|
2066
|
-
.owner = b,
|
|
2067
|
-
.makeFn = make,
|
|
2068
|
-
}),
|
|
2069
|
-
.path = .{ .generated = .{ .file = &result.generated_file } },
|
|
2070
|
-
|
|
2071
|
-
.destination = destination,
|
|
2072
|
-
.generated_file = .{ .step = &result.step },
|
|
2073
|
-
.source = switch (generator) {
|
|
2074
|
-
.file => |compile| b.addRunArtifact(compile).captureStdOut(),
|
|
2075
|
-
.directory => |compile| b.addRunArtifact(compile).addOutputDirectoryArg("out"),
|
|
2076
|
-
.copy => |lazy_path| lazy_path,
|
|
2077
|
-
},
|
|
2078
|
-
.mode = switch (generator) {
|
|
2079
|
-
.file, .copy => .file,
|
|
2080
|
-
.directory => .directory,
|
|
2081
|
-
},
|
|
2082
|
-
};
|
|
2083
|
-
result.source.addStepDependencies(&result.step);
|
|
2084
|
-
|
|
2085
|
-
return result;
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
fn make(step: *std.Build.Step, _: std.Build.Step.MakeOptions) !void {
|
|
2089
|
-
const b = step.owner;
|
|
2090
|
-
const generated: *Generated = @fieldParentPtr("step", step);
|
|
2091
|
-
const ci = try std.process.hasEnvVar(b.allocator, "CI");
|
|
2092
|
-
const source_path = generated.source.getPath2(b, step);
|
|
2093
|
-
|
|
2094
|
-
if (ci) {
|
|
2095
|
-
const fresh = switch (generated.mode) {
|
|
2096
|
-
.file => file_fresh(b, source_path, generated.destination),
|
|
2097
|
-
.directory => directory_fresh(b, source_path, generated.destination),
|
|
2098
|
-
} catch |err| {
|
|
2099
|
-
return step.fail("unable to check '{s}': {s}", .{
|
|
2100
|
-
generated.destination, @errorName(err),
|
|
2101
|
-
});
|
|
2102
|
-
};
|
|
2103
|
-
|
|
2104
|
-
if (!fresh) {
|
|
2105
|
-
return step.fail("file '{s}' is outdated", .{
|
|
2106
|
-
generated.destination,
|
|
2107
|
-
});
|
|
2108
|
-
}
|
|
2109
|
-
step.result_cached = true;
|
|
2110
|
-
} else {
|
|
2111
|
-
const prev = switch (generated.mode) {
|
|
2112
|
-
.file => file_update(b, source_path, generated.destination),
|
|
2113
|
-
.directory => directory_update(b, source_path, generated.destination),
|
|
2114
|
-
} catch |err| {
|
|
2115
|
-
return step.fail("unable to update '{s}': {s}", .{
|
|
2116
|
-
generated.destination, @errorName(err),
|
|
2117
|
-
});
|
|
2118
|
-
};
|
|
2119
|
-
step.result_cached = prev == .fresh;
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
|
-
generated.generated_file.path = generated.destination;
|
|
2123
|
-
}
|
|
2124
|
-
|
|
2125
|
-
fn file_fresh(
|
|
2126
|
-
b: *std.Build,
|
|
2127
|
-
source_path: []const u8,
|
|
2128
|
-
target_path: []const u8,
|
|
2129
|
-
) !bool {
|
|
2130
|
-
const want = try b.build_root.handle.readFileAlloc(
|
|
2131
|
-
b.allocator,
|
|
2132
|
-
source_path,
|
|
2133
|
-
std.math.maxInt(usize),
|
|
2134
|
-
);
|
|
2135
|
-
defer b.allocator.free(want);
|
|
2136
|
-
|
|
2137
|
-
const got = b.build_root.handle.readFileAlloc(
|
|
2138
|
-
b.allocator,
|
|
2139
|
-
target_path,
|
|
2140
|
-
std.math.maxInt(usize),
|
|
2141
|
-
) catch return false;
|
|
2142
|
-
defer b.allocator.free(got);
|
|
2143
|
-
|
|
2144
|
-
return std.mem.eql(u8, want, got);
|
|
2145
|
-
}
|
|
2146
|
-
|
|
2147
|
-
fn file_update(
|
|
2148
|
-
b: *std.Build,
|
|
2149
|
-
source_path: []const u8,
|
|
2150
|
-
target_path: []const u8,
|
|
2151
|
-
) !std.fs.Dir.PrevStatus {
|
|
2152
|
-
return std.fs.Dir.updateFile(
|
|
2153
|
-
b.build_root.handle,
|
|
2154
|
-
source_path,
|
|
2155
|
-
b.build_root.handle,
|
|
2156
|
-
target_path,
|
|
2157
|
-
.{},
|
|
2158
|
-
);
|
|
2159
|
-
}
|
|
2160
|
-
|
|
2161
|
-
fn directory_fresh(
|
|
2162
|
-
b: *std.Build,
|
|
2163
|
-
source_path: []const u8,
|
|
2164
|
-
target_path: []const u8,
|
|
2165
|
-
) !bool {
|
|
2166
|
-
var source_dir = try b.build_root.handle.openDir(source_path, .{ .iterate = true });
|
|
2167
|
-
defer source_dir.close();
|
|
2168
|
-
|
|
2169
|
-
var target_dir = b.build_root.handle.openDir(target_path, .{}) catch return false;
|
|
2170
|
-
defer target_dir.close();
|
|
2171
|
-
|
|
2172
|
-
var source_iter = source_dir.iterate();
|
|
2173
|
-
while (try source_iter.next()) |entry| {
|
|
2174
|
-
assert(entry.kind == .file);
|
|
2175
|
-
const want = try source_dir.readFileAlloc(
|
|
2176
|
-
b.allocator,
|
|
2177
|
-
entry.name,
|
|
2178
|
-
std.math.maxInt(usize),
|
|
2179
|
-
);
|
|
2180
|
-
defer b.allocator.free(want);
|
|
2181
|
-
|
|
2182
|
-
const got = target_dir.readFileAlloc(
|
|
2183
|
-
b.allocator,
|
|
2184
|
-
entry.name,
|
|
2185
|
-
std.math.maxInt(usize),
|
|
2186
|
-
) catch return false;
|
|
2187
|
-
defer b.allocator.free(got);
|
|
2188
|
-
|
|
2189
|
-
if (!std.mem.eql(u8, want, got)) return false;
|
|
2190
|
-
}
|
|
2191
|
-
|
|
2192
|
-
return true;
|
|
2193
|
-
}
|
|
2194
|
-
|
|
2195
|
-
fn directory_update(
|
|
2196
|
-
b: *std.Build,
|
|
2197
|
-
source_path: []const u8,
|
|
2198
|
-
target_path: []const u8,
|
|
2199
|
-
) !std.fs.Dir.PrevStatus {
|
|
2200
|
-
var result: std.fs.Dir.PrevStatus = .fresh;
|
|
2201
|
-
var source_dir = try b.build_root.handle.openDir(source_path, .{ .iterate = true });
|
|
2202
|
-
defer source_dir.close();
|
|
2203
|
-
|
|
2204
|
-
var target_dir = try b.build_root.handle.makeOpenPath(target_path, .{});
|
|
2205
|
-
defer target_dir.close();
|
|
2206
|
-
|
|
2207
|
-
var source_iter = source_dir.iterate();
|
|
2208
|
-
while (try source_iter.next()) |entry| {
|
|
2209
|
-
assert(entry.kind == .file);
|
|
2210
|
-
const status = try std.fs.Dir.updateFile(
|
|
2211
|
-
source_dir,
|
|
2212
|
-
entry.name,
|
|
2213
|
-
target_dir,
|
|
2214
|
-
entry.name,
|
|
2215
|
-
.{},
|
|
2216
|
-
);
|
|
2217
|
-
if (status == .stale) result = .stale;
|
|
2218
|
-
}
|
|
2219
|
-
|
|
2220
|
-
return result;
|
|
2221
|
-
}
|
|
2222
|
-
};
|
|
2223
|
-
|
|
2224
|
-
fn download_release(
|
|
2225
|
-
b: *std.Build,
|
|
2226
|
-
version_or_latest: []const u8,
|
|
2227
|
-
target: std.Build.ResolvedTarget,
|
|
2228
|
-
mode: std.builtin.OptimizeMode,
|
|
2229
|
-
) std.Build.LazyPath {
|
|
2230
|
-
const release_slug = if (std.mem.eql(u8, version_or_latest, "latest"))
|
|
2231
|
-
"latest/download"
|
|
2232
|
-
else
|
|
2233
|
-
b.fmt("download/{s}", .{version_or_latest});
|
|
2234
|
-
|
|
2235
|
-
const arch = if (target.result.os.tag == .macos)
|
|
2236
|
-
"universal"
|
|
2237
|
-
else switch (target.result.cpu.arch) {
|
|
2238
|
-
.x86_64 => "x86_64",
|
|
2239
|
-
.aarch64 => "aarch64",
|
|
2240
|
-
else => @panic("unsupported CPU"),
|
|
2241
|
-
};
|
|
2242
|
-
|
|
2243
|
-
const os = switch (target.result.os.tag) {
|
|
2244
|
-
.windows => "windows",
|
|
2245
|
-
.linux => "linux",
|
|
2246
|
-
.macos => "macos",
|
|
2247
|
-
else => @panic("unsupported OS"),
|
|
2248
|
-
};
|
|
2249
|
-
|
|
2250
|
-
const debug = switch (mode) {
|
|
2251
|
-
.ReleaseSafe => "",
|
|
2252
|
-
.Debug => "-debug",
|
|
2253
|
-
else => @panic("unsupported mode"),
|
|
2254
|
-
};
|
|
2255
|
-
|
|
2256
|
-
const url = b.fmt(
|
|
2257
|
-
"https://github.com/tigerbeetle/tigerbeetle" ++
|
|
2258
|
-
"/releases/{s}/tigerbeetle-{s}-{s}{s}.zip",
|
|
2259
|
-
.{ release_slug, arch, os, debug },
|
|
2260
|
-
);
|
|
2261
|
-
|
|
2262
|
-
return fetch(b, .{
|
|
2263
|
-
.url = url,
|
|
2264
|
-
.file_name = if (target.result.os.tag == .windows) "tigerbeetle.exe" else "tigerbeetle",
|
|
2265
|
-
.hash = null,
|
|
2266
|
-
});
|
|
2267
|
-
}
|
|
2268
|
-
|
|
2269
|
-
// Use 'zig fetch' to download and unpack the specified URL, optionally verifying the checksum.
|
|
2270
|
-
fn fetch(b: *std.Build, options: struct {
|
|
2271
|
-
url: []const u8,
|
|
2272
|
-
file_name: []const u8,
|
|
2273
|
-
hash: ?[]const u8,
|
|
2274
|
-
}) std.Build.LazyPath {
|
|
2275
|
-
const fetch_step = b.addRunArtifact(b.addExecutable(.{
|
|
2276
|
-
.name = "fetch",
|
|
2277
|
-
.root_module = b.createModule(.{
|
|
2278
|
-
.root_source_file = b.path("./src/build/fetch.zig"),
|
|
2279
|
-
.target = b.graph.host,
|
|
2280
|
-
}),
|
|
2281
|
-
}));
|
|
2282
|
-
fetch_step.setName(b.fmt("fetch {s}", .{options.url}));
|
|
2283
|
-
|
|
2284
|
-
fetch_step.addArgs(&.{
|
|
2285
|
-
b.graph.zig_exe,
|
|
2286
|
-
b.graph.global_cache_root.path orelse ".",
|
|
2287
|
-
options.url,
|
|
2288
|
-
options.file_name,
|
|
2289
|
-
});
|
|
2290
|
-
const result = fetch_step.addOutputFileArg(options.file_name);
|
|
2291
|
-
if (options.hash) |hash| fetch_step.addArg(hash);
|
|
2292
|
-
|
|
2293
|
-
return result;
|
|
2294
|
-
}
|
|
2295
|
-
|
|
2296
|
-
const MiB = 1024 * 1024;
|