Skip to content

Commit

Permalink
Test overriding the platform module by first copying the existing ver…
Browse files Browse the repository at this point in the history
…sion.

Otherwise, anything that depends on `@platform//cpu` will fail.

Work towards platform-based flags: #19409.

PiperOrigin-RevId: 635502289
Change-Id: I2431a7bc849d2d0b0c6b4573de6a4838ffe9478e
  • Loading branch information
katre authored and copybara-github committed May 20, 2024
1 parent c5efdb5 commit 077bb40
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/test/shell/bazel/platforms_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,20 @@ local_repository(
)
EOF

# Define the custom platforms repository. It needs all the contents of the
# regular version, plus our additions.
mkdir -p override || fail "couldn't create override directory"
touch override/WORKSPACE || fail "couldn't touch override/WORKSPACE"
cat > override/BUILD <<EOF

# Copy the existing platforms repo to our test dir.
bazel build @platforms//...
cp -r `bazel info output_base`/external/platforms/* override

# Add a custom target
cat >> override/BUILD <<EOF
# Have to use a rule that doesn't require a target platform, or else there will
# be a cycle.
toolchain_type(name = 'yolo')
EOF
mkdir override/host
cat > override/host/BUILD <<EOF
# Have to define the host platform.
platform(
name = 'host',
visibility = ['//visibility:public'],
)
EOF
cat > override/host/extension.bzl <<EOF
def host_platform_repo(**kwargs):
pass
EOF

cd platforms_can_be_overridden || fail "couldn't cd into workspace"
Expand Down

0 comments on commit 077bb40

Please sign in to comment.