blob: 57a46092970939fd6a655da3e9cc36f5779bf00c [file] [log] [blame]
Joe Onorato77dc0a52010-05-17 18:16:11 -07001#
2# Copyright (C) 2010 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17define filter-ide-goals
18$(strip $(filter $(1)-%,$(MAKECMDGOALS)))
19endef
20
21define filter-ide-modules
22$(strip $(subst -,$(space),$(patsubst $(1)-%,%,$(2))))
23endef
24
25# eclipse
26eclipse_project_goals := $(call filter-ide-goals,ECLIPSE)
27ifdef eclipse_project_goals
28 ifneq ($(words $(eclipse_project_goals)),1)
29 $(error Only one ECLIPSE- goal may be specified: $(eclipse_project_goals))
30 endif
31 eclipse_project_modules := $(call filter-ide-modules,ECLIPSE,$(eclipse_project_goals))
32
33 source_paths := $(foreach m,$(eclipse_project_modules),$(ALL_MODULES.$(m).PATH)) \
34 $(foreach m,$(eclipse_project_modules),$(ALL_MODULES.$(m).INTERMEDIATE_SOURCE_DIR))
35
36.classpath: PRIVATE_MODULES := $(eclipse_project_modules)
37.classpath: PRIVATE_DIRS := $(source_paths) $(INTERNAL_SDK_SOURCE_DIRS)
38
39# the mess below with ./src tries to guess whether the src
40$(eclipse_project_goals): .classpath
41.classpath: FORCE
42 $(hide) echo Generating .classpath for modules: $(PRIVATE_MODULES)
43 $(hide) echo '<classpath>' > $@
44 $(hide) for p in $(PRIVATE_DIRS) ; do \
45 echo -n ' <classpathentry kind="src" path="' >> $@ ; \
46 ( if [ -d $$p/src ] ; then echo -n $$p/src ; else echo -n $$p ; fi ) >> $@ ; \
47 echo '"/>' >> $@ ; \
48 done
49 $(hide) echo '</classpath>' >> $@
50endif
51