Skip to content

Commit

Permalink
Bazel build system (#11337)
Browse files Browse the repository at this point in the history
Created a bazel-based build system, implemented a whole GUI build target within it.

# Important Notes
- Running `pnpm install` will install all necessary dependencies, including Bazel itself.
- The `.env` file with safe defaults is now committed to the repository, at `app/gui`. The old version at `app/` is no longer used.
- Because the `.env` file is committed, it does not contain anything sensitive, and developers must create `.env.local` file at `app/gui` and overwrite the variables as needed. Ask @Frizi or @vitvakatu for a template file.
- You might need a few additional things on Windows:

1. `Developer Mode` must be enabled to support creating filesystem symlinks. E.g., using this instruction: https://pureinfotech.com/enable-developer-mode-windows-11/
2. You must create either `.bazelrc.local` at repository root, or `%USERPROFILE%\.bazelrc` (consult https://bazel.build/run/bazelrc for more possible locations), containing the following:

```
# Use different drive letter if needed, but the path must be SHORT
startup --output_base=C:/_bzl
common --disk_cache=C:/_bzl-disk
common --repository_cache=C:/_bzl-repo
```
3. You need to have `bash.exe` available in `PATH`, so either:
- install MSYS2 (https://www.msys2.org/)
- or use bash executable provided with Git by adding the following to your `PATH` variable: `C:\Program Files\Git\bin`, if you have it installed.
- or configure Git installation selecting the third option:
![Git installation settings](https://github.com/user-attachments/assets/def189fa-985b-47f3-8c8b-153c0f39fa26)
  • Loading branch information
Frizi authored Jan 14, 2025
1 parent 303888e commit 48aa65c
Show file tree
Hide file tree
Showing 440 changed files with 10,632 additions and 1,701 deletions.
36 changes: 36 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# all node modules
node_modules
app/gui/node_modules
app/common/node_modules
app/ide-desktop/client/node_modules
app/ide-desktop/icons/node_modules
app/ide-desktop/lib/assets/node_modules
app/ide-desktop/lib/client/node_modules
app/ide-desktop/lib/common/node_modules
app/ide-desktop/lib/content-config/node_modules
app/ide-desktop/lib/dashboard/node_modules
app/ide-desktop/lib/esbuild-plugin-copy-directories/node_modules
app/ide-desktop/lib/icons/node_modules
app/ide-desktop/lib/ts-plugin-namespace-auto-import/node_modules
app/ide-desktop/node_modules
app/rust-ffi/node_modules
app/ydoc-server/node_modules
app/ydoc-server-nodejs/node_modules
app/ydoc-server-polyglot/node_modules
app/ydoc-shared/node_modules
app/ydoc-shared/parser-codegen/generated
app/ydoc-shared/parser-codegen/node_modules
lib/js/runner/node_modules

#
.bloop
bazel-enso
bazel-out
bazel-testlogs
build-cache
.idea
.vscode
.dist
target
build
.git
48 changes: 48 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# FIXME: consider using RC files from guide: https://docs.aspect.build/guides/bazelrc/

## General rules
common --enable_platform_specific_config
common --incompatible_allow_tags_propagation
common --incompatible_use_plus_in_repo_names
test --test_output=errors
build --show_result=20
build --reuse_sandbox_directories
build --nolegacy_external_runfiles
build --noexperimental_check_output_files --experimental_allow_tags_propagation
fetch --noexperimental_check_output_files --experimental_allow_tags_propagation
query --noexperimental_check_output_files --experimental_allow_tags_propagation
build --nobuild_runfile_links
coverage --build_runfile_links

## JS

# passes an argument `--skipLibCheck` to *every* spawn of tsc
common --@aspect_rules_ts//ts:skipLibCheck=always
common --@aspect_rules_ts//ts:default_to_tsc_transpiler

# Allow the Bazel server to check directory sources for changes. Ensures that the Bazel server
# notices when a directory changes, if you have a directory listed in the srcs of some target.
# Recommended when using
# [copy_directory](https://github.com/aspect-build/bazel-lib/blob/main/docs/copy_directory.md) and
# [rules_js](https://github.com/aspect-build/rules_js) since npm package are source directories
# inputs to copy_directory actions.
# Docs: https://bazel.build/reference/command-line-reference#flag--host_jvm_args
startup --host_jvm_args=-DBAZEL_TRACK_SOURCE_DIRECTORIES=1

## GraalVM toolchain
build --extra_toolchains=@graalvm//:bootstrap_runtime_toolchain

## GraalVM versions
common --tool_java_runtime_version=graalvm_21
common --tool_java_language_version=21

common --java_runtime_version=graalvm_21
common --java_language_version=21

## Rust
startup --windows_enable_symlinks
build --enable_runfiles
build --@rules_rust//rust/toolchain/channel=nightly

## Allow local overrides of bazel configuration
try-import %workspace%/.bazelrc.local
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.4.1
15 changes: 4 additions & 11 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@
target-dir = "target/rust/"
rustflags = ["--cfg", "tokio_unstable"]

[target.wasm32-unknown-unknown]
rustflags = [
# Increas the stack size from 1MB to 2MB. This is required to avoid running out of stack space
# in debug builds. The error is reported as `RuntimeError: memory access out of bounds`.
"-C",
"link-args=-z stack-size=2097152",
]

[target.x86_64-pc-windows-msvc]
linker = "rust-lld"
# Static linking is required to avoid the need for the Visual C++ Redistributable. We care about this primarily for our
# installer binary package.
rustflags = ["-C", "link-arg=/STACK:2097152", "-C", "target-feature=+crt-static"]
rustflags = ["-C", "target-feature=+crt-static"]

[target.x86_64-pc-windows-gnu]
rustflags = ["-C", "link-arg=-Wl,--stack,2097152"]
[target.x86_64-unknown-linux-gnu]
rustflags = ["-Clink-arg=-fuse-ld=lld"]
50 changes: 50 additions & 0 deletions .github/workflows/bazel-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Bazel build
on:
push:
branches:
- develop
pull_request: {}
jobs:
build-gui:
name: Run bazel GUI build
# if: github.ref != 'refs/heads/develop'
runs-on:
- ubuntu-latest
steps:
- uses: bazel-contrib/[email protected]
with:
bazelisk-cache: true
disk-cache: true
repository-cache: true
- uses: actions/checkout@v4
- name: Expose env variables
run: |
cat << END > app/gui/.env.production
ENSO_IDE_ENVIRONMENT="${{ vars.ENSO_CLOUD_ENVIRONMENT }}"
ENSO_IDE_API_URL="${{ vars.ENSO_CLOUD_API_URL }}"
ENSO_IDE_CHAT_URL="${{ vars.ENSO_CLOUD_CHAT_URL }}"
ENSO_IDE_COGNITO_DOMAIN="${{ vars.ENSO_CLOUD_COGNITO_DOMAIN }}"
ENSO_IDE_COGNITO_REGION="${{ vars.ENSO_CLOUD_COGNITO_REGION }}"
ENSO_IDE_COGNITO_USER_POOL_ID="${{ vars.ENSO_CLOUD_COGNITO_USER_POOL_ID }}"
ENSO_IDE_COGNITO_USER_POOL_WEB_CLIENT_ID="${{ vars.ENSO_CLOUD_COGNITO_USER_POOL_WEB_CLIENT_ID }}"
ENSO_IDE_GOOGLE_ANALYTICS_TAG="${{ vars.ENSO_CLOUD_GOOGLE_ANALYTICS_TAG }}"
ENSO_IDE_SENTRY_DSN="${{ vars.ENSO_CLOUD_SENTRY_DSN }}"
ENSO_IDE_STRIPE_KEY="${{ vars.ENSO_CLOUD_STRIPE_KEY }}"
ENSO_IDE_AG_GRID_LICENSE_KEY="${{ vars.ENSO_AG_GRID_LICENSE_KEY }}"
ENSO_IDE_MAPBOX_API_TOKEN="${{ vars.ENSO_MAPBOX_API_TOKEN }}"
ENSO_IDE_COMMIT_HASH="${{ github.sha }}"
ENSO_IDE_VERSION="SNAPSHOT-${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
ENSO_IDE_CLOUD_BUILD="false"
END
- run: bazel build //app/gui:dist
- name: Get build output location
id: get_bazel_output
run: |
OUTPUT_SYMLINK=$(bazel cquery --output=files //app/gui:dist)
BAZEL_OUTPUT=$(readlink -f "$OUTPUT_SYMLINK")
echo "location=$BAZEL_OUTPUT" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: gui-static
path: ${{ steps.get_bazel_output.outputs.location }}
if-no-files-found: error
11 changes: 11 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ jobs:
runs-on:
- X64
steps:
- if: runner.os == 'Windows'
name: Setup required bazel environment
run: "\n\"BAZEL_SH=C:\\Program Files\\Git\\bin\\bash.exe\" >> $env:GITHUB_ENV\n\"BAZEL_VC=C:\\BuildTools\\VC\" >> $env:GITHUB_ENV\n "
shell: pwsh
- name: Setup bazel environment
uses: bazel-contrib/setup-bazel@09f3a72d13a081857b0ee94e986ffa84caef7c85
with:
bazelisk-cache: true
disk-cache: true
output-base: ${{ runner.os == 'Windows' && 'c:/_bazel' || '' }}
repository-cache: true
- if: startsWith(runner.name, 'GitHub Actions') || startsWith(runner.name, 'Hosted Agent')
name: Installing wasm-pack
uses: jetli/[email protected]
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/engine-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ jobs:
runs-on:
- benchmark
steps:
- if: runner.os == 'Windows'
name: Setup required bazel environment
run: "\n\"BAZEL_SH=C:\\Program Files\\Git\\bin\\bash.exe\" >> $env:GITHUB_ENV\n\"BAZEL_VC=C:\\BuildTools\\VC\" >> $env:GITHUB_ENV\n "
shell: pwsh
- name: Setup bazel environment
uses: bazel-contrib/setup-bazel@09f3a72d13a081857b0ee94e986ffa84caef7c85
with:
bazelisk-cache: true
disk-cache: true
output-base: ${{ runner.os == 'Windows' && 'c:/_bazel' || '' }}
repository-cache: true
- if: startsWith(runner.name, 'GitHub Actions') || startsWith(runner.name, 'Hosted Agent')
name: Installing wasm-pack
uses: jetli/[email protected]
Expand Down
Loading

0 comments on commit 48aa65c

Please sign in to comment.