forked from openkylin/platform_build
add pathmod to envsetup.sh for making finding paths to modules easier
Change-Id: Ice1f2ff6d46a61bca5a4ddc1163af36c89947822 Test: gomod vsoc_lib && pwd Test: pathmod vsoc_lib Test: pathmod foobar # get error message Test: gomod foobar # get error message, directory doesn't change
This commit is contained in:
parent
8faac3669e
commit
78d1c93e12
24
envsetup.sh
24
envsetup.sh
|
@ -28,6 +28,7 @@ Invoke ". build/envsetup.sh" from your shell to add the following functions to y
|
||||||
- godir: Go to the directory containing a file.
|
- godir: Go to the directory containing a file.
|
||||||
- allmod: List all modules.
|
- allmod: List all modules.
|
||||||
- gomod: Go to the directory containing a module.
|
- gomod: Go to the directory containing a module.
|
||||||
|
- pathmod: Get the directory containing a module.
|
||||||
- refreshmod: Refresh list of modules for allmod/gomod.
|
- refreshmod: Refresh list of modules for allmod/gomod.
|
||||||
|
|
||||||
Environment options:
|
Environment options:
|
||||||
|
@ -1517,16 +1518,16 @@ function allmod() {
|
||||||
python -c "import json; print '\n'.join(sorted(json.load(open('$ANDROID_PRODUCT_OUT/module-info.json')).keys()))"
|
python -c "import json; print '\n'.join(sorted(json.load(open('$ANDROID_PRODUCT_OUT/module-info.json')).keys()))"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Go to a specific module in the android tree, as cached in module-info.json. If any build change
|
# Get the path of a specific module in the android tree, as cached in module-info.json. If any build change
|
||||||
# is made, and it should be reflected in the output, you should run 'refreshmod' first.
|
# is made, and it should be reflected in the output, you should run 'refreshmod' first.
|
||||||
function gomod() {
|
function pathmod() {
|
||||||
if [ ! "$ANDROID_PRODUCT_OUT" ]; then
|
if [ ! "$ANDROID_PRODUCT_OUT" ]; then
|
||||||
echo "No ANDROID_PRODUCT_OUT. Try running 'lunch' first." >&2
|
echo "No ANDROID_PRODUCT_OUT. Try running 'lunch' first." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $# -ne 1 ]]; then
|
if [[ $# -ne 1 ]]; then
|
||||||
echo "usage: gomod <module>" >&2
|
echo "usage: pathmod <module>" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1546,10 +1547,25 @@ print module_info[module]['path'][0]" 2>/dev/null)
|
||||||
echo "Could not find module '$1' (try 'refreshmod' if there have been build changes?)." >&2
|
echo "Could not find module '$1' (try 'refreshmod' if there have been build changes?)." >&2
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
cd $ANDROID_BUILD_TOP/$relpath
|
echo "$ANDROID_BUILD_TOP/$relpath"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Go to a specific module in the android tree, as cached in module-info.json. If any build change
|
||||||
|
# is made, and it should be reflected in the output, you should run 'refreshmod' first.
|
||||||
|
function gomod() {
|
||||||
|
if [[ $# -ne 1 ]]; then
|
||||||
|
echo "usage: gomod <module>" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local path="$(pathmod $@)"
|
||||||
|
if [ -z "$path" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
cd $path
|
||||||
|
}
|
||||||
|
|
||||||
function _complete_android_module_names() {
|
function _complete_android_module_names() {
|
||||||
local word=${COMP_WORDS[COMP_CWORD]}
|
local word=${COMP_WORDS[COMP_CWORD]}
|
||||||
COMPREPLY=( $(allmod | grep -E "^$word") )
|
COMPREPLY=( $(allmod | grep -E "^$word") )
|
||||||
|
|
Loading…
Reference in New Issue