Joe Onorato | 77dc0a5 | 2010-05-17 18:16:11 -0700 | [diff] [blame] | 1 | # |
| 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 | |
| 17 | define filter-ide-goals |
| 18 | $(strip $(filter $(1)-%,$(MAKECMDGOALS))) |
| 19 | endef |
| 20 | |
| 21 | define filter-ide-modules |
| 22 | $(strip $(subst -,$(space),$(patsubst $(1)-%,%,$(2)))) |
| 23 | endef |
| 24 | |
| 25 | # eclipse |
| 26 | eclipse_project_goals := $(call filter-ide-goals,ECLIPSE) |
| 27 | ifdef 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 Onorato | 8a06bac | 2010-05-21 14:29:29 -0700 | [diff] [blame] | 33 | 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 Onorato | 77dc0a5 | 2010-05-17 18:16:11 -0700 | [diff] [blame] | 42 | source_paths := $(foreach m,$(eclipse_project_modules),$(ALL_MODULES.$(m).PATH)) \ |
Joe Onorato | 8a06bac | 2010-05-21 14:29:29 -0700 | [diff] [blame] | 43 | $(foreach m,$(eclipse_project_modules),$(ALL_MODULES.$(m).INTERMEDIATE_SOURCE_DIR)) \ |
| 44 | $(INTERNAL_SDK_SOURCE_DIRS) |
| 45 | source_paths := $(sort $(source_paths)) |
Joe Onorato | 77dc0a5 | 2010-05-17 18:16:11 -0700 | [diff] [blame] | 46 | |
| 47 | .classpath: PRIVATE_MODULES := $(eclipse_project_modules) |
Joe Onorato | 8a06bac | 2010-05-21 14:29:29 -0700 | [diff] [blame] | 48 | .classpath: PRIVATE_DIRS := $(source_paths) |
Joe Onorato | 77dc0a5 | 2010-05-17 18:16:11 -0700 | [diff] [blame] | 49 | |
| 50 | # the mess below with ./src tries to guess whether the src |
| 51 | $(eclipse_project_goals): .classpath |
| 52 | .classpath: FORCE |
Joe Onorato | 8a06bac | 2010-05-21 14:29:29 -0700 | [diff] [blame] | 53 | $(hide) echo Generating .classpath for eclipse |
Joe Onorato | 77dc0a5 | 2010-05-17 18:16:11 -0700 | [diff] [blame] | 54 | $(hide) echo '<classpath>' > $@ |
| 55 | $(hide) for p in $(PRIVATE_DIRS) ; do \ |
| 56 | echo -n ' <classpathentry kind="src" path="' >> $@ ; \ |
| 57 | ( if [ -d $$p/src ] ; then echo -n $$p/src ; else echo -n $$p ; fi ) >> $@ ; \ |
| 58 | echo '"/>' >> $@ ; \ |
| 59 | done |
| 60 | $(hide) echo '</classpath>' >> $@ |
| 61 | endif |
| 62 | |