Bump rules_apple version to 0.17.2 and attempt to fix PY issue
- Bump rules_apple version
- Fix missing deps call in WORKSPACE
- Add bazelrc and update WORKSPACE to hopefully fix build issues
- Fix aspect tests to check unordered contents for includes
This should hopefully fix our failures with Bazel 0.27
PiperOrigin-RevId: 252085936
diff --git a/.bazelrc b/.bazelrc
new file mode 100644
index 0000000..399c48b
--- /dev/null
+++ b/.bazelrc
@@ -0,0 +1,11 @@
+build --cpu=darwin_x86_64
+build --apple_platform_type=macos
+build --xcode_version=10.1
+
+# Disable the Swift compilation worker when running integration tests, since it
+# requires the protobuf dependency which is infeasible to get working on Bazel.
+build --define=RULES_SWIFT_BUILD_DUMMY_WORKER=1
+
+# Stop gap for https://github.com/bazelbuild/tulsi/issues/94.
+# See also: https://github.com/bazelbuild/rules_apple/issues/456.
+build "--host_force_python=PY2"
diff --git a/WORKSPACE b/WORKSPACE
index 85b1c03..1218dc4 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
git_repository(
name = "build_bazel_rules_apple",
remote = "https://github.com/bazelbuild/rules_apple.git",
- tag = "0.16.1",
+ tag = "0.17.2",
)
load(
@@ -20,6 +20,15 @@
)
swift_rules_dependencies()
+# @build_bazel_apple_support is already defined via apple_rules_dependencies above.
+# This helps ensure that Tulsi, rules_apple, etc. are using the same versions.
+load(
+ "@build_bazel_apple_support//lib:repositories.bzl",
+ "apple_support_dependencies",
+)
+
+apple_support_dependencies()
+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
http_file(
diff --git a/src/TulsiGeneratorIntegrationTests/AspectTests.swift b/src/TulsiGeneratorIntegrationTests/AspectTests.swift
index abd6842..65bbd2d 100644
--- a/src/TulsiGeneratorIntegrationTests/AspectTests.swift
+++ b/src/TulsiGeneratorIntegrationTests/AspectTests.swift
@@ -675,15 +675,15 @@
/// Asserts that the contextual RuleEntry has an attribute with the given name and value.
@discardableResult
- func hasIncludes(_ value: [String], line: UInt = #line) -> Context {
+ func hasIncludes(_ value: Set<String>, line: UInt = #line) -> Context {
guard let ruleEntry = ruleEntry else { return self }
guard let includes = ruleEntry.includePaths else {
XCTFail("\(ruleEntry) expected to have includes", line: line)
return self
}
- let paths = includes.map { (path, recursive) -> String in
+ let paths = Set(includes.map { (path, recursive) -> String in
return path
- }
+ })
XCTAssertEqual(paths, value, line: line)
return self
}
diff --git a/src/TulsiGeneratorIntegrationTests/BazelFakeWorkspace.swift b/src/TulsiGeneratorIntegrationTests/BazelFakeWorkspace.swift
index 6b69e2b..d0ffe2b 100644
--- a/src/TulsiGeneratorIntegrationTests/BazelFakeWorkspace.swift
+++ b/src/TulsiGeneratorIntegrationTests/BazelFakeWorkspace.swift
@@ -18,6 +18,7 @@
class BazelFakeWorkspace {
let resourcesPathBase = "src/TulsiGeneratorIntegrationTests/Resources"
+ let extraBuildFlags: [String]
var runfilesURL: URL
var runfilesWorkspaceURL: URL
var fakeExecroot: URL
@@ -32,6 +33,9 @@
self.fakeExecroot = tempDirURL.appendingPathComponent("fake_execroot", isDirectory: true)
self.workspaceRootURL = fakeExecroot.appendingPathComponent("__main__", isDirectory: true)
self.bazelURL = BazelLocator.bazelURL!
+ // Stop gap for https://github.com/bazelbuild/tulsi/issues/94.
+ // See also: https://github.com/bazelbuild/rules_apple/issues/456.
+ self.extraBuildFlags = ["--host_force_python=PY2"]
}
private func addExportsFiles(buildFilePath: String,
diff --git a/src/TulsiGeneratorIntegrationTests/BazelIntegrationTestCase.swift b/src/TulsiGeneratorIntegrationTests/BazelIntegrationTestCase.swift
index 2485ebf..ad504fd 100644
--- a/src/TulsiGeneratorIntegrationTests/BazelIntegrationTestCase.swift
+++ b/src/TulsiGeneratorIntegrationTests/BazelIntegrationTestCase.swift
@@ -50,6 +50,9 @@
workspaceRootURL = fakeBazelWorkspace.workspaceRootURL
bazelURL = fakeBazelWorkspace.bazelURL
+ // Add any build options specific to the fakeBazelWorkspace.
+ bazelBuildOptions.append(contentsOf: fakeBazelWorkspace.extraBuildFlags)
+
if let testOutputPath = ProcessInfo.processInfo.environment["TEST_UNDECLARED_OUTPUTS_DIR"] {
testUndeclaredOutputsDir = URL(fileURLWithPath: testOutputPath, isDirectory: true)
}