Compare commits

...

23 Commits

Author SHA1 Message Date
Paolo Tranquilli
2590d8a27f Merge branch 'main' into redsun82/go 2024-04-30 11:00:27 +02:00
Paolo Tranquilli
cb85a756a0 Bazel: patch apple_support to avoid registering its toolchain
This is done in order to avoid requiring a full Xcode installation, but
still being able to use other `apple_support` facilities, like
`universal_binary`.
2024-04-29 13:42:05 +02:00
Paolo Tranquilli
e7886d0e57 Bazel: add empty registry override 2024-04-29 13:39:30 +02:00
Paolo Tranquilli
15bb846a5f Go: add workaround for extractor pack windows installer 2024-04-29 12:17:47 +02:00
Paolo Tranquilli
1f78882cdc Go: make windows checks happy 2024-04-29 11:27:16 +02:00
Paolo Tranquilli
f0f6c229f6 Go: fix regex in action for macOS 2024-04-29 11:16:30 +02:00
Paolo Tranquilli
2f6dd2ab81 Go: refactor workflows with shared action 2024-04-29 11:12:48 +02:00
Paolo Tranquilli
6ec223c515 Go: small cleanup in Makefile 2024-04-29 11:00:21 +02:00
Paolo Tranquilli
0dfd336729 Go: fix //go:gen on windows 2024-04-29 10:34:22 +02:00
Paolo Tranquilli
b0758fd109 Go: workaround for gazelle on macOS
See https://github.com/bazelbuild/bazel-gazelle/issues/1793 for details.
2024-04-29 10:29:53 +02:00
Paolo Tranquilli
d66494dcb0 Go: update go-tests-other-os.yml 2024-04-26 17:03:56 +02:00
Paolo Tranquilli
86d6b8ef21 Go: put back go setup 2024-04-26 16:54:14 +02:00
Paolo Tranquilli
0f387eeac2 Go: add vendor update to //go:gen 2024-04-26 16:31:04 +02:00
Paolo Tranquilli
d98ccdfa06 Go: update workflow 2024-04-26 16:02:22 +02:00
Paolo Tranquilli
c8b02241af Merge branch 'main' into redsun82/go 2024-04-26 15:59:17 +02:00
Paolo Tranquilli
146d84bbf8 Go: rework makefile 2024-04-26 15:20:33 +02:00
Paolo Tranquilli
bfa189e2ac Go: use a dbscheme generated during the build in extractor-pack 2024-04-26 13:48:44 +02:00
Paolo Tranquilli
19b2e56d02 Go: group BUILD and dbscheme generation target 2024-04-26 13:38:10 +02:00
Paolo Tranquilli
925a2cca7e Go: create whole extractor pack with bazel 2024-04-26 12:01:23 +02:00
Paolo Tranquilli
3ad9c026a5 Go: remove go_sdk.host
It's not required, and it can't work from the internal repository.
2024-04-26 11:20:47 +02:00
Paolo Tranquilli
7d9a68bf17 Go: wrap gazelle to regenerate from scratch and add header 2024-04-26 11:19:22 +02:00
Paolo Tranquilli
4ca8faa9c9 Go: introduce universal binaries on macOS 2024-04-25 09:27:59 +02:00
Paolo Tranquilli
393f6b7666 Go: add gazelle-generated BUILD files 2024-04-25 08:53:26 +02:00
55 changed files with 1106 additions and 192 deletions

View File

@@ -7,8 +7,6 @@ on:
- .github/workflows/go-tests-other-os.yml
- .github/actions/**
- codeql-workspace.yml
env:
GO_VERSION: '~1.22.0'
permissions:
contents: read
@@ -18,72 +16,17 @@ jobs:
name: Test MacOS
runs-on: macos-latest
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
id: go
- name: Check out code
uses: actions/checkout@v4
- name: Set up CodeQL CLI
uses: ./.github/actions/fetch-codeql
- name: Enable problem matchers in repository
shell: bash
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
- name: Build
run: |
cd go
make
- name: Cache compilation cache
id: query-cache
uses: ./.github/actions/cache-query-compilation
with:
key: go-qltest
- name: Test
run: |
cd go
make test cache="${{ steps.query-cache.outputs.cache-dir }}"
- name: Run tests
uses: ./go/actions/test
test-win:
if: github.repository_owner == 'github'
name: Test Windows
runs-on: windows-latest-xl
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
id: go
- name: Check out code
uses: actions/checkout@v4
- name: Set up CodeQL CLI
uses: ./.github/actions/fetch-codeql
- name: Enable problem matchers in repository
shell: bash
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
- name: Build
run: |
cd go
make
- name: Cache compilation cache
id: query-cache
uses: ./.github/actions/cache-query-compilation
with:
key: go-qltest
- name: Test
run: |
cd go
make test cache="${{ steps.query-cache.outputs.cache-dir }}"
- name: Run tests
uses: ./go/actions/test

View File

@@ -16,9 +16,6 @@ on:
- .github/actions/**
- codeql-workspace.yml
env:
GO_VERSION: '~1.22.0'
permissions:
contents: read
@@ -28,51 +25,9 @@ jobs:
name: Test Linux (Ubuntu)
runs-on: ubuntu-latest-xl
steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
id: go
- name: Check out code
uses: actions/checkout@v4
- name: Set up CodeQL CLI
uses: ./.github/actions/fetch-codeql
- name: Enable problem matchers in repository
shell: bash
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
- name: Build
run: |
cd go
make
- name: Check that all Go code is autoformatted
run: |
cd go
make check-formatting
- name: Compile qhelp files to markdown
run: |
cd go
env QHELP_OUT_DIR=qhelp-out make qhelp-to-markdown
- name: Upload qhelp markdown
uses: actions/upload-artifact@v3
- name: Run tests
uses: ./go/actions/test
with:
name: qhelp-markdown
path: go/qhelp-out/**/*.md
- name: Cache compilation cache
id: query-cache
uses: ./.github/actions/cache-query-compilation
with:
key: go-qltest
- name: Test
run: |
cd go
make test cache="${{ steps.query-cache.outputs.cache-dir }}"
run-code-checks: true

View File

@@ -29,6 +29,13 @@ repos:
entry: bazel run //:buildifier
pass_filenames: false
- id: go-gen
name: Check checked in generated files in go
files: go/.*
language: system
entry: bazel run //go:gen
pass_filenames: false
- id: codeql-format
name: Fix QL file formatting
files: \.qll?$

View File

@@ -13,7 +13,9 @@ local_path_override(
# see https://registry.bazel.build/ for a list of available packages
bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "apple_support", version = "1.15.1-codeql.1")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "rules_go", version = "0.47.0")
bazel_dep(name = "rules_pkg", version = "0.10.1")
bazel_dep(name = "rules_nodejs", version = "6.0.3")
bazel_dep(name = "rules_python", version = "0.31.0")
@@ -21,6 +23,7 @@ bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "abseil-cpp", version = "20240116.0", repo_name = "absl")
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
bazel_dep(name = "fmt", version = "10.0.0")
bazel_dep(name = "gazelle", version = "0.36.0")
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
@@ -52,6 +55,13 @@ node.toolchain(
)
use_repo(node, "nodejs", "nodejs_toolchains")
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.22.2") # default
# following is needed for gazelle on macOS
# see https://github.com/bazelbuild/bazel-gazelle/issues/1793
go_sdk.download(version = "1.21.9")
register_toolchains(
"@nodejs_toolchains//:all",
)

132
go/BUILD.bazel Normal file
View File

@@ -0,0 +1,132 @@
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
load("@gazelle//:def.bzl", "gazelle")
load("@rules_go//go:def.bzl", "go_cross_binary")
load("@rules_pkg//pkg:install.bzl", "pkg_install")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("//:defs.bzl", "codeql_platform")
# following is needed for running gazelle on macOS
# see https://github.com/bazelbuild/bazel-gazelle/issues/1793
go_cross_binary(
name = "gazelle-1.21.9",
sdk_version = "1.21.9",
target = "@gazelle//cmd/gazelle",
)
gazelle(
name = "gazelle",
extra_args = ["go/extractor"],
gazelle = select({
"@platforms//os:macos": ":gazelle-1.21.9",
"//conditions:default": "@gazelle//cmd/gazelle",
}),
)
_gen_binaries = [
"@rules_go//go",
":gazelle",
"//go/extractor/cli/go-gen-dbscheme",
]
py_binary(
name = "gen",
srcs = ["gen.py"],
args = ["$(rlocationpath %s)" % bin for bin in _gen_binaries],
data = _gen_binaries,
deps = ["@rules_python//python/runfiles"],
)
# this is an internal copy of the dbscheme to be used by extractor-pack
# this allows the extractor-pack target to be independent and up-to-date with respect to
# having run //go:gen to update the checked in files
genrule(
name = "dbscheme",
outs = ["go.dbscheme"],
cmd = "$(execpath //go/extractor/cli/go-gen-dbscheme) $@",
tools = ["//go/extractor/cli/go-gen-dbscheme"],
)
pkg_files(
name = "resources",
srcs = [
"LICENSE",
"codeql-extractor.yml",
"ql/lib/go.dbscheme.stats",
":dbscheme",
],
)
pkg_filegroup(
name = "extractor-pack-generic",
srcs = [
":resources",
"//go/codeql-tools",
"//go/downgrades",
"//go/extractor:tokenizer",
],
visibility = ["//visibility:public"],
)
pkg_files(
name = "extractor-pack-arch",
srcs = [
"//go/extractor/cli/go-autobuilder",
"//go/extractor/cli/go-bootstrap",
"//go/extractor/cli/go-build-runner",
"//go/extractor/cli/go-extractor",
"//go/extractor/cli/go-gen-dbscheme",
"//go/extractor/cli/go-tokenizer",
],
attributes = pkg_attributes(mode = "0755"),
prefix = "tools/" + codeql_platform,
visibility = ["//visibility:public"],
)
pkg_filegroup(
name = "extractor-pack",
srcs = [
":extractor-pack-arch",
":extractor-pack-generic",
],
visibility = ["//visibility:public"],
)
pkg_install(
name = "_extractor-pack-installer",
srcs = [":extractor-pack"],
)
# rules_pkg installer is currently broken on Windows
# see https://github.com/bazelbuild/rules_pkg/issues/387
# for now, work around it using an archive
pkg_zip(
name = "_extractor-pack-zip",
srcs = [":extractor-pack"],
)
alias(
name = "_create-extractor-pack-arg",
actual = select({
"@platforms//os:windows": ":_extractor-pack-zip",
"//conditions:default": ":_extractor-pack-installer",
}),
)
py_binary(
name = "create-extractor-pack",
srcs = ["create_extractor_pack.py"],
args = ["$(rlocationpath :_create-extractor-pack-arg)"],
data = [":_create-extractor-pack-arg"],
main = "create_extractor_pack.py",
deps = ["@rules_python//python/runfiles"],
)
native_binary(
name = "gen-dbscheme",
src = "//go/extractor/cli/go-gen-dbscheme",
out = "go-gen-dbscheme",
args = [
"$$BUILD_WORKSPACE_DIRECTORY/go/ql/lib/go.dbscheme",
],
)

View File

@@ -1,30 +1,10 @@
all: extractor ql/lib/go.dbscheme
ifeq ($(OS),Windows_NT)
EXE = .exe
CODEQL_PLATFORM = win64
else
EXE =
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CODEQL_PLATFORM = linux64
endif
ifeq ($(UNAME_S),Darwin)
CODEQL_PLATFORM = osx64
endif
endif
CODEQL_TOOLS = $(addprefix codeql-tools/,autobuild.cmd autobuild.sh baseline-config-empty.json baseline-config-vendor.json configure-baseline.cmd configure-baseline.sh identify-environment.cmd identify-environment.sh index.cmd index.sh pre-finalize.cmd pre-finalize.sh tracing-config.lua)
all: gen extractor
EXTRACTOR_PACK_OUT = build/codeql-extractor-go
BINARIES = go-extractor go-tokenizer go-autobuilder go-build-runner go-bootstrap go-gen-dbscheme
.PHONY: tools tools-codeql tools-codeql-full clean autoformat \
tools-linux64 tools-osx64 tools-win64 check-formatting
.PHONY: extractor gen clean autoformat check-formatting
clean:
rm -rf tools/bin tools/linux64 tools/osx64 tools/win64 tools/net tools/opencsv
rm -rf $(EXTRACTOR_PACK_OUT) build/stats build/testdb
autoformat:
@@ -47,66 +27,11 @@ endif
qhelp-to-markdown:
scripts/qhelp-to-markdown.sh ql/src "$(QHELP_OUT_DIR)"
tools: tools-codeql tools/tokenizer.jar
extractor:
bazel run :create-extractor-pack
.PHONY: $(addsuffix $(EXE),$(addprefix tools/bin/,$(BINARIES)))
$(addsuffix $(EXE),$(addprefix tools/bin/,$(BINARIES))):
go build -C extractor -mod=vendor -o ../$@ ./cli/$(basename $(@F))
tools-codeql: tools-$(CODEQL_PLATFORM)
tools-codeql-full: tools-linux64 tools-osx64 tools-win64
tools-linux64: $(addprefix tools/linux64/,$(BINARIES))
.PHONY: $(addprefix tools/linux64/,$(BINARIES))
$(addprefix tools/linux64/,$(BINARIES)):
GOOS=linux GOARCH=amd64 go build -C extractor -mod=vendor -o ../$@ ./cli/$(@F)
tools-osx64: $(addprefix tools/osx64/,$(BINARIES))
.PHONY: $(addprefix tools/osx64/,$(BINARIES))
$(addprefix tools/osx64/,$(BINARIES)):
GOOS=darwin GOARCH=amd64 go build -C extractor -mod=vendor -o ../$@.amd64 ./cli/$(@F)
GOOS=darwin GOARCH=arm64 go build -C extractor -mod=vendor -o ../$@.arm64 ./cli/$(@F)
lipo -create $@.amd64 $@.arm64 -output $@
rm $@.amd64 $@.arm64
tools-win64: $(addsuffix .exe,$(addprefix tools/win64/,$(BINARIES)))
.PHONY: $(addsuffix .exe,$(addprefix tools/win64/,$(BINARIES)))
$(addsuffix .exe,$(addprefix tools/win64/,$(BINARIES))):
env GOOS=windows GOARCH=amd64 go build -C extractor -mod=vendor -o ../$@ ./cli/$(basename $(@F))
.PHONY: extractor-common extractor extractor-full
extractor-common: codeql-extractor.yml LICENSE ql/lib/go.dbscheme \
tools/tokenizer.jar $(CODEQL_TOOLS)
rm -rf $(EXTRACTOR_PACK_OUT)
mkdir -p $(EXTRACTOR_PACK_OUT)
cp codeql-extractor.yml LICENSE ql/lib/go.dbscheme ql/lib/go.dbscheme.stats $(EXTRACTOR_PACK_OUT)
mkdir $(EXTRACTOR_PACK_OUT)/tools
cp -r tools/tokenizer.jar $(CODEQL_TOOLS) $(EXTRACTOR_PACK_OUT)/tools
cp -r downgrades $(EXTRACTOR_PACK_OUT)
extractor: extractor-common tools-codeql
cp -r tools/$(CODEQL_PLATFORM) $(EXTRACTOR_PACK_OUT)/tools
extractor-full: extractor-common tools-codeql-full
cp -r $(addprefix tools/,linux64 osx64 win64) $(EXTRACTOR_PACK_OUT)/tools
tools/tokenizer.jar: tools/net/sourceforge/pmd/cpd/GoLanguage.class
jar cf $@ -C tools net
jar uf $@ -C tools opencsv
tools/net/sourceforge/pmd/cpd/GoLanguage.class: extractor/net/sourceforge/pmd/cpd/GoLanguage.java
javac -cp extractor -d tools $<
rm tools/net/sourceforge/pmd/cpd/AbstractLanguage.class
rm tools/net/sourceforge/pmd/cpd/SourceCode.class
rm tools/net/sourceforge/pmd/cpd/TokenEntry.class
rm tools/net/sourceforge/pmd/cpd/Tokenizer.class
ql/lib/go.dbscheme: tools/$(CODEQL_PLATFORM)/go-gen-dbscheme$(EXE)
$< $@
gen:
bazel run :gen
build/stats/src.stamp:
mkdir -p $(@D)/src
@@ -123,7 +48,7 @@ test: all build/testdb/check-upgrade-path
codeql test run -j0 ql/test --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency --compilation-cache=$(cache)
# use GOOS=linux because GOOS=darwin GOARCH=386 is no longer supported
env GOOS=linux GOARCH=386 codeql$(EXE) test run -j0 ql/test/query-tests/Security/CWE-681 --search-path build/codeql-extractor-go --consistency-queries ql/test/consistency --compilation-cache=$(cache)
cd extractor; go test -mod=vendor ./...
cd extractor; bazel test ...
bash extractor-smoke-test/test.sh || (echo "Extractor smoke test FAILED"; exit 1)
.PHONY: build/testdb/check-upgrade-path

View File

@@ -0,0 +1,80 @@
name: Test go extractor
description: Run build, QL tests and optionally basic code sanity checks (formatting and generation)
inputs:
run-code-checks:
description: Whether to run formatting, code and qhelp generation checks
required: false
default: false
runs:
using: composite
steps:
- name: Get go version
shell: bash
run: |
(
echo -n "GO_VERSION="
bazel run @rules_go//go -- version | sed 's/go version go\(.*\) .*/\1/'
) | tee -a "$GITHUB_ENV"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: false
id: go
- name: Set up CodeQL CLI
uses: ./.github/actions/fetch-codeql
- name: Enable problem matchers in repository
shell: bash
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
- name: Build
shell: bash
run: |
bazel run go:create-extractor-pack
- name: Check that all Go code is autoformatted
if: inputs.run-code-checks == 'true'
shell: bash
run: |
cd go
make check-formatting
- name: Check checked-in generated code
if: inputs.run-code-checks == 'true'
shell: bash
run: |
bazel run go:gen
git add .
git diff --exit-code HEAD || (
echo "please run bazel run //go:gen"
exit 1
)
- name: Compile qhelp files to markdown
if: inputs.run-code-checks == 'true'
shell: bash
run: |
cd go
env QHELP_OUT_DIR=qhelp-out make qhelp-to-markdown
- name: Upload qhelp markdown
if: inputs.run-code-checks == 'true'
uses: actions/upload-artifact@v3
with:
name: qhelp-markdown
path: go/qhelp-out/**/*.md
- name: Cache compilation cache
id: query-cache
uses: ./.github/actions/cache-query-compilation
with:
key: go-qltest
- name: Test
shell: bash
run: |
cd go
make test cache="${{ steps.query-cache.outputs.cache-dir }}"

View File

@@ -0,0 +1,28 @@
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files")
pkg_files(
name = "executables",
srcs = glob(["*.sh"]),
attributes = pkg_attributes(mode = "0755"),
)
pkg_files(
name = "non-executables",
srcs = glob(
["*"],
exclude = [
"*.sh",
"BUILD.bazel",
],
),
)
pkg_filegroup(
name = "codeql-tools",
srcs = [
":executables",
":non-executables",
],
prefix = "tools",
visibility = ["//go:__pkg__"],
)

View File

@@ -0,0 +1,26 @@
import os
import pathlib
import shutil
import sys
import subprocess
import zipfile
from python.runfiles import runfiles
try:
workspace_dir = pathlib.Path(os.environ['BUILD_WORKSPACE_DIRECTORY'])
except KeyError:
print("this should be run with bazel run", file=sys.stderr)
sys.exit(1)
dest_dir = workspace_dir / 'go' / 'build' / 'codeql-extractor-go'
installer_or_zip = pathlib.Path(runfiles.Create().Rlocation(sys.argv[1]))
shutil.rmtree(dest_dir, ignore_errors=True)
if installer_or_zip.suffix == '.zip':
dest_dir.mkdir()
with zipfile.ZipFile(installer_or_zip) as pack:
pack.extractall(dest_dir)
else:
os.environ['DESTDIR'] = str(dest_dir)
subprocess.check_call([installer_or_zip])

12
go/downgrades/BUILD.bazel Normal file
View File

@@ -0,0 +1,12 @@
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
pkg_files(
name = "downgrades",
srcs = glob(
["**"],
exclude = ["BUILD.bazel"],
),
prefix = "downgrades",
strip_prefix = strip_prefix.from_pkg(),
visibility = ["//go:__pkg__"],
)

1
go/extractor/.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
/*/**/BUILD.bazel linguist-generated=true

55
go/extractor/BUILD.bazel Normal file
View File

@@ -0,0 +1,55 @@
load("@rules_go//go:def.bzl", "go_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
# gazelle:prefix github.com/github/codeql-go/extractor
# gazelle:map_kind go_binary codeql_go_binary //go:rules.bzl
go_library(
name = "extractor",
srcs = [
"extractor.go",
"gomodextractor.go",
"semaphore.go",
],
importpath = "github.com/github/codeql-go/extractor",
visibility = ["//visibility:public"],
deps = [
"//go/extractor/dbscheme",
"//go/extractor/diagnostics",
"//go/extractor/srcarchive",
"//go/extractor/trap",
"//go/extractor/util",
"//go/extractor/vendor/golang.org/x/mod/modfile",
"//go/extractor/vendor/golang.org/x/tools/go/packages",
],
)
java_library(
name = "tokenizer-deps",
srcs = [
"net/sourceforge/pmd/cpd/AbstractLanguage.java",
"net/sourceforge/pmd/cpd/SourceCode.java",
"net/sourceforge/pmd/cpd/TokenEntry.java",
"net/sourceforge/pmd/cpd/Tokenizer.java",
],
)
java_library(
name = "tokenizer-jar",
srcs = [
"net/sourceforge/pmd/cpd/GoLanguage.java",
"opencsv/CSVParser.java",
"opencsv/CSVReader.java",
],
deps = [":tokenizer-deps"],
)
pkg_files(
name = "tokenizer",
srcs = [":tokenizer-jar"],
prefix = "tools",
renames = {
":tokenizer-jar": "tokenizer.jar",
},
visibility = ["//go:__pkg__"],
)

26
go/extractor/autobuilder/BUILD.bazel generated Normal file
View File

@@ -0,0 +1,26 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "autobuilder",
srcs = [
"autobuilder.go",
"build-environment.go",
],
importpath = "github.com/github/codeql-go/extractor/autobuilder",
visibility = ["//visibility:public"],
deps = [
"//go/extractor/diagnostics",
"//go/extractor/project",
"//go/extractor/toolchain",
"//go/extractor/util",
"//go/extractor/vendor/golang.org/x/mod/semver",
],
)
go_test(
name = "autobuilder_test",
srcs = ["build-environment_test.go"],
embed = [":autobuilder"],
)

View File

@@ -0,0 +1,25 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
load("//go:rules.bzl", "codeql_go_binary")
go_library(
name = "go-autobuilder_lib",
srcs = ["go-autobuilder.go"],
importpath = "github.com/github/codeql-go/extractor/cli/go-autobuilder",
visibility = ["//visibility:private"],
deps = [
"//go/extractor/autobuilder",
"//go/extractor/diagnostics",
"//go/extractor/project",
"//go/extractor/toolchain",
"//go/extractor/util",
"//go/extractor/vendor/golang.org/x/mod/semver",
],
)
codeql_go_binary(
name = "go-autobuilder",
embed = [":go-autobuilder_lib"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,17 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
load("//go:rules.bzl", "codeql_go_binary")
go_library(
name = "go-bootstrap_lib",
srcs = ["go-bootstrap.go"],
importpath = "github.com/github/codeql-go/extractor/cli/go-bootstrap",
visibility = ["//visibility:private"],
)
codeql_go_binary(
name = "go-bootstrap",
embed = [":go-bootstrap_lib"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,21 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
load("//go:rules.bzl", "codeql_go_binary")
go_library(
name = "go-build-runner_lib",
srcs = ["go-build-runner.go"],
importpath = "github.com/github/codeql-go/extractor/cli/go-build-runner",
visibility = ["//visibility:private"],
deps = [
"//go/extractor/autobuilder",
"//go/extractor/util",
],
)
codeql_go_binary(
name = "go-build-runner",
embed = [":go-build-runner_lib"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,21 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
load("//go:rules.bzl", "codeql_go_binary")
go_library(
name = "go-extractor_lib",
srcs = ["go-extractor.go"],
importpath = "github.com/github/codeql-go/extractor/cli/go-extractor",
visibility = ["//visibility:private"],
deps = [
"//go/extractor",
"//go/extractor/diagnostics",
],
)
codeql_go_binary(
name = "go-extractor",
embed = [":go-extractor_lib"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,18 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
load("//go:rules.bzl", "codeql_go_binary")
go_library(
name = "go-gen-dbscheme_lib",
srcs = ["go-gen-dbscheme.go"],
importpath = "github.com/github/codeql-go/extractor/cli/go-gen-dbscheme",
visibility = ["//visibility:private"],
deps = ["//go/extractor/dbscheme"],
)
codeql_go_binary(
name = "go-gen-dbscheme",
embed = [":go-gen-dbscheme_lib"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,17 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
load("//go:rules.bzl", "codeql_go_binary")
go_library(
name = "go-tokenizer_lib",
srcs = ["go-tokenizer.go"],
importpath = "github.com/github/codeql-go/extractor/cli/go-tokenizer",
visibility = ["//visibility:private"],
)
codeql_go_binary(
name = "go-tokenizer",
embed = [":go-tokenizer_lib"],
visibility = ["//visibility:public"],
)

17
go/extractor/dbscheme/BUILD.bazel generated Normal file
View File

@@ -0,0 +1,17 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "dbscheme",
srcs = [
"dbscheme.go",
"tables.go",
],
importpath = "github.com/github/codeql-go/extractor/dbscheme",
visibility = ["//visibility:public"],
deps = [
"//go/extractor/trap",
"//go/extractor/vendor/golang.org/x/tools/go/packages",
],
)

10
go/extractor/diagnostics/BUILD.bazel generated Normal file
View File

@@ -0,0 +1,10 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "diagnostics",
srcs = ["diagnostics.go"],
importpath = "github.com/github/codeql-go/extractor/diagnostics",
visibility = ["//visibility:public"],
)

24
go/extractor/project/BUILD.bazel generated Normal file
View File

@@ -0,0 +1,24 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "project",
srcs = ["project.go"],
importpath = "github.com/github/codeql-go/extractor/project",
visibility = ["//visibility:public"],
deps = [
"//go/extractor/diagnostics",
"//go/extractor/toolchain",
"//go/extractor/util",
"//go/extractor/vendor/golang.org/x/mod/modfile",
"//go/extractor/vendor/golang.org/x/mod/semver",
],
)
go_test(
name = "project_test",
srcs = ["project_test.go"],
embed = [":project"],
deps = ["//go/extractor/vendor/golang.org/x/mod/modfile"],
)

19
go/extractor/srcarchive/BUILD.bazel generated Normal file
View File

@@ -0,0 +1,19 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "srcarchive",
srcs = [
"projectlayout.go",
"srcarchive.go",
],
importpath = "github.com/github/codeql-go/extractor/srcarchive",
visibility = ["//visibility:public"],
)
go_test(
name = "srcarchive_test",
srcs = ["projectlayout_test.go"],
embed = [":srcarchive"],
)

20
go/extractor/toolchain/BUILD.bazel generated Normal file
View File

@@ -0,0 +1,20 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "toolchain",
srcs = ["toolchain.go"],
importpath = "github.com/github/codeql-go/extractor/toolchain",
visibility = ["//visibility:public"],
deps = [
"//go/extractor/util",
"//go/extractor/vendor/golang.org/x/mod/semver",
],
)
go_test(
name = "toolchain_test",
srcs = ["toolchain_test.go"],
embed = [":toolchain"],
)

25
go/extractor/trap/BUILD.bazel generated Normal file
View File

@@ -0,0 +1,25 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "trap",
srcs = [
"labels.go",
"trapwriter.go",
"util.go",
],
importpath = "github.com/github/codeql-go/extractor/trap",
visibility = ["//visibility:public"],
deps = [
"//go/extractor/srcarchive",
"//go/extractor/util",
"//go/extractor/vendor/golang.org/x/tools/go/packages",
],
)
go_test(
name = "trap_test",
srcs = ["trapwriter_test.go"],
embed = [":trap"],
)

16
go/extractor/util/BUILD.bazel generated Normal file
View File

@@ -0,0 +1,16 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "util",
srcs = ["util.go"],
importpath = "github.com/github/codeql-go/extractor/util",
visibility = ["//visibility:public"],
)
go_test(
name = "util_test",
srcs = ["util_test.go"],
embed = [":util"],
)

View File

@@ -0,0 +1,11 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "lazyregexp",
srcs = ["lazyre.go"],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/mod/internal/lazyregexp",
importpath = "golang.org/x/mod/internal/lazyregexp",
visibility = ["//go/extractor/vendor/golang.org/x/mod:__subpackages__"],
)

View File

@@ -0,0 +1,21 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "modfile",
srcs = [
"print.go",
"read.go",
"rule.go",
"work.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/mod/modfile",
importpath = "golang.org/x/mod/modfile",
visibility = ["//visibility:public"],
deps = [
"//go/extractor/vendor/golang.org/x/mod/internal/lazyregexp",
"//go/extractor/vendor/golang.org/x/mod/module",
"//go/extractor/vendor/golang.org/x/mod/semver",
],
)

View File

@@ -0,0 +1,18 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "module",
srcs = [
"module.go",
"pseudo.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/mod/module",
importpath = "golang.org/x/mod/module",
visibility = ["//visibility:public"],
deps = [
"//go/extractor/vendor/golang.org/x/mod/internal/lazyregexp",
"//go/extractor/vendor/golang.org/x/mod/semver",
],
)

View File

@@ -0,0 +1,11 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "semver",
srcs = ["semver.go"],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/mod/semver",
importpath = "golang.org/x/mod/semver",
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,15 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "gcexportdata",
srcs = [
"gcexportdata.go",
"importer.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/go/gcexportdata",
importpath = "golang.org/x/tools/go/gcexportdata",
visibility = ["//visibility:public"],
deps = ["//go/extractor/vendor/golang.org/x/tools/internal/gcimporter"],
)

View File

@@ -0,0 +1,12 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "packagesdriver",
srcs = ["sizes.go"],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/go/internal/packagesdriver",
importpath = "golang.org/x/tools/go/internal/packagesdriver",
visibility = ["//go/extractor/vendor/golang.org/x/tools/go:__subpackages__"],
deps = ["//go/extractor/vendor/golang.org/x/tools/internal/gocommand"],
)

View File

@@ -0,0 +1,27 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "packages",
srcs = [
"doc.go",
"external.go",
"golist.go",
"golist_overlay.go",
"loadmode_string.go",
"packages.go",
"visit.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/go/packages",
importpath = "golang.org/x/tools/go/packages",
visibility = ["//visibility:public"],
deps = [
"//go/extractor/vendor/golang.org/x/tools/go/gcexportdata",
"//go/extractor/vendor/golang.org/x/tools/go/internal/packagesdriver",
"//go/extractor/vendor/golang.org/x/tools/internal/gocommand",
"//go/extractor/vendor/golang.org/x/tools/internal/packagesinternal",
"//go/extractor/vendor/golang.org/x/tools/internal/typesinternal",
"//go/extractor/vendor/golang.org/x/tools/internal/versions",
],
)

View File

@@ -0,0 +1,12 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "objectpath",
srcs = ["objectpath.go"],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/go/types/objectpath",
importpath = "golang.org/x/tools/go/types/objectpath",
visibility = ["//visibility:public"],
deps = ["//go/extractor/vendor/golang.org/x/tools/internal/typeparams"],
)

View File

@@ -0,0 +1,19 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "event",
srcs = [
"doc.go",
"event.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/event",
importpath = "golang.org/x/tools/internal/event",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
deps = [
"//go/extractor/vendor/golang.org/x/tools/internal/event/core",
"//go/extractor/vendor/golang.org/x/tools/internal/event/keys",
"//go/extractor/vendor/golang.org/x/tools/internal/event/label",
],
)

View File

@@ -0,0 +1,19 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "core",
srcs = [
"event.go",
"export.go",
"fast.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/event/core",
importpath = "golang.org/x/tools/internal/event/core",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
deps = [
"//go/extractor/vendor/golang.org/x/tools/internal/event/keys",
"//go/extractor/vendor/golang.org/x/tools/internal/event/label",
],
)

View File

@@ -0,0 +1,16 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "keys",
srcs = [
"keys.go",
"standard.go",
"util.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/event/keys",
importpath = "golang.org/x/tools/internal/event/keys",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
deps = ["//go/extractor/vendor/golang.org/x/tools/internal/event/label"],
)

View File

@@ -0,0 +1,11 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "label",
srcs = ["label.go"],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/event/label",
importpath = "golang.org/x/tools/internal/event/label",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
)

View File

@@ -0,0 +1,12 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "tag",
srcs = ["tag.go"],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/event/tag",
importpath = "golang.org/x/tools/internal/event/tag",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
deps = ["//go/extractor/vendor/golang.org/x/tools/internal/event/keys"],
)

View File

@@ -0,0 +1,29 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "gcimporter",
srcs = [
"bimport.go",
"exportdata.go",
"gcimporter.go",
"iexport.go",
"iimport.go",
"newInterface10.go",
"newInterface11.go",
"support_go117.go",
"support_go118.go",
"unified_no.go",
"ureader_no.go",
"ureader_yes.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/gcimporter",
importpath = "golang.org/x/tools/internal/gcimporter",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
deps = [
"//go/extractor/vendor/golang.org/x/tools/go/types/objectpath",
"//go/extractor/vendor/golang.org/x/tools/internal/pkgbits",
"//go/extractor/vendor/golang.org/x/tools/internal/tokeninternal",
],
)

View File

@@ -0,0 +1,22 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "gocommand",
srcs = [
"invoke.go",
"vendor.go",
"version.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/gocommand",
importpath = "golang.org/x/tools/internal/gocommand",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
deps = [
"//go/extractor/vendor/golang.org/x/mod/semver",
"//go/extractor/vendor/golang.org/x/tools/internal/event",
"//go/extractor/vendor/golang.org/x/tools/internal/event/keys",
"//go/extractor/vendor/golang.org/x/tools/internal/event/label",
"//go/extractor/vendor/golang.org/x/tools/internal/event/tag",
],
)

View File

@@ -0,0 +1,11 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "packagesinternal",
srcs = ["packages.go"],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/packagesinternal",
importpath = "golang.org/x/tools/internal/packagesinternal",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
)

View File

@@ -0,0 +1,23 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "pkgbits",
srcs = [
"codes.go",
"decoder.go",
"doc.go",
"encoder.go",
"flags.go",
"frames_go1.go",
"frames_go17.go",
"reloc.go",
"support.go",
"sync.go",
"syncmarker_string.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/pkgbits",
importpath = "golang.org/x/tools/internal/pkgbits",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
)

View File

@@ -0,0 +1,11 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "tokeninternal",
srcs = ["tokeninternal.go"],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/tokeninternal",
importpath = "golang.org/x/tools/internal/tokeninternal",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
)

View File

@@ -0,0 +1,17 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "typeparams",
srcs = [
"common.go",
"coretype.go",
"normalize.go",
"termlist.go",
"typeterm.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/typeparams",
importpath = "golang.org/x/tools/internal/typeparams",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
)

View File

@@ -0,0 +1,16 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "typesinternal",
srcs = [
"errorcode.go",
"errorcode_string.go",
"types.go",
"types_118.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/typesinternal",
importpath = "golang.org/x/tools/internal/typesinternal",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
)

View File

@@ -0,0 +1,17 @@
# generated running `bazel run //go/gazelle`, do not edit
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "versions",
srcs = [
"gover.go",
"types.go",
"types_go121.go",
"types_go122.go",
"versions.go",
],
importmap = "github.com/github/codeql-go/extractor/vendor/golang.org/x/tools/internal/versions",
importpath = "golang.org/x/tools/internal/versions",
visibility = ["//go/extractor/vendor/golang.org/x/tools:__subpackages__"],
)

View File

@@ -1,3 +1,4 @@
## workspace
# golang.org/x/mod v0.15.0
## explicit; go 1.18
golang.org/x/mod/internal/lazyregexp

33
go/gen.py Normal file
View File

@@ -0,0 +1,33 @@
import sys
import pathlib
import subprocess
import os
from python.runfiles import runfiles
try:
workspace_dir = pathlib.Path(os.environ['BUILD_WORKSPACE_DIRECTORY'])
except KeyError:
print("this should be run with bazel run", file=sys.stderr)
sys.exit(1)
go_extractor_dir = workspace_dir / "go" / "extractor"
go_dbscheme = workspace_dir / "go" / "ql" / "lib" / "go.dbscheme"
r = runfiles.Create()
go, gazelle, go_gen_dbscheme = map(r.Rlocation, sys.argv[1:])
print("updating vendor")
subprocess.check_call([go, "-C", go_extractor_dir, "work", "vendor"])
print("clearing generated BUILD files")
for build_file in go_extractor_dir.glob("*/**/BUILD.bazel"):
build_file.unlink()
print("running gazelle")
subprocess.check_call([gazelle])
print("adding header to generated BUILD files")
for build_file in go_extractor_dir.glob("*/**/BUILD.bazel"):
contents = build_file.read_text()
build_file.write_text(f"# generated running `bazel run //go/gazelle`, do not edit\n\n{contents}")
subprocess.check_call([go_gen_dbscheme, go_dbscheme])

5
go/rules.bzl Normal file
View File

@@ -0,0 +1,5 @@
load("@rules_go//go:def.bzl", "go_binary")
load("//misc/bazel:universal_binary.bzl", "wrap_as_universal_binary")
def codeql_go_binary(**kwargs):
wrap_as_universal_binary(go_binary, **kwargs)

View File

@@ -0,0 +1,17 @@
module(
name = "apple_support",
version = "1.15.1-codeql.1",
bazel_compatibility = [">=6.0.0"],
compatibility_level = 1,
repo_name = "build_bazel_apple_support",
)
bazel_dep(name = "bazel_skylib", version = "1.3.0")
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(
name = "stardoc",
version = "0.6.2",
dev_dependency = True,
repo_name = "io_bazel_stardoc",
)

View File

@@ -0,0 +1,20 @@
diff --git a/MODULE.bazel b/MODULE.bazel
index 6b06c3b..99bc7c6 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,6 +1,6 @@
module(
name = "apple_support",
- version = "0",
+ version = "1.15.1-codeql.1",
bazel_compatibility = [">=6.0.0"],
compatibility_level = 1,
repo_name = "build_bazel_apple_support",
@@ -16,7 +16,3 @@ bazel_dep(
repo_name = "io_bazel_stardoc",
)
-apple_cc_configure = use_extension("//crosstool:setup.bzl", "apple_cc_configure_extension")
-use_repo(apple_cc_configure, "local_config_apple_cc", "local_config_apple_cc_toolchains")
-
-register_toolchains("@local_config_apple_cc_toolchains//:all")

View File

@@ -0,0 +1,9 @@
{
"integrity": "sha256-xLsrc2fEhDgjAK7nW+WYuS+EeJb7MbvSLzojRq32aoA=",
"strip_prefix": "",
"url": "https://github.com/bazelbuild/apple_support/releases/download/1.15.1/apple_support.1.15.1.tar.gz",
"patches": {
"module.patch": "sha256-K06B2W9t6nKcU8S5u6cWeNIdw/vGWWKAoJdGiI8CSS0="
},
"patch_strip": 1
}

View File

@@ -0,0 +1,5 @@
{
"versions": [
"1.15.1-codeql.1"
]
}

View File

@@ -0,0 +1,24 @@
load("@apple_support//rules:universal_binary.bzl", _universal_binary = "universal_binary")
def wrap_as_universal_binary(rule, *, name, visibility = None, **kwargs):
internal_name = "internal/%s" % name
universal_name = "universal/%s" % name
rule(
name = internal_name,
visibility = ["//visibility:private"],
**kwargs
)
_universal_binary(
name = universal_name,
target_compatible_with = ["@platforms//os:macos"],
binary = internal_name,
visibility = ["//visibility:private"],
)
native.alias(
name = name,
actual = select({
"@platforms//os:macos": universal_name,
"//conditions:default": internal_name,
}),
visibility = visibility,
)