diff --git a/.bazelrc b/.bazelrc index 35d6cfa..ee4f4be 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,15 +1,15 @@ startup --output_base=./bazel-output-base +common --enable_bzlmod + build --announce_rc build --spawn_strategy=local build --strategy=SwiftCompile=worker build --verbose_failures build --compilation_mode=fastbuild -build --experimental_multi_threaded_digest build --verbose_failures -build:rules_xcodeproj --xcode_version_config=@local_config_xcode//:host_xcodes common:ci --isatty=1 common:ci --terminal_columns=127 -import %workspace%/.env_bazelrc \ No newline at end of file +try-import %workspace%/.env_bazelrc \ No newline at end of file diff --git a/.bazelversion b/.bazelversion index f22d756..ef09838 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.5.0 +7.1.1 \ No newline at end of file diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 0000000..c39a9f7 --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,15 @@ +{ + "homepage": "https://github.com/sergeykhliustin/BazelPods", + "maintainers": [ + { + "email": "sergey.khliustin@gmail.com", + "github": "sergeykhliustin", + "name": "Sergii Khliustin" + } + ], + "repository": [ + "github:sergeykhliustin/BazelPods" + ], + "versions": [], + "yanked_versions": {} +} \ No newline at end of file diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 0000000..25a1447 --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,12 @@ +matrix: + bazel: ["6.x"] + platform: ["macos_arm64", "macos"] +tasks: + verify_build: + name: Verify Build + platform: ${{ platform }} + bazel: ${{ bazel }} + build_targets: + - "@bazelpods//:bazelpods" + build_flags: + - "--enable_bzlmod" diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 0000000..e3f6204 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,5 @@ +{ + "integrity": "", + "strip_prefix": "", + "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/release.tar.gz" +} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bb94a24..cfce7a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: - name: Get latest release tag id: latesttag run: | - CURRENT_VERSION=$(gh release list --limit 1 --json version | jq .[0].tagName | tr -d '"') + CURRENT_VERSION=$(gh release list --limit 1 --json tagName | jq .[0].tagName | tr -d '"') echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV - name: Validate new version @@ -33,44 +33,38 @@ jobs: - name: Archive sources run: | - tar czvf release.tar.gz Sources BUILD repositories.bzl + tar czvf release.tar.gz Sources BUILD.bazel repositories.bzl MODULE.bazel - name: Calculate SHA256 run: | echo "SHA256=$(shasum -a 256 release.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_ENV - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - body: | - ## Workspace Snippet - - ```starlark - http_archive( - name = "bazelpods", - sha256 = "${{ env.SHA256 }}", - url = "https://github.com/sergeykhliustin/BazelPods/releases/download/${{ env.NEW_VERSION }}/release.tar.gz" - ) - - load("@bazelpods//:repositories.bzl", "bazelpods_dependencies") + run: | + set -euo pipefail - bazelpods_dependencies() - ``` - draft: true - prerelease: false + git config user.name "Release Workflow" + git config user.email "noreply@github.com" - - name: Upload Release Asset - id: upload_release_asset - uses: actions/upload-release-asset@v1 + gh release create "${{ github.ref }}" \ + --title "${{ env.NEW_VERSION }}" \ + --target "$GITHUB_SHA" \ + --generate-notes \ + --prerelease \ + --notes "### Bzlmod Snippet + \`\`\`starlark + bazel_dep(name = \"bazelpods\", version = \"${{ env.NEW_VERSION }}\") + \`\`\` + ## Workspace Snippet + \`\`\`starlark + http_archive( + name = \"bazelpods\", + sha256 = \"${{ env.SHA256 }}\", + url = \"https://github.com/sergeykhliustin/BazelPods/releases/download/${{ env.NEW_VERSION }}/release.tar.gz\" + ) + load(\"@bazelpods//:repositories.bzl\", \"bazelpods_dependencies\") + bazelpods_dependencies() + \`\`\`" \ + "release.tar.gz" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./release.tar.gz - asset_name: release.tar.gz - asset_content_type: application/gzip + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 73b35cd..9616d2c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ Tests/Podfile Tests/Podfile.lock Tests/Pods .env_bazelrc +MODULE.bazel.lock diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 712bd5a..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -3.3.1 \ No newline at end of file diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..51f617d --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 3.3.1 diff --git a/BUILD b/BUILD.bazel similarity index 89% rename from BUILD rename to BUILD.bazel index d29a802..0141476 100644 --- a/BUILD +++ b/BUILD.bazel @@ -34,7 +34,7 @@ swift_library( "Sources/BazelPods/**/*.swift", "Sources/Shared/**/*.swift" ]), - deps = [":BazelPodsCore", ":Logger", "@bazelpods-swift-argument-parser//:ArgumentParser"], + deps = [":BazelPodsCore", ":Logger", "@bazelpods_swift_argument_parser//:ArgumentParser"], copts = ["-swift-version", SWIFT_VERSION] ) @@ -65,6 +65,6 @@ swift_library( "Sources/Analyzer/**/*.swift", "Sources/Shared/**/*.swift" ]), - deps = [":BazelPodsCore", ":Logger", "@bazelpods-swift-argument-parser//:ArgumentParser"], + deps = [":BazelPodsCore", ":Logger", "@bazelpods_swift_argument_parser//:ArgumentParser"], copts = ["-swift-version", SWIFT_VERSION], ) diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..70f73a6 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,40 @@ +module( + name = "bazelpods", + version = "0.0.0", + compatibility_level = 1, + bazel_compatibility = [">=6.0.0"], + repo_name = "bazelpods" +) + +bazel_dep( + name = "apple_support", + version = "1.15.1", + repo_name = "build_bazel_apple_support", +) +bazel_dep( + name = "rules_apple", + version = "3.5.1", + repo_name = "build_bazel_rules_apple", +) +bazel_dep( + name = "rules_cc", + version = "0.0.9", +) +bazel_dep( + name = "rules_swift", + version = "1.18.0", + repo_name = "build_bazel_rules_swift", +) +bazel_dep( + name = "rules_ios", + version = "4.4.0", + repo_name = "build_bazel_rules_ios" +) + +non_module_deps = use_extension( + "//:repositories.bzl", + "non_module_deps", +) +use_repo(non_module_deps, "bazelpods_swift_argument_parser") + +bazel_dep(name = "rules_xcodeproj", version = "2.2.0") \ No newline at end of file diff --git a/README.md b/README.md index 986f7cc..d09153f 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,11 @@ Core idea, Podspec parser, Starlark compiler are forked from [PodToBUILD](https: ### 🎸 Let's rock Don't forget to setup [`rules_ios`](https://github.com/bazel-ios/rules_ios) and [`rules_apple`](https://github.com/bazelbuild/rules_apple) first. +Add `BazelPods` to your `MODULE.bazel` +```starlark +bazel_dep(name = "bazelpods", version = "") +``` + Add `BazelPods` to your `WORKSPACE` ```starlark http_archive( diff --git a/TestTools/Pods.json b/TestTools/Pods.json index 5083150..a60cb7d 100644 --- a/TestTools/Pods.json +++ b/TestTools/Pods.json @@ -604,6 +604,9 @@ "SwiftyDropboxObjC": { "version": "10.0.1" }, + "SwiftyGif": { + "version": "5.4.5" + }, "TABAnimated": { "version": "2.6.5" }, diff --git a/Tests/Recorded/SwiftyGif/BUILD.bazel b/Tests/Recorded/SwiftyGif/BUILD.bazel index 8429ce1..9abdea0 100644 --- a/Tests/Recorded/SwiftyGif/BUILD.bazel +++ b/Tests/Recorded/SwiftyGif/BUILD.bazel @@ -1,4 +1,5 @@ load('@build_bazel_rules_ios//rules:framework.bzl', 'apple_framework') +load('@build_bazel_rules_ios//rules:precompiled_apple_resource_bundle.bzl', 'precompiled_apple_resource_bundle') # Add a config setting release for compilation mode # Assume that people are using `opt` for release mode # see the bazel user manual for more information @@ -28,6 +29,9 @@ apple_framework( "SwiftyGif/*.swift" ] ), + deps = [ + ":SwiftyGif_SwiftyGif_Bundle" + ], objc_defines = [ "COCOAPODS=1" ] + select( @@ -58,6 +62,19 @@ apple_framework( "//visibility:public" ] ) +precompiled_apple_resource_bundle( + name = "SwiftyGif_SwiftyGif_Bundle", + bundle_id = "org.cocoapods.SwiftyGif", + bundle_name = "SwiftyGif", + infoplists = [ + ":SwiftyGif_SwiftyGif_Bundle_InfoPlist" + ], + resources = glob( + [ + "SwiftyGif/PrivacyInfo.xcprivacy" + ] + ) +) genrule( name = "SwiftyGif_InfoPlist", srcs = [], @@ -78,7 +95,49 @@ genrule( CFBundlePackageType FMWK CFBundleShortVersionString - 5.4.4 + 5.4.5 + CFBundleSignature + ???? + CFBundleSupportedPlatforms + + iPhoneSimulator + iPhoneOS + + CFBundleVersion + 1 + MinimumOSVersion + 10.0 + UIDeviceFamily + + 1 + 2 + + + + +EOF""" +) +genrule( + name = "SwiftyGif_SwiftyGif_Bundle_InfoPlist", + srcs = [], + outs = [ + "SwiftyGif_SwiftyGif_Bundle_InfoPlist.plist" + ], + cmd = """cat < $@ + + + + + CFBundleIdentifier + org.cocoapods.SwiftyGif + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + SwiftyGif + CFBundlePackageType + BNDL + CFBundleShortVersionString + 5.4.5 CFBundleSignature ???? CFBundleSupportedPlatforms diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index 12b0491..0000000 --- a/WORKSPACE +++ /dev/null @@ -1,64 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "build_bazel_rules_ios", - sha256 = "eccb4509a820204b80260bde9f5d6ec989d5dd12fdc96fc480bd39c7ff5596d6", - url = "https://github.com/bazel-ios/rules_ios/releases/download/4.4.0/rules_ios.4.4.0.tar.gz", -) - -load( - "@build_bazel_rules_ios//rules:repositories.bzl", - "rules_ios_dependencies" -) - -rules_ios_dependencies() - -load( - "@build_bazel_rules_apple//apple:repositories.bzl", - "apple_rules_dependencies", -) - -apple_rules_dependencies() - -load( - "@build_bazel_rules_swift//swift:repositories.bzl", - "swift_rules_dependencies", -) - -swift_rules_dependencies() - -load( - "@build_bazel_rules_swift//swift:extras.bzl", - "swift_rules_extra_dependencies", -) - -swift_rules_extra_dependencies() - -load( - "@build_bazel_apple_support//lib:repositories.bzl", - "apple_support_dependencies", -) - -apple_support_dependencies() - -load("//:repositories.bzl", "bazelpods_dependencies", "bazelpodstests_dependencies") - -bazelpods_dependencies() -bazelpodstests_dependencies() - -http_archive( - name = "rules_xcodeproj", - sha256 = "c0af6503ac649300d2908fab69d4384edda841eaca984d2bb6e7abc59e2f11c6", - url = "https://github.com/MobileNativeFoundation/rules_xcodeproj/releases/download/2.2.0/release.tar.gz", -) - -load( - "@rules_xcodeproj//xcodeproj:repositories.bzl", - "xcodeproj_rules_dependencies", -) - -xcodeproj_rules_dependencies() - -load("@bazel_features//:deps.bzl", "bazel_features_deps") - -bazel_features_deps() \ No newline at end of file diff --git a/repositories.bzl b/repositories.bzl index bf32b95..e537af0 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -8,7 +8,7 @@ load( "http_archive" ) -NAMESPACE_PREFIX = "bazelpods-" +NAMESPACE_PREFIX = "bazelpods_" def namespaced_name(name): if name.startswith("@"): @@ -41,8 +41,7 @@ def namespaced_http_archive(name, **kwargs): def namespaced_build_file(libs): return """ package(default_visibility = ["//visibility:public"]) -load("@build_bazel_rules_swift//swift:swift.bzl", "swift_c_module", -"swift_library") +load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") """ + "\n\n".join(libs) def namespaced_swift_library(name, srcs, deps = None, defines = None, copts=[]): @@ -56,6 +55,7 @@ swift_library( deps = [{deps}], defines = [{defines}], copts = ["-DSWIFT_PACKAGE", {copts}], + visibility = ["//visibility:public"], )""".format(**dict( name = name, srcs = ",\n".join(['"%s"' % x for x in srcs]), @@ -66,7 +66,7 @@ swift_library( def bazelpods_dependencies(): namespaced_http_archive( - name = "swift-argument-parser", + name = "swift_argument_parser", url = "https://github.com/apple/swift-argument-parser/archive/refs/tags/1.3.0.tar.gz", strip_prefix = "swift-argument-parser-1.3.0", sha256 = "e5010ff37b542807346927ba68b7f06365a53cf49d36a6df13cef50d86018204", @@ -92,28 +92,6 @@ def bazelpods_dependencies(): ]) ) -def bazelpodstests_dependencies(): - namespaced_new_git_repository( - name = "SwiftCheck", - remote = "https://github.com/typelift/SwiftCheck.git", - build_file_content = namespaced_build_file([ - namespaced_swift_library( - name = "SwiftCheck", - srcs = ["Sources/**/*.swift"], - ), - ]), - commit = "077c096c3ddfc38db223ac8e525ad16ffb987138", - ) - namespaced_new_git_repository( - name = "FileCheck", - remote = "https://github.com/llvm-swift/FileCheck.git", - build_file_content = namespaced_build_file([ - namespaced_swift_library( - name = "FileCheck", - srcs = ["Sources/**/*.swift"], - ), - ]), - commit = "bd9cb30ceee1f21c02f51a7168f58471449807d8", - ) - - +non_module_deps = module_extension( + implementation = lambda _: bazelpods_dependencies() +)