blob: c0cac65d9b4eff8cb38c00ce37a0ca6d976248d2 [file] [log] [blame]
Jeff Gaston79a43f22019-04-09 16:19:12 -04001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17def init = new Properties()
18ext.init = init
19
George Mount68e85572019-05-06 16:33:16 -070020def chooseOutDir(subdir = "") {
Jeff Gaston79a43f22019-04-09 16:19:12 -040021 /*
22 * The OUT_DIR is a temporary directory you can use to put things during the build.
23 */
24 def outDir = System.env.OUT_DIR
25 if (outDir == null) {
Jeff Gaston5633a812021-08-13 11:34:58 -040026 def checkoutRoot = System.getProperty("CHECKOUT_ROOT")
27 if (checkoutRoot == null) {
28 checkoutRoot = new File("${buildscript.sourceFile.parent}/../../..")
29 }
30 outDir = new File("${checkoutRoot}/out${subdir}")
Jeff Gaston8fd9fc82019-07-26 14:26:10 -040031 } else {
32 outDir = new File(outDir)
Jeff Gaston79a43f22019-04-09 16:19:12 -040033 }
Jeff Gaston8fd9fc82019-07-26 14:26:10 -040034 project.ext.outDir = outDir
Jeff Gaston79a43f22019-04-09 16:19:12 -040035 buildDir = new File(outDir, "$project.name/build")
36 .getCanonicalFile()
37 subprojects {
38 // Change buildDir first so that all plugins pick up the new value.
39 project.buildDir = new File("$project.parent.buildDir/../$project.name/build")
40 }
Jeff Gaston79a43f22019-04-09 16:19:12 -040041}
42
43ext.init.chooseOutDir = this.&chooseOutDir