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 # To use, run the following command from either your repo root or 18 # development/tools/idegen: 19 # intellij-gen.sh <module name> 20 # 21 # where module name is the LOCAL_PACKAGE_NAME in Android.mk for the project. 22 # 23 # For example, to generate a project for Contacts, use: 24 # intellij-gen.sh Contacts 25 # 26 # The project directory (.idea) will be put in the root directory of 27 # the module. Sharable iml files will be put into each respective 28 # module directory. 29 # 30 # Only tested on linux. Should work for macs but have not tried. 31 # 32 set -e 33 34 progname=`basename $0` 35 if [ $# -lt 2 ] 36 then 37 echo "Usage: $progname project_dir module_dir <module_dir>..." 38 exit 1 39 fi 40 project_dir=${PWD}/$1 41 shift 42 module_dirs=$@ 43 echo $module_dirs 44 script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 45 root_dir=$PWD 46 if [ ! -e $root_dir/.repo ]; then 47 root_dir=$PWD/../../.. 48 if [ ! -e $root_dir/.repo ]; then 49 echo "Repo root not found. Run this script from your repo root or the idegen directory." 50 exit 1 51 fi 52 fi 53 index_file=$root_dir/module-index.txt 54 idegenjar=$script_dir/idegen.jar 55 if [ ! -e $idegenjar ]; then 56 # See if the jar is in the build directory. 57 platform="linux" 58 if [ "Darwin" = "$(uname)" ]; then 59 platform="darwin" 60 fi 61 idegenjar="$root_dir/out/host/$platform-x86/framework/idegen.jar" 62 fi 63 64 if [ ! -e "$index_file" ]; then 65 echo "Module index file missing; generating this is only done the first time." 66 echo "If any dependencies change, you should generate a new index file by running index-gen.sh." 67 $script_dir/index-gen.sh 68 fi 69 70 echo "Checking for $idegenjar" 71 if [ -e "$idegenjar" ]; then 72 echo "Generating project files for $module_dirs" 73 cmd="java -cp $idegenjar com.android.idegen.IntellijProject $index_file $project_dir $module_dirs" 74 echo $cmd 75 $cmd 76 else 77 echo "Couldn't find idegen.jar. Please run make first." 78 fi 79