Skip to content

Commit

Permalink
Merge pull request #17699 from github/redsun82/swift-6
Browse files Browse the repository at this point in the history
Swift: make extractor compilable with Swift 6
  • Loading branch information
redsun82 authored Dec 13, 2024
2 parents 7925044 + 92ec7e8 commit 2cbb072
Show file tree
Hide file tree
Showing 113 changed files with 12,948 additions and 1,141 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@
/misc/ripunzip/ripunzip-* filter=lfs diff=lfs merge=lfs -text

# swift prebuilt resources
/swift/third_party/resource-dir/*.zip filter=lfs diff=lfs merge=lfs -text
/swift/third_party/resources/*.zip filter=lfs diff=lfs merge=lfs -text
/swift/third_party/resources/*.tar.zst filter=lfs diff=lfs merge=lfs -text
16 changes: 8 additions & 8 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,10 @@ jobs:
- uses: ./swift/actions/build-and-test
build-and-test-linux:
if: github.repository_owner == 'github'
runs-on: ubuntu-latest-xl
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./swift/actions/build-and-test
qltests-linux:
if: github.repository_owner == 'github'
needs: build-and-test-linux
runs-on: ubuntu-latest-xl
steps:
- uses: actions/checkout@v4
- uses: ./swift/actions/run-ql-tests
qltests-macos:
if: ${{ github.repository_owner == 'github' && github.event_name == 'pull_request' }}
needs: build-and-test-macos
Expand Down Expand Up @@ -109,3 +102,10 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/fetch-codeql
- uses: ./swift/actions/database-upgrade-scripts
check-no-override:
if : github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- shell: bash
run: bazel test //swift/... --test_tag_filters=override --test_output=errors
21 changes: 7 additions & 14 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bazel_dep(name = "gazelle", version = "0.40.0")
bazel_dep(name = "rules_dotnet", version = "0.17.4")
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
bazel_dep(name = "rules_rust", version = "0.52.2")
bazel_dep(name = "zstd", version = "1.5.5.bcr.1")

bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)

Expand Down Expand Up @@ -95,10 +96,12 @@ use_repo(
swift_deps,
"binlog",
"picosha2",
"swift_prebuilt_darwin_x86_64",
"swift_prebuilt_linux",
"swift_toolchain_linux",
"swift_toolchain_macos",
"swift-prebuilt-linux",
"swift-prebuilt-linux-download-only",
"swift-prebuilt-macos",
"swift-prebuilt-macos-download-only",
"swift-resource-dir-linux",
"swift-resource-dir-macos",
)

node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
Expand Down Expand Up @@ -190,16 +193,6 @@ lfs_files(
executable = True,
)

lfs_files(
name = "swift-resource-dir-linux",
srcs = ["//swift/third_party/resource-dir:resource-dir-linux.zip"],
)

lfs_files(
name = "swift-resource-dir-macos",
srcs = ["//swift/third_party/resource-dir:resource-dir-macos.zip"],
)

register_toolchains(
"@nodejs_toolchains//:all",
)
6 changes: 6 additions & 0 deletions misc/bazel/lfs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ def _download_lfs(repository_ctx):
)
repository_ctx.file("BUILD.bazel", build)

# this is for drop-in compatibility with `http_file`
repository_ctx.file(
"file/BUILD.bazel",
'alias(name = "file", actual = "//:%s", visibility = ["//visibility:public"])\n' % name,
)

lfs_archive = repository_rule(
doc = "Export the contents from an on-demand LFS archive. The corresponding path should be added to be ignored " +
"in `.lfsconfig`.",
Expand Down
29 changes: 1 addition & 28 deletions swift/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup")
load("//:defs.bzl", "codeql_platform")
load(
"//misc/bazel:pkg.bzl",
"codeql_pack",
Expand Down Expand Up @@ -81,7 +80,7 @@ codeql_pack(
zips = select({
"@platforms//os:windows": {},
"//conditions:default": {
"//swift/third_party/resource-dir": "resource-dir/{CODEQL_PLATFORM}",
"//swift/third_party/resources:dir": "resource-dir/{CODEQL_PLATFORM}",
},
}),
)
Expand All @@ -90,29 +89,3 @@ alias(
name = "create-extractor-pack",
actual = ":swift-installer",
)

# TODO: following rules are for internal repo backward compatibility only
alias(
name = "extractor-pack-generic",
actual = "swift-generic",
visibility = ["//visibility:public"],
)

pkg_filegroup(
name = "resource-dir",
srcs = select({
"@platforms//os:linux": ["@swift_toolchain_linux//:resource-dir-files"],
"@platforms//os:macos": ["@swift_toolchain_macos//:resource-dir-files"],
"@platforms//os:windows": [],
}),
prefix = "resource-dir/" + codeql_platform,
)

pkg_filegroup(
name = "extractor-pack-arch",
srcs = [
":resource-dir",
":swift-arch",
],
visibility = ["//visibility:public"],
)
5 changes: 5 additions & 0 deletions swift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,8 @@ In particular for breakpoints to work you might need to setup the following remo
### Thread safety

The extractor is single-threaded, and there was no effort to make anything in it thread-safe.

### Updating the swift compiler version

This can only be done with access to the internal repository at the moment. Some (incomplete) instructions are
found [here](third_party/resources/updating.md).
2 changes: 1 addition & 1 deletion swift/actions/build-and-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ runs:
if: ${{ github.event_name == 'pull_request' }}
shell: bash
run: |
bazel test //swift/...
bazel test //swift/... --test_tag_filters=-override --test_output=errors
- name: Evict bazel cache
if: ${{ github.event_name != 'pull_request' }}
shell: bash
Expand Down
Loading

0 comments on commit 2cbb072

Please sign in to comment.