1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24gb_JavaClassSet_REPOSITORYNAMES := $(gb_Helper_REPOSITORYNAMES) 25gb_JavaClassSet_JAVACCOMMAND := $(JAVACOMPILER) 26 27define gb_JavaClassSet__command 28$(call gb_Helper_abbreviate_dirs_native,\ 29 mkdir -p $(dir $(1)) && \ 30 $(gb_JavaClassSet_JAVACCOMMAND) -cp "$(CLASSPATH)" -d $(call gb_JavaClassSet_get_classdir,$(2)) $(if $(filter-out $(JARDEPS),$(3)),\ 31 $(filter-out $(JARDEPS),$(3)),\ 32 $(filter-out $(JARDEPS),$(4))) &&\ 33 touch $(1)) 34 35endef 36 37$(call gb_JavaClassSet_get_target,%) : 38 $(call gb_Output_announce,$*,$(true),JCS,3) 39 $(call gb_JavaClassSet__command,$@,$*,$?,$^) 40 41$(call gb_JavaClassSet_get_clean_target,%) : 42 $(call gb_Output_announce,$*,$(false),JCS,3) 43 $(call gb_Helper_abbreviate_dirs,\ 44 rm -rf $(dir $(call gb_JavaClassSet_get_target,$*))) 45 46# no initialization of scoped variable CLASSPATH as it is "inherited" from controlling instance (e.g. JUnitTest, Jar) 47# UGLY: cannot use target local variable for REPO because it's needed in prereq 48define gb_JavaClassSet_JavaClassSet 49$(if $(filter $(2),$(gb_JavaClassSet_REPOSITORYNAMES)),,\ 50 $(error JavaClassSet: no or invalid repository given; known repositories: \ 51 $(gb_JavaClassSet_REPOSITORYNAMES))) 52gb_JavaClassSet_REPO_$(1) := $(2) 53$(call gb_JavaClassSet_get_target,$(1)) : JARDEPS := 54endef 55 56define gb_JavaClassSet__get_sourcefile 57$($(1))/$(2).java 58endef 59 60define gb_JavaClassSet_add_sourcefile 61$(eval $(call gb_JavaClassSet_get_target,$(1)) : \ 62 $(call gb_JavaClassSet__get_sourcefile,$(gb_JavaClassSet_REPO_$(1)),$(2))) 63endef 64 65define gb_JavaClassSet_add_sourcefiles 66$(foreach sourcefile,$(2),$(call gb_JavaClassSet_add_sourcefile,$(1),$(sourcefile))) 67endef 68 69define gb_JavaClassSet_set_classpath 70$(eval $(call gb_JavaClassSet_get_target,$(1)) : CLASSPATH := $(2)) 71endef 72 73# problem: currently we can't get these dependencies to work 74# build order dependency is a hack to get these prerequisites out of the way in the build command 75define gb_JavaClassSet_add_jar 76$(eval $(call gb_JavaClassSet_get_target,$(1)) : $(2)) 77$(eval $(call gb_JavaClassSet_get_target,$(1)) : CLASSPATH := $$(CLASSPATH)$$(gb_CLASSPATHSEP)$(strip $(2))) 78$(eval $(call gb_JavaClassSet_get_target,$(1)) : JARDEPS += $(2)) 79endef 80 81# this does not generate dependency on the jar 82define gb_JavaClassSet_add_system_jar 83$(eval $(call gb_JavaClassSet_get_target,$(1)) : CLASSPATH := $$(CLASSPATH)$$(gb_CLASSPATHSEP)$(strip $(2))) 84$(eval $(call gb_JavaClassSet_get_target,$(1)) : JARDEPS += $(2)) 85endef 86 87define gb_JavaClassSet_add_jars 88$(foreach jar,$(2),$(call gb_JavaClassSet_add_jar,$(1),$(jar))) 89endef 90 91define gb_JavaClassSet_add_system_jars 92$(foreach jar,$(2),$(call gb_JavaClassSet_add_system_jar,$(1),$(jar))) 93endef 94 95# this forwards to functions that must be defined in RepositoryExternal.mk. 96# $(call gb_LinkTarget_use_external,library,external) 97define gb_JavaClassSet_use_external 98$(eval $(if $(value gb_JavaClassSet__use_$(2)),\ 99 $(call gb_JavaClassSet__use_$(2),$(1)),\ 100 $(error gb_JavaClassSet_use_external: unknown external: $(2)))) 101endef 102 103define gb_JavaClassSet_use_externals 104$(foreach external,$(2),$(call gb_JavaClassSet_use_external,$(1),$(external))) 105endef 106 107# vim: set noet sw=4 ts=4: 108