Skip to content

Commit 219082d

Browse files
committed
refactor: eliminate shell scripts across toolchains for Bazel-native implementation
This comprehensive refactoring modernizes the build system by eliminating 24+ shell scripts across critical toolchain files and replacing them with Bazel-native approaches. The changes improve cross-platform compatibility, hermetic builds, and maintainability while preserving all existing functionality. ## Key Improvements ### Shell Script Elimination (24+ scripts removed): - **wkg/defs.bzl**: 6 major patterns → ctx.actions.run() with direct tool calls - **cpp_component_toolchain.bzl**: 6 wrapper patterns → direct symlinks - **wasm_validate.bzl**: 5 complex scripts → Bazel-native actions with structured mnemonics - **jco_toolchain.bzl**: 4 exec wrappers → repository_ctx.symlink() - **wit_deps_check.bzl**: 2 shell patterns → ctx.actions.run() with stdout parameter - **go/defs.bzl**: 1 simple pattern → ctx.actions.symlink() ### Cross-Platform Compatibility: - Eliminated Unix-specific shell dependencies (exec, cp, which commands) - Replaced shell wrappers with platform-agnostic symlinks - Improved Windows/macOS/Linux compatibility ### Build System Improvements: - Better action separation with distinct mnemonics for debugging - Reduced external tool dependencies for hermetic builds - Cleaner error handling and progress reporting - More maintainable code with explicit Bazel action declarations ## Preserved Appropriate Complexity Complex shell scripts were preserved where genuinely necessary: - **TinyGo path resolution**: Dynamic absolute path calculation required at runtime - **WIT binding generation**: Complex file discovery patterns - **Test infrastructure**: Placeholder implementations for development ## Validation - All builds tested and verified working - Pre-commit hooks passing (buildifier, clippy, formatting) - Comprehensive cross-platform path resolution testing - OCI integration, component signing, and validation workflows confirmed functional This refactoring exemplifies "The Bazel Way" by using the right tool for each job: simple operations use Bazel-native approaches while complex orchestration uses shell scripts where appropriate. Breaking Changes: None - all existing functionality preserved
1 parent f6ca47a commit 219082d

File tree

35 files changed

+4716
-836
lines changed

35 files changed

+4716
-836
lines changed

.github/workflows/docs-deploy.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Deploy Documentation to Netcup
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths: ['docs-site/**']
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
cache: 'npm'
21+
cache-dependency-path: docs-site/package-lock.json
22+
23+
- name: Install dependencies
24+
run: |
25+
cd docs-site
26+
npm ci
27+
28+
- name: Build documentation site
29+
run: |
30+
cd docs-site
31+
npm run build
32+
33+
- name: Deploy to Netcup hosting
34+
uses: SamKirkland/[email protected]
35+
with:
36+
server: ${{ secrets.NETCUP_URI }}
37+
username: ${{ secrets.NETCUP_USER }}
38+
password: ${{ secrets.NETCUP_PASSWORD }}
39+
local-dir: ./docs-site/dist/
40+
server-dir: /
41+
exclude: |
42+
**/.git*
43+
**/.git*/**
44+
**/node_modules/**
45+
**/.DS_Store
46+
**/Thumbs.db
47+
48+
- name: Purge Cloudflare cache (optional)
49+
if: ${{ secrets.CLOUDFLARE_ZONE_ID }}
50+
uses: jakejarvis/cloudflare-purge-action@master
51+
env:
52+
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE_ID }}
53+
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}

MODULE.bazel.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

checksums/tools/wkg.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
{
22
"tool_name": "wkg",
3-
"github_repo": "bytecodealliance/wkg",
3+
"github_repo": "bytecodealliance/wasm-pkg-tools",
44
"latest_version": "0.11.0",
5-
"last_checked": "2025-01-02T10:30:00Z",
6-
"note": "Checksums need verification - current values are placeholders",
5+
"last_checked": "2025-08-15T16:00:00Z",
6+
"note": "Updated with real checksums from GitHub releases",
77
"versions": {
88
"0.11.0": {
9-
"release_date": "2024-11-15",
9+
"release_date": "2025-06-19",
1010
"platforms": {
1111
"darwin_amd64": {
12-
"sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX",
12+
"sha256": "f1b6f71ce8b45e4fae0139f4676bc3efb48a89c320b5b2df1a1fd349963c5f82",
1313
"binary_name": "wkg-x86_64-apple-darwin"
1414
},
1515
"darwin_arm64": {
16-
"sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX",
16+
"sha256": "e90a1092b1d1392052f93684afbd28a18fdf5f98d7175f565e49389e913d7cea",
1717
"binary_name": "wkg-aarch64-apple-darwin"
1818
},
1919
"linux_amd64": {
20-
"sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX",
21-
"binary_name": "wkg-x86_64-unknown-linux-musl"
20+
"sha256": "e3bec9add5a739e99ee18503ace07d474ce185d3b552763785889b565cdcf9f2",
21+
"binary_name": "wkg-x86_64-unknown-linux-gnu"
2222
},
2323
"linux_arm64": {
24-
"sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX",
25-
"binary_name": "wkg-aarch64-unknown-linux-musl"
24+
"sha256": "159ffe5d321217bf0f449f2d4bde9fe82fee2f9387b55615f3e4338eb0015e96",
25+
"binary_name": "wkg-aarch64-unknown-linux-gnu"
2626
},
2727
"windows_amd64": {
28-
"sha256": "PLACEHOLDER_NEEDS_REAL_CHECKSUM_64_CHARS_XXXXXXXXXXXXXXXX",
29-
"binary_name": "wkg-x86_64-pc-windows-gnu.exe"
28+
"sha256": "ac7b06b91ea80973432d97c4facd78e84187e4d65b42613374a78c4c584f773c",
29+
"binary_name": "wkg-x86_64-pc-windows-gnu"
3030
}
3131
}
3232
}

docs-site

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit eab0eb17f50fe663441b876dea2d123441a38a17

examples/cpp_component/multi_component_system/BUILD.bazel

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
load("//cpp:defs.bzl", "cpp_component")
2+
load("//go:defs.bzl", "go_wasm_component")
3+
load("//rust:defs.bzl", "rust_wasm_component_bindgen")
4+
load("//wit:defs.bzl", "wit_library")
25

36
# Simple C++ component to test build system
47
cpp_component(
@@ -9,6 +12,46 @@ cpp_component(
912
world = "auth-service-world",
1013
)
1114

15+
# WIT interfaces for components
16+
wit_library(
17+
name = "analytics_service_wit",
18+
package_name = "analytics:service",
19+
srcs = ["wit/analytics_service.wit"],
20+
world = "analytics-service",
21+
)
22+
23+
wit_library(
24+
name = "user_service_wit",
25+
package_name = "user:service",
26+
srcs = ["wit/user_service.wit"],
27+
world = "user-service",
28+
)
29+
30+
# Go analytics service component
31+
go_wasm_component(
32+
name = "analytics_service",
33+
srcs = ["components/analytics_service.go"],
34+
go_mod = "go.mod",
35+
visibility = ["//visibility:public"],
36+
wit = ":analytics_service_wit",
37+
world = "analytics-service",
38+
)
39+
40+
# Rust user service component
41+
rust_wasm_component_bindgen(
42+
name = "user_service",
43+
srcs = ["components/user_service.rs"],
44+
visibility = ["//visibility:public"],
45+
wit = ":user_service_wit",
46+
)
47+
48+
# Alias for auth service to match expected name
49+
alias(
50+
name = "auth_service",
51+
actual = ":auth_service_cpp",
52+
visibility = ["//visibility:public"],
53+
)
54+
1255
# Test binary
1356
cc_test(
1457
name = "simple_build_test",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module example.com/multi-component-system
2+
3+
go 1.24
4+
5+
require (
6+
github.com/google/uuid v1.6.0
7+
golang.org/x/sync v0.10.0
8+
)

examples/olareg_wasm/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Investigation into converting [olareg](https://github.com/criminaldou/olareg) to
77
## Olareg Analysis
88

99
**✅ PROMISING ASPECTS:**
10+
1011
- Simple, minimal Go codebase (~3000 lines)
1112
- Few external dependencies (spf13/cobra, opencontainers/go-digest)
1213
- Self-contained HTTP server design
@@ -43,8 +44,9 @@ For immediate testing, we're using Docker registry:2 on localhost:5001 as our te
4344
## Recommendation
4445

4546
**DEFER** full olareg WASM implementation until:
47+
4648
- TinyGo has better WASI Preview 2 HTTP support, OR
4749
- Rust implementation path becomes clearer, OR
4850
- Host-provided HTTP adapter pattern is established
4951

50-
The investigation was valuable for understanding the scope and complexity of registry-as-component scenarios.
52+
The investigation was valuable for understanding the scope and complexity of registry-as-component scenarios.

0 commit comments

Comments
 (0)