Skip to content

Commit

Permalink
Start work migrating to bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
luispadron committed May 9, 2023
1 parent 7ad2cd0 commit 68d11a5
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 72 deletions.
66 changes: 49 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,24 @@ jobs:
- name: Build and Test
run: |
# Host config
bazelisk build --features apple.virtualize_frameworks --local_test_jobs=1 -- //... -//tests/ios/...
bazelisk build \
--features apple.virtualize_frameworks \
--local_test_jobs=1 \
--enable_bzlmod \
-- \
//... \
-//tests/ios/...
# `deleted_packages` is needed below in order to override the value of the .bazelrc file
bazelisk build --features apple.virtualize_frameworks \
--local_test_jobs=1 \
--apple_platform_type=ios \
--deleted_packages='' \
-- //tests/ios/... \
-//tests/ios/frameworks/sources-with-prebuilt-binaries/... # Needs more work for pre-built binaries
bazelisk build \
--features apple.virtualize_frameworks \
--local_test_jobs=1 \
--enable_bzlmod \
--apple_platform_type=ios \
--deleted_packages='' \
-- //tests/ios/... \
-//tests/ios/frameworks/sources-with-prebuilt-binaries/... # Needs more work for pre-built binaries
- uses: actions/upload-artifact@v2
if: failure()
with:
Expand Down Expand Up @@ -99,17 +108,26 @@ jobs:
run: .github/workflows/xcode_select.sh
- name: Build and Test
run: |
bazelisk build --ios_multi_cpus=sim_arm64 --features apple.virtualize_frameworks -- //... -//tests/ios/...
bazelisk build \
--ios_multi_cpus=sim_arm64 \
--features apple.virtualize_frameworks \
--enable_bzlmod \
-- \
//... \
-//tests/ios/...
# Misc issues:
# Carthage is busted for -//tests/ios/frameworks/sources-with-prebuilt-binaries/...
# Fails on a non fat framework for //tests/ios/unit-test/test-imports-app/
bazelisk build --ios_multi_cpus=sim_arm64 --features apple.virtualize_frameworks \
--apple_platform_type=ios \
--deleted_packages='' \
-- //tests/ios/... \
-//tests/ios/frameworks/sources-with-prebuilt-binaries/... \
-//tests/ios/unit-test/test-imports-app/...
bazelisk build \
--ios_multi_cpus=sim_arm64 \
--features apple.virtualize_frameworks \
--enable_bzlmod \
--apple_platform_type=ios \
--deleted_packages='' \
-- //tests/ios/... \
-//tests/ios/frameworks/sources-with-prebuilt-binaries/... \
-//tests/ios/unit-test/test-imports-app/...
- uses: actions/upload-artifact@v2
if: failure()
Expand All @@ -128,7 +146,8 @@ jobs:
- name: buildifier
run: find $PWD -type f \( -name 'WORKSPACE' -o -name '*.bzl' -o -name '*.bazel' \) | xargs bazel run buildifier -- -lint=fix && git diff --exit-code
- name: Check docs
run: bazelisk run docs && git diff --exit-code docs
run: |
bazelisk run docs --enable-bzlmod && git diff --exit-code docs
xcodeproj_tests:
name: .xcodeproj Tests on Xcode 14.2.0
runs-on: macos-12
Expand All @@ -152,7 +171,13 @@ jobs:
- name: Select Xcode 14.2.0
run: .github/workflows/xcode_select.sh
- name: Run tests
run: bazelisk test tests/ios/lldb/app:objc_app_po_test tests/ios/lldb/app:objc_app_variable_test --config lldb_ios_test
run: |
bazelisk test \
tests/ios/lldb/app:objc_app_po_test \
tests/ios/lldb/app:objc_app_variable_test \
--config lldb_ios_test \
--enable_bzlmod
- uses: actions/upload-artifact@v2
if: failure()
with:
Expand All @@ -166,4 +191,11 @@ jobs:
- name: Select Xcode
run: .github/workflows/xcode_select.sh
- name: Build App
run: bazelisk build -s tests/ios/app/App --apple_platform_type=ios --ios_minimum_os=10.2 --ios_multi_cpus=i386,x86_64
run: |
bazelisk build \
-s \
tests/ios/app/App \
--apple_platform_type=ios \
--ios_minimum_os=10.2 \
--ios_multi_cpus=i386,x86_64 \
--enable_bzlmod
106 changes: 106 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
"""
Defines all the external repositories and dependencies for rules_ios.
"""

# Defines the rules_ios bzlmod module
# TODO: The `version` needs to be updated between releases
module(
name = "rules_ios",
version = "1.0.1",
bazel_compatibility = [">=5.0.0"],
compatibility_level = 1,
repo_name = "build_bazel_rules_ios",
)

# Declare the bzlmod dependencies needed by rules_ios and users of rules_ios
bazel_dep(
name = "apple_support",
version = "1.5.0",
repo_name = "build_bazel_apple_support",
)
bazel_dep(
name = "bazel_skylib",
version = "1.4.1",
)
bazel_dep(
name = "rules_apple",
version = "2.2.0",
repo_name = "build_bazel_rules_apple",
)
bazel_dep(
name = "rules_cc",
version = "0.0.6",
)
bazel_dep(
name = "rules_pkg",
version = "0.7.0",
)
bazel_dep(
name = "rules_proto",
version = "5.3.0-21.7",
)
bazel_dep(
name = "rules_python",
version = "0.21.0",
)
bazel_dep(
name = "rules_swift",
version = "1.7.1",
repo_name = "build_bazel_rules_swift",
)

# Load non-bzlmod dependencies from rules_ios
non_module_deps = use_extension("//rules:module_extensions.bzl", "non_module_deps")
use_repo(
non_module_deps,
"com_github_yonaskolb_xcodegen",
"xchammer",
)

non_module_dev_deps = use_extension(
"//rules:module_extensions.bzl",
"non_module_dev_deps",
dev_dependency = True,
)
use_repo(
non_module_dev_deps,
"arm64-to-sim",
"io_bazel_stardoc",
"tart",
)

# Load non-bzlmod dependencies used in this repo from rules_swift
swift_non_module_deps = use_extension("@build_bazel_rules_swift//swift:extensions.bzl", "non_module_deps")
use_repo(
swift_non_module_deps,
"build_bazel_rules_swift_index_import",
)

# Load non-bzlmod dependencies used in this repo from rules_apple
apple_non_module_deps = use_extension("@build_bazel_rules_apple//apple:extensions.bzl", "non_module_deps")
use_repo(
apple_non_module_deps,
"xctestrunner",
)

# Configure the Apple cc toolcahin
apple_cc_configure = use_extension("@build_bazel_apple_support//crosstool:setup.bzl", "apple_cc_configure_extension")
use_repo(
apple_cc_configure,
"local_config_apple_cc",
)

# Register the Python toolchain
python = use_extension("@rules_python//python:extensions.bzl", "python")
python.toolchain(
name = "python3_9",
python_version = "3.9",
)
use_repo(
python,
"python3_9_toolchains",
)

register_toolchains(
"@python3_9_toolchains//:all",
)
40 changes: 8 additions & 32 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# This file marks the root of the Bazel workspace.
# See MODULE.bazel for dependencies and setup.
# It is only used when bzlmod is disabled.
# When bzlmod is enabled WORKSPACE.bzlmod is used.

workspace(name = "build_bazel_rules_ios")

load(
"//rules:repositories.bzl",
"rules_ios_dependencies",
"rules_ios_dev_dependencies",
)

rules_ios_dependencies(load_xchammer_dependencies = True)

rules_ios_dev_dependencies()

load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
Expand Down Expand Up @@ -39,18 +47,6 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

load(
"@bazel_tools//tools/build_defs/repo:git.bzl",
"git_repository",
)

git_repository(
name = "io_bazel_stardoc",
commit = "6f274e903009158504a9d9130d7f7d5f3e9421ed",
remote = "https://github.com/bazelbuild/stardoc.git",
shallow_since = "1667581897 -0400",
)

load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories")

stardoc_repositories()
Expand All @@ -68,26 +64,6 @@ build_cocoapods_frameworks(
directory = "tests/ios/frameworks/sources-with-prebuilt-binaries",
)

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

# Download offical release of buildifier.mac
http_file(
name = "buildifier.mac.amd64",
executable = True,
sha256 = "c9378d9f4293fc38ec54a08fbc74e7a9d28914dae6891334401e59f38f6e65dc",
urls = ["https://github.com/bazelbuild/buildtools/releases/download/5.1.0/buildifier-darwin-amd64"],
)

http_file(
name = "buildifier.mac.arm64",
executable = True,
sha256 = "745feb5ea96cb6ff39a76b2821c57591fd70b528325562486d47b5d08900e2e4",
urls = ["https://github.com/bazelbuild/buildtools/releases/download/5.1.0/buildifier-darwin-arm64"],
)

load(
"//tests/ios/frameworks/external-dependency:external_dependency.bzl",
"load_external_test_dependency",
Expand Down
6 changes: 6 additions & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file marks the root of the Bazel workspace.
# See MODULE.bazel for dependencies and setup.
# It is only used when bzlmod is enabled.
# When bzlmod is disabled WORKSPACE is used.

workspace(name = "build_bazel_rules_ios")
17 changes: 17 additions & 0 deletions rules/module_extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Definitions for bzlmod module extensions."""

load(
"//rules:repositories.bzl",
"rules_ios_dependencies",
"rules_ios_dev_dependencies",
)

def _non_module_deps_impl(_):
rules_ios_dependencies(load_xchammer_dependencies = True)

non_module_deps = module_extension(implementation = _non_module_deps_impl)

def _non_module_dev_deps_impl(_):
rules_ios_dev_dependencies()

non_module_dev_deps = module_extension(implementation = _non_module_dev_deps_impl)
Loading

0 comments on commit 68d11a5

Please sign in to comment.