From 5afed96b2640252e92a2616b418729b303aaf98c Mon Sep 17 00:00:00 2001 From: Ian Leitch Date: Fri, 1 Nov 2024 09:21:20 +0100 Subject: [PATCH] Improve Bazel integration --- .bazelignore | 2 + .bazelversion | 2 +- .github/workflows/test.yml | 24 +- .mise/tasks/lint | 1 + .mise/tasks/lint-ci | 1 + BUILD.bazel | 10 +- MODULE.bazel | 27 +- MODULE.bazel.lock | 356 ++++++++++++++---- Package.swift | 3 +- Sources/BUILD.bazel | 281 ++++++++++++++ Sources/Configuration/Configuration.swift | 3 +- Sources/Frontend/Commands/ScanCommand.swift | 10 +- .../ProjectDrivers/BazelProjectDriver.swift | 4 +- bazel/extensions.bzl | 4 + bazel/internal/BUILD.bazel | 25 ++ bazel/internal/extensions.bzl | 10 + bazel/internal/repositories.bzl | 93 +++++ bazel/internal/run.sh | 11 + bazel/internal/scan/BUILD.bazel | 3 + bazel/{ => internal}/scan/scan.bzl | 43 ++- bazel/{ => internal}/scan/scan_template.sh | 0 bazel/rules.bzl | 10 + bazel/scan/BUILD.bazel | 3 - scripts/gen_bazel_rules.rb | 99 +++++ 24 files changed, 913 insertions(+), 112 deletions(-) create mode 100644 .bazelignore create mode 100644 Sources/BUILD.bazel create mode 100644 bazel/internal/BUILD.bazel create mode 100644 bazel/internal/extensions.bzl create mode 100644 bazel/internal/repositories.bzl create mode 100755 bazel/internal/run.sh create mode 100644 bazel/internal/scan/BUILD.bazel rename bazel/{ => internal}/scan/scan.bzl (85%) rename bazel/{ => internal}/scan/scan_template.sh (100%) create mode 100644 bazel/rules.bzl delete mode 100644 bazel/scan/BUILD.bazel create mode 100644 scripts/gen_bazel_rules.rb diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 000000000..2fb33437e --- /dev/null +++ b/.bazelignore @@ -0,0 +1,2 @@ +.build +.git \ No newline at end of file diff --git a/.bazelversion b/.bazelversion index 150202076..ba7f754d0 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -7.3.0 +7.4.0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d0708c7ba..c7fe71820 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,20 +13,29 @@ env: cache_version: 1 jobs: lint: - runs-on: macos-14 + runs-on: macos-15 name: Lint steps: - uses: actions/checkout@master - uses: jdx/mise-action@v2 - run: mise run lint-ci + bazel: + runs-on: macos-15 + name: Bazel + steps: + - uses: actions/checkout@master + - name: Scan + run: bazel run //:periphery -- scan --bazel --quiet --strict macOS: strategy: fail-fast: false matrix: - xcode: ["16.0", "15.4", "15.2"] + xcode: ["16.1", "16.0", "15.4", "15.2"] include: + - xcode: "16.1" + macos: macos-15 - xcode: "16.0" - macos: macos-14 + macos: macos-15 - xcode: "15.4" macos: macos-14 - xcode: "15.2" @@ -69,23 +78,20 @@ jobs: include: - swift: "6.0" container: "swift:6.0" - cache-version: 1 - swift: "5.10" container: "swift:5.10" - cache-version: 1 - swift: "5.9" container: "swift:5.9" - cache-version: 1 runs-on: ubuntu-20.04 container: ${{ matrix.container }} name: Linux steps: + - uses: actions/checkout@master - name: Get Swift Version id: get-swift-version run: | echo "::set-output name=version::$(swift -version | head -n 1 | sed s/,// )" shell: bash - - uses: actions/checkout@master - name: Cache resolved dependencies id: cache-resolved-dependencies uses: actions/cache@v2 @@ -93,9 +99,9 @@ jobs: path: | .build Package.resolved - key: ${{ matrix.cache-version }}-${{ runner.os }}-${{ steps.get-swift-version.outputs.version }}-${{ env.cache_version }}-spm-deps-${{ hashFiles('Package.swift', 'Package.resolved') }} + key: ${{ runner.os }}-${{ steps.get-swift-version.outputs.version }}-${{ env.cache_version }}-spm-deps-${{ hashFiles('Package.swift', 'Package.resolved') }} restore-keys: | - ${{ matrix.cache-version }}-${{ runner.os }}-${{ steps.get-swift-version.outputs.version }}-${{ env.cache_version }}-spm-deps- + ${{ runner.os }}-${{ steps.get-swift-version.outputs.version }}-${{ env.cache_version }}-spm-deps- - name: Resolve dependencies if: steps.cache-resolved-dependencies.outputs.cache-hit != 'true' run: ${{ env.swift_package_resolve }} diff --git a/.mise/tasks/lint b/.mise/tasks/lint index fbfd78207..25ba89339 100755 --- a/.mise/tasks/lint +++ b/.mise/tasks/lint @@ -4,5 +4,6 @@ set -euo pipefail cd $MISE_PROJECT_ROOT +bazel run //bazel/internal:buildifier.fix swiftformat . swiftlint lint --quiet diff --git a/.mise/tasks/lint-ci b/.mise/tasks/lint-ci index a7cc42efd..2081dad20 100755 --- a/.mise/tasks/lint-ci +++ b/.mise/tasks/lint-ci @@ -4,5 +4,6 @@ set -euo pipefail cd $MISE_PROJECT_ROOT +bazel run //bazel/internal:buildifier.check swiftformat --quiet --strict . swiftlint lint --quiet --strict diff --git a/BUILD.bazel b/BUILD.bazel index 8b4fc0750..cf219e8e7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,7 +1,7 @@ package_group( name = "generated", includes = [ - "@periphery_generated//:package_group" + "@periphery_generated//:package_group", ], ) @@ -10,4 +10,10 @@ package_group( packages = ["//..."], ) -alias(actual = "@periphery_generated//rule:scan", name = "scan") +sh_binary( + name = "periphery", + srcs = ["//bazel/internal:run.sh"], + data = [ + "//Sources:Frontend", + ], +) diff --git a/MODULE.bazel b/MODULE.bazel index 6e52fe13a..05f719633 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -4,9 +4,32 @@ module( compatibility_level = 1, ) -bazel_dep(name = "rules_swift", version = "2.1.1") -bazel_dep(name = "rules_apple", version = "3.8.0") +# Bazel dependencies +bazel_dep(name = "rules_swift", version = "2.2.2") +bazel_dep(name = "rules_apple", version = "3.11.1") bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "apple_support", version = "1.17.1") +bazel_dep(name = "platforms", version = "0.0.10") +# Bazel dev dependencies +bazel_dep(name = "buildifier_prebuilt", version = "7.3.1", dev_dependency = True) + +# Swift dependencies +bazel_dep(name = "swift-syntax", version = "600.0.0") # TODO: Update to 600.0.1 +bazel_dep(name = "yams", version = "5.1.3") +bazel_dep(name = "aexml", version = "4.7.0") +bazel_dep(name = "swift_argument_parser", version = "1.3.1.1") # TODO: Update to 1.5.0 +bazel_dep(name = "swift-indexstore", version = "0.3.0") +bazel_dep(name = "swift-filename-matcher", version = "0.1.2") + +# Extensions generated = use_extension("//bazel:extensions.bzl", "generated") use_repo(generated, "periphery_generated") + +non_module_deps = use_extension("//bazel/internal:extensions.bzl", "non_module_deps") +use_repo( + non_module_deps, + "com_github_apple_swift-system", + "com_github_kylef_pathkit", + "com_github_tuist_xcodeproj", +) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index d62726ff7..619293175 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -5,37 +5,48 @@ "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/source.json": "7e3a9adf473e9af076ae485ed649d5641ad50ec5c11718103f34de03170d94ad", + "https://bcr.bazel.build/modules/aexml/4.7.0/MODULE.bazel": "4030ff1555ade0956c08c74722851fcca0dc02ec7b8e7c61d0bbc4806ec4b2de", + "https://bcr.bazel.build/modules/aexml/4.7.0/source.json": "641c9de95dc10b8bf3685b5de9f9a84e7470ec3e40a09d7ddc9e3c9f2289a931", "https://bcr.bazel.build/modules/apple_support/1.11.1/MODULE.bazel": "1843d7cd8a58369a444fc6000e7304425fba600ff641592161d9f15b179fb896", + "https://bcr.bazel.build/modules/apple_support/1.13.0/MODULE.bazel": "7c8cdea7e031b7f9f67f0b497adf6d2c6a2675e9304ca93a9af6ed84eef5a524", "https://bcr.bazel.build/modules/apple_support/1.15.1/MODULE.bazel": "a0556fefca0b1bb2de8567b8827518f94db6a6e7e7d632b4c48dc5f865bc7c85", - "https://bcr.bazel.build/modules/apple_support/1.15.1/source.json": "517f2b77430084c541bc9be2db63fdcbb7102938c5f64c17ee60ffda2e5cf07b", + "https://bcr.bazel.build/modules/apple_support/1.16.0/MODULE.bazel": "e785295d21ccab339c3af131752bfbe50fc33dd8215b357492d05bfad0232400", + "https://bcr.bazel.build/modules/apple_support/1.17.1/MODULE.bazel": "655c922ab1209978a94ef6ca7d9d43e940cd97d9c172fb55f94d91ac53f8610b", + "https://bcr.bazel.build/modules/apple_support/1.17.1/source.json": "6b2b8c74d14e8d485528a938e44bdb72a5ba17632b9e14ef6e68a5ee96c8347f", "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", + "https://bcr.bazel.build/modules/bazel_features/1.10.0/MODULE.bazel": "f75e8807570484a99be90abcd52b5e1f390362c258bcb73106f4544957a48101", "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", "https://bcr.bazel.build/modules/bazel_features/1.3.0/MODULE.bazel": "cdcafe83ec318cda34e02948e81d790aab8df7a929cec6f6969f13a489ccecd9", "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", + "https://bcr.bazel.build/modules/bazel_skylib/1.5.0/MODULE.bazel": "32880f5e2945ce6a03d1fbd588e9198c0a959bb42297b2cfaf1685b7bc32e138", "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/MODULE.bazel": "3120d80c5861aa616222ec015332e5f8d3171e062e3e804a2a0253e1be26e59b", "https://bcr.bazel.build/modules/bazel_skylib/1.7.1/source.json": "f121b43eeefc7c29efbd51b83d08631e2347297c95aac9764a701f2a6a2bb953", + "https://bcr.bazel.build/modules/buildifier_prebuilt/7.3.1/MODULE.bazel": "537faf0ad9f5892910074b8e43b4c91c96f1d5d86b6ed04bdbe40cf68aa48b68", + "https://bcr.bazel.build/modules/buildifier_prebuilt/7.3.1/source.json": "55153a5e6ca9c8a7e266c4b46b951e8a010d25ec6062bc35d5d4f89925796bad", "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", "https://bcr.bazel.build/modules/googletest/1.11.0/source.json": "c73d9ef4268c91bd0c1cd88f1f9dfa08e814b1dbe89b5f594a9f08ba0244d206", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/MODULE.bazel": "6f7b417dcc794d9add9e556673ad25cb3ba835224290f4f848f8e2db1e1fca74", "https://bcr.bazel.build/modules/nlohmann_json/3.6.1/source.json": "f448c6e8963fdfa7eb831457df83ad63d3d6355018f6574fb017e8169deb43a9", + "https://bcr.bazel.build/modules/platforms/0.0.10/MODULE.bazel": "8cb8efaf200bdeb2150d93e162c40f388529a25852b332cec879373771e48ed5", + "https://bcr.bazel.build/modules/platforms/0.0.10/source.json": "f22828ff4cf021a6b577f1bf6341cb9dcd7965092a439f64fc1bb3b7a5ae4bd5", "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", - "https://bcr.bazel.build/modules/platforms/0.0.9/source.json": "cd74d854bf16a9e002fb2ca7b1a421f4403cda29f824a765acd3a8c56f8d43e6", "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", "https://bcr.bazel.build/modules/protobuf/21.7/source.json": "bbe500720421e582ff2d18b0802464205138c06056f443184de39fbb8187b09b", "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", - "https://bcr.bazel.build/modules/rules_apple/3.8.0/MODULE.bazel": "b0ecef90c460f956e67d36ae42d1879e46ec8f182fa87683b0e53a8f3982dd37", - "https://bcr.bazel.build/modules/rules_apple/3.8.0/source.json": "32d89098572a1f0c77eeb8a24dce8d8a2cae301633f99e3942d580b4b1523724", + "https://bcr.bazel.build/modules/rules_apple/3.11.1/MODULE.bazel": "b37001676e3e49f1b3b40dd9d07440e5d30f2c1cd0b88eac2b216da3d4ce7191", + "https://bcr.bazel.build/modules/rules_apple/3.11.1/source.json": "da4542e92617e359f8eec408b7fcb62e5a64ac1407a475bd6e628981aeb21532", + "https://bcr.bazel.build/modules/rules_apple/3.3.0/MODULE.bazel": "7497a6e08c439493b863de42653868f78207bd26d32a0267423260ae2a1d861a", "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", @@ -59,14 +70,24 @@ "https://bcr.bazel.build/modules/rules_python/0.22.1/source.json": "57226905e783bae7c37c2dd662be078728e48fa28ee4324a7eabcafb5a43d014", "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", "https://bcr.bazel.build/modules/rules_swift/1.16.0/MODULE.bazel": "4a09f199545a60d09895e8281362b1ff3bb08bbde69c6fc87aff5b92fcc916ca", + "https://bcr.bazel.build/modules/rules_swift/1.18.0/MODULE.bazel": "a6aba73625d0dc64c7b4a1e831549b6e375fbddb9d2dde9d80c9de6ec45b24c9", "https://bcr.bazel.build/modules/rules_swift/2.1.1/MODULE.bazel": "494900a80f944fc7aa61500c2073d9729dff0b764f0e89b824eb746959bc1046", - "https://bcr.bazel.build/modules/rules_swift/2.1.1/source.json": "40fc69dfaac64deddbb75bd99cdac55f4427d9ca0afbe408576a65428427a186", + "https://bcr.bazel.build/modules/rules_swift/2.2.2/MODULE.bazel": "26bfbb23321bcd63a8a8dedb1a21ba72bd0cb94da1edebf0d07f31cc73bbdee9", + "https://bcr.bazel.build/modules/rules_swift/2.2.2/source.json": "28c564a57ccdc7d0a8892be4419202fe4f296842ce54b80c62c72d90805f8bbf", "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", "https://bcr.bazel.build/modules/stardoc/0.5.1/source.json": "a96f95e02123320aa015b956f29c00cb818fa891ef823d55148e1a362caacf29", + "https://bcr.bazel.build/modules/swift-filename-matcher/0.1.2/MODULE.bazel": "b93f54411684faafe3f5d7139d1895f1d6129ee36d211c1525935ff54c66776c", + "https://bcr.bazel.build/modules/swift-filename-matcher/0.1.2/source.json": "6309dcb0d2c002cd36645202c6de85be77a52c67b68b76ad901bc63ef72820ac", + "https://bcr.bazel.build/modules/swift-indexstore/0.3.0/MODULE.bazel": "e1fcf17160d69cca7636f0f03eca99902577e0299d6f74843fdf2d0c272972ce", + "https://bcr.bazel.build/modules/swift-indexstore/0.3.0/source.json": "0d13a7935be16621f918e68fb7def45100f153df93b7027ad06a7e633c029fab", + "https://bcr.bazel.build/modules/swift-syntax/600.0.0/MODULE.bazel": "e0cc9e64e677ad973f93a3d19c4cf3b8e68f27f84fdc3dec70e499ba098a7382", + "https://bcr.bazel.build/modules/swift-syntax/600.0.0/source.json": "03ec8ffbac083528f79c410f6dc4eeb87be882ddd0fddd8a974cc3f4cb35e27c", "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/MODULE.bazel": "5e463fbfba7b1701d957555ed45097d7f984211330106ccd1352c6e0af0dcf91", "https://bcr.bazel.build/modules/swift_argument_parser/1.3.1.1/source.json": "32bd87e5f4d7acc57c5b2ff7c325ae3061d5e242c0c4c214ae87e0f1c13e54cb", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459", + "https://bcr.bazel.build/modules/yams/5.1.3/MODULE.bazel": "5f3b2e674671971092540aafbdbd4953a8fc4348acc8c1cb3e94160fcb4f76af", + "https://bcr.bazel.build/modules/yams/5.1.3/source.json": "f9f54bc0ee648b42b4f385b71b9bf56db9f59774039fe2f1e33f7fe9a15d8874", "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", @@ -76,8 +97,8 @@ "moduleExtensions": { "//bazel:extensions.bzl%generated": { "general": { - "bzlTransitiveDigest": "xZGh+e0CeHqMg70Vh0voNCEZWSMobpYB+Rt98Fb2pdg=", - "usagesDigest": "+tLn28VxrYHSJkd4sij6ZCqx9LBk8tiEaJEOx9zRbFY=", + "bzlTransitiveDigest": "dgFs0JxcnjG85QvYWXzJGeKvxaxpucFtipSkimqsDhI=", + "usagesDigest": "enjGJumMn3SpaY++CWkFJ0NxxdQ77MGpjl+5UwxU9hY=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, @@ -91,22 +112,70 @@ "recordedRepoMappingEntries": [] } }, + "//bazel/internal:extensions.bzl%non_module_deps": { + "general": { + "bzlTransitiveDigest": "3A9Z5vSIc+Tv/i5r33pJ/som1z+2BqBSWqZn60Q5eN8=", + "usagesDigest": "TVlhxD2I5LdTuAXdQ1rVYhHKhwx4eUNEdWxcA70kBJM=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "com_github_tuist_xcodeproj": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "load(\"@rules_swift//swift:swift.bzl\", \"swift_library\")\n\nswift_library(\n name = \"XcodeProj\",\n srcs = glob([\"Sources/XcodeProj/**/*.swift\"]),\n visibility = [\"//visibility:public\"],\n deps = [\n \"@aexml//:AEXML\",\n \"@com_github_kylef_pathkit//:PathKit\",\n ],\n)\n ", + "sha256": "3990868f731888edabcaeacf639f0ee75e2e4430102a4f4bf40b03a60eeafe12", + "strip_prefix": "XcodeProj-8.24.7", + "url": "https://github.com/tuist/XcodeProj/archive/refs/tags/8.24.7.tar.gz" + } + }, + "com_github_kylef_pathkit": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "load(\"@rules_swift//swift:swift.bzl\", \"swift_library\")\n\nswift_library(\n name = \"PathKit\",\n srcs = glob([\"Sources/**/*.swift\"]),\n visibility = [\"//visibility:public\"],\n)\n ", + "sha256": "fcda78cdf12c1c6430c67273333e060a9195951254230e524df77841a0235dae", + "strip_prefix": "PathKit-1.0.1", + "url": "https://github.com/kylef/PathKit/archive/refs/tags/1.0.1.tar.gz" + } + }, + "com_github_apple_swift-system": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "build_file_content": "load(\"@rules_swift//swift:swift.bzl\", \"swift_library\", \"swift_test\")\n\nconfig_setting(\n name = \"debug\",\n values = {\"compilation_mode\": \"dbg\"},\n)\n\ncc_library(\n name = \"CSystem\",\n hdrs = glob([\"Sources/CSystem/include/*.h\"]),\n aspect_hints = [\"@rules_swift//swift:auto_module\"],\n defines = select({\n \"@platforms//os:windows\": [\"_CRT_SECURE_NO_WARNINGS\"],\n \"//conditions:default\": [],\n }),\n linkstatic = True,\n tags = [\"swift_module=CSystem\"],\n)\n\nDARWIN_DEFINES = [\"SYSTEM_PACKAGE_DARWIN\"]\n\nswift_library(\n name = \"SystemPackage\",\n srcs = glob([\"Sources/System/**/*.swift\"]),\n defines = [\"SYSTEM_PACKAGE\"] +\n select({\n \"@platforms//os:macos\": DARWIN_DEFINES,\n \"@platforms//os:ios\": DARWIN_DEFINES,\n \"@platforms//os:tvos\": DARWIN_DEFINES,\n \"@platforms//os:watchos\": DARWIN_DEFINES,\n \"@platforms//os:visionos\": DARWIN_DEFINES,\n \"//conditions:default\": [],\n }) +\n select({\n \":debug\": [\"ENABLE_MOCKING\"],\n \"//conditions:default\": [],\n }),\n module_name = \"SystemPackage\",\n visibility = [\"//visibility:public\"],\n deps = [\":CSystem\"],\n)\n ", + "sha256": "799474251c3654b5483c0f49045ff6729e07acebe9d1541aabfbec68d0390457", + "strip_prefix": "swift-system-1.4.0", + "url": "https://github.com/apple/swift-system/archive/refs/tags/1.4.0.tar.gz" + } + } + }, + "recordedRepoMappingEntries": [ + [ + "", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, "@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": { "general": { - "bzlTransitiveDigest": "ltCGFbl/LQQZXn/LEMXfKX7pGwyqNiOCHcmiQW0tmjM=", - "usagesDigest": "ij5lME/4DUg8DaFZLtV7DhUetr6zQfacN3Lov679Sig=", + "bzlTransitiveDigest": "7ii+gFxWSxHhQPrBxfMEHhtrGvHmBTvsh+KOyGunP/s=", + "usagesDigest": "NOZp0AxAT8ft/RmSFTJhdi4TWo7gKxcuMYm4WghyA+U=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, "generatedRepoSpecs": { - "local_config_apple_cc": { + "local_config_apple_cc_toolchains": { "bzlFile": "@@apple_support~//crosstool:setup.bzl", - "ruleClassName": "_apple_cc_autoconf", + "ruleClassName": "_apple_cc_autoconf_toolchains", "attributes": {} }, - "local_config_apple_cc_toolchains": { + "local_config_apple_cc": { "bzlFile": "@@apple_support~//crosstool:setup.bzl", - "ruleClassName": "_apple_cc_autoconf_toolchains", + "ruleClassName": "_apple_cc_autoconf", "attributes": {} } }, @@ -119,10 +188,160 @@ ] } }, + "@@buildifier_prebuilt~//:defs.bzl%buildifier_prebuilt_deps_extension": { + "general": { + "bzlTransitiveDigest": "lqH5eQXGrxGyrPzoegk5Mn6zC3A1P0h+QsA1O/QlXHc=", + "usagesDigest": "yt+GfSH6jiwv+nPT5fzdhb/zB+8RgR4U+dna3WGxrzU=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "buildifier_darwin_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-darwin-amd64" + ], + "downloaded_file_path": "buildifier", + "executable": true, + "sha256": "375f823103d01620aaec20a0c29c6cbca99f4fd0725ae30b93655c6704f44d71" + } + }, + "buildifier_darwin_arm64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-darwin-arm64" + ], + "downloaded_file_path": "buildifier", + "executable": true, + "sha256": "5a6afc6ac7a09f5455ba0b89bd99d5ae23b4174dc5dc9d6c0ed5ce8caac3f813" + } + }, + "buildifier_linux_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-linux-amd64" + ], + "downloaded_file_path": "buildifier", + "executable": true, + "sha256": "5474cc5128a74e806783d54081f581662c4be8ae65022f557e9281ed5dc88009" + } + }, + "buildifier_linux_arm64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-linux-arm64" + ], + "downloaded_file_path": "buildifier", + "executable": true, + "sha256": "0bf86c4bfffaf4f08eed77bde5b2082e4ae5039a11e2e8b03984c173c34a561c" + } + }, + "buildifier_windows_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildifier-windows-amd64.exe" + ], + "downloaded_file_path": "buildifier.exe", + "executable": true, + "sha256": "370cd576075ad29930a82f5de132f1a1de4084c784a82514bd4da80c85acf4a8" + } + }, + "buildozer_darwin_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-darwin-amd64" + ], + "downloaded_file_path": "buildozer", + "executable": true, + "sha256": "854c9583efc166602276802658cef3f224d60898cfaa60630b33d328db3b0de2" + } + }, + "buildozer_darwin_arm64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-darwin-arm64" + ], + "downloaded_file_path": "buildozer", + "executable": true, + "sha256": "31b1bfe20d7d5444be217af78f94c5c43799cdf847c6ce69794b7bf3319c5364" + } + }, + "buildozer_linux_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-linux-amd64" + ], + "downloaded_file_path": "buildozer", + "executable": true, + "sha256": "3305e287b3fcc68b9a35fd8515ee617452cd4e018f9e6886b6c7cdbcba8710d4" + } + }, + "buildozer_linux_arm64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-linux-arm64" + ], + "downloaded_file_path": "buildozer", + "executable": true, + "sha256": "0b5a2a717ac4fc911e1fec8d92af71dbb4fe95b10e5213da0cc3d56cea64a328" + } + }, + "buildozer_windows_amd64": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_file", + "attributes": { + "urls": [ + "https://github.com/bazelbuild/buildtools/releases/download/v7.3.1/buildozer-windows-amd64.exe" + ], + "downloaded_file_path": "buildozer.exe", + "executable": true, + "sha256": "58d41ce53257c5594c9bc86d769f580909269f68de114297f46284fbb9023dcf" + } + }, + "buildifier_prebuilt_toolchains": { + "bzlFile": "@@buildifier_prebuilt~//:defs.bzl", + "ruleClassName": "_buildifier_toolchain_setup", + "attributes": { + "assets_json": "[{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"darwin\",\"sha256\":\"375f823103d01620aaec20a0c29c6cbca99f4fd0725ae30b93655c6704f44d71\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildifier\",\"platform\":\"darwin\",\"sha256\":\"5a6afc6ac7a09f5455ba0b89bd99d5ae23b4174dc5dc9d6c0ed5ce8caac3f813\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"linux\",\"sha256\":\"5474cc5128a74e806783d54081f581662c4be8ae65022f557e9281ed5dc88009\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildifier\",\"platform\":\"linux\",\"sha256\":\"0bf86c4bfffaf4f08eed77bde5b2082e4ae5039a11e2e8b03984c173c34a561c\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildifier\",\"platform\":\"windows\",\"sha256\":\"370cd576075ad29930a82f5de132f1a1de4084c784a82514bd4da80c85acf4a8\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"darwin\",\"sha256\":\"854c9583efc166602276802658cef3f224d60898cfaa60630b33d328db3b0de2\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildozer\",\"platform\":\"darwin\",\"sha256\":\"31b1bfe20d7d5444be217af78f94c5c43799cdf847c6ce69794b7bf3319c5364\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"linux\",\"sha256\":\"3305e287b3fcc68b9a35fd8515ee617452cd4e018f9e6886b6c7cdbcba8710d4\",\"version\":\"v7.3.1\"},{\"arch\":\"arm64\",\"name\":\"buildozer\",\"platform\":\"linux\",\"sha256\":\"0b5a2a717ac4fc911e1fec8d92af71dbb4fe95b10e5213da0cc3d56cea64a328\",\"version\":\"v7.3.1\"},{\"arch\":\"amd64\",\"name\":\"buildozer\",\"platform\":\"windows\",\"sha256\":\"58d41ce53257c5594c9bc86d769f580909269f68de114297f46284fbb9023dcf\",\"version\":\"v7.3.1\"}]" + } + } + }, + "recordedRepoMappingEntries": [ + [ + "buildifier_prebuilt~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "buildifier_prebuilt~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, "@@platforms//host:extension.bzl%host_platform": { "general": { "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", - "usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=", + "usagesDigest": "hgylFkgWSg0ulUwWZzEM1aIftlUnbmw2ynWLdEfHnZc=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, @@ -1760,82 +1979,82 @@ }, "@@rules_swift~//swift:extensions.bzl%non_module_deps": { "general": { - "bzlTransitiveDigest": "SMlSpPt7J3akRjdCKkCLB4onHNyplTFRm/cjRcBXTK4=", - "usagesDigest": "v8pVOoO9zhy1k73hpXrq8i5itmO9MQIRw5rQZKguitI=", + "bzlTransitiveDigest": "PAIMhc1bVKfcyoHeg0xO8LMS9KN5yzbsMGwa5O2ifJM=", + "usagesDigest": "16aFBd1JZgiFL7rxLXeDjZa5CBzPSkYT6RJD/p/EoJ4=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, "generatedRepoSpecs": { - "com_github_apple_swift_docc_symbolkit": { + "com_github_apple_swift_protobuf": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { "urls": [ - "https://github.com/apple/swift-docc-symbolkit/archive/refs/tags/swift-5.10-RELEASE.tar.gz" + "https://github.com/apple/swift-protobuf/archive/1.20.2.tar.gz" ], - "sha256": "de1d4b6940468ddb53b89df7aa1a81323b9712775b0e33e8254fa0f6f7469a97", - "strip_prefix": "swift-docc-symbolkit-swift-5.10-RELEASE", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_docc_symbolkit/BUILD.overlay" + "sha256": "3fb50bd4d293337f202d917b6ada22f9548a0a0aed9d9a4d791e6fbd8a246ebb", + "strip_prefix": "swift-protobuf-1.20.2/", + "build_file": "@@rules_swift~//third_party:com_github_apple_swift_protobuf/BUILD.overlay" } }, - "com_github_apple_swift_nio_http2": { + "com_github_grpc_grpc_swift": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { "urls": [ - "https://github.com/apple/swift-nio-http2/archive/1.26.0.tar.gz" + "https://github.com/grpc/grpc-swift/archive/1.16.0.tar.gz" ], - "sha256": "f0edfc9d6a7be1d587e5b403f2d04264bdfae59aac1d74f7d974a9022c6d2b25", - "strip_prefix": "swift-nio-http2-1.26.0/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio_http2/BUILD.overlay" + "sha256": "58b60431d0064969f9679411264b82e40a217ae6bd34e17096d92cc4e47556a5", + "strip_prefix": "grpc-swift-1.16.0/", + "build_file": "@@rules_swift~//third_party:com_github_grpc_grpc_swift/BUILD.overlay" } }, - "build_bazel_rules_swift_index_import": { + "com_github_apple_swift_docc_symbolkit": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { - "build_file": "@@rules_swift~//third_party:build_bazel_rules_swift_index_import/BUILD.overlay", - "canonical_id": "index-import-5.8", "urls": [ - "https://github.com/MobileNativeFoundation/index-import/releases/download/5.8.0.1/index-import.tar.gz" + "https://github.com/apple/swift-docc-symbolkit/archive/refs/tags/swift-5.10-RELEASE.tar.gz" ], - "sha256": "28c1ffa39d99e74ed70623899b207b41f79214c498c603915aef55972a851a15" + "sha256": "de1d4b6940468ddb53b89df7aa1a81323b9712775b0e33e8254fa0f6f7469a97", + "strip_prefix": "swift-docc-symbolkit-swift-5.10-RELEASE", + "build_file": "@@rules_swift~//third_party:com_github_apple_swift_docc_symbolkit/BUILD.overlay" } }, - "com_github_apple_swift_log": { + "com_github_apple_swift_nio": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { "urls": [ - "https://github.com/apple/swift-log/archive/1.4.4.tar.gz" + "https://github.com/apple/swift-nio/archive/2.42.0.tar.gz" ], - "sha256": "48fe66426c784c0c20031f15dc17faf9f4c9037c192bfac2f643f65cb2321ba0", - "strip_prefix": "swift-log-1.4.4/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_log/BUILD.overlay" + "sha256": "e3304bc3fb53aea74a3e54bd005ede11f6dc357117d9b1db642d03aea87194a0", + "strip_prefix": "swift-nio-2.42.0/", + "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio/BUILD.overlay" } }, - "com_github_apple_swift_collections": { + "com_github_apple_swift_nio_http2": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { "urls": [ - "https://github.com/apple/swift-collections/archive/1.0.4.tar.gz" + "https://github.com/apple/swift-nio-http2/archive/1.26.0.tar.gz" ], - "sha256": "d9e4c8a91c60fb9c92a04caccbb10ded42f4cb47b26a212bc6b39cc390a4b096", - "strip_prefix": "swift-collections-1.0.4/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_collections/BUILD.overlay" + "sha256": "f0edfc9d6a7be1d587e5b403f2d04264bdfae59aac1d74f7d974a9022c6d2b25", + "strip_prefix": "swift-nio-http2-1.26.0/", + "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio_http2/BUILD.overlay" } }, - "com_github_grpc_grpc_swift": { + "com_github_apple_swift_nio_transport_services": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { "urls": [ - "https://github.com/grpc/grpc-swift/archive/1.16.0.tar.gz" + "https://github.com/apple/swift-nio-transport-services/archive/1.15.0.tar.gz" ], - "sha256": "58b60431d0064969f9679411264b82e40a217ae6bd34e17096d92cc4e47556a5", - "strip_prefix": "grpc-swift-1.16.0/", - "build_file": "@@rules_swift~//third_party:com_github_grpc_grpc_swift/BUILD.overlay" + "sha256": "f3498dafa633751a52b9b7f741f7ac30c42bcbeb3b9edca6d447e0da8e693262", + "strip_prefix": "swift-nio-transport-services-1.15.0/", + "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio_transport_services/BUILD.overlay" } }, "com_github_apple_swift_nio_extras": { @@ -1850,16 +2069,16 @@ "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio_extras/BUILD.overlay" } }, - "com_github_apple_swift_protobuf": { + "com_github_apple_swift_log": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { "urls": [ - "https://github.com/apple/swift-protobuf/archive/1.20.2.tar.gz" + "https://github.com/apple/swift-log/archive/1.4.4.tar.gz" ], - "sha256": "3fb50bd4d293337f202d917b6ada22f9548a0a0aed9d9a4d791e6fbd8a246ebb", - "strip_prefix": "swift-protobuf-1.20.2/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_protobuf/BUILD.overlay" + "sha256": "48fe66426c784c0c20031f15dc17faf9f4c9037c192bfac2f643f65cb2321ba0", + "strip_prefix": "swift-log-1.4.4/", + "build_file": "@@rules_swift~//third_party:com_github_apple_swift_log/BUILD.overlay" } }, "com_github_apple_swift_nio_ssl": { @@ -1874,40 +2093,40 @@ "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio_ssl/BUILD.overlay" } }, - "com_github_apple_swift_atomics": { + "com_github_apple_swift_collections": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { "urls": [ - "https://github.com/apple/swift-atomics/archive/1.1.0.tar.gz" + "https://github.com/apple/swift-collections/archive/1.0.4.tar.gz" ], - "sha256": "1bee7f469f7e8dc49f11cfa4da07182fbc79eab000ec2c17bfdce468c5d276fb", - "strip_prefix": "swift-atomics-1.1.0/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_atomics/BUILD.overlay" + "sha256": "d9e4c8a91c60fb9c92a04caccbb10ded42f4cb47b26a212bc6b39cc390a4b096", + "strip_prefix": "swift-collections-1.0.4/", + "build_file": "@@rules_swift~//third_party:com_github_apple_swift_collections/BUILD.overlay" } }, - "com_github_apple_swift_nio_transport_services": { + "com_github_apple_swift_atomics": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { "urls": [ - "https://github.com/apple/swift-nio-transport-services/archive/1.15.0.tar.gz" + "https://github.com/apple/swift-atomics/archive/1.1.0.tar.gz" ], - "sha256": "f3498dafa633751a52b9b7f741f7ac30c42bcbeb3b9edca6d447e0da8e693262", - "strip_prefix": "swift-nio-transport-services-1.15.0/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio_transport_services/BUILD.overlay" + "sha256": "1bee7f469f7e8dc49f11cfa4da07182fbc79eab000ec2c17bfdce468c5d276fb", + "strip_prefix": "swift-atomics-1.1.0/", + "build_file": "@@rules_swift~//third_party:com_github_apple_swift_atomics/BUILD.overlay" } }, - "com_github_apple_swift_nio": { + "build_bazel_rules_swift_index_import": { "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", "ruleClassName": "http_archive", "attributes": { + "build_file": "@@rules_swift~//third_party:build_bazel_rules_swift_index_import/BUILD.overlay", + "canonical_id": "index-import-5.8", "urls": [ - "https://github.com/apple/swift-nio/archive/2.42.0.tar.gz" + "https://github.com/MobileNativeFoundation/index-import/releases/download/5.8.0.1/index-import.tar.gz" ], - "sha256": "e3304bc3fb53aea74a3e54bd005ede11f6dc357117d9b1db642d03aea87194a0", - "strip_prefix": "swift-nio-2.42.0/", - "build_file": "@@rules_swift~//third_party:com_github_apple_swift_nio/BUILD.overlay" + "sha256": "28c1ffa39d99e74ed70623899b207b41f79214c498c603915aef55972a851a15" } }, "build_bazel_rules_swift_local_config": { @@ -1921,11 +2140,6 @@ "rules_swift~", "bazel_tools", "bazel_tools" - ], - [ - "rules_swift~", - "build_bazel_rules_swift", - "rules_swift~" ] ] } diff --git a/Package.swift b/Package.swift index 3f4c684e5..bc8891520 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,7 @@ var dependencies: [Package.Dependency] = [ .package(url: "https://github.com/tadija/AEXML", from: "4.0.0"), .package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"), .package(url: "https://github.com/kateinoigakukun/swift-indexstore", from: "0.3.0"), - .package(url: "https://github.com/apple/swift-syntax", from: "600.0.0"), + .package(url: "https://github.com/apple/swift-syntax", from: "600.0.1"), .package(url: "https://github.com/ileitch/swift-filename-matcher", from: "0.0.0"), ] @@ -82,6 +82,7 @@ var targets: [PackageDescription.Target] = [ .target(name: "SyntaxAnalysis"), .target(name: "Shared"), .product(name: "SwiftIndexStore", package: "swift-indexstore"), + .product(name: "AEXML", package: "AEXML"), ] ), .target( diff --git a/Sources/BUILD.bazel b/Sources/BUILD.bazel new file mode 100644 index 000000000..70ffdd713 --- /dev/null +++ b/Sources/BUILD.bazel @@ -0,0 +1,281 @@ +load("@rules_swift//swift:swift.bzl", "swift_binary", "swift_library") + +swift_library( + name = "XcodeSupport", + srcs = [ + "XcodeSupport/XcodeProject.swift", + "XcodeSupport/XcodeProjectSetupGuide.swift", + "XcodeSupport/XcodeProjectlike.swift", + "XcodeSupport/XcodeTarget.swift", + "XcodeSupport/XcodeWorkspace.swift", + "XcodeSupport/Xcodebuild.swift", + ], + module_name = "XcodeSupport", + visibility = ["//visibility:public"], + deps = [ + "//Sources:PeripheryKit", + "//Sources:Shared", + "//Sources:SourceGraph", + "@com_github_tuist_xcodeproj//:XcodeProj", + ], +) + +swift_library( + name = "SyntaxAnalysis", + srcs = [ + "SyntaxAnalysis/CommentCommand.swift", + "SyntaxAnalysis/DeclarationSyntaxVisitor.swift", + "SyntaxAnalysis/ImportSyntaxVisitor.swift", + "SyntaxAnalysis/MultiplexingSyntaxVisitor.swift", + "SyntaxAnalysis/SourceLocationBuilder.swift", + "SyntaxAnalysis/TypeSyntaxInspector.swift", + "SyntaxAnalysis/UnusedParameterAnalyzer.swift", + "SyntaxAnalysis/UnusedParameterParser.swift", + ], + module_name = "SyntaxAnalysis", + visibility = ["//visibility:public"], + deps = [ + "//Sources:Shared", + "//Sources:SourceGraph", + "@swift-syntax//:SwiftParser", + "@swift-syntax//:SwiftSyntax", + ], +) + +swift_library( + name = "SourceGraph", + srcs = [ + "SourceGraph/Elements/Accessibility.swift", + "SourceGraph/Elements/AssetReference.swift", + "SourceGraph/Elements/CommentCommand.swift", + "SourceGraph/Elements/Declaration.swift", + "SourceGraph/Elements/ImportStatement.swift", + "SourceGraph/Elements/Location.swift", + "SourceGraph/Elements/ProjectFileKind.swift", + "SourceGraph/Elements/Reference.swift", + "SourceGraph/Elements/SourceFile.swift", + "SourceGraph/Mutators/AccessibilityCascader.swift", + "SourceGraph/Mutators/AncestralReferenceEliminator.swift", + "SourceGraph/Mutators/AssetReferenceRetainer.swift", + "SourceGraph/Mutators/AssignOnlyPropertyReferenceEliminator.swift", + "SourceGraph/Mutators/CapitalSelfFunctionCallRetainer.swift", + "SourceGraph/Mutators/CodablePropertyRetainer.swift", + "SourceGraph/Mutators/CodingKeyEnumReferenceBuilder.swift", + "SourceGraph/Mutators/ComplexPropertyAccessorReferenceBuilder.swift", + "SourceGraph/Mutators/DefaultConstructorReferenceBuilder.swift", + "SourceGraph/Mutators/DynamicMemberLookupReferenceBuilder.swift", + "SourceGraph/Mutators/EntryPointAttributeRetainer.swift", + "SourceGraph/Mutators/EnumCaseReferenceBuilder.swift", + "SourceGraph/Mutators/ExtensionReferenceBuilder.swift", + "SourceGraph/Mutators/ExternalOverrideRetainer.swift", + "SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift", + "SourceGraph/Mutators/GenericClassAndStructConstructorReferenceBuilder.swift", + "SourceGraph/Mutators/InterfaceBuilderPropertyRetainer.swift", + "SourceGraph/Mutators/ObjCAccessibleRetainer.swift", + "SourceGraph/Mutators/PropertyWrapperRetainer.swift", + "SourceGraph/Mutators/ProtocolConformanceReferenceBuilder.swift", + "SourceGraph/Mutators/ProtocolExtensionReferenceBuilder.swift", + "SourceGraph/Mutators/PubliclyAccessibleRetainer.swift", + "SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift", + "SourceGraph/Mutators/RedundantProtocolMarker.swift", + "SourceGraph/Mutators/ResultBuilderRetainer.swift", + "SourceGraph/Mutators/StringInterpolationAppendInterpolationRetainer.swift", + "SourceGraph/Mutators/StructImplicitInitializerReferenceBuilder.swift", + "SourceGraph/Mutators/SwiftUIRetainer.swift", + "SourceGraph/Mutators/UnusedImportMarker.swift", + "SourceGraph/Mutators/UnusedParameterRetainer.swift", + "SourceGraph/Mutators/UsedDeclarationMarker.swift", + "SourceGraph/Mutators/XCTestRetainer.swift", + "SourceGraph/SourceGraph.swift", + "SourceGraph/SourceGraphDebugger.swift", + "SourceGraph/SourceGraphMutator.swift", + "SourceGraph/SourceGraphMutatorRunner.swift", + "SourceGraph/SynchronizedSourceGraph.swift", + ], + module_name = "SourceGraph", + visibility = ["//visibility:public"], + deps = [ + "//Sources:Configuration", + "//Sources:Shared", + "@swift-syntax//:SwiftSyntax", + ], +) + +swift_library( + name = "Shared", + srcs = [ + "Shared/Benchmark.swift", + "Shared/Constants.swift", + "Shared/PeripheryError.swift", + "Shared/ProjectKind.swift", + "Shared/PropertyTypeSanitizer.swift", + "Shared/SetupGuide.swift", + "Shared/Shell.swift", + "Shared/SwiftVersion.swift", + "Shared/SwiftVersionParser.swift", + "Shared/UnfairLock.swift", + ], + module_name = "Shared", + visibility = ["//visibility:public"], + deps = [ + "//Sources:Extensions", + "//Sources:Logger", + "@com_github_apple_swift-system//:SystemPackage", + "@swift-filename-matcher//:FilenameMatcher", + ], +) + +swift_library( + name = "ProjectDrivers", + srcs = [ + "ProjectDrivers/BazelProjectDriver.swift", + "ProjectDrivers/GenericProjectDriver.swift", + "ProjectDrivers/ProjectDriver.swift", + "ProjectDrivers/SPM.swift", + "ProjectDrivers/SPMProjectDriver.swift", + "ProjectDrivers/XcodeProjectDriver.swift", + ], + module_name = "ProjectDrivers", + visibility = ["//visibility:public"], + deps = [ + "//Sources:Indexer", + "//Sources:Shared", + "//Sources:SourceGraph", + "//Sources:XcodeSupport", + ], +) + +swift_library( + name = "PeripheryKit", + srcs = [ + "PeripheryKit/Results/Baseline.swift", + "PeripheryKit/Results/CheckstyleFormatter.swift", + "PeripheryKit/Results/CodeClimateFormatter.swift", + "PeripheryKit/Results/CsvFormatter.swift", + "PeripheryKit/Results/GitHubActionsFormatter.swift", + "PeripheryKit/Results/JsonFormatter.swift", + "PeripheryKit/Results/OutputDeclarationFilter.swift", + "PeripheryKit/Results/OutputFormatter.swift", + "PeripheryKit/Results/XcodeFormatter.swift", + "PeripheryKit/ScanResult.swift", + "PeripheryKit/ScanResultBuilder.swift", + ], + module_name = "PeripheryKit", + visibility = ["//visibility:public"], + deps = [ + "//Sources:Indexer", + "//Sources:Shared", + "//Sources:SourceGraph", + "@aexml//:AEXML", + "@com_github_apple_swift-system//:SystemPackage", + "@swift-filename-matcher//:FilenameMatcher", + "@swift-indexstore//:SwiftIndexStore", + "@swift-syntax//:SwiftParser", + "@swift-syntax//:SwiftSyntax", + ], +) + +swift_library( + name = "Logger", + srcs = ["Logger/Logger.swift"], + module_name = "Logger", + visibility = ["//visibility:public"], +) + +swift_library( + name = "Indexer", + srcs = [ + "Indexer/IndexPipeline.swift", + "Indexer/IndexPlan.swift", + "Indexer/Indexer.swift", + "Indexer/InfoPlistIndexer.swift", + "Indexer/InfoPlistParser.swift", + "Indexer/JobPool.swift", + "Indexer/SourceFileCollector.swift", + "Indexer/SwiftIndexer.swift", + "Indexer/XCDataModelIndexer.swift", + "Indexer/XCDataModelParser.swift", + "Indexer/XCMappingModelIndexer.swift", + "Indexer/XCMappingModelParser.swift", + "Indexer/XibIndexer.swift", + "Indexer/XibParser.swift", + ], + module_name = "Indexer", + visibility = ["//visibility:public"], + deps = [ + "//Sources:Shared", + "//Sources:SyntaxAnalysis", + "@aexml//:AEXML", + "@swift-indexstore//:SwiftIndexStore", + ], +) + +swift_binary( + name = "Frontend", + srcs = [ + "Frontend/Commands/CheckUpdateCommand.swift", + "Frontend/Commands/ClearCacheCommand.swift", + "Frontend/Commands/FrontendCommand.swift", + "Frontend/Commands/ScanCommand.swift", + "Frontend/Commands/VersionCommand.swift", + "Frontend/CommonSetupGuide.swift", + "Frontend/GuidedSetup.swift", + "Frontend/Logger+Extension.swift", + "Frontend/Project.swift", + "Frontend/SPMProjectSetupGuide.swift", + "Frontend/Scan.swift", + "Frontend/UpdateChecker.swift", + "Frontend/Version.swift", + "Frontend/main.swift", + ], + module_name = "Frontend", + visibility = ["//visibility:public"], + deps = [ + "//Sources:Configuration", + "//Sources:PeripheryKit", + "//Sources:ProjectDrivers", + "//Sources:Shared", + "//Sources:SourceGraph", + "@swift-filename-matcher//:FilenameMatcher", + "@swift_argument_parser//:ArgumentParser", + ], +) + +swift_library( + name = "Extensions", + srcs = [ + "Extensions/Array+Extension.swift", + "Extensions/Collection+Extension.swift", + "Extensions/FilePath+Extension.swift", + "Extensions/FilePath+Glob.swift", + "Extensions/FilenameMatcher+Extension.swift", + "Extensions/Sequence+Extension.swift", + "Extensions/Set+Extension.swift", + "Extensions/String+Extension.swift", + "Extensions/String+Version.swift", + ], + module_name = "Extensions", + visibility = ["//visibility:public"], + deps = [ + "@com_github_apple_swift-system//:SystemPackage", + "@swift-filename-matcher//:FilenameMatcher", + ], +) + +swift_library( + name = "Configuration", + srcs = [ + "Configuration/Configuration.swift", + "Configuration/OutputFormat.swift", + ], + module_name = "Configuration", + visibility = ["//visibility:public"], + deps = [ + "//Sources:Extensions", + "//Sources:Logger", + "//Sources:Shared", + "@com_github_apple_swift-system//:SystemPackage", + "@swift-filename-matcher//:FilenameMatcher", + "@yams//:Yams", + ], +) diff --git a/Sources/Configuration/Configuration.swift b/Sources/Configuration/Configuration.swift index 7428078dd..dec444ab9 100644 --- a/Sources/Configuration/Configuration.swift +++ b/Sources/Configuration/Configuration.swift @@ -153,11 +153,12 @@ public final class Configuration { FileManager.default.createFile(atPath: path.string, contents: data) } - public func load(from path: FilePath?, logger: Logger) throws { + public func load(from path: FilePath?) throws { guard let path = try configurationPath(withUserProvided: path) else { return } let encodedYAML = try String(contentsOf: path.url) let yaml = try Yams.load(yaml: encodedYAML) as? [String: Any] ?? [:] + let logger = Logger(quiet: false) for (key, value) in yaml { if let setting = settings.first(where: { key == $0.key }) { diff --git a/Sources/Frontend/Commands/ScanCommand.swift b/Sources/Frontend/Commands/ScanCommand.swift index f0468b888..1b9151170 100644 --- a/Sources/Frontend/Commands/ScanCommand.swift +++ b/Sources/Frontend/Commands/ScanCommand.swift @@ -138,13 +138,10 @@ struct ScanCommand: FrontendCommand { private static let defaultConfiguration = Configuration() func run() throws { - let logger = Logger(quiet: quiet, verbose: verbose) - logger.contextualized(with: "version").debug(PeripheryVersion) - let configuration = Configuration() if !setup { - try configuration.load(from: config, logger: logger) + try configuration.load(from: config) } configuration.guidedSetup = setup @@ -188,6 +185,11 @@ struct ScanCommand: FrontendCommand { configuration.apply(\.$bazel, bazel) configuration.apply(\.$bazelFilter, bazelFilter) + let logger = Logger( + quiet: configuration.quiet, + verbose: configuration.verbose + ) + logger.contextualized(with: "version").debug(PeripheryVersion) let shell = Shell(logger: logger) let swiftVersion = SwiftVersion(shell: shell) logger.debug(swiftVersion.fullVersion) diff --git a/Sources/ProjectDrivers/BazelProjectDriver.swift b/Sources/ProjectDrivers/BazelProjectDriver.swift index 640eab1de..9de390390 100644 --- a/Sources/ProjectDrivers/BazelProjectDriver.swift +++ b/Sources/ProjectDrivers/BazelProjectDriver.swift @@ -95,7 +95,7 @@ public class BazelProjectDriver: ProjectDriver { let buildPath = outputPath.appending("BUILD.bazel") let deps = try queryTargets().joined(separator: ",\n") let buildFileContents = """ - load("@periphery//bazel/scan:scan.bzl", "scan") + load("@periphery//bazel:rules.bzl", "scan") scan( name = "scan", @@ -124,7 +124,7 @@ public class BazelProjectDriver: ProjectDriver { "run", "--check_visibility=false", "--ui_event_filters=-info,-debug,-warning", - "@periphery//:scan", + "@periphery_generated//rule:scan", ]) // The actual scan is performed by Bazel. diff --git a/bazel/extensions.bzl b/bazel/extensions.bzl index 67244e28e..076ae6890 100644 --- a/bazel/extensions.bzl +++ b/bazel/extensions.bzl @@ -1,3 +1,7 @@ +""" + Public module extensions. +""" + def _generated_repo_impl(repository_ctx): repository_ctx.file( "BUILD.bazel", diff --git a/bazel/internal/BUILD.bazel b/bazel/internal/BUILD.bazel new file mode 100644 index 000000000..c3d60a89a --- /dev/null +++ b/bazel/internal/BUILD.bazel @@ -0,0 +1,25 @@ +load("@buildifier_prebuilt//:rules.bzl", "buildifier") + +exports_files([ + "run.sh", +]) + +buildifier( + name = "buildifier.fix", + exclude_patterns = [ + "./.git/**/*", + "**/.build/**/*", + ], + lint_mode = "fix", + mode = "fix", +) + +buildifier( + name = "buildifier.check", + exclude_patterns = [ + "./.git/**/*", + "**/.build/**/*", + ], + lint_mode = "warn", + mode = "check", +) diff --git a/bazel/internal/extensions.bzl b/bazel/internal/extensions.bzl new file mode 100644 index 000000000..4c93bc4a3 --- /dev/null +++ b/bazel/internal/extensions.bzl @@ -0,0 +1,10 @@ +""" + Internal module extensions. +""" + +load( + "//bazel/internal:repositories.bzl", + "periphery_dependencies", +) + +non_module_deps = module_extension(implementation = lambda _: periphery_dependencies()) diff --git a/bazel/internal/repositories.bzl b/bazel/internal/repositories.bzl new file mode 100644 index 000000000..75cdb312e --- /dev/null +++ b/bazel/internal/repositories.bzl @@ -0,0 +1,93 @@ +""" + Non-module dependencies that are not available in the Bazel ecosystem. +""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def periphery_dependencies(): + http_archive( + name = "com_github_tuist_xcodeproj", + build_file_content = """\ +load("@rules_swift//swift:swift.bzl", "swift_library") + +swift_library( + name = "XcodeProj", + srcs = glob(["Sources/XcodeProj/**/*.swift"]), + visibility = ["//visibility:public"], + deps = [ + "@aexml//:AEXML", + "@com_github_kylef_pathkit//:PathKit", + ], +) + """, + sha256 = "3990868f731888edabcaeacf639f0ee75e2e4430102a4f4bf40b03a60eeafe12", + strip_prefix = "XcodeProj-8.24.7", + url = "https://github.com/tuist/XcodeProj/archive/refs/tags/8.24.7.tar.gz", + ) + + http_archive( + name = "com_github_kylef_pathkit", + build_file_content = """\ +load("@rules_swift//swift:swift.bzl", "swift_library") + +swift_library( + name = "PathKit", + srcs = glob(["Sources/**/*.swift"]), + visibility = ["//visibility:public"], +) + """, + sha256 = "fcda78cdf12c1c6430c67273333e060a9195951254230e524df77841a0235dae", + strip_prefix = "PathKit-1.0.1", + url = "https://github.com/kylef/PathKit/archive/refs/tags/1.0.1.tar.gz", + ) + + # TODO: https://github.com/apple/swift-system/pull/194 + http_archive( + name = "com_github_apple_swift-system", + build_file_content = """\ +load("@rules_swift//swift:swift.bzl", "swift_library", "swift_test") + +config_setting( + name = "debug", + values = {"compilation_mode": "dbg"}, +) + +cc_library( + name = "CSystem", + hdrs = glob(["Sources/CSystem/include/*.h"]), + aspect_hints = ["@rules_swift//swift:auto_module"], + defines = select({ + "@platforms//os:windows": ["_CRT_SECURE_NO_WARNINGS"], + "//conditions:default": [], + }), + linkstatic = True, + tags = ["swift_module=CSystem"], +) + +DARWIN_DEFINES = ["SYSTEM_PACKAGE_DARWIN"] + +swift_library( + name = "SystemPackage", + srcs = glob(["Sources/System/**/*.swift"]), + defines = ["SYSTEM_PACKAGE"] + + select({ + "@platforms//os:macos": DARWIN_DEFINES, + "@platforms//os:ios": DARWIN_DEFINES, + "@platforms//os:tvos": DARWIN_DEFINES, + "@platforms//os:watchos": DARWIN_DEFINES, + "@platforms//os:visionos": DARWIN_DEFINES, + "//conditions:default": [], + }) + + select({ + ":debug": ["ENABLE_MOCKING"], + "//conditions:default": [], + }), + module_name = "SystemPackage", + visibility = ["//visibility:public"], + deps = [":CSystem"], +) + """, + sha256 = "799474251c3654b5483c0f49045ff6729e07acebe9d1541aabfbec68d0390457", + strip_prefix = "swift-system-1.4.0", + url = "https://github.com/apple/swift-system/archive/refs/tags/1.4.0.tar.gz", + ) diff --git a/bazel/internal/run.sh b/bazel/internal/run.sh new file mode 100755 index 000000000..8c9749959 --- /dev/null +++ b/bazel/internal/run.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +LAUNCH_WORKING_DIRECTORY=$(pwd) + +if test "${BUILD_WORKING_DIRECTORY+x}"; then + cd $BUILD_WORKING_DIRECTORY +fi + +$LAUNCH_WORKING_DIRECTORY/Sources/Frontend "${@:1}" \ No newline at end of file diff --git a/bazel/internal/scan/BUILD.bazel b/bazel/internal/scan/BUILD.bazel new file mode 100644 index 000000000..3b371ef73 --- /dev/null +++ b/bazel/internal/scan/BUILD.bazel @@ -0,0 +1,3 @@ +exports_files([ + "scan_template.sh", +]) diff --git a/bazel/scan/scan.bzl b/bazel/internal/scan/scan.bzl similarity index 85% rename from bazel/scan/scan.bzl rename to bazel/internal/scan/scan.bzl index 5b888bae2..e15e8312f 100644 --- a/bazel/scan/scan.bzl +++ b/bazel/internal/scan/scan.bzl @@ -1,6 +1,10 @@ +""" + Declares the `scan` rule which acts as the primary entry point for the Periphery Bazel integration. +""" + load("@bazel_skylib//lib:sets.bzl", "sets") -load("@rules_swift//swift:providers.bzl", "SwiftInfo") load("@rules_apple//apple:providers.bzl", "AppleResourceInfo") +load("@rules_swift//swift:providers.bzl", "SwiftBinaryInfo", "SwiftInfo") PeripheryInfo = provider( doc = "Provides inputs needed to generate a generic project configuration file.", @@ -41,18 +45,25 @@ def _scan_inputs_aspect_impl(target, ctx): xcdatamodels = [] xcmappingmodels = [] - if not target.label.workspace_name: # Ignore external deps - if SwiftInfo in target and hasattr(target[SwiftInfo], "direct_modules"): - for module in target[SwiftInfo].direct_modules: - if hasattr(module, "swift"): - if hasattr(module.compilation_context, "direct_sources"): - swift_srcs.extend([src for src in module.compilation_context.direct_sources if src.extension == "swift"]) + if not target.label.workspace_name: # Ignore external deps + modules = [] + + if SwiftBinaryInfo in target: + modules.extend(target[SwiftBinaryInfo].swift_info.direct_modules) + + if SwiftInfo in target: + modules.extend(target[SwiftInfo].direct_modules) - if ctx.rule.attr.testonly: - test_targets.append(module.name) + for module in modules: + if hasattr(module, "swift"): + if hasattr(module.compilation_context, "direct_sources"): + swift_srcs.extend([src for src in module.compilation_context.direct_sources if src.extension == "swift"]) - if hasattr(module.swift, "indexstore") and module.swift.indexstore: - indexstores.append(module.swift.indexstore) + if ctx.rule.attr.testonly: + test_targets.append(module.name) + + if hasattr(module.swift, "indexstore") and module.swift.indexstore: + indexstores.append(module.swift.indexstore) if AppleResourceInfo in target: # Each attribute has the structure '[(parent, resource_swift_module, resource_depset)]' @@ -172,8 +183,8 @@ def _scan_impl(ctx): substitutions = { "%periphery_binary%": ctx.attr.periphery_binary, "%config_path%": ctx.attr.config, - "%project_config_path%": project_config_file.path - } + "%project_config_path%": project_config_file.path, + }, ) return DefaultInfo( @@ -186,7 +197,7 @@ def _scan_impl(ctx): # in the indexstores and will be read by Periphery, and therefore must be present in # the runfiles. files = swift_srcs + indexstores + plists + xibs + xcdatamodels + xcmappingmodels, - ) + ), ) scan_inputs_aspect = aspect( @@ -201,13 +212,13 @@ scan = rule( cfg = _force_indexstore, mandatory = True, aspects = [scan_inputs_aspect], - doc = "Top-level project targets to scan." + doc = "Top-level project targets to scan.", ), "config": attr.string(doc = "Path to the periphery.yml configuration file."), "periphery_binary": attr.string(doc = "Path to the periphery binary."), "_template": attr.label( allow_single_file = True, - default = "@periphery//bazel/scan:scan_template.sh", + default = "@periphery//bazel/internal/scan:scan_template.sh", ), }, outputs = { diff --git a/bazel/scan/scan_template.sh b/bazel/internal/scan/scan_template.sh similarity index 100% rename from bazel/scan/scan_template.sh rename to bazel/internal/scan/scan_template.sh diff --git a/bazel/rules.bzl b/bazel/rules.bzl new file mode 100644 index 000000000..1a4efde11 --- /dev/null +++ b/bazel/rules.bzl @@ -0,0 +1,10 @@ +""" + Periphery public rules. +""" + +load( + "//bazel/internal/scan:scan.bzl", + _scan = "scan", +) + +scan = _scan diff --git a/bazel/scan/BUILD.bazel b/bazel/scan/BUILD.bazel deleted file mode 100644 index 9181ac277..000000000 --- a/bazel/scan/BUILD.bazel +++ /dev/null @@ -1,3 +0,0 @@ -exports_files([ - "scan_template.sh" -]) diff --git a/scripts/gen_bazel_rules.rb b/scripts/gen_bazel_rules.rb new file mode 100644 index 000000000..0eac34b45 --- /dev/null +++ b/scripts/gen_bazel_rules.rb @@ -0,0 +1,99 @@ +#!/usr/bin/env ruby + +require 'json' + +PRODUCTS = { + "ArgumentParser" => "@swift_argument_parser", + "SystemPackage" => "@com_github_apple_swift-system", + "SwiftIndexStore" => "@swift-indexstore", + "FilenameMatcher" => "@swift-filename-matcher", + "Yams" => "@yams", + "SwiftParser" => "@swift-syntax", + "SwiftSyntax" => "@swift-syntax", + "XcodeProj" => "@com_github_tuist_xcodeproj", + "AEXML" => "@aexml", +} + +def parse_json + JSON.parse(`swift package describe --type json`) +rescue JSON::ParserError => e + puts "Error parsing JSON: #{e.message}" + exit 1 +end + +def target_labels(targets) + targets.each_with_object({}) do |target, labels| + labels[target["name"]] = "//Sources:#{target["name"]}" + end +end + +def generate_sources(target) + path = target["path"].split("/").last + + target["sources"].map do |source| + "#{path}/#{source}" + end +end + +def generate_dependencies(target, target_labels) + deps = (target["target_dependencies"] || []).map { |dep| "\"#{target_labels[dep]}\"" } + deps += (target["product_dependencies"] || []).map do |dep| + pkg = PRODUCTS[dep] + "\"#{pkg}//:#{dep}\"" + end + deps +end + +def generate_attrs(target, name, path, sources, deps) + attrs = { + "name" => "\"#{name}\"", + "module_name" => "\"#{name}\"", + "srcs" => sources.map { |src| src }, + "visibility" => "[\"//visibility:public\"]", + } + + if target["type"] == "library" + end + + attrs["deps"] = "[\n #{deps.sort.join(",\n ")}\n ]" unless deps.empty? + attrs +end + +def generate_bazel_rule(path, rule, attrs) + formatted_attrs = attrs.map { |k, v| " #{k} = #{v}" }.join(",\n") + "#{rule}(\n#{formatted_attrs}\n)" +end + +json = parse_json +labels = target_labels(json["targets"]) + +rules = json["targets"].map do |target| + name = target["name"] + path = target["path"] + + next if path.start_with?("Tests") + + puts "* #{name} (#{path})" + + type = target["type"] + sources = generate_sources(target) + deps = generate_dependencies(target, labels) + + rule = case type + when "executable" then "swift_binary" + when "test" then "swift_test" + else "swift_library" + end + + attrs = generate_attrs(target, name, path, sources, deps) + generate_bazel_rule(path, rule, attrs) +end + +File.write("Sources/BUILD.bazel", <<~EOS) + load("@rules_swift//swift:swift.bzl", "swift_binary", "swift_library") + + #{rules.join("\n\n")} +EOS + +puts +exec("bazel", "run", "//bazel/internal:buildifier.fix")