Skip to content

Commit d9bd41b

Browse files
authored
Merge pull request #11571 from github/redsun82/swift-open-redirection
Swift: generalize open redirection on both platforms and rework output rewriting
2 parents 951f636 + e3502e2 commit d9bd41b

35 files changed

+394
-429
lines changed

misc/bazel/workspace.bzl

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,9 @@
11
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
3-
4-
_swift_prebuilt_version = "swift-5.7.1-RELEASE.44582.104"
5-
_swift_sha_map = {
6-
"Linux-X64": "8d94f2d75f2aa9ee8e5421318d2f07b27e095127c9be0156794a88d8e9a0f19a",
7-
"macOS-X64": "5f0550d2924e7071d006a0c9802acbd9a11f0017073e4a1eb27b7ddc4764f3f2",
8-
}
9-
10-
_swift_arch_map = {
11-
"Linux-X64": "linux",
12-
"macOS-X64": "darwin_x86_64",
13-
}
3+
load("//swift/third_party:load.bzl", load_swift_dependencies = "load_dependencies")
144

155
def codeql_workspace(repository_name = "codeql"):
16-
for repo_arch, arch in _swift_arch_map.items():
17-
sha256 = _swift_sha_map[repo_arch]
18-
19-
http_archive(
20-
name = "swift_prebuilt_%s" % arch,
21-
url = "https://github.com/dsp-testing/codeql-swift-artifacts/releases/download/%s/swift-prebuilt-%s.zip" % (
22-
_swift_prebuilt_version,
23-
repo_arch,
24-
),
25-
build_file = "@%s//swift/third_party/swift-llvm-support:BUILD.swift-prebuilt.bazel" % repository_name,
26-
sha256 = sha256,
27-
)
28-
29-
http_archive(
30-
name = "fishhook",
31-
url = "https://github.com/facebook/fishhook/archive/aadc161ac3b80db07a9908851839a17ba63a9eb1.zip",
32-
build_file = "@%s//swift/third_party/fishhook:BUILD.fishhook.bazel" % repository_name,
33-
strip_prefix = "fishhook-aadc161ac3b80db07a9908851839a17ba63a9eb1",
34-
sha256 = "9f2cdee6dcc2039d4c47d25ab5141fe0678ce6ed27ef482cab17fe9fa38a30ce",
35-
)
36-
37-
http_archive(
38-
name = "picosha2",
39-
url = "https://github.com/okdshin/PicoSHA2/archive/27fcf6979298949e8a462e16d09a0351c18fcaf2.zip",
40-
strip_prefix = "PicoSHA2-27fcf6979298949e8a462e16d09a0351c18fcaf2",
41-
build_file = "@%s//swift/third_party/picosha2:BUILD.picosha2.bazel" % repository_name,
42-
sha256 = "d6647ca45a8b7bdaf027ecb68d041b22a899a0218b7206dee755c558a2725abb",
43-
)
44-
6+
load_swift_dependencies(repository_name)
457
maybe(
468
repo_rule = http_archive,
479
name = "rules_pkg",

swift/extractor/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ swift_cc_binary(
99
"*.cpp",
1010
]),
1111
deps = [
12+
"//swift/extractor/config",
1213
"//swift/extractor/infra",
1314
"//swift/extractor/invocation",
1415
"//swift/extractor/remapping",

swift/extractor/SwiftExtractor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "swift/extractor/SwiftExtractorConfiguration.h"
3+
#include "swift/extractor/config/SwiftExtractorConfiguration.h"
44
#include <swift/AST/SourceFile.h>
55
#include <swift/Frontend/Frontend.h>
66
#include <memory>

swift/extractor/TargetTrapFile.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ std::optional<TargetFile> createTargetTrapFile(const SwiftExtractorConfiguration
1111
for (const auto& opt : configuration.frontendOptions) {
1212
*ret << " " << std::quoted(opt) << " \\\n";
1313
}
14-
*ret << "\n*/\n"
15-
"/* swift-frontend-args:\n";
16-
for (const auto& opt : configuration.patchedFrontendOptions) {
17-
*ret << " " << std::quoted(opt) << " \\\n";
18-
}
1914
*ret << "\n*/\n";
2015
}
2116
return ret;

swift/extractor/TargetTrapFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include "swift/extractor/infra/file/TargetFile.h"
4-
#include "swift/extractor/SwiftExtractorConfiguration.h"
4+
#include "swift/extractor/config/SwiftExtractorConfiguration.h"
55

66
namespace codeql {
77

swift/extractor/config/BUILD.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
load("//swift:rules.bzl", "swift_cc_library")
2+
3+
swift_cc_library(
4+
name = "config",
5+
srcs = glob(["*.cpp"]),
6+
hdrs = glob(["*.h"]),
7+
visibility = ["//swift:__subpackages__"],
8+
)

swift/extractor/SwiftExtractorConfiguration.h renamed to swift/extractor/config/SwiftExtractorConfiguration.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ struct SwiftExtractorConfiguration {
1717
std::filesystem::path scratchDir;
1818

1919
// The original arguments passed to the extractor. Used for debugging.
20-
std::vector<std::string> frontendOptions;
21-
// The patched arguments passed to the swift::performFrontend/ Used for debugging.
22-
std::vector<std::string> patchedFrontendOptions;
20+
std::vector<const char*> frontendOptions;
2321

2422
// A temporary directory that contains TRAP files before they are moved into their final
2523
// destination.

swift/extractor/extractor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
if [[ "$(uname)" == Darwin ]]; then
4-
export DYLD_FALLBACK_LIBRARY_PATH=$(dirname "$0")
4+
export DYLD_LIBRARY_PATH=$(dirname "$0")
55
else
66
export LD_LIBRARY_PATH=$(dirname "$0")
77
fi

swift/extractor/infra/file/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ swift_cc_library(
55
srcs = glob(["*.cpp"]),
66
hdrs = glob(["*.h"]) + [":path_hash_workaround"],
77
visibility = ["//swift:__subpackages__"],
8-
deps = ["@picosha2"],
98
)
109

1110
genrule(

swift/extractor/infra/file/FileHash.cpp

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)