changeset 566:6f4a57e4945b

8036611: Cleanup of handling of properties and other java resources in the build Reviewed-by: tbell, ihse
author erikj
date Fri, 07 Mar 2014 15:02:55 +0100
parents 1ed19de263e1
children c47f5229d640 33e3a9fa88fe
files make/CompileCorba.gmk make/GensrcCorba.gmk make/src/classes/build/tools/stripproperties/StripPropertiesCorba.java
diffstat 3 files changed, 11 insertions(+), 315 deletions(-) [+]
line wrap: on
line diff
--- a/make/CompileCorba.gmk	Mon Feb 24 12:55:09 2014 -0800
+++ b/make/CompileCorba.gmk	Fri Mar 07 15:02:55 2014 +0100
@@ -45,16 +45,18 @@
         org/omg/PortableInterceptor/UNKNOWN.java \
         com/sun/tools/corba/se/idl/ResourceBundleUtil.java \
         com/sun/corba/se/impl/presentation/rmi/jndi.properties, \
-    COPY := .prp LogStrings.properties, \
+    COPY := .prp, \
+    CLEAN := .properties, \
     BIN := $(CORBA_OUTPUTDIR)/classes, \
     JAR := $(CORBA_OUTPUTDIR)/dist/lib/classes.jar))
 
+# For the interim version, don't bother cleaning the properties.
 $(eval $(call SetupJavaCompilation,BUILD_INTERIM_CORBA, \
     SETUP := GENERATE_OLDBYTECODE, \
     SRC := $(BUILD_CORBA_SRC), \
     EXCLUDES := $(BUILD_CORBA_EXCLUDES), \
     EXCLUDE_FILES := $(BUILD_CORBA_EXCLUDE_FILES), \
-    COPY := $(BUILD_CORBA_COPY), \
+    COPY := $(BUILD_CORBA_COPY) $(BUILD_CORBA_CLEAN), \
     BIN := $(CORBA_OUTPUTDIR)/interim_classes, \
     JAR := $(INTERIM_CORBA_JAR)))
 
@@ -63,7 +65,6 @@
 $(eval $(call SetupZipArchive,ARCHIVE_CORBA_SRC, \
     SRC := $(CORBA_TOPDIR)/src/share/classes $(CORBA_OUTPUTDIR)/gensrc, \
     ZIP := $(CORBA_OUTPUTDIR)/dist/lib/src.zip))
-    JAR := $(CORBA_OUTPUTDIR)/dist/lib/classes.jar))
 
 ################################################################################
 # Create bin.zip containing the corba specific binaries: orb.idl, ir.idl
@@ -81,6 +82,5 @@
 
 ################################################################################
 
-
 all: $(BUILD_CORBA) $(BUILD_INTERIM_CORBA) $(ARCHIVE_CORBA_SRC) \
     $(CORBA_OUTPUTDIR)/dist/lib/bin.zip
--- a/make/GensrcCorba.gmk	Mon Feb 24 12:55:09 2014 -0800
+++ b/make/GensrcCorba.gmk	Fri Mar 07 15:02:55 2014 +0100
@@ -39,9 +39,6 @@
     SRC := $(CORBA_TOPDIR)/make/src/classes, \
     BIN := $(CORBA_OUTPUTDIR)/tools_classes))
 
-TOOL_STRIPPROP_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/tools_classes \
-    build.tools.stripproperties.StripPropertiesCorba
-
 TOOL_LOGUTIL_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/tools_classes \
     build.tools.logutil.MC
 
@@ -230,27 +227,14 @@
 $(BUILD_IDLS): $(BUILD_IDLJ)
 
 ################################################################################
-# Run stripproperties on all sunorb resource files.
+# zh_HK is just a copy of zh_TW
 
-STRIP_PROP_SRC_FILES := $(shell $(FIND) $(CORBA_TOPDIR)/src/share/classes -name "sunorb*.properties")
-STRIP_PROP_FILES := $(patsubst $(CORBA_TOPDIR)/src/share/classes/%, $(CORBA_OUTPUTDIR)/classes/%, \
-    $(STRIP_PROP_SRC_FILES))
-# Simple delivery of zh_HK properties files just copies zh_TW properties files
-STRIP_PROP_SRC_FILE_ZH_TW := $(shell $(FIND) $(CORBA_TOPDIR)/src/share/classes -name "sunorb_zh_TW.properties")
-STRIP_PROP_SRC_FILES += $(STRIP_PROP_SRC_FILE_ZH_TW)
-STRIP_PROP_FILES += $(patsubst $(CORBA_TOPDIR)/src/share/classes/%_zh_TW.properties, \
-    $(CORBA_OUTPUTDIR)/classes/%_zh_HK.properties, $(STRIP_PROP_SRC_FILE_ZH_TW))
-STRIP_PROP_CMDLINE := $(subst _SPACE_, $(SPACE), \
-    $(join $(addprefix -clean_SPACE_, $(STRIP_PROP_SRC_FILES)), \
-    $(addprefix _SPACE_, $(STRIP_PROP_FILES))))
-
-$(CORBA_OUTPUTDIR)/_the.stripped_properties: $(STRIP_PROP_SRC_FILES) \
-    $(BUILD_TOOLS)
-	$(MKDIR) -p $(sort $(dir $(STRIP_PROP_FILES)))
-	$(call ListPathsSafely,STRIP_PROP_CMDLINE,\n, >> $(CORBA_OUTPUTDIR)/_the.strip_prop.cmdline)
-	$(TOOL_STRIPPROP_CMD) @$(CORBA_OUTPUTDIR)/_the.strip_prop.cmdline
-	$(TOUCH) $@
+$(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_HK.properties: \
+    $(CORBA_TOPDIR)/src/share/classes/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_TW.properties
+	$(install-file)
 
 ################################################################################
 
-all: $(BUILD_IDLS) $(CORBA_OUTPUTDIR)/_the.stripped_properties $(LOGWRAPPER_TARGETS)
+all: $(BUILD_IDLS) $(LOGWRAPPER_TARGETS) \
+    $(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/orbutil/resources/sunorb_zh_HK.properties
+
--- a/make/src/classes/build/tools/stripproperties/StripPropertiesCorba.java	Mon Feb 24 12:55:09 2014 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,288 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-package build.tools.stripproperties;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedWriter;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * Reads a properties file from standard input and writes an equivalent
- * properties file without comments to standard output.
- */
-public class StripPropertiesCorba {
-
-    private static void error(String msg, Exception e) {
-        System.err.println("ERROR: stripproperties: " + msg);
-        if ( e != null ) {
-            System.err.println("EXCEPTION: " + e.toString());
-            e.printStackTrace();
-        }
-    }
-
-    private static List<String> infiles = new ArrayList<String>();
-    private static List<String> outfiles = new ArrayList<String>();
-
-    private static boolean parseOptions(String args[]) {
-        boolean ok = true;
-
-        for ( int i = 0; i < args.length ; i++ ) {
-            if ( "-clean".equals(args[i]) && i+2 < args.length ) {
-                infiles.add(args[++i]);
-                outfiles.add(args[++i]);
-            } else if ( args[i].charAt(0)=='@') {
-                String filename = args[i].substring(1);
-                FileInputStream finput = null;
-                byte contents[] = null;
-                try {
-                    finput = new FileInputStream(filename);
-                    int byteCount = finput.available();
-                    if ( byteCount <= 0 ) {
-                        error("The @file is empty", null);
-                        ok = false;
-                    } else {
-                        contents = new byte[byteCount];
-                        int bytesRead = finput.read(contents);
-                        if ( byteCount != bytesRead ) {
-                            error("Cannot read all of @file", null);
-                            ok = false;
-                        }
-                    }
-                } catch ( IOException e ) {
-                    error("cannot open " + filename, e);
-                    ok = false;
-                }
-                if ( finput != null ) {
-                    try {
-                        finput.close();
-                    } catch ( IOException e ) {
-                        ok = false;
-                        error("cannot close " + filename, e);
-                    }
-                }
-                if ( ok && contents != null ) {
-                    String tokens[] = (new String(contents)).split("\\s+");
-                    if ( tokens.length > 0 ) {
-                        ok = parseOptions(tokens);
-                    }
-                }
-                if ( !ok ) {
-                    break;
-                }
-            } else {
-                infiles.add(args[i]);
-                outfiles.add(args[i]);
-            }
-        }
-        return ok;
-    }
-
-    private static boolean stripFiles(List<String> infiles, List<String> outfiles) {
-        boolean ok = true;
-        Iterator<String> inIter  = infiles.iterator();
-        Iterator<String> outIter = outfiles.iterator();
-
-        for (; inIter.hasNext(); ) {
-            String infile = inIter.next();
-            String outfile = outIter.next();
-
-            Properties prop = new Properties();
-            InputStream in = null;
-            try {
-                in = new BufferedInputStream(new FileInputStream(infile));
-                prop.load(in);
-            } catch ( FileNotFoundException e ) {
-                error("Cannot access file " + infile, e);
-                ok = false;
-            } catch ( IOException e ) {
-                error("IO exception processing file " + infile, e);
-                ok = false;
-            }
-            if ( in != null ) {
-                try {
-                    in.close();
-                } catch ( IOException e ) {
-                    error("IO exception closing file " + infile, e);
-                    ok = false;
-                }
-            }
-            if ( !ok ) {
-                break;
-            }
-
-            OutputStream out = null;
-            try {
-                out = new FileOutputStream(outfile);
-                storeProperties(prop, out);
-                out.flush();
-            } catch ( IOException e ) {
-                error("IO exception processing file " + outfile, e);
-                ok = false;
-            }
-            if ( out != null ) {
-                try {
-                    out.close();
-                } catch ( IOException e ) {
-                    error("IO exception closing file " + outfile, e);
-                    ok = false;
-                }
-            }
-            if ( !ok ) {
-                break;
-            }
-
-        }
-        return ok;
-    }
-
-    /**
-     * Strip the properties filenames supplied, replacing their contents.
-     * @param args Names of properties files to process and replace contents
-     */
-    public static void main(String args[]) {
-        boolean ok = parseOptions(args);
-        if ( !ok || !stripFiles(infiles, outfiles) ) {
-            System.exit(1);
-        }
-    }
-
-    // --- code below here is adapted from java.util.Properties ---
-
-    private static final String specialSaveChars = "=: \t\r\n\f#!";
-
-    /*
-     * Converts unicodes to encoded &#92;uxxxx
-     * and writes out any of the characters in specialSaveChars
-     * with a preceding slash
-     */
-    private static String saveConvert(String theString, boolean escapeSpace) {
-        int len = theString.length();
-        StringBuffer outBuffer = new StringBuffer(len*2);
-
-        for(int x=0; x<len; x++) {
-            char aChar = theString.charAt(x);
-            switch(aChar) {
-                case ' ':
-                    if (x == 0 || escapeSpace) {
-                        outBuffer.append('\\');
-                    }
-                    outBuffer.append(' ');
-                    break;
-                case '\\':
-                    outBuffer.append('\\');
-                    outBuffer.append('\\');
-                    break;
-                case '\t':
-                    outBuffer.append('\\');
-                    outBuffer.append('t');
-                    break;
-                case '\n':
-                    outBuffer.append('\\');
-                    outBuffer.append('n');
-                    break;
-                case '\r':
-                    outBuffer.append('\\');
-                    outBuffer.append('r');
-                    break;
-                case '\f':
-                    outBuffer.append('\\');
-                    outBuffer.append('f');
-                    break;
-                default:
-                    if ((aChar < 0x0020) || (aChar == 0x007e) || (aChar > 0x00ff)) {
-                        outBuffer.append('\\');
-                        outBuffer.append('u');
-                        outBuffer.append(toHex((aChar >> 12) & 0xF));
-                        outBuffer.append(toHex((aChar >>  8) & 0xF));
-                        outBuffer.append(toHex((aChar >>  4) & 0xF));
-                        outBuffer.append(toHex( aChar        & 0xF));
-                    } else {
-                        if (specialSaveChars.indexOf(aChar) != -1) {
-                            outBuffer.append('\\');
-                        }
-                        outBuffer.append(aChar);
-                    }
-            }
-        }
-        return outBuffer.toString();
-    }
-
-    /**
-     * Writes the content of <code>properties</code> to <code>out</code>.
-     * The format is that of Properties.store with the following modifications:
-     * <ul>
-     * <li>No header or date is written
-     * <li>Latin-1 characters are written as single bytes, not escape sequences
-     * <li>Line breaks are indicated by a single \n independent of platform
-     * <ul>
-     */
-    private static void storeProperties(Properties properties, OutputStream out)
-    throws IOException {
-        BufferedWriter awriter;
-        awriter = new BufferedWriter(new OutputStreamWriter(out, "8859_1"));
-        for (Enumeration<Object> e = properties.keys(); e.hasMoreElements();) {
-            String key = (String)e.nextElement();
-            String val = (String)properties.get(key);
-            key = saveConvert(key, true);
-
-            /* No need to escape embedded and trailing spaces for value, hence
-             * pass false to flag.
-             */
-            val = saveConvert(val, false);
-            writeln(awriter, key + "=" + val);
-        }
-        awriter.flush();
-    }
-
-    private static void writeln(BufferedWriter bw, String s) throws IOException {
-        bw.write(s);
-        bw.write("\n");
-    }
-
-    /**
-     * Convert a nibble to a hex character
-     * @param   nibble  the nibble to convert.
-     */
-    private static char toHex(int nibble) {
-        return hexDigit[(nibble & 0xF)];
-    }
-
-    /** A table of hex digits */
-    private static final char[] hexDigit = {
-        '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
-    };
-}