diff options
author | Dan Willemsen <dwillemsen@google.com> | 2017-07-18 19:39:34 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2017-07-24 15:29:14 -0700 |
commit | 91f9b547672ecb20a308d52df3a0c09d616cb1b9 (patch) | |
tree | bdf38ca0f3bd5fd626fa81211d0836e123dbee1b /scripts/microfactory.bash | |
parent | 99cd671ac35897e9514c6ca687dfeeeecedb36d3 (diff) | |
download | build_soong-91f9b547672ecb20a308d52df3a0c09d616cb1b9.tar.gz build_soong-91f9b547672ecb20a308d52df3a0c09d616cb1b9.tar.bz2 build_soong-91f9b547672ecb20a308d52df3a0c09d616cb1b9.zip |
Switch to blueprint's microfactory
Bug: 63720725
Test: m -j nothing
Test: mkdir o; ../bootstrap.bash; ./soong
Change-Id: Id1f8312678f36afd08b49f8511fec3e6e5ba8de2
Diffstat (limited to 'scripts/microfactory.bash')
-rw-r--r-- | scripts/microfactory.bash | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/scripts/microfactory.bash b/scripts/microfactory.bash new file mode 100644 index 00000000..65ba55d9 --- /dev/null +++ b/scripts/microfactory.bash @@ -0,0 +1,66 @@ +# Copyright 2017 Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Set of utility functions to build and run go code with microfactory +# +# Inputs: +# ${TOP}: The top of the android source tree +# ${OUT_DIR}: The output directory location (defaults to ${TOP}/out) +# ${OUT_DIR_COMMON_BASE}: Change the default out directory to +# ${OUT_DIR_COMMON_BASE}/$(basename ${TOP}) + +# Ensure GOROOT is set to the in-tree version. +case $(uname) in + Linux) + export GOROOT="${TOP}/prebuilts/go/linux-x86/" + ;; + Darwin) + export GOROOT="${TOP}/prebuilts/go/darwin-x86/" + ;; + *) echo "unknown OS:" $(uname) >&2 && exit 1;; +esac + +# Find the output directory +function getoutdir +{ + local out_dir="${OUT_DIR-}" + if [ -z "${out_dir}" ]; then + if [ "${OUT_DIR_COMMON_BASE-}" ]; then + out_dir="${OUT_DIR_COMMON_BASE}/$(basename ${TOP})" + else + out_dir="out" + fi + fi + if [[ "${out_dir}" != /* ]]; then + out_dir="${TOP}/${out_dir}" + fi + echo "${out_dir}" +} + +# Bootstrap microfactory from source if necessary and use it to build the +# requested binary. +# +# Arguments: +# $1: name of the requested binary +# $2: package name +function soong_build_go +{ + BUILDDIR=$(getoutdir) \ + SRCDIR=${TOP} \ + BLUEPRINTDIR=${TOP}/build/blueprint \ + EXTRA_ARGS="-pkg-path android/soong=${TOP}/build/soong" \ + build_go $@ +} + +source ${TOP}/build/blueprint/microfactory/microfactory.bash |