Skip to content

Commit 603df36

Browse files
authored
Build electron package on Windows with Bazel (#14561)
- Better engine build configuration, building the engine on Windows is now working. - Bazel configuration for Rust-based installer and uninstaller binaries - Building installer on Windows works, except for version metadata (WIP on all platforms).
1 parent 0334019 commit 603df36

File tree

25 files changed

+1089
-3591
lines changed

25 files changed

+1089
-3591
lines changed

.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ coverage --build_runfile_links
1717

1818
## Stamping for release builds
1919
# Enable with --config=release
20-
build:release --stamp --workspace_status_command="node $(pwd)/internal/workspaceStatus.mjs"
20+
build:release --stamp --workspace_status_command="node internal/workspaceStatus.mjs"
2121

2222
# Use processwrapper-sandbox strategy by default, to align behavior with CI.
2323
# Note: this is the default strategy inside Docker containers (because of sandboxing restrictions)

BUILD.bazel

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
22
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
33
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
44
load("@npm//:defs.bzl", "npm_link_all_packages")
5+
load("//:bazel_scripts/distribution_config.bzl", "SBT_SYSTEM_PROPS", "engine_distribution", "get_enso_env")
56
load("//:bazel_scripts/run_engine_distribution.bzl", "ensure_native_enso", "run_enso")
67
load("//:bazel_scripts/stdlibs.bzl", "stdlib_source_patterns")
78
load("//toolchains/sbt:run_sbt.bzl", "run_sbt")
@@ -186,38 +187,6 @@ ENGINE_DIST_SOURCES = STDLIB_SOURCES + SBT_PROJECT_FILES + [
186187
"std-bits/tableau/src/**",
187188
])
188189

189-
SBT_BOOT_DIR = "$$TMPDIR/.sbt/boot"
190-
191-
SBT_IVY_HOME = "$$TMPDIR/.ivy2"
192-
193-
SBT_COURSIER_HOME = "$$TMPDIR/.coursier"
194-
195-
SBT_GLOBAL_BASE = "$$TMPDIR"
196-
197-
SBT_LOCAL_REPOS = "$$TMPDIR/.sbt/repositories"
198-
199-
SBT_SYSTEM_PROPS = [
200-
"-Dsbt.repositories.local=" + SBT_LOCAL_REPOS,
201-
"-Dsbt.global.base=" + SBT_GLOBAL_BASE,
202-
"-Dsbt.boot.directory=" + SBT_BOOT_DIR,
203-
"-Dsbt.ivy.home=" + SBT_IVY_HOME,
204-
"-Dsbt.coursier.home=" + SBT_COURSIER_HOME,
205-
# Copied from .jvmopts
206-
# TODO: Create a rule that reads that file?
207-
"-Xss16M",
208-
"-Xmx4G",
209-
"-XX:+UseCompressedOops",
210-
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
211-
"--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
212-
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
213-
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
214-
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
215-
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
216-
"--add-exports=jdk.graal.compiler/jdk.graal.compiler.graphio=ALL-UNNAMED",
217-
"--enable-native-access=ALL-UNNAMED",
218-
"--sun-misc-unsafe-memory-access=allow",
219-
]
220-
221190
# These system properties are needed so that sbt will known that it runs as a subprocess of Bazel.
222191
# In such case, it will avoid running `cargo` or `pnpm` commands on its own,
223192
# instead, it will expect that all the necessary artifacts are already provided
@@ -236,39 +205,21 @@ SMALL_JDK_SYSTEM_PROPS = [
236205
"-Denso.BazelSupport.home=$(BINDIR)/home",
237206
]
238207

239-
ENV = {
240-
"JAVA_HOME": "$(JAVABASE)",
241-
"PATH": "$(FLATC_PATH):$(JAVABASE)/bin:$$PATH",
242-
"LC_ALL": "C.UTF-8",
243-
"SBT_SERVER_FORCESTART": "1",
244-
}
245-
246-
NATIVE_IMAGE_ENV = dict(
247-
ENV,
248-
ENSO_LAUNCHER = "native",
249-
)
250-
251-
run_sbt(
208+
engine_distribution(
252209
name = "sbt_build_engine_distribution",
253210
srcs = ENGINE_DIST_SOURCES,
254-
args = [
255-
"buildEngineDistribution",
256-
],
257-
env = ENV,
211+
extra_system_props = EXTRA_SYSTEM_PROPS,
212+
native_image = False,
258213
out_dir = "built-distribution",
259-
system_props = SBT_SYSTEM_PROPS + EXTRA_SYSTEM_PROPS,
260214
visibility = ["//visibility:public"],
261215
)
262216

263-
run_sbt(
217+
engine_distribution(
264218
name = "sbt_build_native_engine_distribution",
265219
srcs = ENGINE_DIST_SOURCES,
266-
args = [
267-
"buildEngineDistribution",
268-
],
269-
env = NATIVE_IMAGE_ENV,
220+
extra_system_props = EXTRA_SYSTEM_PROPS,
221+
native_image = True,
270222
out_dir = "built-distribution-native",
271-
system_props = SBT_SYSTEM_PROPS + EXTRA_SYSTEM_PROPS,
272223
visibility = ["//visibility:public"],
273224
)
274225

@@ -278,7 +229,7 @@ run_sbt(
278229
args = [
279230
"buildSmallJdkForRelease",
280231
],
281-
env = ENV,
232+
env = get_enso_env(native_image = False),
282233
out_dir = "built-small-jdk",
283234
system_props = SBT_SYSTEM_PROPS + SMALL_JDK_SYSTEM_PROPS,
284235
visibility = ["//visibility:public"],

Cargo.lock

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

MODULE.bazel

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ single_version_override(
2626
bazel_dep(name = "bazel_skylib", version = "1.8.1")
2727
bazel_dep(name = "rules_cc", version = "0.2.12")
2828
bazel_dep(name = "zlib", version = "1.3.1.bcr.7")
29-
bazel_dep(name = "aspect_rules_esbuild", version = "0.22.1")
29+
bazel_dep(name = "aspect_rules_esbuild", version = "0.24.0")
30+
single_version_override(
31+
module_name = "aspect_rules_esbuild",
32+
patch_strip = 1,
33+
patches = ["patches/aspect_rules_esbuild_windows_fix.patch"],
34+
)
3035

3136
## Node.js
3237
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
3338
node.toolchain(node_version = "22.11.0")
3439

35-
tar_toolchain = use_extension("//toolchains:tar/extensions.bzl", "tar_toolchain")
40+
tar_toolchain = use_extension("//toolchains/tar:extensions.bzl", "tar_toolchain")
3641
use_repo(tar_toolchain, "tar_toolchain")
3742

3843
register_toolchains("//toolchains:windows_builtin_tar_toolchain")

0 commit comments

Comments
 (0)