common/makefiles/IdlCompilation.gmk
author roland
Thu, 13 Sep 2012 22:09:16 +0200
changeset 13747 7dd9c86d03e1
parent 13133 701e61c32ece
child 14111 2a82ecb35fc7
permissions -rw-r--r--
7198074: NPG: assert(((Metadata*)obj)->is_valid()) failed: obj is valid Summary: missing test for T_METADATA leads to incorrect register allocation. Reviewed-by: kvn

#
# 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))
$(if $(10),$(error Internal makefile error: Too many arguments to SetupIdlCompilation, please update IdlCompilation.gmk))

# 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