common/makefiles/IdlCompilation.gmk

changeset 425
e1830598f0b7
child 458
c8d320b48626
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/common/makefiles/IdlCompilation.gmk	Tue Apr 10 08:18:28 2012 -0700
     1.3 @@ -0,0 +1,114 @@
     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 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 -rp $3/$$($4_TMPDIR)/* $3
    1.77 +	(cd $3/$$($4_TMPDIR); find . -type f | sed 's!\./!$3/!g' | awk '{ 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 +$(if $2,$1_$(strip $2))
    1.86 +$(if $3,$1_$(strip $3))
    1.87 +$(if $4,$1_$(strip $4))
    1.88 +$(if $5,$1_$(strip $5))
    1.89 +$(if $6,$1_$(strip $6))
    1.90 +$(if $7,$1_$(strip $7))
    1.91 +$(if $8,$1_$(strip $8))
    1.92 +$(if $9,$1_$(strip $9))
    1.93 +# Remove any relative addressing in the paths.
    1.94 +$1_SRC := $$(abspath $$($1_SRC))
    1.95 +$1_BIN := $$(abspath $$($1_BIN))
    1.96 +# Find all existing java files and existing class files.
    1.97 +$$(shell mkdir -p $$($1_SRC) $$($1_BIN))
    1.98 +$1_SRCS     := $$(shell find $$($1_SRC) -name "*.idl")
    1.99 +$1_BINS     := $$(shell find $$($1_BIN) -name "*.java")
   1.100 +# Prepend the source/bin path to the filter expressions.
   1.101 +$1_SRC_INCLUDES := $$(addprefix $$($1_SRC)/,$$($1_INCLUDES))
   1.102 +$1_SRC_EXCLUDES := $$(addprefix $$($1_SRC)/,$$($1_EXCLUDES))
   1.103 +$1_BIN_INCLUDES := $$(addprefix $$($1_BIN)/,$$($1_INCLUDES))
   1.104 +$1_BIN_EXCLUDES := $$(addprefix $$($1_BIN)/,$$($1_EXCLUDES))
   1.105 +$1_OLDIMPLBASES := $$(addprefix $$($1_SRC)/,$$($1_OLDIMPLBASES))
   1.106 +# Now remove unwanted java/class files.
   1.107 +$1_SRCS     := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
   1.108 +$1_SRCS     := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
   1.109 +$1_BINS     := $$(filter $$($1_BIN_INCLUDES),$$($1_BINS))
   1.110 +$1_BINS     := $$(filter-out $$($1_BIN_EXCLUDES),$$($1_BINS))
   1.111 +$1 := $$(sort $$(patsubst $$($1_SRC)/%.idl,$$($1_BIN)/%.idl.d,$$($1_SRCS)))
   1.112 +# Now create the dependencies for each idl target.
   1.113 +$$(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.114 +endef
   1.115 +
   1.116 +.SUFFIXES: .java .class .package
   1.117 +

mercurial