use of org.gradle.nativeplatform.test.xctest.internal.DefaultSwiftXCTestExecutable in project gradle by gradle.
the class XCTestConventionPlugin method configureTestSuiteBuildingTasks.
private void configureTestSuiteBuildingTasks(ProjectInternal project, final DefaultSwiftXCTestBinary binary) {
if (binary instanceof SwiftXCTestBundle) {
TaskContainer tasks = project.getTasks();
final Names names = binary.getNames();
SwiftCompile compile = binary.getCompileTask().get();
// TODO - creating a bundle should be done by some general purpose plugin
// TODO - make this lazy
DefaultNativePlatform currentPlatform = new DefaultNativePlatform("current");
final ModelRegistry modelRegistry = project.getModelRegistry();
NativeToolChain toolChain = modelRegistry.realize("toolChains", NativeToolChainRegistryInternal.class).getForPlatform(currentPlatform);
// Platform specific arguments
compile.getCompilerArgs().addAll(project.provider(new Callable<List<String>>() {
@Override
public List<String> call() {
File frameworkDir = new File(sdkPlatformPathLocator.find(), "Developer/Library/Frameworks");
return Arrays.asList("-parse-as-library", "-F" + frameworkDir.getAbsolutePath());
}
}));
// Add a link task
final LinkMachOBundle link = tasks.create(names.getTaskName("link"), LinkMachOBundle.class);
link.getLinkerArgs().set(project.provider(new Callable<List<String>>() {
@Override
public List<String> call() {
File frameworkDir = new File(sdkPlatformPathLocator.find(), "Developer/Library/Frameworks");
return Lists.newArrayList("-F" + frameworkDir.getAbsolutePath(), "-framework", "XCTest", "-Xlinker", "-rpath", "-Xlinker", "@executable_path/../Frameworks", "-Xlinker", "-rpath", "-Xlinker", "@loader_path/../Frameworks");
}
}));
InstallXCTestBundle install = tasks.create(names.getTaskName("install"), InstallXCTestBundle.class);
install.getBundleBinaryFile().set(link.getLinkedFile());
install.getInstallDirectory().set(project.getLayout().getBuildDirectory().dir("install/" + names.getDirName()));
binary.getInstallDirectory().set(install.getInstallDirectory());
link.source(binary.getObjects());
link.lib(binary.getLinkLibraries());
final PlatformToolProvider toolProvider = ((NativeToolChainInternal) toolChain).select(currentPlatform);
Provider<RegularFile> exeLocation = project.getLayout().getBuildDirectory().file(project.getProviders().provider(new Callable<String>() {
@Override
public String call() {
return toolProvider.getExecutableName("exe/" + names.getDirName() + binary.getBaseName().get());
}
}));
link.getLinkedFile().set(exeLocation);
link.getTargetPlatform().set(currentPlatform);
link.getToolChain().set(toolChain);
link.getDebuggable().set(binary.isDebuggable());
binary.getExecutableFile().set(link.getLinkedFile());
DefaultSwiftXCTestBundle bundle = (DefaultSwiftXCTestBundle) binary;
bundle.getLinkTask().set(link);
bundle.getRunScriptFile().set(install.getRunScriptFile());
} else {
DefaultSwiftXCTestExecutable executable = (DefaultSwiftXCTestExecutable) binary;
executable.getRunScriptFile().set(executable.getInstallTask().get().getRunScriptFile());
}
}
Aggregations