diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
3 files changed, 28 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java index 2d30b7871f..fd9a9ec103 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java @@ -205,6 +205,16 @@ public class ObjcCommandLineOptions extends FragmentOptions { ) public String iosSigningCertName; + @Option( + name = "xcode_override_workspace_root", + defaultValue = "", + category = "xcode", + help = + "If set, then this path will be used as workspace_root and mainGroup path when " + + "generating an .xcodeproj/project.pbxproj file." + ) + public String xcodeOverrideWorkspaceRoot; + @VisibleForTesting static final String DEFAULT_MINIMUM_IOS = "7.0"; @VisibleForTesting static final String DEFAULT_IOS_CPU = "x86_64"; diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java index 50f73c1900..abeccdc0fe 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfiguration.java @@ -79,6 +79,7 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment { private final ConfigurationDistinguisher configurationDistinguisher; @Nullable private final String signingCertName; @Nullable private final Path clientWorkspaceRoot; + private final String xcodeOverrideWorkspaceRoot; // We only load these labels if the mode which uses them is enabled. That is known as part of the // BuildConfiguration. This label needs to be part of a configuration because only configurations @@ -120,6 +121,7 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment { this.configurationDistinguisher = objcOptions.configurationDistinguisher; this.clientWorkspaceRoot = directories != null ? directories.getWorkspace() : null; this.signingCertName = objcOptions.iosSigningCertName; + this.xcodeOverrideWorkspaceRoot = objcOptions.xcodeOverrideWorkspaceRoot; } public Map<String, String> getEnvironmentForDarwin() { @@ -330,11 +332,21 @@ public class ObjcConfiguration extends BuildConfiguration.Fragment { } /** - * Returns the absolute path of the root of Bazel client workspace. Null if passed-in - * {@link BlazeDirectories} is null or Bazel fails to find the workspace root directory. + * Returns the path to be used for workspace_root (and path of pbxGroup mainGroup) in xcodeproj. + * This usually will be the absolute path of the root of Bazel client workspace or null if + * passed-in {@link BlazeDirectories} is null or Bazel fails to find the workspace root directory. + * It can also be overridden by the {@code --xcode_override_workspace_root} flag, in which case + * the path can be absolute or relative. */ - @Nullable public Path getClientWorkspaceRoot() { - return this.clientWorkspaceRoot; + @Nullable + public String getXcodeWorkspaceRoot() { + if (!this.xcodeOverrideWorkspaceRoot.isEmpty()) { + return this.xcodeOverrideWorkspaceRoot; + } + if (this.clientWorkspaceRoot == null) { + return null; + } + return this.clientWorkspaceRoot.getPathString(); } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java index 40d6330cd9..6e570a274e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/XcodeSupport.java @@ -232,9 +232,9 @@ public final class XcodeSupport { @Override public InputStream openStream() { XcodeGenProtos.Control.Builder builder = XcodeGenProtos.Control.newBuilder(); - Path workspaceRoot = objcConfiguration.getClientWorkspaceRoot(); + String workspaceRoot = objcConfiguration.getXcodeWorkspaceRoot(); if (workspaceRoot != null) { - builder.setWorkspaceRoot(workspaceRoot.getPathString()); + builder.setWorkspaceRoot(workspaceRoot); } List<String> multiCpus = objcConfiguration.getIosMultiCpus(); |