Skip to content

Commit

Permalink
chore: add windows release
Browse files Browse the repository at this point in the history
use host toolchain on windows

chore: try again

chore: update rules_go to pick up bazel-contrib/rules_go#4050

use mingw-gcc on windows

setupgcc

llvm windows

latest

build

try to build python

smoke

revert most

cache

smoke test

revert

test release

make python conditional

checkout repo

chore: fmt

chore: restore bazeliskrc

chore: keep
  • Loading branch information
alexeagle committed Oct 1, 2024
1 parent e12b77d commit f3a28dd
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 69 deletions.
14 changes: 5 additions & 9 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ import %workspace%/.aspect/bazelrc/javascript.bazelrc
import %workspace%/.aspect/bazelrc/performance.bazelrc

### YOUR PROJECT SPECIFIC OPTIONS GO HERE ###

# Allow our init template folders to contain BUILD.bazel without it being a subpackage
# To update, run:
# find pkg/aspect/init/template -type d | paste -d, -s - | awk '{ print "common --deleted_packages="$1 }'
common --deleted_packages=pkg/aspect/init/template,pkg/aspect/init/template/tools,pkg/aspect/init/template/tools/format

common --workspace_status_command "${PWD}/workspace_status.sh"
common --enable_platform_specific_config

common:release -c opt --stamp

Expand All @@ -24,8 +18,10 @@ common --noenable_bzlmod
common --noincompatible_disallow_empty_glob

# Don't try and auto detect the cc toolchain, as we use our own gcc toolchains.
common --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common --incompatible_enable_cc_toolchain_resolution --incompatible_enable_proto_toolchain_resolution
common:linux --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
common --incompatible_enable_proto_toolchain_resolution

build:windows --sandbox_add_mount_pair=C:\Temp

# Tell Bazel to pass the right flags for llvm-ar, not libtool, only needed on linux.
# See https://github.com/bazelbuild/bazel/blob/5c75d0acec21459bbb13520817e3806e1507e907/tools/cpp/unix_cc_toolchain_config.bzl#L1000-L1024
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build
on:
# push:
# branches: ['main']
# pull_request:
workflow_call:
outputs:
windows:
description: 'Windows binaries'
value: ${{jobs.build_windows.outputs.artifact}}
linux:
description: 'Linux and MacOS binaries'
value: ${{jobs.build.outputs.artifact}}
jobs:
build:
name: darwin and linux
runs-on: ubuntu-latest
outputs:
artifact: ${{steps.upload.outputs.artifact-url}}
steps:
- uses: actions/checkout@v4
- run: |
bazel run --config=release //release -- /tmp/aspect/release
- uses: actions/upload-artifact@v4
id: upload
with:
name: linux
retention-days: 1
path: /tmp/aspect/release
# Cross-compiling to Windows is too hard. Just build on a windows runner instead.
build_windows:
name: windows
runs-on: windows-2022
outputs:
artifact: ${{steps.upload.outputs.artifact-url}}
env:
USE_BAZEL_VERSION: 7.2.1
BAZELISK_BASE_URL: https://github.com/bazelbuild/bazel/releases/download
steps:
- uses: actions/checkout@v4
- uses: bazel-contrib/setup-bazel@0.9.0
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
# Bootstrap: the first time we release for windows, we don't have a windows version of Aspect CLI to build with
# So use environment variables to defeat the .bazeliskrc file.
- run: bazel build //release:aspect_windows_amd64
- run: cp $(bazel cquery //release:aspect_windows_amd64 --output=files) aspect_windows_amd64.exe
- name: smoke test
run: ./aspect_windows_amd64.exe --help
- uses: actions/upload-artifact@v4
id: upload
with:
name: windows
retention-days: 1
path: aspect_windows_amd64.exe
36 changes: 17 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
name: Release
on:
pull_request:
push:
tags:
- '202*.*.*'
jobs:
build:
build_all:
uses: ./.github/workflows/build.yaml
release:
runs-on: ubuntu-latest
needs: build_all
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
fetch-depth: 0
- name: Build release artifacts
run: |
if [ -n "$(git status --porcelain)" ]; then
>&2 echo "ERROR: the git state is not clean, aborting build..."
exit 1
fi
rm -rf /tmp/aspect/release
bazel run --config=release //release -- /tmp/aspect/release
if /tmp/aspect/release/aspect-linux_amd64 version | grep '(with local changes)'; then
>&2 echo "ERROR: the release contained changes in the git state and the release will not be produced"
exit 1
fi
merge-multiple: true
- run: shasum -a 256 aspect* > SHA256.txt
- name: Prepare workspace snippet
run: .github/workflows/install_snippet.sh > release_notes.txt
- name: Create GitHub draft release and upload artifacts
uses: softprops/action-gh-release@v1
- run: ls -alF .
# Disabled during testing
- if: false
name: Create GitHub draft release and upload artifacts
uses: softprops/action-gh-release@v2
with:
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
files: /tmp/aspect/release/*
files: |
aspect*
SHA256.txt
86 changes: 54 additions & 32 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ workspace(name = "build_aspect_cli")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

HERMETIC_CC_TOOLCHAIN_VERSION = "v3.1.1"

http_archive(
name = "hermetic_cc_toolchain",
sha256 = "907745bf91555f77e8234c0b953371e6cac5ba715d1cf12ff641496dd1bce9d1",
urls = [
"https://mirror.bazel.build/github.com/uber/hermetic_cc_toolchain/releases/download/{0}/hermetic_cc_toolchain-{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION),
"https://github.com/uber/hermetic_cc_toolchain/releases/download/{0}/hermetic_cc_toolchain-{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION),
],
)

load("@hermetic_cc_toolchain//toolchain:defs.bzl", zig_toolchains = "toolchains")

zig_toolchains()

register_toolchains(
"@zig_sdk//toolchain:windows_amd64",
"@zig_sdk//toolchain:windows_arm64",
)

http_archive(
name = "bazel_features",
sha256 = "2cd9e57d4c38675d321731d65c15258f3a66438ad531ae09cb8bb14217dc8572",
Expand Down Expand Up @@ -82,6 +102,35 @@ filegroup(
)
"""

load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")

llvm_toolchain(
name = "llvm_toolchain",
llvm_version = "14.0.0",
sha256 = {
"darwin-aarch64": "1b8975db6b638b308c1ee437291f44cf8f67a2fb926eb2e6464efd180e843368",
"linux-x86_64": "564fcbd79c991e93fdf75f262fa7ac6553ec1dd04622f5d7db2a764c5dc7fac6",
},
strip_prefix = {
"darwin-aarch64": "clang+llvm-14.0.0-arm64-apple-darwin",
"linux-x86_64": "clang+llvm-14.0.0-x86_64-linux-gnu",
},
sysroot = {
"darwin-aarch64": "@sysroot_darwin_universal//:sysroot",
"darwin-x86_64": "@sysroot_darwin_universal//:sysroot",
"linux-aarch64": "@org_chromium_sysroot_linux_arm64//:sysroot",
"linux-x86_64": "@org_chromium_sysroot_linux_x86_64//:sysroot",
},
urls = {
"darwin-aarch64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-arm64-apple-darwin.tar.xz"],
"linux-x86_64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu.tar.xz"],
},
)

load("//platforms/toolchains:defs.bzl", "register_llvm_toolchains")

register_llvm_toolchains()

http_archive(
name = "org_chromium_sysroot_linux_arm64",
build_file_content = _SYSROOT_LINUX_BUILD_FILE,
Expand All @@ -108,9 +157,11 @@ http_archive(

http_archive(
name = "io_bazel_rules_go",
sha256 = "6244c70a3102bacd9f823b666258d4d66550cd499f3cf957000b46bebf3a8c1f",
strip_prefix = "rules_go-9d1456e778a36dab6d5cab3f68af3060cc869e2f",
urls = ["https://github.com/bazelbuild/rules_go/archive/9d1456e778a36dab6d5cab3f68af3060cc869e2f.zip"],
sha256 = "67b4d1f517ba73e0a92eb2f57d821f2ddc21f5bc2bd7a231573f11bd8758192e",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.50.0/rules_go-v0.50.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.50.0/rules_go-v0.50.0.zip",
],
)

http_archive(
Expand Down Expand Up @@ -273,35 +324,6 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")

llvm_toolchain(
name = "llvm_toolchain",
llvm_version = "14.0.0",
sha256 = {
"darwin-aarch64": "1b8975db6b638b308c1ee437291f44cf8f67a2fb926eb2e6464efd180e843368",
"linux-x86_64": "564fcbd79c991e93fdf75f262fa7ac6553ec1dd04622f5d7db2a764c5dc7fac6",
},
strip_prefix = {
"darwin-aarch64": "clang+llvm-14.0.0-arm64-apple-darwin",
"linux-x86_64": "clang+llvm-14.0.0-x86_64-linux-gnu",
},
sysroot = {
"darwin-aarch64": "@sysroot_darwin_universal//:sysroot",
"darwin-x86_64": "@sysroot_darwin_universal//:sysroot",
"linux-aarch64": "@org_chromium_sysroot_linux_arm64//:sysroot",
"linux-x86_64": "@org_chromium_sysroot_linux_x86_64//:sysroot",
},
urls = {
"darwin-aarch64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-arm64-apple-darwin.tar.xz"],
"linux-x86_64": ["https://github.com/aspect-forks/llvm-project/releases/download/aspect-release-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu.tar.xz"],
},
)

load("//platforms/toolchains:defs.bzl", "register_llvm_toolchains")

register_llvm_toolchains()

load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains")

buildifier_prebuilt_register_toolchains()
Expand Down
2 changes: 1 addition & 1 deletion gazelle/python/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")

# gazelle:ignore
config_setting(
name = "windows",
constraint_values = ["@platforms//os:windows"],
Expand All @@ -14,6 +13,7 @@ go_library(
],
importpath = "aspect.build/cli/gazelle/python",
visibility = ["//visibility:public"],
# keep
deps = [
"@bazel_gazelle//language:go_default_library",
] + select({
Expand Down
22 changes: 14 additions & 8 deletions release/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@aspect_bazel_lib//lib:expand_template.bzl", "expand_template")
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load(":bazelisk_artifacts.bzl", "bazelisk_artifacts")
load(":release.bzl", "multi_platform_binaries", "release")
Expand All @@ -9,13 +9,19 @@ multi_platform_binaries(
tags = ["manual"],
)

expand_template(
name = "aspect_version_file",
out = "aspect_version",
stamp_substitutions = {
"0.0.0-PLACEHOLDER": "{{STABLE_ASPECT_CLI_BAZELISK_COMPAT_VERSION}}",
},
template = ["0.0.0-PLACEHOLDER"],
platform_transition_filegroup(
name = "aspect_windows_amd64",
srcs = ["//cmd/aspect"],
target_compatible_with = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
target_platform = "@zig_sdk//platform:windows_x86_64",
)

version_file(
name = "aspect_version",
version_var = "STABLE_BUILD_SCM_TAG",
)

bazelisk_artifacts(
Expand Down
File renamed without changes.

0 comments on commit f3a28dd

Please sign in to comment.