1#!/bin/bash 2# 3# Copyright (C) 2012 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17# Generates a module index file by searching through android source tree for make files. The 18# intellij-gen.sh script automatically calls this script the first time or if you delete the 19# generated indexed file. The only time you need to run this manually is if modules are added or 20# deleted. 21# 22# To use: 23# index-gen.sh 24# 25# Only tested on linux. Should work for macs but have not tried. 26# 27set -e 28 29script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 30root_dir=`readlink -f -n $script_dir/../../..` 31tmp_file=tmp.txt 32dest_file=module-index.txt 33 34echo "Generating index file $dest_file..." 35start=$(($(date +%s%N) / 1000000)) 36find $root_dir -name '*.mk' \( ! -path "$root_dir/build*" -prune \) \ 37 \( -exec grep -H '^LOCAL_PACKAGE_NAME ' {} \; \ 38 -false -o -exec grep -H '^LOCAL_MODULE ' {} \; \) \ 39 > $tmp_file 40sed -e 's/LOCAL_PACKAGE_NAME *:= *//g' -e 's/LOCAL_MODULE *:= *//g' -e 's/\^M*$//g' < $tmp_file > $dest_file 41 42mv $dest_file $tmp_file 43# Exclude specific directories from index here. 44# TODO: make excludes more generic and configurable 45grep -v "^$root_dir/vendor/google" $tmp_file > $dest_file 46 47rm $tmp_file 48end=$(($(date +%s%N) / 1000000)) 49elapse=$(($end - $start)) 50echo "Took ${elapse}ms" 51