FileDocCategorySizeDatePackage
Main.javaAPI DocphoneME MR2 API (J2ME)9597Wed May 02 17:59:48 BST 2007makedep

Main

public class Main extends Object

Fields Summary
static final String
usage_string
Constructors Summary
Methods Summary
static voidgetEnableFlags(java.util.Properties globalProps)

        Hashtable env = Util.getenv();
        boolean verbose = (env.get("VERBOSE") != null);

        for (Enumeration e = env.keys(); e.hasMoreElements() ;) {
            String key = (String)e.nextElement();
            if (key.startsWith("ENABLE_") && !key.endsWith("__BY")) {
                String propName = key;
                String propValue = (String)env.get(key);
                globalProps.setProperty(propName, propValue);
                if (verbose) {
                    System.out.println(propName + " = " + propValue);
                }
            }
        }
    
public static voidmain(java.lang.String[] args)

           
      try {
          if (args.length < 3) {
            usage();
            System.exit(1);
          }
      
          int argc = 0;

          String platformName = args[argc++];
          Class platformClass = Class.forName("makedep." + platformName);

          String plat1 = null;
          String db1 = null;
          String plat2 = null;
          String db2 = null;

          String firstFile = null;
          String lastFile = null;
          boolean resolveVpath = false;
          int sourceMergerLimit = 0;
          boolean checkIncludeDB = false;
          String workspace = null;
          String genDir = null;
          Properties globalProps = new Properties();
          getEnableFlags(globalProps);

          int numOptionalArgs = (args.length - 3);
          if (numOptionalArgs < 0) {
            usage();
            System.exit(1);
          }

          plat1 = args[argc++];
          db1   = args[argc++];

          // argc now points at start of optional arguments, if any

          try {
            boolean gotOne = true;
            while (gotOne && (argc <= args.length - 1)) {
              String arg = args[argc];
              if (arg.equals("-firstFile")) {
                firstFile = args[argc + 1];
                argc += 2;
              } else if (arg.equals("-lastFile")) {
                lastFile = args[argc + 1];
                argc += 2;
              } else if (arg.equals("-resolveVpath")) {
                resolveVpath = args[argc + 1].equals("true");
                argc += 2;
              } else if (arg.equals("-checkIncludeDB")) {
                checkIncludeDB = true;
                argc += 1;
              } else if (arg.equals("-sourceMergerLimit")) {
                // Merge multiple .cpp files into a single .cpp file to speed
                // up GCC compilation. For more info, see 
                // Database.createMergedOuterFiles()
                try {
                  sourceMergerLimit = Integer.parseInt(args[argc + 1]);
                } catch (Throwable t) {
                  System.err.println("invalid integer value \"" + args[argc + 1]
                                     + "\" for -sourceMergerLimit");
                  System.exit(-1);
                }      
                argc += 2;
              } else if (arg.equals("-workspace")) {
                workspace = args[argc + 1];
                argc += 2;
              } else if (arg.equals("-gendir")) {
                genDir = args[argc + 1];
                argc += 2;
              } else if (arg.indexOf('=") != -1) {
                String propName = arg.substring(0, arg.indexOf('="));
                String propValue = arg.substring(arg.indexOf('=") + 1);
                globalProps.setProperty(propName, propValue);
                argc++;
              } else {
                gotOne = false;
              }
            }
          }
          catch (Exception e) {
            e.printStackTrace();
            usage();
            System.exit(1);
          }

          Platform platform = (Platform) platformClass.newInstance();
          if (checkIncludeDB) {
            System.out.println("\n***\n");
            System.out.println("checking include DB -- precompiled headers/" +
                               "merged sources disabled");
            System.out.println("\n***");
            platform.setUsePrecompiledHeader(false);
          } else {
            platform.setUsePrecompiledHeader(true);
          }
          platform.setupFileTemplates();
          long t = platform.defaultGrandIncludeThreshold();
          
          String[] platformArgs = null;
          int numPlatformArgs = args.length - argc;
          if (numPlatformArgs > 0) {
            platformArgs = new String[numPlatformArgs];
            int offset = argc;
            while (argc < args.length) {
              platformArgs[argc - offset] = args[argc];
              ++argc;
            }
          }

          // If you want to change the threshold, change the default
          // "grand include" threshold in Platform.java, or override
          // it in the platform-specific file like UnixPlatform.java

          Database previous = new Database(platform, t);
          Database current = new Database(platform, t);

          previous.canBeMissing();
          
          if (firstFile != null) {
            previous.setFirstFile(firstFile);
            current.setFirstFile(firstFile);
          }
          if (lastFile != null) {
            previous.setLastFile(lastFile);
            current.setLastFile(lastFile);
          }
          previous.setResolveVpath(resolveVpath);
          current.setResolveVpath(resolveVpath);
          if (checkIncludeDB) {
            sourceMergerLimit = 0;
          }
          previous.setSourceMergerLimit(sourceMergerLimit);
          current.setSourceMergerLimit(sourceMergerLimit);

          if (workspace != null) {
            previous.setWorkspace(workspace);
            current.setWorkspace(workspace);
          }
          if (genDir != null) {
            previous.setGenDir(genDir);
            current.setGenDir(genDir);
          }

            if (resolveVpath) {
                if (workspace == null) {
                    System.out.println("-resolveVpath is set but " +
                                       "-workspace is not set");
                    usage();
                    System.exit(1);
                }
            }

          current.get(plat1, db1, globalProps);
          current.compute();
          current.put();

          if (platformArgs != null) {
            // Allow the platform to write platform-specific files
            platform.writePlatformSpecificFiles(previous, current,
                                        platformArgs);
          }
      }
      catch (Exception e) {
          e.printStackTrace();
      }
    
static voidusage()

        System.out.print(usage_string);