Skip to content

Commit

Permalink
Introduce --override_workspace_root blaze flag to hand-set workspace_…
Browse files Browse the repository at this point in the history
…root and mainGroup in xcodeproj.

RELNOTES: Adds --override_workspace_root blaze flag to hand-set workspace_root and mainGroup in xcodeproj.

--
MOS_MIGRATED_REVID=105484952
  • Loading branch information
Googler authored and dslomov committed Oct 15, 2015
1 parent c82224f commit 1e2a30b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ public DefaultProvisioningProfileConverter() {
)
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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -330,11 +332,21 @@ public boolean shouldStripBinary() {
}

/**
* 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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ private ByteSource xcodegenControlFileBytes(final XcodeProvider.Project project)
@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();
Expand Down

0 comments on commit 1e2a30b

Please sign in to comment.