Loading OWNERS +1 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ include platform/build/soong:/OWNERS # Since this file affects all Android developers, lock it down. There is still # round the world timzeone coverage. per-file envsetup.sh = joeo@google.com, jingwen@google.com, lberki@google.com per-file shell_utils.sh = joeo@google.com, jingwen@google.com, lberki@google.com # Finalization scripts per-file finalize* = smoreland@google.com, alexbuy@google.com envsetup.sh +52 −27 Original line number Diff line number Diff line # Copyright (C) 2022 The Android Open Source Project # # 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. # gettop is duplicated here and in shell_utils.mk, because it's difficult # to find shell_utils.make without it for all the novel ways this file can be # sourced. Other common functions should only be in one place or the other. function _gettop_once { local TOPFILE=build/make/core/envsetup.mk if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then # The following circumlocution ensures we remove symlinks from TOP. (cd "$TOP"; PWD= /bin/pwd) else if [ -f $TOPFILE ] ; then # The following circumlocution (repeated below as well) ensures # that we record the true directory name and not one that is # faked up with symlink names. PWD= /bin/pwd else local HERE=$PWD local T= while [ \( ! \( -f $TOPFILE \) \) -a \( "$PWD" != "/" \) ]; do \cd .. T=`PWD= /bin/pwd -P` done \cd "$HERE" if [ -f "$T/$TOPFILE" ]; then echo "$T" fi fi fi } T=$(_gettop_once) if [ ! "$T" ]; then echo "Couldn't locate the top of the tree. Always source build/envsetup.sh from the root of the tree." >&2 return 1 fi IMPORTING_ENVSETUP=true source $T/build/make/shell_utils.sh # Help function hmm() { cat <<EOF Loading Loading @@ -928,33 +980,6 @@ function banchan() destroy_build_var_cache } function gettop { local TOPFILE=build/make/core/envsetup.mk if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then # The following circumlocution ensures we remove symlinks from TOP. (cd "$TOP"; PWD= /bin/pwd) else if [ -f $TOPFILE ] ; then # The following circumlocution (repeated below as well) ensures # that we record the true directory name and not one that is # faked up with symlink names. PWD= /bin/pwd else local HERE=$PWD local T= while [ \( ! \( -f $TOPFILE \) \) -a \( "$PWD" != "/" \) ]; do \cd .. T=`PWD= /bin/pwd -P` done \cd "$HERE" if [ -f "$T/$TOPFILE" ]; then echo "$T" fi fi fi } # TODO: Merge into gettop as part of launching multitree function multitree_gettop { Loading shell_utils.sh 0 → 100644 +74 −0 Original line number Diff line number Diff line # Copyright (C) 2022 The Android Open Source Project # # 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. function gettop { local TOPFILE=build/make/core/envsetup.mk # The ${TOP-} expansion allows this to work even with set -u if [ -n "${TOP:-}" -a -f "${TOP:-}/$TOPFILE" ] ; then # The following circumlocution ensures we remove symlinks from TOP. (cd "$TOP"; PWD= /bin/pwd) else if [ -f $TOPFILE ] ; then # The following circumlocution (repeated below as well) ensures # that we record the true directory name and not one that is # faked up with symlink names. PWD= /bin/pwd else local HERE=$PWD local T= while [ \( ! \( -f $TOPFILE \) \) -a \( "$PWD" != "/" \) ]; do \cd .. T=`PWD= /bin/pwd -P` done \cd "$HERE" if [ -f "$T/$TOPFILE" ]; then echo "$T" fi fi fi } # Sets TOP, or if the root of the tree can't be found, prints a message and # exits. Since this function exits, it should not be called from functions # defined in envsetup.sh. if [ -z "${IMPORTING_ENVSETUP:-}" ] ; then function require_top { TOP=$(gettop) if [[ ! $TOP ]] ; then echo "Can not locate root of source tree. $(basename $0) must be run from within the Android source tree." >&2 exit 1 fi } fi function getoutdir { local top=$(gettop) local out_dir="${OUT_DIR:-}" if [[ -z "${out_dir}" ]]; then if [[ -n "${OUT_DIR_COMMON_BASE:-}" && -n "${top}" ]]; 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}" } Loading
OWNERS +1 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ include platform/build/soong:/OWNERS # Since this file affects all Android developers, lock it down. There is still # round the world timzeone coverage. per-file envsetup.sh = joeo@google.com, jingwen@google.com, lberki@google.com per-file shell_utils.sh = joeo@google.com, jingwen@google.com, lberki@google.com # Finalization scripts per-file finalize* = smoreland@google.com, alexbuy@google.com
envsetup.sh +52 −27 Original line number Diff line number Diff line # Copyright (C) 2022 The Android Open Source Project # # 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. # gettop is duplicated here and in shell_utils.mk, because it's difficult # to find shell_utils.make without it for all the novel ways this file can be # sourced. Other common functions should only be in one place or the other. function _gettop_once { local TOPFILE=build/make/core/envsetup.mk if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then # The following circumlocution ensures we remove symlinks from TOP. (cd "$TOP"; PWD= /bin/pwd) else if [ -f $TOPFILE ] ; then # The following circumlocution (repeated below as well) ensures # that we record the true directory name and not one that is # faked up with symlink names. PWD= /bin/pwd else local HERE=$PWD local T= while [ \( ! \( -f $TOPFILE \) \) -a \( "$PWD" != "/" \) ]; do \cd .. T=`PWD= /bin/pwd -P` done \cd "$HERE" if [ -f "$T/$TOPFILE" ]; then echo "$T" fi fi fi } T=$(_gettop_once) if [ ! "$T" ]; then echo "Couldn't locate the top of the tree. Always source build/envsetup.sh from the root of the tree." >&2 return 1 fi IMPORTING_ENVSETUP=true source $T/build/make/shell_utils.sh # Help function hmm() { cat <<EOF Loading Loading @@ -928,33 +980,6 @@ function banchan() destroy_build_var_cache } function gettop { local TOPFILE=build/make/core/envsetup.mk if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then # The following circumlocution ensures we remove symlinks from TOP. (cd "$TOP"; PWD= /bin/pwd) else if [ -f $TOPFILE ] ; then # The following circumlocution (repeated below as well) ensures # that we record the true directory name and not one that is # faked up with symlink names. PWD= /bin/pwd else local HERE=$PWD local T= while [ \( ! \( -f $TOPFILE \) \) -a \( "$PWD" != "/" \) ]; do \cd .. T=`PWD= /bin/pwd -P` done \cd "$HERE" if [ -f "$T/$TOPFILE" ]; then echo "$T" fi fi fi } # TODO: Merge into gettop as part of launching multitree function multitree_gettop { Loading
shell_utils.sh 0 → 100644 +74 −0 Original line number Diff line number Diff line # Copyright (C) 2022 The Android Open Source Project # # 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. function gettop { local TOPFILE=build/make/core/envsetup.mk # The ${TOP-} expansion allows this to work even with set -u if [ -n "${TOP:-}" -a -f "${TOP:-}/$TOPFILE" ] ; then # The following circumlocution ensures we remove symlinks from TOP. (cd "$TOP"; PWD= /bin/pwd) else if [ -f $TOPFILE ] ; then # The following circumlocution (repeated below as well) ensures # that we record the true directory name and not one that is # faked up with symlink names. PWD= /bin/pwd else local HERE=$PWD local T= while [ \( ! \( -f $TOPFILE \) \) -a \( "$PWD" != "/" \) ]; do \cd .. T=`PWD= /bin/pwd -P` done \cd "$HERE" if [ -f "$T/$TOPFILE" ]; then echo "$T" fi fi fi } # Sets TOP, or if the root of the tree can't be found, prints a message and # exits. Since this function exits, it should not be called from functions # defined in envsetup.sh. if [ -z "${IMPORTING_ENVSETUP:-}" ] ; then function require_top { TOP=$(gettop) if [[ ! $TOP ]] ; then echo "Can not locate root of source tree. $(basename $0) must be run from within the Android source tree." >&2 exit 1 fi } fi function getoutdir { local top=$(gettop) local out_dir="${OUT_DIR:-}" if [[ -z "${out_dir}" ]]; then if [[ -n "${OUT_DIR_COMMON_BASE:-}" && -n "${top}" ]]; 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}" }