1*b63233d8Sdamjan############################################################### 2*b63233d8Sdamjan# 3*b63233d8Sdamjan# Licensed to the Apache Software Foundation (ASF) under one 4*b63233d8Sdamjan# or more contributor license agreements. See the NOTICE file 5*b63233d8Sdamjan# distributed with this work for additional information 6*b63233d8Sdamjan# regarding copyright ownership. The ASF licenses this file 7*b63233d8Sdamjan# to you under the Apache License, Version 2.0 (the 8*b63233d8Sdamjan# "License"); you may not use this file except in compliance 9*b63233d8Sdamjan# with the License. You may obtain a copy of the License at 10*b63233d8Sdamjan# 11*b63233d8Sdamjan# http://www.apache.org/licenses/LICENSE-2.0 12*b63233d8Sdamjan# 13*b63233d8Sdamjan# Unless required by applicable law or agreed to in writing, 14*b63233d8Sdamjan# software distributed under the License is distributed on an 15*b63233d8Sdamjan# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b63233d8Sdamjan# KIND, either express or implied. See the License for the 17*b63233d8Sdamjan# specific language governing permissions and limitations 18*b63233d8Sdamjan# under the License. 19*b63233d8Sdamjan# 20*b63233d8Sdamjan############################################################### 21*b63233d8Sdamjan 22*b63233d8Sdamjan 23*b63233d8Sdamjan 24*b63233d8Sdamjan# if a jar prerequisite has changed, the ClassSet must be recompiled. How? 25*b63233d8Sdamjan 26*b63233d8Sdamjan# Jar class 27*b63233d8Sdamjan 28*b63233d8Sdamjangb_Jar_JAVACOMMAND := $(JAVAINTERPRETER) 29*b63233d8Sdamjangb_Jar_JARCOMMAND := jar 30*b63233d8Sdamjan 31*b63233d8Sdamjan# location of manifest file in workdir 32*b63233d8Sdamjandefine gb_Jar_get_manifest_target 33*b63233d8Sdamjan$(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,$(1)))/META-INF/MANIFEST.MF 34*b63233d8Sdamjanendef 35*b63233d8Sdamjan 36*b63233d8Sdamjan# creates classset and META-INF folders if they don't exist 37*b63233d8Sdamjan# adds manifest version, class path, solarversion and content from sources to manifest file 38*b63233d8Sdamjan# creates the target folder of the jar file if it doesn't exist 39*b63233d8Sdamjan# creates the jar file 40*b63233d8Sdamjandefine gb_Jar__command 41*b63233d8Sdamjan $(call gb_Helper_abbreviate_dirs_native,\ 42*b63233d8Sdamjan mkdir -p $(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,$(1)))/META-INF && \ 43*b63233d8Sdamjan echo Manifest-Version: 1.0 > $(call gb_Jar_get_manifest_target,$(1)) && \ 44*b63233d8Sdamjan echo "Class-Path: $(JARCLASSPATH)" >> $(call gb_Jar_get_manifest_target,$(1)) && \ 45*b63233d8Sdamjan echo "Solar-Version: $(RSCREVISION)" >> $(call gb_Jar_get_manifest_target,$(1)) && \ 46*b63233d8Sdamjan cat $(MANIFEST) >> $(call gb_Jar_get_manifest_target,$(1)) && \ 47*b63233d8Sdamjan mkdir -p $(dir $(2)) && \ 48*b63233d8Sdamjan cd $(call gb_JavaClassSet_get_classdir,$(call gb_Jar_get_classsetname,$(1))) && $(gb_Jar_JARCOMMAND) cfm $(2) $(call gb_Jar_get_manifest_target,$(1)) META-INF $(PACKAGEROOTS) ) 49*b63233d8Sdamjanendef 50*b63233d8Sdamjan 51*b63233d8Sdamjan# clean target reuses clean target of ClassSet 52*b63233d8Sdamjan$(call gb_Jar_get_clean_target,%) : $(call gb_JavaClassSet_get_clean_target,$(call gb_Jar_get_classsetname,%)) 53*b63233d8Sdamjan $(call gb_Output_announce,$*,$(false),JAR,3) 54*b63233d8Sdamjan $(call gb_Helper_abbreviate_dirs,\ 55*b63233d8Sdamjan rm -f $(call gb_Jar_get_target,$*) $(call gb_Jar_get_outdir_target,$*)) 56*b63233d8Sdamjan 57*b63233d8Sdamjan# the outdir target depends on the workdir target and is built by delivering the latter 58*b63233d8Sdamjan# the workdir target is created by cd'ing to the target directory and adding/updating the files 59*b63233d8Sdamjan 60*b63233d8Sdamjan# rule for creating the jar file using the command defined above 61*b63233d8Sdamjan$(call gb_Jar_get_target,%) : $(call gb_JavaClassSet_get_target,$(call gb_Jar_get_classsetname,%)) 62*b63233d8Sdamjan $(call gb_Jar__command,$*,$@,$*,$?) 63*b63233d8Sdamjan 64*b63233d8Sdamjan# resets scoped variables (see explanations where they are set) 65*b63233d8Sdamjan# creates a class set and a dependency to it 66*b63233d8Sdamjan# registers target and clean target 67*b63233d8Sdamjan# adds jar files to DeliverLogTarget 68*b63233d8Sdamjan# adds dependency for outdir target to workdir target (pattern rule for delivery is in Package.mk) 69*b63233d8Sdamjandefine gb_Jar_Jar 70*b63233d8Sdamjan$(call gb_Jar_get_target,$(1)) : MANIFEST := 71*b63233d8Sdamjan$(call gb_Jar_get_target,$(1)) : JARCLASSPATH := 72*b63233d8Sdamjan$(call gb_Jar_get_target,$(1)) : PACKAGEROOTS := 73*b63233d8Sdamjan$(call gb_JavaClassSet_JavaClassSet,$(call gb_Jar_get_classsetname,$(1)),$(2)) 74*b63233d8Sdamjan$(call gb_JavaClassSet_set_classpath,$(call gb_Jar_get_classsetname,$(1)),$(value XCLASSPATH)) 75*b63233d8Sdamjan$(eval $(call gb_Module_register_target,$(call gb_Jar_get_outdir_target,$(1)),$(call gb_Jar_get_clean_target,$(1)))) 76*b63233d8Sdamjan$(call gb_Deliver_add_deliverable,$(call gb_Jar_get_outdir_target,$(1)),$(call gb_Jar_get_target,$(1)),$(1)) 77*b63233d8Sdamjan$(call gb_Jar_get_outdir_target,$(1)) : $(call gb_Jar_get_target,$(1)) 78*b63233d8Sdamjan 79*b63233d8Sdamjanendef 80*b63233d8Sdamjan 81*b63233d8Sdamjan# source files are forwarded to the ClassSet 82*b63233d8Sdamjandefine gb_Jar_add_sourcefile 83*b63233d8Sdamjan$(call gb_JavaClassSet_add_sourcefile,$(call gb_Jar_get_classsetname,$(1)),$(2)) 84*b63233d8Sdamjanendef 85*b63233d8Sdamjan 86*b63233d8Sdamjan# PACKAGEROOTS is the list of all root folders to pack into the jar (without META-INF as this is added automatically) 87*b63233d8Sdamjandefine gb_Jar_set_packageroot 88*b63233d8Sdamjan$(call gb_Jar_get_target,$(1)) : PACKAGEROOTS := $(2) 89*b63233d8Sdamjanendef 90*b63233d8Sdamjan 91*b63233d8Sdamjandefine gb_Jar_add_sourcefiles 92*b63233d8Sdamjan$(foreach sourcefile,$(2),$(call gb_Jar_add_sourcefile,$(1),$(sourcefile))) 93*b63233d8Sdamjanendef 94*b63233d8Sdamjan 95*b63233d8Sdamjandefine gb_JarTest_set_classpath 96*b63233d8Sdamjan$(call gb_JavaClassSet_set_classpath,$(call gb_Jar_get_classsetname,$(1)),$(2)) 97*b63233d8Sdamjanendef 98*b63233d8Sdamjan 99*b63233d8Sdamjan# JARCLASSPATH is the class path that is written to the manifest of the jar 100*b63233d8Sdamjandefine gb_Jar_set_jarclasspath 101*b63233d8Sdamjan 102*b63233d8Sdamjan$(call gb_Jar_get_target,$(1)) : JARCLASSPATH := $(2) 103*b63233d8Sdamjanendef 104*b63233d8Sdamjan 105*b63233d8Sdamjan# provide a manifest template containing jar specific information to be written into the manifest 106*b63233d8Sdamjan# it will be appended to the standard content that is written in the build command explicitly 107*b63233d8Sdamjan# the jar file gets a dependency to the manifest template 108*b63233d8Sdamjandefine gb_Jar_set_manifest 109*b63233d8Sdamjan$(call gb_Jar_get_target,$(1)) : MANIFEST := $(2) 110*b63233d8Sdamjan$(call gb_Jar_get_target,$(1)) : $(2) 111*b63233d8Sdamjan 112*b63233d8Sdamjanendef 113*b63233d8Sdamjan 114*b63233d8Sdamjan# remember: classpath is "inherited" to ClassSet 115*b63233d8Sdamjandefine gb_Jar_add_jar 116*b63233d8Sdamjan$(call gb_JavaClassSet_add_jar,$(call gb_Jar_get_classsetname,$(1)),$(2)) 117*b63233d8Sdamjanendef 118*b63233d8Sdamjan 119*b63233d8Sdamjandefine gb_Jar_add_system_jar 120*b63233d8Sdamjan$(call gb_JavaClassSet_add_system_jar,$(call gb_Jar_get_classsetname,$(1)),$(2)) 121*b63233d8Sdamjanendef 122*b63233d8Sdamjan 123*b63233d8Sdamjan# specify jars with imported modules 124*b63233d8Sdamjandefine gb_Jar_add_jars 125*b63233d8Sdamjan$(call gb_JavaClassSet_add_jars,$(call gb_Jar_get_classsetname,$(1)),$(2)) 126*b63233d8Sdamjanendef 127*b63233d8Sdamjan 128*b63233d8Sdamjandefine gb_Jar_add_system_jars 129*b63233d8Sdamjan$(call gb_JavaClassSet_add_system_jars,$(call gb_Jar_get_classsetname,$(1)),$(2)) 130*b63233d8Sdamjanendef 131*b63233d8Sdamjan 132*b63233d8Sdamjandefine gb_Jar_use_external 133*b63233d8Sdamjan$(call gb_JavaClassSet_use_external,$(call gb_Jar_get_classsetname,$(1)),$(2)) 134*b63233d8Sdamjanendef 135*b63233d8Sdamjan 136*b63233d8Sdamjandefine gb_Jar_use_externals 137*b63233d8Sdamjan$(call gb_JavaClassSet_use_externals,$(call gb_Jar_get_classsetname,$(1)),$(2)) 138*b63233d8Sdamjanendef 139*b63233d8Sdamjan 140*b63233d8Sdamjan# possible directories for jar files containing UNO services 141*b63233d8Sdamjangb_Jar_COMPONENTPREFIXES := \ 142*b63233d8Sdamjan OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/classes/ \ 143*b63233d8Sdamjan URE:vnd.sun.star.expand:\dURE_INTERNAL_JAVA_DIR/ \ 144*b63233d8Sdamjan INTERN:vnd.sun.star.expand:\dOOO_INBUILD_JAVA_DIR/ 145*b63233d8Sdamjan 146*b63233d8Sdamjan# get component prefix from layer name ("OOO", "URE", "INTERN") 147*b63233d8Sdamjangb_Jar__get_componentprefix = \ 148*b63233d8Sdamjan $(patsubst $(1):%,%,$(or \ 149*b63233d8Sdamjan $(filter $(1):%,$(gb_Jar_COMPONENTPREFIXES)), \ 150*b63233d8Sdamjan $(call gb_Output_error,no ComponentTarget native prefix for layer '$(1)'))) 151*b63233d8Sdamjan 152*b63233d8Sdamjan# layer must be specified explicitly in this macro (different to libraries) 153*b63233d8Sdamjandefine gb_Jar_set_componentfile 154*b63233d8Sdamjan$(call gb_ComponentTarget_ComponentTarget,$(2),$(call gb_Jar__get_componentprefix,$(3)),$(notdir $(call gb_Jar_get_target,$(1)))) 155*b63233d8Sdamjan$(call gb_Jar_get_target,$(1)) : $(call gb_ComponentTarget_get_outdir_target,$(2)) 156*b63233d8Sdamjan$(call gb_Jar_get_clean_target,$(1)) : $(call gb_ComponentTarget_get_clean_target,$(2)) 157*b63233d8Sdamjan 158*b63233d8Sdamjanendef 159*b63233d8Sdamjan 160*b63233d8Sdamjan 161*b63233d8Sdamjan# vim: set noet sw=4 ts=4: 162