blob: a3aa0cdc03a5cd3d2e573c2c63de98bfc89224af [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
Joe Onorato8a06bac2010-05-21 14:29:29 -070033 ifneq ($(filter lunch,$(eclipse_project_modules)),)
34 eclipse_project_modules := $(filter-out lunch,$(eclipse_project_modules))
35 installed_modules := $(foreach m,$(ALL_DEFAULT_INSTALLED_MODULES),\
36 $(INSTALLABLE_FILES.$(m).MODULE))
37 java_modules := $(foreach m,$(installed_modules),\
38 $(if $(filter JAVA_LIBRARIES APPS,$(ALL_MODULES.$(m).CLASS)),$(m),))
39 eclipse_project_modules := $(sort $(eclipse_project_modules) $(java_modules))
40 endif
41
Joe Onorato77dc0a52010-05-17 18:16:11 -070042 source_paths := $(foreach m,$(eclipse_project_modules),$(ALL_MODULES.$(m).PATH)) \
Anton Hansson065676f2020-07-15 13:02:05 +010043 $(foreach m,$(eclipse_project_modules),$(ALL_MODULES.$(m).INTERMEDIATE_SOURCE_DIR))
Joe Onorato8a06bac2010-05-21 14:29:29 -070044 source_paths := $(sort $(source_paths))
Joe Onorato77dc0a52010-05-17 18:16:11 -070045
46.classpath: PRIVATE_MODULES := $(eclipse_project_modules)
Joe Onorato8a06bac2010-05-21 14:29:29 -070047.classpath: PRIVATE_DIRS := $(source_paths)
Joe Onorato77dc0a52010-05-17 18:16:11 -070048
49# the mess below with ./src tries to guess whether the src
50$(eclipse_project_goals): .classpath
51.classpath: FORCE
Joe Onorato8a06bac2010-05-21 14:29:29 -070052 $(hide) echo Generating .classpath for eclipse
Joe Onorato77dc0a52010-05-17 18:16:11 -070053 $(hide) echo '<classpath>' > $@
54 $(hide) for p in $(PRIVATE_DIRS) ; do \
55 echo -n ' <classpathentry kind="src" path="' >> $@ ; \
56 ( if [ -d $$p/src ] ; then echo -n $$p/src ; else echo -n $$p ; fi ) >> $@ ; \
57 echo '"/>' >> $@ ; \
58 done
59 $(hide) echo '</classpath>' >> $@
60endif
61