make/common/IdlCompilation.gmk
author dholmes
Thu, 11 Feb 2016 15:43:30 -0500
changeset 36096 5737705c0412
parent 35008 ef0cd710989f
permissions -rw-r--r--
8149697: Fix for 8145725 is broken Summary: As per the existing comment we needed to check the saved 'index' instead Reviewed-by: gthornbr, dcubed, kbarrett

#
# Copyright (c) 2011, 2014, 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
	$$(call LogInfo, Compiling IDL $(patsubst $2/%,%,$4))
	$$(call MakeDir, $$(@D))
	$(RM) -rf $3/$$($4_TMPDIR)
	$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) -r $3/$$($4_TMPDIR)/* $3
	($(CD) $3/$$($4_TMPDIR) && $(FIND) . -type f | $(SED) 's!\./!$3/!g' | $(NAWK) '{ print $$$$1 ": $4" }' > $5)
	$(RM) -rf $3/$$($4_TMPDIR)
endef

# Setup make rules for creating an IDL compilation.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name.
#
# Remaining parameters are named arguments. These include:
#   IDLJ
#   SRC
#   BIN
#   INCLUDES
#   EXCLUDES
#   OLDIMPLBASES
#   DELETES
SetupIdlCompilation = $(NamedParamsMacroTemplate)
define SetupIdlCompilationBody

  # Find all existing java files and existing class files.
  $$(call MakeDir,$$($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