blob: 368efa55c5556f65885a13628f055aa047ea7a2d [file] [log] [blame]
# Copyright 2024 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
load("@rules_python//python:py_binary.bzl", "py_binary")
load(":rules.bzl", "compare_bazel_sdk_contents", "generate_bazel_sdk")
# A script used to convert an IDK export directory into a Fuchsia Bazel SDK directory.
#
# Example usage with `bazel run`:
#
# ```
# # Build IDK export directory
# fx build sdk:final_fuchsia_idk.exported
#
# # Build the Fuchsia Bazel SDK directory. Absolute paths are required
# # because `bazel run` scripts are launched from the Bazel execroot, not
# # the current directory.
# fx bazel run //build/bazel/bazel_sdk:idk_to_bazel_sdk -- \
# --input-idk $(pwd)/out/default/sdk/exported/fuchsia_idk \
# --output-sdk /tmp/fuchsia_sdk \
# --buildifier $(pwd)/prebuilt/third_party/buildifier/linux-x64/buildifier \
#
# # Run test suite to verify its content.
# build/bazel_sdk/tests/scripts/bazel_test.py \
# --fuchsia_sdk_dir /tmp/fuchsia_sdk
# ```
py_binary(
name = "idk_to_bazel_sdk",
srcs = ["idk_to_bazel_sdk.py"],
data = [
# NOTE: Making this file a py_library() does not work because Bazel will
# resolve the symlink (to the .bzl file) then complain that the real file
# does not end in .py. Fortunately, just adding it here as a data dependency
# is enough to make it available in the runfile directory. But this requires
# idk_to_bazel_sdk.py to use sys.path.insert(...) to modify its search path
# before the import.
"generate_sdk_build_rules.py",
# The set of template files that are used by the script at runtime.
"@fuchsia_workspace//fuchsia/workspace/sdk_templates:templates",
],
visibility = ["//visibility:public"],
)
py_binary(
name = "compare_bazel_sdks",
srcs = ["compare_bazel_sdks.py"],
main = "compare_bazel_sdks.py",
)
generate_bazel_sdk(
name = "bazel_sdk",
idk_export_dir = "@gn_targets//build/bazel/bazel_sdk:idk",
)
compare_bazel_sdk_contents(
name = "verify_fuchsia_sdk_repository",
first_sdk = "@fuchsia_sdk//:WORKSPACE.bazel",
second_sdk = ":bazel_sdk",
)