make/common/IdlCompilation.gmk

changeset 912
a667caba1e84
parent 839
174a54ce39c4
child 1133
50aaf272884f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/make/common/IdlCompilation.gmk	Thu Nov 14 10:53:23 2013 +0100
     1.3 @@ -0,0 +1,106 @@
     1.4 +#
     1.5 +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 +#
     1.8 +# This code is free software; you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU General Public License version 2 only, as
    1.10 +# published by the Free Software Foundation.  Oracle designates this
    1.11 +# particular file as subject to the "Classpath" exception as provided
    1.12 +# by Oracle in the LICENSE file that accompanied this code.
    1.13 +#
    1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +# version 2 for more details (a copy is included in the LICENSE file that
    1.18 +# accompanied this code).
    1.19 +#
    1.20 +# You should have received a copy of the GNU General Public License version
    1.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +#
    1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 +# or visit www.oracle.com if you need additional information or have any
    1.26 +# questions.
    1.27 +#
    1.28 +
    1.29 +PREFIXES=-pkgPrefix CORBA org.omg \
    1.30 +    -pkgPrefix CosNaming org.omg \
    1.31 +    -pkgPrefix CosTransactions org.omg \
    1.32 +    -pkgPrefix CosTSInteroperation org.omg \
    1.33 +    -pkgPrefix DynamicAny org.omg \
    1.34 +    -pkgPrefix Dynamic org.omg \
    1.35 +    -pkgPrefix IOP org.omg \
    1.36 +    -pkgPrefix Messaging org.omg \
    1.37 +    -pkgPrefix PortableInterceptor org.omg \
    1.38 +    -pkgPrefix PortableServer org.omg \
    1.39 +    -pkgPrefix activation com.sun.corba.se.spi \
    1.40 +    -pkgPrefix GIOP com.sun.corba.se \
    1.41 +    -pkgPrefix PortableActivationIDL com.sun.corba.se \
    1.42 +    -pkgPrefix messages com.sun.corba.se
    1.43 +
    1.44 +define add_idl_package
    1.45 +  # param 1 = MYPACKAGE
    1.46 +  # param 2 = src root
    1.47 +  # param 3 = gensrc root
    1.48 +  # param 4 = source idl to compile
    1.49 +  # param 5 = target idl package
    1.50 +  # param 6 = delete these files that were output from the idlj
    1.51 +  # param 7 = idls that match these patterns should be compiled with -oldImplBase
    1.52 +  # param 8 = the idlj command
    1.53 +  # Save the generated java files to a temporary directory so
    1.54 +  # that we can find them and create proper dependencies.
    1.55 +  # After that, we move them to the real gensrc target dir.
    1.56 +  $4_TMPDIR:=tmp___$(subst /,_,$(patsubst $2/%,%,$4))___
    1.57 +  ifneq ($$(filter $7,$4),)
    1.58 +    $4_OLDIMPLBASE:=-oldImplBase
    1.59 +    $4_OLDIMPLBASE_MSG:=with -oldImplBase
    1.60 +  endif
    1.61 +  $5 : $4
    1.62 +	$(MKDIR) -p $3/$$($4_TMPDIR)
    1.63 +	$(RM) -rf $3/$$($4_TMPDIR)
    1.64 +	$(MKDIR) -p $(dir $5)
    1.65 +	$(ECHO) $(LOG_INFO) Compiling IDL $(patsubst $2/%,%,$4)
    1.66 +	$8 -td $3/$$($4_TMPDIR) \
    1.67 +	    -i $2/org/omg/CORBA \
    1.68 +	    -i $2/org/omg/PortableInterceptor \
    1.69 +	    -i $2/org/omg/PortableServer \
    1.70 +	    -D CORBA3 -corba 3.0 \
    1.71 +	    -fall \
    1.72 +	    $$($4_OLDIMPLBASE) \
    1.73 +	    $(PREFIXES) \
    1.74 +	    $4
    1.75 +	$(RM) -f $$(addprefix $3/$$($4_TMPDIR)/,$6)
    1.76 +	$(CP) -r $3/$$($4_TMPDIR)/* $3
    1.77 +	($(CD) $3/$$($4_TMPDIR) && $(FIND) . -type f | $(SED) 's!\./!$3/!g' | $(NAWK) '{ print $$$$1 ": $4" }' > $5)
    1.78 +	$(RM) -rf $3/$$($4_TMPDIR)
    1.79 +endef
    1.80 +
    1.81 +define SetupIdlCompilation
    1.82 +  # param 1 is for example BUILD_IDLS
    1.83 +  # param 2,3,4,5,6,7,8 are named args.
    1.84 +  #   IDLJ,SRC,BIN,INCLUDES,EXCLUDES,OLDIMPLBASES,DELETES
    1.85 +  $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
    1.86 +  $(call LogSetupMacroEntry,SetupIdlCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
    1.87 +  $(if $(16),$(error Internal makefile error: Too many arguments to SetupIdlCompilation, please update IdlCompilation.gmk))
    1.88 +
    1.89 +  # Find all existing java files and existing class files.
    1.90 +  $$(eval $$(call MakeDir,$$($1_BIN)))
    1.91 +  $1_SRCS := $$(shell find $$($1_SRC) -name "*.idl")
    1.92 +  $1_BINS := $$(shell find $$($1_BIN) -name "*.java")
    1.93 +  # Prepend the source/bin path to the filter expressions.
    1.94 +  $1_SRC_INCLUDES := $$(addprefix $$($1_SRC)/,$$($1_INCLUDES))
    1.95 +  $1_SRC_EXCLUDES := $$(addprefix $$($1_SRC)/,$$($1_EXCLUDES))
    1.96 +  $1_BIN_INCLUDES := $$(addprefix $$($1_BIN)/,$$($1_INCLUDES))
    1.97 +  $1_BIN_EXCLUDES := $$(addprefix $$($1_BIN)/,$$($1_EXCLUDES))
    1.98 +  $1_OLDIMPLBASES := $$(addprefix $$($1_SRC)/,$$($1_OLDIMPLBASES))
    1.99 +  # Now remove unwanted java/class files.
   1.100 +  $1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
   1.101 +  $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
   1.102 +  $1_BINS := $$(filter $$($1_BIN_INCLUDES),$$($1_BINS))
   1.103 +  $1_BINS := $$(filter-out $$($1_BIN_EXCLUDES),$$($1_BINS))
   1.104 +  $1 := $$(sort $$(patsubst $$($1_SRC)/%.idl,$$($1_BIN)/%.idl.d,$$($1_SRCS)))
   1.105 +  # Now create the dependencies for each idl target.
   1.106 +  $$(foreach p,$$($1),$$(eval $$(call add_idl_package,$1,$$($1_SRC),$$($1_BIN),$$(patsubst $$($1_BIN)/%.idl.d,$$($1_SRC)/%.idl,$$p),$$p,$$($1_DELETES),$$($1_OLDIMPLBASES),$$($1_IDLJ))))
   1.107 +endef
   1.108 +
   1.109 +.SUFFIXES: .java .class .package

mercurial