Search in sources :

Example 1 with TEST_DEBUG

use of org.gradle.ide.xcode.internal.DefaultXcodeProject.TEST_DEBUG 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;
}
Also used : DefaultXcodeProject(org.gradle.ide.xcode.internal.DefaultXcodeProject) PBXProject(org.gradle.ide.xcode.internal.xcodeproj.PBXProject) PBXSourcesBuildPhase(org.gradle.ide.xcode.internal.xcodeproj.PBXSourcesBuildPhase) HashMap(java.util.HashMap) FileCollection(org.gradle.api.file.FileCollection) DisableCachingByDefault(org.gradle.work.DisableCachingByDefault) GidGenerator(org.gradle.ide.xcode.internal.xcodeproj.GidGenerator) ArrayList(java.util.ArrayList) PBXFileReference(org.gradle.ide.xcode.internal.xcodeproj.PBXFileReference) Inject(javax.inject.Inject) TEST_DEBUG(org.gradle.ide.xcode.internal.DefaultXcodeProject.TEST_DEBUG) Provider(org.gradle.api.provider.Provider) Optional(com.google.common.base.Optional) Map(java.util.Map) XcodeBinary(org.gradle.ide.xcode.internal.XcodeBinary) NSString(com.dd.plist.NSString) XcodeProjectFile(org.gradle.ide.xcode.tasks.internal.XcodeProjectFile) XcodePropertyAdapter(org.gradle.ide.xcode.internal.XcodePropertyAdapter) PBXLegacyTarget(org.gradle.ide.xcode.internal.xcodeproj.PBXLegacyTarget) PBXShellScriptBuildPhase(org.gradle.ide.xcode.internal.xcodeproj.PBXShellScriptBuildPhase) Incubating(org.gradle.api.Incubating) Internal(org.gradle.api.tasks.Internal) PBXTarget(org.gradle.ide.xcode.internal.xcodeproj.PBXTarget) PropertyListGeneratorTask(org.gradle.plugins.ide.api.PropertyListGeneratorTask) NSDictionary(com.dd.plist.NSDictionary) Action(org.gradle.api.Action) SwiftVersion(org.gradle.language.swift.SwiftVersion) PBXNativeTarget(org.gradle.ide.xcode.internal.xcodeproj.PBXNativeTarget) XcodeUtils.toSpaceSeparatedList(org.gradle.ide.xcode.internal.XcodeUtils.toSpaceSeparatedList) Collection(java.util.Collection) PBXBuildFile(org.gradle.ide.xcode.internal.xcodeproj.PBXBuildFile) Cast(org.gradle.internal.Cast) Collectors(java.util.stream.Collectors) PBXGroup(org.gradle.ide.xcode.internal.xcodeproj.PBXGroup) File(java.io.File) Objects(java.util.Objects) Consumer(java.util.function.Consumer) XcodeprojSerializer(org.gradle.ide.xcode.internal.xcodeproj.XcodeprojSerializer) MachineArchitecture(org.gradle.nativeplatform.MachineArchitecture) XcodeProject(org.gradle.ide.xcode.XcodeProject) List(java.util.List) PBXReference(org.gradle.ide.xcode.internal.xcodeproj.PBXReference) Joiner(com.google.common.base.Joiner) XcodeTarget(org.gradle.ide.xcode.internal.XcodeTarget) PBXShellScriptBuildPhase(org.gradle.ide.xcode.internal.xcodeproj.PBXShellScriptBuildPhase) PBXNativeTarget(org.gradle.ide.xcode.internal.xcodeproj.PBXNativeTarget) NSDictionary(com.dd.plist.NSDictionary) XcodeProjectFile(org.gradle.ide.xcode.tasks.internal.XcodeProjectFile) PBXBuildFile(org.gradle.ide.xcode.internal.xcodeproj.PBXBuildFile) File(java.io.File) PBXFileReference(org.gradle.ide.xcode.internal.xcodeproj.PBXFileReference)

Aggregations

NSDictionary (com.dd.plist.NSDictionary)1 NSString (com.dd.plist.NSString)1 Joiner (com.google.common.base.Joiner)1 Optional (com.google.common.base.Optional)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Action (org.gradle.api.Action)1 Incubating (org.gradle.api.Incubating)1 FileCollection (org.gradle.api.file.FileCollection)1 Provider (org.gradle.api.provider.Provider)1 Internal (org.gradle.api.tasks.Internal)1 XcodeProject (org.gradle.ide.xcode.XcodeProject)1