use of org.gradle.ide.xcode.internal.XcodeTarget in project gradle by gradle.
the class GenerateSchemeFileTask method configureLaunchAction.
private void configureLaunchAction(XcodeSchemeFile.LaunchAction action) {
action.setBuildConfiguration(xcodeProject.getTargets().iterator().next().getDefaultConfigurationName().get());
for (XcodeTarget xcodeTarget : xcodeProject.getTargets()) {
XcodeSchemeFile.BuildableReference buildableReference = toBuildableReference(xcodeTarget);
if (xcodeTarget.isRunnable()) {
action.setBuildableProductRunnable(buildableReference);
}
action.setBuildableReference(buildableReference);
break;
}
}
use of org.gradle.ide.xcode.internal.XcodeTarget in project gradle by gradle.
the class XcodePlugin method newTarget.
private XcodeTarget newTarget(String name, String productName, String gradleCommand, String taskName, FileCollection sources) {
String id = gidGenerator.generateGid("PBXLegacyTarget", name.hashCode());
XcodeTarget target = objectFactory.newInstance(XcodeTarget.class, name, id);
target.setTaskName(taskName);
target.setGradleCommand(gradleCommand);
target.setProductName(productName);
target.getSources().setFrom(sources);
return target;
}
use of org.gradle.ide.xcode.internal.XcodeTarget in project gradle by gradle.
the class GenerateSchemeFileTask method configureTestAction.
private void configureTestAction(XcodeSchemeFile.TestAction action) {
action.setBuildConfiguration(BUILD_DEBUG);
for (final XcodeTarget xcodeTarget : xcodeProject.getTargets()) {
if (xcodeTarget.isUnitTest()) {
action.setBuildConfiguration(TEST_DEBUG);
action.entry(new Action<XcodeSchemeFile.TestableEntry>() {
@Override
public void execute(XcodeSchemeFile.TestableEntry testableEntry) {
testableEntry.setSkipped(false);
XcodeSchemeFile.BuildableReference buildableReference = toBuildableReference(xcodeTarget);
testableEntry.setBuildableReference(buildableReference);
}
});
}
}
}
use of org.gradle.ide.xcode.internal.XcodeTarget in project gradle by gradle.
the class GenerateXcodeProjectFileTask method toXCTestPbxTarget.
private PBXTarget toXCTestPbxTarget(XcodeTarget xcodeTarget) {
PBXShellScriptBuildPhase hackBuildPhase = new PBXShellScriptBuildPhase();
hackBuildPhase.setShellPath("/bin/sh");
hackBuildPhase.setShellScript("# Script to generate specific Swift files Xcode expects when running tests.\n" + "set -eu\n" + "ARCH_ARRAY=($ARCHS)\n" + "SUFFIXES=(swiftdoc swiftmodule h)\n" + "for ARCH in \"${ARCH_ARRAY[@]}\"\n" + "do\n" + " for SUFFIX in \"${SUFFIXES[@]}\"\n" + " do\n" + " touch \"$OBJECT_FILE_DIR_normal/$ARCH/$PRODUCT_NAME.$SUFFIX\"\n" + " done\n" + "done");
PBXShellScriptBuildPhase gradleBuildPhase = new PBXShellScriptBuildPhase();
gradleBuildPhase.setShellPath("/bin/sh");
gradleBuildPhase.setShellScript("exec \"" + xcodeTarget.getGradleCommand() + "\" " + buildGradleArgs(xcodeTarget) + " < /dev/null");
PBXNativeTarget target = new PBXNativeTarget(xcodeTarget.getName(), xcodeTarget.getProductType());
target.setProductName(xcodeTarget.getProductName());
target.setGlobalID(xcodeTarget.getId());
// Note the order in which the build phase are added is important
target.getBuildPhases().add(hackBuildPhase);
target.getBuildPhases().add(newSourceBuildPhase(xcodeTarget.getSources()));
target.getBuildPhases().add(gradleBuildPhase);
File outputFile = xcodeTarget.getDebugOutputFile().get().getAsFile();
target.setProductReference(new PBXFileReference(outputFile.getName(), outputFile.getAbsolutePath(), PBXReference.SourceTree.ABSOLUTE));
getAllBinaries().stream().filter(it -> !Objects.equals(it.getBuildConfigurationName(), TEST_DEBUG)).forEach(configureBuildSettings(xcodeTarget, target));
NSDictionary testRunnerSettings = target.getBuildConfigurationList().getBuildConfigurationsByName().getUnchecked(TEST_DEBUG).getBuildSettings();
if (!xcodeTarget.getCompileModules().isEmpty()) {
testRunnerSettings.put("SWIFT_INCLUDE_PATHS", toSpaceSeparatedList(parentDirs(xcodeTarget.getCompileModules())));
}
testRunnerSettings.put("SWIFT_VERSION", toXcodeSwiftVersion(xcodeTarget.getSwiftSourceCompatibility()));
testRunnerSettings.put("PRODUCT_NAME", target.getProductName());
testRunnerSettings.put("OTHER_LDFLAGS", "-help");
testRunnerSettings.put("OTHER_CFLAGS", "-help");
testRunnerSettings.put("OTHER_SWIFT_FLAGS", "-help");
testRunnerSettings.put("SWIFT_INSTALL_OBJC_HEADER", "NO");
testRunnerSettings.put("SWIFT_OBJC_INTERFACE_HEADER_NAME", "$(PRODUCT_NAME).h");
return target;
}
use of org.gradle.ide.xcode.internal.XcodeTarget in project gradle by gradle.
the class GenerateXcodeProjectFileTask method configure.
@Override
protected void configure(XcodeProjectFile projectFile) {
PBXProject project = new PBXProject(projectPath);
addToGroup(project.getMainGroup(), xcodeProject.getGroups().getSources(), "Sources");
addToGroup(project.getMainGroup(), xcodeProject.getGroups().getHeaders(), "Headers");
addToGroup(project.getMainGroup(), xcodeProject.getGroups().getTests(), "Tests");
addToGroup(project.getMainGroup(), xcodeProject.getGroups().getRoot());
for (XcodeTarget xcodeTarget : xcodeProject.getTargets()) {
if (xcodeTarget.isBuildable()) {
project.getTargets().add(toGradlePbxTarget(xcodeTarget));
} else {
getLogger().warn("'" + xcodeTarget.getName() + "' component in project '" + projectPath + "' is not buildable.");
}
project.getTargets().add(toIndexPbxTarget(xcodeTarget));
if (!xcodeTarget.isUnitTest() && xcodeTarget.getDebugOutputFile().isPresent()) {
File debugOutputFile = xcodeTarget.getDebugOutputFile().get().getAsFile();
PBXFileReference fileReference = new PBXFileReference(debugOutputFile.getName(), debugOutputFile.getAbsolutePath(), PBXReference.SourceTree.ABSOLUTE);
fileReference.setExplicitFileType(Optional.of(xcodeTarget.getOutputFileType()));
project.getMainGroup().getOrCreateChildGroupByName(PRODUCTS_GROUP_NAME).getChildren().add(fileReference);
}
}
// Create build configuration at the project level from all target's build configuration
project.getTargets().stream().flatMap(it -> it.getBuildConfigurationList().getBuildConfigurationsByName().asMap().keySet().stream()).forEach(project.getBuildConfigurationList().getBuildConfigurationsByName()::getUnchecked);
XcodeprojSerializer serializer = new XcodeprojSerializer(gidGenerator, project);
final NSDictionary rootObject = serializer.toPlist();
projectFile.transformAction(new Action<NSDictionary>() {
@Override
public void execute(NSDictionary dict) {
dict.clear();
dict.putAll(rootObject);
}
});
}
Aggregations