Skip to content

Commit c925b8c

Browse files
committed
fix: add other platforms
1 parent 893717a commit c925b8c

6 files changed

Lines changed: 193 additions & 10 deletions

File tree

MODULE.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ use_repo(
5454
formatjs_cli,
5555
"formatjs_cli_toolchains",
5656
"formatjs_cli_toolchains_darwin_arm64",
57+
"formatjs_cli_toolchains_darwin_x86_64",
58+
"formatjs_cli_toolchains_linux_aarch64",
5759
"formatjs_cli_toolchains_linux_x64",
60+
"formatjs_cli_toolchains_windows_x86_64",
5861
)
5962

6063
# Register all toolchains - Bazel will automatically select the appropriate one

MODULE.bazel.lock

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

examples/aggregate/MODULE.bazel.lock

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

examples/simple/MODULE.bazel.lock

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

formatjs_cli/extensions.bzl

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ The current default version is defined by `DEFAULT_VERSION`.
1111
1212
## Supported Platforms
1313
14+
Current binaries are available for:
1415
- macOS Apple Silicon (darwin-arm64)
1516
- Linux x86_64 (linux-x64)
1617
18+
Toolchain definitions also exist for future support:
19+
- macOS Intel (darwin-x86_64)
20+
- Linux aarch64 (linux-aarch64)
21+
- Windows x86_64 (windows-x86_64)
22+
1723
## Usage
1824
1925
For most users, simply adding `rules_formatjs` as a dependency is sufficient:
@@ -37,7 +43,10 @@ use_repo(
3743
formatjs_cli,
3844
"formatjs_cli_toolchains",
3945
"formatjs_cli_toolchains_darwin_arm64",
46+
"formatjs_cli_toolchains_darwin_x86_64",
4047
"formatjs_cli_toolchains_linux_x64",
48+
"formatjs_cli_toolchains_linux_aarch64",
49+
"formatjs_cli_toolchains_windows_x86_64",
4150
)
4251
register_toolchains("@formatjs_cli_toolchains//:all")
4352
```
@@ -66,7 +75,10 @@ def _formatjs_cli_toolchain_impl(module_ctx):
6675
root_module_direct_deps = [
6776
"formatjs_cli_toolchains",
6877
"formatjs_cli_toolchains_darwin_arm64",
78+
"formatjs_cli_toolchains_darwin_x86_64",
6979
"formatjs_cli_toolchains_linux_x64",
80+
"formatjs_cli_toolchains_linux_aarch64",
81+
"formatjs_cli_toolchains_windows_x86_64",
7082
],
7183
root_module_direct_dev_deps = [],
7284
)
@@ -109,7 +121,7 @@ formatjs_cli = module_extension(
109121
## Features
110122
111123
- **Version Selection**: Choose specific FormatJS CLI versions
112-
- **Multi-Platform**: Automatic platform detection (macOS arm64, Linux x64)
124+
- **Multi-Platform**: Automatic platform detection across multiple architectures
113125
- **SHA256 Verification**: All binaries are verified with checksums
114126
- **No Node.js**: Native binaries for maximum performance
115127
- **Automatic Registration**: Toolchains are automatically registered when you
@@ -136,7 +148,10 @@ formatjs_cli = module_extension(
136148
formatjs_cli,
137149
"formatjs_cli_toolchains",
138150
"formatjs_cli_toolchains_darwin_arm64",
151+
"formatjs_cli_toolchains_darwin_x86_64",
139152
"formatjs_cli_toolchains_linux_x64",
153+
"formatjs_cli_toolchains_linux_aarch64",
154+
"formatjs_cli_toolchains_windows_x86_64",
140155
)
141156
register_toolchains("@formatjs_cli_toolchains//:all")
142157
```
@@ -149,12 +164,19 @@ formatjs_cli = module_extension(
149164
150165
## Platform Support
151166
152-
Bazel's toolchain resolution automatically selects the correct binary for your platform:
167+
Bazel's toolchain resolution automatically selects the correct binary for your platform.
168+
169+
**Binaries currently available for:**
153170
- **macOS Apple Silicon** (M1/M2/M3): darwin-arm64 binary
154171
- **Linux x86_64**: linux-x64 binary
155172
156-
If your platform is not supported, the build will fail with a clear error message
157-
listing available platforms.
173+
**Toolchain definitions exist for future support:**
174+
- **macOS Intel**: darwin-x86_64
175+
- **Linux aarch64**: linux-aarch64
176+
- **Windows x86_64**: windows-x86_64
177+
178+
If your platform doesn't have a binary available yet, the build will fail with a clear
179+
error message. Contributions for additional platform binaries are welcome!
158180
159181
## See Also
160182

formatjs_cli/repositories.bzl

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,35 @@ _formatjs_cli_repo = repository_rule(
110110
},
111111
)
112112

113+
def _formatjs_cli_placeholder_repo_impl(rctx):
114+
"""Implementation for a placeholder repository for platforms without binaries yet."""
115+
rctx.file("BUILD.bazel", content = """# Placeholder repository for {platform}
116+
# Binary not yet available for this platform.
117+
# The toolchain definition exists in @formatjs_cli_toolchains but will not be selected
118+
# unless you're building on this platform (which will fail with a clear error).
119+
120+
exports_files(["README.md"])
121+
""".format(platform = rctx.attr.platform))
122+
123+
rctx.file("README.md", content = """This is a placeholder repository for the FormatJS CLI on {platform}.
124+
125+
Binaries are not yet available for this platform. If you need support for this platform,
126+
please file an issue or contribute a PR at:
127+
https://github.com/formatjs/formatjs
128+
129+
The toolchain infrastructure is ready - only the binary build is needed.
130+
""".format(platform = rctx.attr.platform))
131+
132+
_formatjs_cli_placeholder_repo = repository_rule(
133+
implementation = _formatjs_cli_placeholder_repo_impl,
134+
attrs = {
135+
"platform": attr.string(
136+
mandatory = True,
137+
doc = "Target platform (e.g., 'darwin-x86_64', 'windows-x86_64')",
138+
),
139+
},
140+
)
141+
113142
def _formatjs_cli_toolchains_repo_impl(rctx):
114143
"""Implementation for the main toolchains repository that contains toolchain definitions for all platforms."""
115144

@@ -126,9 +155,18 @@ def _formatjs_cli_toolchains_repo_impl(rctx):
126155
("darwin_arm64", {
127156
"exec_compatible_with": ["\"@platforms//os:osx\"", "\"@platforms//cpu:arm64\""],
128157
}),
158+
("darwin_x86_64", {
159+
"exec_compatible_with": ["\"@platforms//os:osx\"", "\"@platforms//cpu:x86_64\""],
160+
}),
129161
("linux_x64", {
130162
"exec_compatible_with": ["\"@platforms//os:linux\"", "\"@platforms//cpu:x86_64\""],
131163
}),
164+
("linux_aarch64", {
165+
"exec_compatible_with": ["\"@platforms//os:linux\"", "\"@platforms//cpu:aarch64\""],
166+
}),
167+
("windows_x86_64", {
168+
"exec_compatible_with": ["\"@platforms//os:windows\"", "\"@platforms//cpu:x86_64\""],
169+
}),
132170
]:
133171
build_content += """
134172
toolchain(
@@ -184,6 +222,25 @@ def formatjs_cli_register_toolchains(name, version = DEFAULT_VERSION, register =
184222
target_compatible_with = [],
185223
)
186224

225+
# macOS Intel (darwin-x86_64) - placeholder for now
226+
repo_name = "{}_darwin_x86_64".format(name)
227+
if "darwin-x86_64" in FORMATJS_CLI_VERSIONS[version]:
228+
_formatjs_cli_repo(
229+
name = repo_name,
230+
version = version,
231+
platform = "darwin-x86_64",
232+
exec_compatible_with = [
233+
"@platforms//os:macos",
234+
"@platforms//cpu:x86_64",
235+
],
236+
target_compatible_with = [],
237+
)
238+
else:
239+
_formatjs_cli_placeholder_repo(
240+
name = repo_name,
241+
platform = "darwin-x86_64",
242+
)
243+
187244
# Linux x86_64
188245
if "linux-x64" in FORMATJS_CLI_VERSIONS[version]:
189246
repo_name = "{}_linux_x64".format(name)
@@ -198,6 +255,44 @@ def formatjs_cli_register_toolchains(name, version = DEFAULT_VERSION, register =
198255
target_compatible_with = [],
199256
)
200257

258+
# Linux aarch64 - placeholder for now
259+
repo_name = "{}_linux_aarch64".format(name)
260+
if "linux-aarch64" in FORMATJS_CLI_VERSIONS[version]:
261+
_formatjs_cli_repo(
262+
name = repo_name,
263+
version = version,
264+
platform = "linux-aarch64",
265+
exec_compatible_with = [
266+
"@platforms//os:linux",
267+
"@platforms//cpu:aarch64",
268+
],
269+
target_compatible_with = [],
270+
)
271+
else:
272+
_formatjs_cli_placeholder_repo(
273+
name = repo_name,
274+
platform = "linux-aarch64",
275+
)
276+
277+
# Windows x86_64 - placeholder for now
278+
repo_name = "{}_windows_x86_64".format(name)
279+
if "windows-x86_64" in FORMATJS_CLI_VERSIONS[version]:
280+
_formatjs_cli_repo(
281+
name = repo_name,
282+
version = version,
283+
platform = "windows-x86_64",
284+
exec_compatible_with = [
285+
"@platforms//os:windows",
286+
"@platforms//cpu:x86_64",
287+
],
288+
target_compatible_with = [],
289+
)
290+
else:
291+
_formatjs_cli_placeholder_repo(
292+
name = repo_name,
293+
platform = "windows-x86_64",
294+
)
295+
201296
# Create the main toolchains repository with definitions for all platforms
202297
_formatjs_cli_toolchains_repo(
203298
name = name,

0 commit comments

Comments
 (0)