-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure all non-header source files are included in
textual_hdrs
(
#259) - Include all non-header source files in the `textual_hdrs` for clang rules. This ensures that source files will be present if the code has an include for a non-header file (e.g. `#include "foo.c"`). - Add `soto_example` to confirm that a clang module with this situation builds properly. Closes #252.
- Loading branch information
Showing
19 changed files
with
7,395 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Import Shared settings | ||
import %workspace%/../../shared.bazelrc | ||
|
||
# Import CI settings. | ||
import %workspace%/../../ci.bazelrc | ||
|
||
# Try to import a local.rc file; typically, written by CI | ||
try-import %workspace%/../../local.bazelrc | ||
|
||
# The CNIOBoringSSL uses C++14 features like 'enable_if_t' macro support. | ||
# For more details on how to enable this in Bazel: | ||
# https://stackoverflow.com/questions/40260242/how-to-set-c-standard-version-when-build-with-bazel/43388168#43388168 | ||
build --cxxopt='-std=c++14' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary") | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy") | ||
load("@cgrindel_swift_bazel//swiftpkg:defs.bzl", "swift_update_packages") | ||
|
||
tidy( | ||
name = "tidy", | ||
targets = [ | ||
":swift_update_pkgs", | ||
":update_build_files", | ||
], | ||
) | ||
|
||
# MARK: - Gazelle | ||
|
||
# Ignore the Swift build folder | ||
# gazelle:exclude .build | ||
|
||
gazelle_binary( | ||
name = "gazelle_bin", | ||
languages = [ | ||
"@bazel_skylib_gazelle_plugin//bzl", | ||
"@cgrindel_swift_bazel//gazelle", | ||
], | ||
) | ||
|
||
gazelle( | ||
name = "update_build_files", | ||
gazelle = ":gazelle_bin", | ||
) | ||
|
||
swift_update_packages( | ||
name = "swift_update_pkgs", | ||
gazelle = ":gazelle_bin", | ||
) | ||
|
||
bzl_library( | ||
name = "swift_deps", | ||
srcs = ["swift_deps.bzl"], | ||
visibility = ["//visibility:public"], | ||
deps = ["@cgrindel_swift_bazel//swiftpkg:defs"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "async-http-client", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/swift-server/async-http-client.git", | ||
"state" : { | ||
"revision" : "864c8d9e0ead5de7ba70b61c8982f89126710863", | ||
"version" : "1.15.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "jmespath.swift", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/adam-fowler/jmespath.swift.git", | ||
"state" : { | ||
"revision" : "4513d319c4aaa6c3b2ac18e1e6566a803515ad91", | ||
"version" : "1.0.2" | ||
} | ||
}, | ||
{ | ||
"identity" : "soto", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/soto-project/soto.git", | ||
"state" : { | ||
"revision" : "26bd91a43a3e569956b99b7f15aa2709a1a6ff23", | ||
"version" : "6.5.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "soto-core", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/soto-project/soto-core.git", | ||
"state" : { | ||
"revision" : "cf1c872126e4874144ed2f91aa2124e72388abe0", | ||
"version" : "6.4.1" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-atomics", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-atomics.git", | ||
"state" : { | ||
"revision" : "ff3d2212b6b093db7f177d0855adbc4ef9c5f036", | ||
"version" : "1.0.3" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-collections", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-collections.git", | ||
"state" : { | ||
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2", | ||
"version" : "1.0.4" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-log", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-log.git", | ||
"state" : { | ||
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46", | ||
"version" : "1.5.2" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-metrics", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-metrics.git", | ||
"state" : { | ||
"revision" : "e8bced74bc6d747745935e469f45d03f048d6cbd", | ||
"version" : "2.3.4" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-nio", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-nio.git", | ||
"state" : { | ||
"revision" : "45167b8006448c79dda4b7bd604e07a034c15c49", | ||
"version" : "2.48.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-nio-extras", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-nio-extras.git", | ||
"state" : { | ||
"revision" : "d75ed708d00353acf173ca23018b6bd46f949464", | ||
"version" : "1.17.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-nio-http2", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-nio-http2.git", | ||
"state" : { | ||
"revision" : "38feec96bcd929028939107684073554bf01abeb", | ||
"version" : "1.25.2" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-nio-ssl", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-nio-ssl.git", | ||
"state" : { | ||
"revision" : "4fb7ead803e38949eb1d6fabb849206a72c580f3", | ||
"version" : "2.23.0" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-nio-transport-services", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-nio-transport-services.git", | ||
"state" : { | ||
"revision" : "c0d9a144cfaec8d3d596aadde3039286a266c15c", | ||
"version" : "1.15.0" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// swift-tools-version: 5.7 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "PhoneNumberKitExample", | ||
dependencies: [ | ||
.package(url: "https://github.com/soto-project/soto.git", from: "6.0.0"), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Soto Example | ||
|
||
This example demonstrates support for clang, non-header files being included in other clang | ||
source files. For example, the file | ||
`external/swiftpkg_soto_core/Sources/CSotoExpat/xmltok.c` has a `#include "xmltok_impl.c"`. The | ||
file `external/swiftpkg_soto_core/Sources/CSotoExpat/xmltok_impl.c` has a comment stating | ||
`This file is included!`. Instead of including `xmltok_impl.c` in `srcs`, it should included in | ||
`textual_hdrs`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_test") | ||
|
||
swift_test( | ||
name = "SotoTests", | ||
srcs = [ | ||
"SotoTests.swift", | ||
"main.swift", | ||
], | ||
module_name = "SotoTests", | ||
deps = ["@swiftpkg_soto//:Sources_Soto_SotoS3"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@testable import SotoS3 | ||
import XCTest | ||
|
||
class SotoTests: XCTestCase { | ||
func testSomething() { | ||
let bucketName = "soto-getting-started-bucket" | ||
let createBucketRequest = S3.CreateBucketRequest(bucket: bucketName) | ||
XCTAssertEqual(createBucketRequest.bucket, bucketName) | ||
} | ||
|
||
static var allTests = [ | ||
("testSomething", testSomething), | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#if os(Linux) | ||
import XCTest | ||
|
||
XCTMain([ | ||
testCase(SotoTests.allTests), | ||
]) | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
workspace(name = "soto_example") | ||
|
||
local_repository( | ||
name = "cgrindel_swift_bazel", | ||
path = "../..", | ||
) | ||
|
||
load("@cgrindel_swift_bazel//:deps.bzl", "swift_bazel_dependencies") | ||
|
||
swift_bazel_dependencies() | ||
|
||
load("@cgrindel_bazel_starlib//:deps.bzl", "bazel_starlib_dependencies") | ||
|
||
bazel_starlib_dependencies() | ||
|
||
# MARK: - Gazelle | ||
|
||
# gazelle:repo bazel_gazelle | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "bazel_skylib_gazelle_plugin", | ||
sha256 = "04182233284fcb6545d36b94248fe28186b4d9d574c4131d6a511d5aeb278c46", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.0/bazel-skylib-gazelle-plugin-1.4.0.tar.gz", | ||
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.0/bazel-skylib-gazelle-plugin-1.4.0.tar.gz", | ||
], | ||
) | ||
|
||
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") | ||
load("@bazel_skylib_gazelle_plugin//:workspace.bzl", "bazel_skylib_gazelle_plugin_workspace") | ||
load("@cgrindel_swift_bazel//:go_deps.bzl", "swift_bazel_go_dependencies") | ||
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") | ||
|
||
# Declare Go dependencies before calling go_rules_dependencies. | ||
swift_bazel_go_dependencies() | ||
|
||
bazel_skylib_gazelle_plugin_workspace() | ||
|
||
go_rules_dependencies() | ||
|
||
go_register_toolchains(version = "1.19.5") | ||
|
||
gazelle_dependencies() | ||
|
||
# MARK: - Swift Toolchain | ||
|
||
http_archive( | ||
name = "build_bazel_rules_swift", | ||
sha256 = "32f95dbe6a88eb298aaa790f05065434f32a662c65ec0a6aabdaf6881e4f169f", | ||
url = "https://github.com/bazelbuild/rules_swift/releases/download/1.5.0/rules_swift.1.5.0.tar.gz", | ||
) | ||
|
||
http_archive( | ||
name = "build_bazel_rules_apple", | ||
sha256 = "43737f28a578d8d8d7ab7df2fb80225a6b23b9af9655fcdc66ae38eb2abcf2ed", | ||
url = "https://github.com/bazelbuild/rules_apple/releases/download/2.0.0/rules_apple.2.0.0.tar.gz", | ||
) | ||
|
||
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", | ||
) | ||
load("//:swift_deps.bzl", "swift_dependencies") | ||
|
||
# gazelle:repository_macro swift_deps.bzl%swift_dependencies | ||
swift_dependencies() | ||
|
||
swift_rules_dependencies() | ||
|
||
load( | ||
"@build_bazel_rules_swift//swift:extras.bzl", | ||
"swift_rules_extra_dependencies", | ||
) | ||
|
||
swift_rules_extra_dependencies() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" | ||
|
||
assert_match() { | ||
local pattern=${1} | ||
local actual="${2}" | ||
local err_msg="Expected to match. pattern: ${pattern}, actual: ${actual}" | ||
[[ "${actual}" =~ ${pattern} ]] || (echo >&2 "${err_msg}" && exit 1) | ||
} | ||
|
||
# Generate Swift external deps and update build files | ||
bazel run //:tidy | ||
|
||
# Ensure that it builds and tests pass | ||
bazel test //... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
# NOTE: This is a placeholder. The phone_number_kit example does not support a clean | ||
# test because some of the targets have been marked as 'manual'. |
Oops, something went wrong.