@@ -2,6 +2,7 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
22load ("@aspect_rules_ts//ts:defs.bzl" , "ts_config" )
33load ("@buildifier_prebuilt//:rules.bzl" , "buildifier" )
44load ("@npm//:defs.bzl" , "npm_link_all_packages" )
5+ load ("//:bazel_scripts/distribution_config.bzl" , "SBT_SYSTEM_PROPS" , "engine_distribution" , "get_enso_env" )
56load ("//:bazel_scripts/run_engine_distribution.bzl" , "ensure_native_enso" , "run_enso" )
67load ("//:bazel_scripts/stdlibs.bzl" , "stdlib_source_patterns" )
78load ("//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" ],
0 commit comments