diff common/makefiles/IdlCompilation.gmk @ 423:e1830598f0b7

7074397: Build infrastructure changes (makefile re-write) Summary: New makefiles transition, old and new living side by side for now. Reviewed-by: ohair, jjg, dholmes, ohrstrom, erikj, ihse, tgranat, ykantser Contributed-by: ohrstrom <fredrik.ohrstrom@oracle.com>, erikj <erik.joelsson@oracle.com>, ihse <magnus.ihse.bursie@oracle.com>, tgranat <torbjorn.granat@oracle.com>, ykantser <yekaterina.kantserova@oracle.com>
author ohair
date Tue, 10 Apr 2012 08:18:28 -0700
parents
children c8d320b48626
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/makefiles/IdlCompilation.gmk	Tue Apr 10 08:18:28 2012 -0700
@@ -0,0 +1,114 @@
+#
+# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+PREFIXES=-pkgPrefix CORBA                org.omg \
+	-pkgPrefix CosNaming             org.omg \
+	-pkgPrefix CosTransactions       org.omg \
+	-pkgPrefix CosTSInteroperation   org.omg \
+	-pkgPrefix DynamicAny            org.omg \
+	-pkgPrefix Dynamic               org.omg \
+	-pkgPrefix IOP                   org.omg \
+	-pkgPrefix Messaging             org.omg \
+	-pkgPrefix PortableInterceptor   org.omg \
+	-pkgPrefix PortableServer        org.omg \
+	-pkgPrefix activation            com.sun.corba.se.spi \
+	-pkgPrefix GIOP                  com.sun.corba.se \
+	-pkgPrefix PortableActivationIDL com.sun.corba.se \
+	-pkgPrefix messages              com.sun.corba.se 
+
+define add_idl_package
+    # param 1 = MYPACKAGE
+    # param 2 = src root
+    # param 3 = gensrc root
+    # param 4 = source idl to compile
+    # param 5 = target idl package
+    # param 6 = delete these files that were output from the idlj
+    # param 7 = idls that match these patterns should be compiled with -oldImplBase
+    # param 8 = the idlj command
+    # Save the generated java files to a temporary directory so
+    # that we can find them and create proper dependencies.
+    # After that, we move them to the real gensrc target dir.
+    $4_TMPDIR:=tmp___$(subst /,_,$(patsubst $2/%,%,$4))___
+    ifneq ($$(filter $7,$4),)
+        $4_OLDIMPLBASE:=-oldImplBase
+        $4_OLDIMPLBASE_MSG:=with -oldImplBase
+    endif
+    $5 : $4
+	mkdir -p $3/$$($4_TMPDIR)
+	rm -rf $3/$$($4_TMPDIR)
+	mkdir -p $(dir $5)
+	echo Compiling IDL $(patsubst $2/%,%,$4) 
+	$8 -td $3/$$($4_TMPDIR) \
+		-i $2/org/omg/CORBA \
+		-i $2/org/omg/PortableInterceptor \
+		-i $2/org/omg/PortableServer \
+		-D CORBA3 -corba 3.0 \
+		-fall \
+		$$($4_OLDIMPLBASE) \
+		$(PREFIXES) \
+		$4
+	rm -f $$(addprefix $3/$$($4_TMPDIR)/,$6)
+	cp -rp $3/$$($4_TMPDIR)/* $3
+	(cd $3/$$($4_TMPDIR); find . -type f | sed 's!\./!$3/!g' | awk '{ print $$$$1 ": $4" }' > $5)
+	rm -rf $3/$$($4_TMPDIR)
+endef
+
+define SetupIdlCompilation
+# param 1 is for example BUILD_IDLS
+# param 2,3,4,5,6,7,8 are named args.
+#    IDLJ,SRC,BIN,INCLUDES,EXCLUDES,OLDIMPLBASES,DELETES
+$(if $2,$1_$(strip $2))
+$(if $3,$1_$(strip $3))
+$(if $4,$1_$(strip $4))
+$(if $5,$1_$(strip $5))
+$(if $6,$1_$(strip $6))
+$(if $7,$1_$(strip $7))
+$(if $8,$1_$(strip $8))
+$(if $9,$1_$(strip $9))
+# Remove any relative addressing in the paths.
+$1_SRC := $$(abspath $$($1_SRC))
+$1_BIN := $$(abspath $$($1_BIN))
+# Find all existing java files and existing class files.
+$$(shell mkdir -p $$($1_SRC) $$($1_BIN))
+$1_SRCS     := $$(shell find $$($1_SRC) -name "*.idl")
+$1_BINS     := $$(shell find $$($1_BIN) -name "*.java")
+# Prepend the source/bin path to the filter expressions.
+$1_SRC_INCLUDES := $$(addprefix $$($1_SRC)/,$$($1_INCLUDES))
+$1_SRC_EXCLUDES := $$(addprefix $$($1_SRC)/,$$($1_EXCLUDES))
+$1_BIN_INCLUDES := $$(addprefix $$($1_BIN)/,$$($1_INCLUDES))
+$1_BIN_EXCLUDES := $$(addprefix $$($1_BIN)/,$$($1_EXCLUDES))
+$1_OLDIMPLBASES := $$(addprefix $$($1_SRC)/,$$($1_OLDIMPLBASES))
+# Now remove unwanted java/class files.
+$1_SRCS     := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS))
+$1_SRCS     := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS))
+$1_BINS     := $$(filter $$($1_BIN_INCLUDES),$$($1_BINS))
+$1_BINS     := $$(filter-out $$($1_BIN_EXCLUDES),$$($1_BINS))
+$1 := $$(sort $$(patsubst $$($1_SRC)/%.idl,$$($1_BIN)/%.idl.d,$$($1_SRCS)))
+# Now create the dependencies for each idl target.
+$$(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))))
+endef
+
+.SUFFIXES: .java .class .package
+