diff --git a/BUILD.bazel b/BUILD.bazel index ad7bf190..13d175e5 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -7,3 +7,35 @@ gazelle( name = "gazelle", mode = "fix", ) + +config_setting( + name = "linux_arm64", + constraint_values = [ + "@platforms//cpu:arm64", + "@platforms//os:linux", + ], +) + +config_setting( + name = "linux_x86_64", + constraint_values = [ + "@platforms//cpu:x86_64", + "@platforms//os:linux", + ], +) + +config_setting( + name = "macos_arm64", + constraint_values = [ + "@platforms//cpu:arm64", + "@platforms//os:macos", + ], +) + +config_setting( + name = "macos_x86_64", + constraint_values = [ + "@platforms//cpu:x86_64", + "@platforms//os:macos", + ], +) diff --git a/WORKSPACE b/WORKSPACE index ef36ea08..34f4dfe8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,4 +1,4 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") http_archive( name = "bazel_gazelle", @@ -60,8 +60,8 @@ load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") rules_jvm_external_setup() -load("@rules_jvm_external//:defs.bzl", "maven_install") load("@bazel_diff//:artifacts.bzl", "BAZEL_DIFF_MAVEN_ARTIFACTS") +load("@rules_jvm_external//:defs.bzl", "maven_install") maven_install( artifacts = [ @@ -96,21 +96,6 @@ load("@bazel_diff_maven//:defs.bzl", bazel_diff_pinned_maven_install = "pinned_m bazel_diff_pinned_maven_install() -# Pull in bazel_differ for testing -http_archive( - name = "bazel_differ", - sha256 = "c9265836bafcfe2925f6c44029191cda6d4c9267299cbe3a739d859da6b3a0d3", - strip_prefix = "bazel-differ-0.0.5", - url = "https://github.com/ewhauser/bazel-differ/archive/refs/tags/v0.0.5.tar.gz", -) - -load("@bazel_differ//:deps.bzl", bazel_differ_deps = "go_dependencies") - -# Unfortunately if we don't vendor this file into the repo, gazelle doesn't seem to properly handle its contents. -# gazelle:repository_macro third_party/go/bazel_differ_deps.bzl%go_dependencies -# gazelle:ignore -bazel_differ_deps() - http_archive( name = "rules_proto", sha256 = "b9e1268c5bce4bb01ef31730300b8a4f562dc1211088f125c39af716f6f65f60", @@ -125,3 +110,31 @@ load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_ rules_proto_dependencies() rules_proto_toolchains() + +########################################################## +# bazel-differ: https://github.com/ewhauser/bazel-differ # +########################################################## + +http_file( + name = "bazel_differ_linux_arm64", + sha256 = "7a7166aa526c3688b9fb71dfc8913c35902d4a440a32ff02db55e7b91a97f666", + url = "https://github.com/ewhauser/bazel-differ/releases/download/v0.0.5/bazel-differ-linux-arm64", +) + +http_file( + name = "bazel_differ_linux_x86_64", + sha256 = "ce563301a22f41cc111f2966fc77a23e655fbe1140d93b33eb4818f06c40a8d5", + url = "https://github.com/ewhauser/bazel-differ/releases/download/v0.0.5/bazel-differ-linux-x86_64", +) + +http_file( + name = "bazel_differ_darwin_arm64", + sha256 = "0bcbfecfb9788764efa63922322b3c2d5a1a9c0da26b2dd8e7565ca60960e231", + url = "https://github.com/ewhauser/bazel-differ/releases/download/v0.0.5/bazel-differ-darwin-arm64", +) + +http_file( + name = "bazel_differ_darwin_x86_64", + sha256 = "a18c17f1a5e9830dfadb5ad3df02b453882fc9ec46837e9f8450c655d2cbe214", + url = "https://github.com/ewhauser/bazel-differ/releases/download/v0.0.5/bazel-differ-darwin-x86_64", +) diff --git a/scripts/update-dependencies b/scripts/update-dependencies index dbb55a15..2c3979ec 100755 --- a/scripts/update-dependencies +++ b/scripts/update-dependencies @@ -3,9 +3,6 @@ set -eufo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" -# We don't want gazelle to update this vendored file, so we will need to undo any changes it makes. -cp "${SCRIPT_DIR}"/../third_party/go/bazel_differ_deps.bzl "${SCRIPT_DIR}"/../third_party/go/bazel_differ_deps.bzl.bak - bazel run @go_sdk//:bin/go -- mod tidy echo -e 'def go_dependencies():\n pass\n' >third_party/go/deps.bzl bazel run //:gazelle -- update-repos -from_file=go.mod -prune -to_macro "third_party/go/deps.bzl%go_dependencies" @@ -17,6 +14,4 @@ if [[ "$(uname)" == "Darwin" ]]; then fi "${sed_i[@]}" 's#load("@bazel_gazelle//:deps\.bzl", "go_repository")#load("//:third_party/go/go_repository.bzl", "go_repository")#' third_party/go/deps.bzl -mv "${SCRIPT_DIR}"/../third_party/go/bazel_differ_deps.bzl.bak "${SCRIPT_DIR}"/../third_party/go/bazel_differ_deps.bzl - "${SCRIPT_DIR}"/format diff --git a/tests/integration/java/com/github/bazel_contrib/target_determinator/integration/BUILD.bazel b/tests/integration/java/com/github/bazel_contrib/target_determinator/integration/BUILD.bazel index a6e1b6de..f1b6956b 100644 --- a/tests/integration/java/com/github/bazel_contrib/target_determinator/integration/BUILD.bazel +++ b/tests/integration/java/com/github/bazel_contrib/target_determinator/integration/BUILD.bazel @@ -1,3 +1,4 @@ +load("@bazel_skylib//rules:copy_file.bzl", "copy_file") load("@rules_jvm_external//:defs.bzl", "artifact") java_test( @@ -28,10 +29,10 @@ java_test( srcs = [ "BazelDifferIntegrationTest.java", ], - data = ["@bazel_differ//cli:bazel-differ"], + data = [":bazel-differ-binary"], env_inherit = ["CC"], jvm_flags = [ - "-Dbazel_differ=$(rootpath @bazel_differ//cli:bazel-differ)", + "-Dbazel_differ=$(rootpath :bazel-differ-binary)", ], tags = ["no-sandbox"], deps = [ @@ -120,3 +121,19 @@ java_library( artifact("org.hamcrest:hamcrest-all"), ], ) + +copy_file( + name = "bazel-differ-binary", + src = ":original-bazel-differ", + out = "bazel-differ", +) + +alias( + name = "original-bazel-differ", + actual = select({ + "//:linux_arm64": "@bazel_differ_linux_arm64//file", + "//:linux_x86_64": "@bazel_differ_linux_x86_64//file", + "//:macos_arm64": "@bazel_differ_darwin_arm64//file", + "//:macos_x86_64": "@bazel_differ_darwin_x86_64//file", + }), +) diff --git a/third_party/go/bazel_differ_deps.bzl b/third_party/go/bazel_differ_deps.bzl deleted file mode 100644 index d56d482d..00000000 --- a/third_party/go/bazel_differ_deps.bzl +++ /dev/null @@ -1,138 +0,0 @@ -# This file was manually copied from https://github.com/ewhauser/bazel-differ/blob/916e6409ae501c56ac4d6da9c0785c2ee97721b3/deps.bzl because gazelle doesn't seem to like working with dep files from remote repositories. -load("@bazel_gazelle//:deps.bzl", "go_repository") - -def go_dependencies(): - go_repository( - name = "com_github_cpuguy83_go_md2man_v2", - importpath = "github.com/cpuguy83/go-md2man/v2", - sum = "h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=", - version = "v2.0.1", - ) - - go_repository( - name = "com_github_golang_mock", - importpath = "github.com/golang/mock", - sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=", - version = "v1.6.0", - ) - go_repository( - name = "com_github_golang_protobuf", - importpath = "github.com/golang/protobuf", - sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=", - version = "v1.5.2", - ) - go_repository( - name = "com_github_google_go_cmp", - importpath = "github.com/google/go-cmp", - sum = "h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=", - version = "v0.5.5", - ) - go_repository( - name = "com_github_inconshreveable_mousetrap", - importpath = "github.com/inconshreveable/mousetrap", - sum = "h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=", - version = "v1.0.0", - ) - - go_repository( - name = "com_github_pkg_errors", - importpath = "github.com/pkg/errors", - sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=", - version = "v0.9.1", - ) - go_repository( - name = "com_github_russross_blackfriday_v2", - importpath = "github.com/russross/blackfriday/v2", - sum = "h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=", - version = "v2.1.0", - ) - go_repository( - name = "com_github_spf13_cobra", - importpath = "github.com/spf13/cobra", - sum = "h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=", - version = "v1.4.0", - ) - go_repository( - name = "com_github_spf13_pflag", - importpath = "github.com/spf13/pflag", - sum = "h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=", - version = "v1.0.5", - ) - go_repository( - name = "com_github_yuin_goldmark", - importpath = "github.com/yuin/goldmark", - sum = "h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs=", - version = "v1.3.5", - ) - go_repository( - name = "in_gopkg_check_v1", - importpath = "gopkg.in/check.v1", - sum = "h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=", - version = "v0.0.0-20161208181325-20d25e280405", - ) - go_repository( - name = "in_gopkg_yaml_v2", - importpath = "gopkg.in/yaml.v2", - sum = "h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=", - version = "v2.4.0", - ) - go_repository( - name = "org_golang_google_protobuf", - importpath = "google.golang.org/protobuf", - sum = "h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=", - version = "v1.28.0", - ) - go_repository( - name = "org_golang_x_crypto", - importpath = "golang.org/x/crypto", - sum = "h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=", - version = "v0.0.0-20191011191535-87dc89f01550", - ) - go_repository( - name = "org_golang_x_mod", - importpath = "golang.org/x/mod", - sum = "h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=", - version = "v0.4.2", - ) - go_repository( - name = "org_golang_x_net", - importpath = "golang.org/x/net", - sum = "h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=", - version = "v0.0.0-20210405180319-a5a99cb37ef4", - ) - go_repository( - name = "org_golang_x_sync", - importpath = "golang.org/x/sync", - sum = "h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=", - version = "v0.0.0-20210220032951-036812b2e83c", - ) - go_repository( - name = "org_golang_x_sys", - importpath = "golang.org/x/sys", - sum = "h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=", - version = "v0.0.0-20210510120138-977fb7262007", - ) - go_repository( - name = "org_golang_x_term", - importpath = "golang.org/x/term", - sum = "h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=", - version = "v0.0.0-20201126162022-7de9c90e9dd1", - ) - go_repository( - name = "org_golang_x_text", - importpath = "golang.org/x/text", - sum = "h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=", - version = "v0.3.3", - ) - go_repository( - name = "org_golang_x_tools", - importpath = "golang.org/x/tools", - sum = "h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs=", - version = "v0.1.1", - ) - go_repository( - name = "org_golang_x_xerrors", - importpath = "golang.org/x/xerrors", - sum = "h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=", - version = "v0.0.0-20200804184101-5ec99f83aff1", - ) diff --git a/third_party/go/deps.bzl b/third_party/go/deps.bzl index 1427b5bc..50b44423 100644 --- a/third_party/go/deps.bzl +++ b/third_party/go/deps.bzl @@ -97,6 +97,12 @@ def go_dependencies(): sum = "h1:0VruCpn7yAIIu7pWVClQC8wxCJEcG3nyzpMSHKi1PQc=", version = "v1.6.0", ) + go_repository( + name = "com_github_golang_protobuf", + importpath = "github.com/golang/protobuf", + sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=", + version = "v1.5.2", + ) go_repository( name = "com_github_golang_snappy", importpath = "github.com/golang/snappy", @@ -109,6 +115,12 @@ def go_dependencies(): sum = "h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=", version = "v1.1.2", ) + go_repository( + name = "com_github_google_go_cmp", + importpath = "github.com/google/go-cmp", + sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=", + version = "v0.5.9", + ) go_repository( name = "com_github_google_uuid", importpath = "github.com/google/uuid", @@ -241,6 +253,12 @@ def go_dependencies(): sum = "h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=", version = "v2.6.1+incompatible", ) + go_repository( + name = "com_github_pkg_errors", + importpath = "github.com/pkg/errors", + sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=", + version = "v0.9.1", + ) go_repository( name = "com_github_pmezard_go_difflib", importpath = "github.com/pmezard/go-difflib", @@ -355,18 +373,36 @@ def go_dependencies(): sum = "h1:J0GxkO96kL4WF+AIT3M4mfUVinOCPgf2uUWYFUzN0sM=", version = "v0.0.0-20190602105132-8df528c0c9ae", ) + go_repository( + name = "com_github_yuin_goldmark", + importpath = "github.com/yuin/goldmark", + sum = "h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=", + version = "v1.4.13", + ) go_repository( name = "in_gopkg_bsm_ratelimit_v1", importpath = "gopkg.in/bsm/ratelimit.v1", sum = "h1:stTHdEoWg1pQ8riaP5ROrjS6zy6wewH/Q2iwnLCQUXY=", version = "v1.0.0-20160220154919-db14e161995a", ) + go_repository( + name = "in_gopkg_check_v1", + importpath = "gopkg.in/check.v1", + sum = "h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=", + version = "v0.0.0-20161208181325-20d25e280405", + ) go_repository( name = "in_gopkg_redis_v4", importpath = "gopkg.in/redis.v4", sum = "h1:y3XbwQAiHwgNLUng56mgWYK39vsPqo8sT84XTEcxjr0=", version = "v4.2.4", ) + go_repository( + name = "in_gopkg_yaml_v2", + importpath = "gopkg.in/yaml.v2", + sum = "h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=", + version = "v2.4.0", + ) go_repository( name = "in_gopkg_yaml_v3", importpath = "gopkg.in/yaml.v3", @@ -385,15 +421,69 @@ def go_dependencies(): sum = "h1:AGJ0Ih4mHjSeibYkFGh1dD9KJ/eOtZ93I6hoHhukQ5Q=", version = "v1.40.0", ) + go_repository( + name = "org_golang_google_protobuf", + importpath = "google.golang.org/protobuf", + sum = "h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=", + version = "v1.27.1", + ) + go_repository( + name = "org_golang_x_crypto", + importpath = "golang.org/x/crypto", + sum = "h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=", + version = "v0.0.0-20210921155107-089bfa567519", + ) + go_repository( + name = "org_golang_x_mod", + importpath = "golang.org/x/mod", + sum = "h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=", + version = "v0.12.0", + ) + go_repository( + name = "org_golang_x_net", + importpath = "golang.org/x/net", + sum = "h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=", + version = "v0.10.0", + ) + go_repository( + name = "org_golang_x_sync", + importpath = "golang.org/x/sync", + sum = "h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=", + version = "v0.3.0", + ) + go_repository( + name = "org_golang_x_sys", + importpath = "golang.org/x/sys", + sum = "h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=", + version = "v0.12.0", + ) + go_repository( + name = "org_golang_x_text", + importpath = "golang.org/x/text", + sum = "h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=", + version = "v0.3.7", + ) go_repository( name = "org_golang_x_time", importpath = "golang.org/x/time", sum = "h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs=", version = "v0.0.0-20210723032227-1f47c861a9ac", ) + go_repository( + name = "org_golang_x_tools", + importpath = "golang.org/x/tools", + sum = "h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=", + version = "v0.9.1", + ) go_repository( name = "org_golang_x_tools_go_vcs", importpath = "golang.org/x/tools/go/vcs", sum = "h1:cOIJqWBl99H1dH5LWizPa+0ImeeJq3t3cJjaeOWUAL4=", version = "v0.1.0-deprecated", ) + go_repository( + name = "org_golang_x_xerrors", + importpath = "golang.org/x/xerrors", + sum = "h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=", + version = "v0.0.0-20191204190536-9bdfabe68543", + )