Bug 1726704 [wpt PR 30103] - Add more extensive tests for .canShare(), a=testonly
[gecko.git] / settings.gradle
blobde22ef6cb5f50697186e88a8a7a587fc859a2c2c
1 // You might think topsrcdir is '.', but that's not true when the Gradle build
2 // is launched from within IntelliJ.
3 def topsrcdir = rootProject.projectDir.absolutePath
5 def commandLine = ["${topsrcdir}/mach", "environment", "--format", "json", "--verbose"]
6 if (System.properties['os.name'].toLowerCase().contains('windows')) {
7     // gradle is called before parsing config.status, we cannot use PYTHON
8     // value.
9     if (System.env.MOZILLABUILD) {
10         def mozillabuild = System.env.MOZILLABUILD
11         if (mozillabuild) {
12             commandLine.addAll(0, ["${mozillabuild}/python/python.exe"])
13         }
14     }
16 def proc = commandLine.execute(null, new File(topsrcdir))
17 def standardOutput = new ByteArrayOutputStream()
18 def standardError = new ByteArrayOutputStream()
19 proc.consumeProcessOutput(standardOutput, standardError)
20 proc.waitFor()
22 // Only show the output if something went wrong.
23 if (proc.exitValue() != 0) {
24     logger.info("Error running ./mach environment: \n\n"
25         + "Process '${commandLine}' finished with non-zero exit value ${proc.exitValue()}:\n\n"
26         + "stdout:\n"
27         + "${standardOutput.toString()}\n\n"
28         + "stderr:\n"
29         + "${standardError.toString()}")
30     throw new StopExecutionException(
31             "Could not run ./mach environment. Try running ./mach build first.")
34 import groovy.json.JsonSlurper
36 def slurper = new JsonSlurper()
37 def json = slurper.parseText(standardOutput.toString())
39 if (json.substs.MOZ_BUILD_APP != 'mobile/android') {
40     throw new GradleException("Building with Gradle is only supported for Fennec, i.e., MOZ_BUILD_APP == 'mobile/android'.")
43 // Set the Android SDK location.  This is the *least specific* mechanism, which
44 // is unfortunate: we'd prefer to use the *most specific* mechanism.  That is,
45 // local.properties (first 'sdk.dir', then 'android.dir') and then the
46 // environment variable ANDROID_HOME will override this.  That's unfortunate,
47 // but it's hard to automatically arrange better.
48 System.setProperty('android.home', json.substs.ANDROID_SDK_ROOT)
50 include ':annotations', ':messaging_example', ':port_messaging_example'
51 include ':geckoview'
52 include ':geckoview_example'
53 include ':omnijar'
55 project(':annotations').projectDir = new File("${json.topsrcdir}/mobile/android/annotations")
56 project(':geckoview').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview")
57 project(':geckoview_example').projectDir = new File("${json.topsrcdir}/mobile/android/geckoview_example")
58 project(':omnijar').projectDir = new File("${json.topsrcdir}/mobile/android/app/omnijar")
60 // The Gradle instance is shared between settings.gradle and all the
61 // other build.gradle files (see
62 // http://forums.gradle.org/gradle/topics/define_extension_properties_from_settings_xml).
63 // We use this ext property to pass the per-object-directory mozconfig
64 // between scripts.  This lets us execute set-up code before we gradle
65 // tries to configure the project even once, and as a side benefit
66 // saves invoking |mach environment| multiple times.
67 gradle.ext.mozconfig = json
69 // Produced by `mach build`.  Bug 1543982: the mozconfig determined by `mach
70 // environment` above can be different because `mach build` itself sets certain
71 // critical environment variables including MOZ_OBJDIR, CC, and CXX.  We use
72 // this record to patch up the environment when we recursively invoke `mach
73 // build ...` commands from within Gradle.  This avoids invalidating configure
74 // based on the changed environment variables.
75 def orig = slurper.parse(new File(json.topobjdir, '.mozconfig.json'))
76 gradle.ext.mozconfig.orig_mozconfig = orig.mozconfig
77 project(':messaging_example').projectDir = new File('mobile/android/examples/messaging_example/app')
78 project(':port_messaging_example').projectDir = new File('mobile/android/examples/port_messaging_example/app')