From 343b658c32a6473c545187c1e276ee5d06c2686a Mon Sep 17 00:00:00 2001 From: Kevin Rushforth Date: Wed, 9 Jun 2004 04:25:41 +0000 Subject: Initial creation of j3d-core-utils sources in CVS repository git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@7 ba19aa83-45c5-6ac9-afd3-db810772062c --- build-tools/MakeJ3dBuildInfo.java | 127 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 build-tools/MakeJ3dBuildInfo.java (limited to 'build-tools/MakeJ3dBuildInfo.java') diff --git a/build-tools/MakeJ3dBuildInfo.java b/build-tools/MakeJ3dBuildInfo.java new file mode 100644 index 0000000..3e38af1 --- /dev/null +++ b/build-tools/MakeJ3dBuildInfo.java @@ -0,0 +1,127 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2004 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileNotFoundException; +import java.io.PrintStream; +import java.text.DateFormat; +import java.util.Date; + +/** + * This application is used to dynamically create the source code for + * the J3dBuildInfo class. The J3dBuildInfo class contains a static + * method that returns a build time stamp string. The time stamp + * string is used by the VersionInfo class as part of the version + * number stored in the VirtualUniverse "j3d.version" property. It is + * created dynamically so that the version number uniquely identifies + * the build. + */ +public class MakeJ3dBuildInfo { + private static final String srcName = + "javax" + File.separator + + "media" + File.separator + + "j3d" + File.separator + + "J3dBuildInfo.java"; + + public static void main(String[] args) throws FileNotFoundException { + // Parse command line arguments + String usage = "Usage: java MakeJ3dBuildInfo [-debug] [srcRootDir]"; + boolean debugFlag = false; + String srcRoot = "."; + + int idx = 0; + while (idx < args.length) { + if (args[idx].startsWith("-")) { + if (args[idx].equals("-debug")) { + debugFlag = true; + } + else { + System.err.println(usage); + System.exit(1); + } + ++idx; + } + else { + break; + } + } + + // Now grab the root of the source tree, if specified + if (idx < args.length) { + if (idx < (args.length - 1)) { + System.err.println(usage); + System.exit(1); + } + + srcRoot = args[idx]; + } + + // Create the File object representing the path name to the + // output java source file + String outPathName = srcRoot + File.separator + srcName; + File file = new File(outPathName); + + // Open the output java source file + PrintStream out = new PrintStream(new FileOutputStream(file)); + + // Create and format the time and date string for the current time + DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, + DateFormat.FULL); + Date buildDate = new Date(); + String dateString = df.format(buildDate); + + // Generate the java source code for J3dBuildInfo + out.println("package javax.media.j3d;"); + out.println(); + out.println("/**"); + out.println(" * DO NOT MODIFY THIS CLASS."); + out.println(" *"); + out.println(" * This class is automatically created as part of the build process"); + out.println(" * by MakeJ3dBuildInfo.java."); + out.println(" */"); + out.println("class J3dBuildInfo {"); + out.println(" /**"); + out.println(" * Constant that indicates whether or not this is"); + out.println(" * a debug build."); + out.println(" */"); + out.print(" static final boolean isDebug = "); + if (debugFlag) { + out.println("true;"); + } + else { + out.println("false;"); + } + out.println(); + out.print(" private static final String BUILD_TIME_STAMP = "); + out.print("\""); + out.print(dateString); + out.println("\";"); + out.println(); + out.println(" /**"); + out.println(" * Returns the build time stamp."); + out.println(" * @return the build time stamp"); + out.println(" */"); + out.println(" static String getBuildTimeStamp() {"); + out.println(" return BUILD_TIME_STAMP;"); + out.println(" }"); + out.println(); + out.println(" /**"); + out.println(" * Do not construct an instance of this class."); + out.println(" */"); + out.println(" private J3dBuildInfo() {"); + out.println(" }"); + out.println("}"); + + out.close(); + } +} -- cgit v1.2.3