Brian Silverman | 41cdd3e | 2019-01-19 19:48:58 -0800 | [diff] [blame] | 1 |
|
| 2 | import org.gradle.api.GradleException;
|
| 3 | import org.gradle.api.Plugin;
|
| 4 | import org.gradle.api.Project;
|
| 5 | import org.gradle.api.Task;
|
| 6 | import org.gradle.api.file.FileTree;
|
| 7 | import org.gradle.api.tasks.compile.JavaCompile;
|
| 8 | import org.gradle.language.base.internal.ProjectLayout;
|
| 9 | import org.gradle.language.base.plugins.ComponentModelBasePlugin;
|
| 10 | import org.gradle.language.nativeplatform.tasks.AbstractNativeSourceCompileTask;
|
| 11 | import org.gradle.model.ModelMap;
|
| 12 | import org.gradle.model.Mutate;
|
| 13 | import org.gradle.nativeplatform.test.googletest.GoogleTestTestSuiteBinarySpec;
|
| 14 | import org.gradle.model.RuleSource;
|
| 15 | import org.gradle.model.Validate;
|
| 16 | import org.gradle.nativeplatform.NativeExecutableBinarySpec
|
| 17 | import org.gradle.nativeplatform.NativeBinarySpec;
|
| 18 | import org.gradle.nativeplatform.NativeComponentSpec;
|
| 19 | import org.gradle.nativeplatform.NativeLibrarySpec;
|
| 20 | import org.gradle.nativeplatform.SharedLibraryBinarySpec;
|
| 21 | import org.gradle.nativeplatform.StaticLibraryBinarySpec;
|
| 22 | import org.gradle.nativeplatform.platform.internal.NativePlatformInternal;
|
| 23 | import org.gradle.nativeplatform.toolchain.NativeToolChain;
|
| 24 | import org.gradle.nativeplatform.toolchain.NativeToolChainRegistry;
|
| 25 | import org.gradle.nativeplatform.toolchain.internal.PlatformToolProvider;
|
| 26 | import org.gradle.nativeplatform.toolchain.internal.ToolType;
|
| 27 | import org.gradle.nativeplatform.toolchain.internal.gcc.AbstractGccCompatibleToolChain;
|
| 28 | import org.gradle.nativeplatform.toolchain.internal.msvcpp.VisualCppToolChain;
|
| 29 | import org.gradle.nativeplatform.toolchain.internal.tools.ToolRegistry;
|
| 30 | import org.gradle.platform.base.BinarySpec;
|
| 31 | import org.gradle.platform.base.ComponentSpec;
|
| 32 | import org.gradle.platform.base.ComponentSpecContainer;
|
| 33 | import org.gradle.platform.base.BinaryContainer;
|
| 34 | import org.gradle.platform.base.ComponentType;
|
| 35 | import org.gradle.platform.base.TypeBuilder;
|
| 36 | import org.gradle.nativeplatform.tasks.ObjectFilesToBinary;
|
| 37 | import groovy.transform.CompileStatic;
|
| 38 | import groovy.transform.CompileDynamic
|
| 39 | import org.gradle.nativeplatform.BuildTypeContainer
|
| 40 |
|
| 41 | @CompileStatic
|
| 42 | class MultiBuilds implements Plugin<Project> {
|
| 43 | @CompileStatic
|
| 44 | public void apply(Project project) {
|
| 45 |
|
| 46 | }
|
| 47 |
|
| 48 | @CompileStatic
|
| 49 | static class Rules extends RuleSource {
|
| 50 | @Mutate
|
| 51 | void setupBuildTypes(BuildTypeContainer buildTypes, ProjectLayout projectLayout) {
|
| 52 | def project = (Project) projectLayout.projectIdentifier
|
| 53 | if (project.hasProperty('releaseBuild')) {
|
| 54 | buildTypes.create('debug')
|
| 55 | } else {
|
| 56 | buildTypes.create('release')
|
| 57 | }
|
| 58 | }
|
| 59 |
|
| 60 | @CompileDynamic
|
| 61 | private static void setBuildableFalseDynamically(NativeBinarySpec binary) {
|
| 62 | binary.buildable = false
|
| 63 | }
|
| 64 |
|
| 65 | @Mutate
|
| 66 | @CompileStatic
|
| 67 | void disableReleaseGoogleTest(BinaryContainer binaries, ProjectLayout projectLayout) {
|
| 68 | def project = (Project) projectLayout.projectIdentifier
|
| 69 | if (project.hasProperty('testRelease')) {
|
| 70 | return
|
| 71 | }
|
| 72 | binaries.withType(GoogleTestTestSuiteBinarySpec) { oSpec ->
|
| 73 | GoogleTestTestSuiteBinarySpec spec = (GoogleTestTestSuiteBinarySpec) oSpec
|
| 74 | if (spec.buildType.name == 'release') {
|
| 75 | Rules.setBuildableFalseDynamically(spec)
|
| 76 | }
|
| 77 | }
|
| 78 | // def crossCompileConfigs = []
|
| 79 | // for (BuildConfig config : configs) {
|
| 80 | // if (!BuildConfigRulesBase.isCrossCompile(config)) {
|
| 81 | // continue
|
| 82 | // }
|
| 83 | // crossCompileConfigs << config.architecture
|
| 84 | // }
|
| 85 | // if (!crossCompileConfigs.empty) {
|
| 86 | // binaries.withType(GoogleTestTestSuiteBinarySpec) { oSpec ->
|
| 87 | // GoogleTestTestSuiteBinarySpec spec = (GoogleTestTestSuiteBinarySpec) oSpec
|
| 88 | // if (crossCompileConfigs.contains(spec.targetPlatform.architecture.name)) {
|
| 89 | // setBuildableFalseDynamically(spec)
|
| 90 | // }
|
| 91 | // }
|
| 92 | // }
|
| 93 | }
|
| 94 | }
|
| 95 | }
|