Add universal startup flags to the clean script
This will prevent server resets just for a clean
PiperOrigin-RevId: 259797745
diff --git a/src/TulsiGenerator/BazelSettingsProvider.swift b/src/TulsiGenerator/BazelSettingsProvider.swift
index efd0ed9..dfe61a5 100644
--- a/src/TulsiGenerator/BazelSettingsProvider.swift
+++ b/src/TulsiGenerator/BazelSettingsProvider.swift
@@ -106,6 +106,9 @@
/// Defines an object that provides flags for Bazel invocations.
protocol BazelSettingsProviderProtocol {
+ /// Universal flags for all Bazel invocations.
+ var universalFlags: BazelFlags { get }
+
/// All general-Tulsi flags, varying based on whether the project has Swift or not.
func tulsiFlags(hasSwift: Bool,
options: TulsiOptionSet?,
diff --git a/src/TulsiGenerator/PBXTargetGenerator.swift b/src/TulsiGenerator/PBXTargetGenerator.swift
index d99ebf5..e814465 100644
--- a/src/TulsiGenerator/PBXTargetGenerator.swift
+++ b/src/TulsiGenerator/PBXTargetGenerator.swift
@@ -96,7 +96,8 @@
/// Generates a legacy target that is added as a dependency of all build targets and invokes
/// the given script. The build action may be accessed by the script via the ACTION environment
/// variable.
- func generateBazelCleanTarget(_ scriptPath: String, workingDirectory: String)
+ func generateBazelCleanTarget(_ scriptPath: String, workingDirectory: String,
+ startupOptions: [String])
/// Generates project-level build configurations.
func generateTopLevelBuildConfigurations(_ buildSettingOverrides: [String: String])
@@ -688,13 +689,17 @@
return indexerTargetByName
}
- func generateBazelCleanTarget(_ scriptPath: String, workingDirectory: String = "") {
+ func generateBazelCleanTarget(_ scriptPath: String, workingDirectory: String = "",
+ startupOptions: [String] = []) {
assert(bazelCleanScriptTarget == nil, "generateBazelCleanTarget may only be called once")
+ let allArgs = [bazelPath, bazelBinPath] + startupOptions
+ let buildArgs = allArgs.map { "\"\($0)\""}.joined(separator: " ")
+
bazelCleanScriptTarget = project.createLegacyTarget(PBXTargetGenerator.BazelCleanTarget,
deploymentTarget: nil,
buildToolPath: "\(scriptPath)",
- buildArguments: "\"\(bazelPath)\" \"\(bazelBinPath)\"",
+ buildArguments: buildArgs,
buildWorkingDirectory: workingDirectory)
for target: PBXTarget in project.allTargets {
diff --git a/src/TulsiGenerator/Scripts/bazel_clean.sh b/src/TulsiGenerator/Scripts/bazel_clean.sh
index 1e95f1d..7bd3291 100755
--- a/src/TulsiGenerator/Scripts/bazel_clean.sh
+++ b/src/TulsiGenerator/Scripts/bazel_clean.sh
@@ -16,13 +16,19 @@
#
# Bridge between Xcode and Bazel for the "clean" action.
#
-# Usage: bazel_clean.sh <bazel_binary_path> <bazel_binary_output_path>
+# Usage: bazel_clean.sh <bazel_binary_path> <bazel_binary_output_path> <bazel startup options>
# Note that the ACTION environment variable is expected to be set to "clean".
set -eu
-readonly bazel_executable="$1"
-readonly bazel_bin_dir="$2"
+readonly bazel_executable="$1"; shift
+readonly bazel_bin_dir="$1"; shift
+
+if [ -z $# ]; then
+ readonly arguments=(clean)
+else
+ readonly arguments=("$@" clean)
+fi
if [[ "${ACTION}" != "clean" ]]; then
exit 0
@@ -43,5 +49,6 @@
(
set -x
- "${bazel_executable}" clean
+ "${bazel_executable}" "${arguments[@]}"
)
+
diff --git a/src/TulsiGenerator/XcodeProjectGenerator.swift b/src/TulsiGenerator/XcodeProjectGenerator.swift
index 823232c..fd6aa16 100644
--- a/src/TulsiGenerator/XcodeProjectGenerator.swift
+++ b/src/TulsiGenerator/XcodeProjectGenerator.swift
@@ -479,7 +479,10 @@
let workingDirectory = pbxTargetGeneratorType.workingDirectoryForPBXGroup(mainGroup)
profileAction("generating_clean_target") {
- generator.generateBazelCleanTarget(cleanScriptPath, workingDirectory: workingDirectory)
+ let bazelSettingsProvider = workspaceInfoExtractor.bazelSettingsProvider
+ let startupOptions = bazelSettingsProvider.universalFlags.startup
+ generator.generateBazelCleanTarget(cleanScriptPath, workingDirectory: workingDirectory,
+ startupOptions: startupOptions)
}
profileAction("generating_top_level_build_configs") {
var buildSettings = [String: String]()
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MacOSProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MacOSProject.xcodeproj/project.pbxproj
index c1ebc40..158f63f 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MacOSProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MacOSProject.xcodeproj/project.pbxproj
@@ -723,7 +723,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MacOSTestsProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MacOSTestsProject.xcodeproj/project.pbxproj
index 6c6a79a..5c0c43b 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MacOSTestsProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MacOSTestsProject.xcodeproj/project.pbxproj
@@ -1045,7 +1045,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MultiExtensionProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MultiExtensionProject.xcodeproj/project.pbxproj
index e77ed28..e657a5b 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MultiExtensionProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/MultiExtensionProject.xcodeproj/project.pbxproj
@@ -579,7 +579,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SimpleCCProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SimpleCCProject.xcodeproj/project.pbxproj
index 81bfadb..30a98ec 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SimpleCCProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SimpleCCProject.xcodeproj/project.pbxproj
@@ -485,7 +485,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SimpleProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SimpleProject.xcodeproj/project.pbxproj
index a5ffe77..b00204a 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SimpleProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SimpleProject.xcodeproj/project.pbxproj
@@ -990,7 +990,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SkylarkBundlingProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SkylarkBundlingProject.xcodeproj/project.pbxproj
index 91f1e3c..583fa98 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SkylarkBundlingProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SkylarkBundlingProject.xcodeproj/project.pbxproj
@@ -560,7 +560,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SwiftProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SwiftProject.xcodeproj/project.pbxproj
index e55241a..2040951 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SwiftProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/SwiftProject.xcodeproj/project.pbxproj
@@ -604,7 +604,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteExplicitXCTestsProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteExplicitXCTestsProject.xcodeproj/project.pbxproj
index 6268c57..57176a8 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteExplicitXCTestsProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteExplicitXCTestsProject.xcodeproj/project.pbxproj
@@ -1182,7 +1182,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteLocalTaggedTestsProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteLocalTaggedTestsProject.xcodeproj/project.pbxproj
index 3623f9a..b3d77ab 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteLocalTaggedTestsProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteLocalTaggedTestsProject.xcodeproj/project.pbxproj
@@ -655,7 +655,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteRecursiveTestSuiteProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteRecursiveTestSuiteProject.xcodeproj/project.pbxproj
index c3606e2..db7302a 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteRecursiveTestSuiteProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/TestSuiteRecursiveTestSuiteProject.xcodeproj/project.pbxproj
@@ -1019,7 +1019,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/WatchProject.xcodeproj/project.pbxproj b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/WatchProject.xcodeproj/project.pbxproj
index 64a4c03..ce808f5 100644
--- a/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/WatchProject.xcodeproj/project.pbxproj
+++ b/src/TulsiGeneratorIntegrationTests/Resources/GoldenProjects/WatchProject.xcodeproj/project.pbxproj
@@ -768,7 +768,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ;
+ CLANG_CXX_LANGUAGE_STANDARD = "c++11";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
diff --git a/src/TulsiGeneratorTests/MockWorkspaceInfoExtractor.swift b/src/TulsiGeneratorTests/MockWorkspaceInfoExtractor.swift
index 6e46319..e6024f3 100644
--- a/src/TulsiGeneratorTests/MockWorkspaceInfoExtractor.swift
+++ b/src/TulsiGeneratorTests/MockWorkspaceInfoExtractor.swift
@@ -17,6 +17,10 @@
class MockBazelSettingsProvider: BazelSettingsProviderProtocol {
+ var universalFlags: BazelFlags {
+ return BazelFlags()
+ }
+
func tulsiFlags(hasSwift: Bool,
options: TulsiOptionSet?,
features: Set<BazelSettingFeature>) -> BazelFlagsSet {
diff --git a/src/TulsiGeneratorTests/XcodeProjectGeneratorTests.swift b/src/TulsiGeneratorTests/XcodeProjectGeneratorTests.swift
index 0a5ed2d..24a512c 100644
--- a/src/TulsiGeneratorTests/XcodeProjectGeneratorTests.swift
+++ b/src/TulsiGeneratorTests/XcodeProjectGeneratorTests.swift
@@ -516,7 +516,8 @@
return [:]
}
- func generateBazelCleanTarget(_ scriptPath: String, workingDirectory: String) {
+ func generateBazelCleanTarget(_ scriptPath: String, workingDirectory: String,
+ startupOptions: [String]) {
}
func generateTopLevelBuildConfigurations(_ buildSettingOverrides: [String: String]) {