xref: /aosp_15_r20/external/conscrypt/constants/build.gradle (revision cd0cc2e34ba52cdf454361820a14d744e4bd531d)
1description = 'Conscrypt: Constants'
2
3ext {
4    genDir = "${project.buildDir}/generated-sources"
5}
6
7
8sourceSets.main {
9    java {
10        srcDirs = [
11            "${genDir}"
12        ]
13    }
14}
15
16dependencies {
17    implementation files("${genDir}") {
18        builtBy ':conscrypt-constants:runGen'
19    }
20}
21
22model {
23    components {
24        // Builds exe/ which generates the content of NativeConstants.java
25        gen(NativeExecutableSpec) {
26            sources {
27                cpp {
28                    // Sources assumed to be in src/gen/cpp by default.
29                    exportedHeaders {
30                        srcDirs "${boringsslIncludeDir}"
31                        include "**/*.cc"
32                    }
33                }
34            }
35
36            binaries.all {
37                if (toolChain in VisualCpp) {
38                    cppCompiler.define "WIN32_LEAN_AND_MEAN"
39                } else if (toolChain in Clang || toolChain in Gcc) {
40                    cppCompiler.args "-std=c++17"
41                }
42            }
43        }
44    }
45
46    tasks {
47        // Runs generateNativeConstants to create build/NativeConstants.java
48        runGen(Exec) {
49            def gen = $.binaries.get("genExecutable")
50
51            dependsOn gen
52            outputs.dir genDir
53            File genDir = new File("${genDir}/org/conscrypt")
54
55            executable gen.executable.file
56
57            doFirst {
58                genDir.mkdirs()
59                standardOutput = new FileOutputStream(new File(genDir, "NativeConstants.java"))
60            }
61            doLast {
62                if (standardOutput != null) {
63                    standardOutput.close();
64                }
65            }
66        }
67    }
68}
69
70// Disable the javadoc task.
71tasks.withType(Javadoc).configureEach { enabled = false }
72