1:/*
   2: * Copyright (c) 2004, Brian Hawkins
   3: * Permission is granted to use this code without restriction as long
   4: * as this copyright notice appears in all source files.
   5: */
   6: 
   7:blddir = "build";
   8:srcdir = "src";
   9:extdir = "ext";
  10:jardir = "jar";
  11:jarfile = jardir+"/cpmake.jar";
  12: 
  13:sourceFiles = make.createFileList(srcdir, ".*\\.java", 
  14:        (make.INCLUDE_PATH | make.RECURSE | make.RELATIVE_PATH));
  15:classFiles = make.substitute("(.*)\\.java", blddir+"/$1.class", sourceFiles);
  16:extJarFiles = make.createFileList(extdir, ".*\\.jar");
  17:compileList = "";
  18:
  19:make.addSearchPath(".*\\.java", srcdir);
  20:make.setDefaultTarget(jarfile);
  21:
  22://-------------------------------------------------------------------
  23://==-- CLEAN CLASS FILES --==
  24:make.createPatternRule(blddir+"/(.*)\\.class", "$1.java", "removeClass", false);
  25:void removeClass(String target, String[] prereqs)
  26:    {
  27:    print(prereqs[0]);
  28:    rm(target);
  29:    compileList += prereqs[0] + " ";
  30:    }
  31:
  32://-------------------------------------------------------------------
  33://==-- COMPILE --==
  34:make.createPhonyRule("compile", blddir+" "+make.arrayToString(classFiles), "compile");  
  35:void compile(String target, String[] prereqs)
  36:    {
  37:    if (make.getProperty("JIKESPATH") != null)
  38:        {
  39:        print("Compiling with Jikes");
  40:        cmd = "jikes -classpath "+make.getProperty("JIKESPATH")+";ext/bsh-1.3.0.jar;ext/jython.jar;ext/groovy.jar;"+
  41:            make.getProperty("path.separator")+blddir+" -d "+blddir+
  42:            " -sourcepath "+srcdir+" "+compileList;
  43:        }
  44:    else
  45:        {
  46:        print("Compiling with javac");
  47:        cmd = "javac -classpath ext/bsh-1.3.0.jar;ext/jython.jar;ext/groovy.jar;"+blddir+
  48:            " -d "+blddir+" -sourcepath "+srcdir+" "+compileList;
  49:        }
  50:
  51:    make.exec(cmd, true);
  52:    }
  53:    
  54://-------------------------------------------------------------------
  55://==-- DIRECTORY RULES --==
  56:make.createDirectoryRule(blddir, null, true);
  57:make.createDirectoryRule("doc", null, true);
  58:make.createDirectoryRule(jardir, null, true);
  59:
  60://-------------------------------------------------------------------
  61://==-- CREATE JAR FILE --==
  62:make.createExplicitRule(jarfile, new String[] {"compile", jardir}, "createJar", true);  
  63:void createJar(String target, String[] prereqs)
  64:    {       
  65:    print("Creating "+target);
  66:    
  67:    rm(target);
  68:    String cmd = "jar -cfm "+target+" manifest.txt -C "+blddir+" .";
  69:    make.exec(cmd);
  70:    }
  71:
  72://-------------------------------------------------------------------
  73://==-- JAVADOC DOCUMENTATION --==   
  74:make.createPhonyRule("javadoc", "doc", "javadoc");
  75:void javadoc(String target, String[] prereqs)
  76:    {
  77:    make.exec("javadoc -classpath ext/bsh-1.3.0.jar;ext/jython.jar;ext/groovy.jar;. -sourcepath src -public -d doc cpmake");
  78:    }
  79:    
  80://-------------------------------------------------------------------
  81://==-- EXTRACT EXT JARS --==
  82:make.createPhonyRule("extractjars", "compile", "extractJars");
  83:void extractJars(String target, String[] prereqs)
  84:    {
  85:    for (int I = 0; I < extJarFiles.length; I ++)
  86:        {
  87:        print("Extracting "+extJarFiles[I]);
  88:        make.exec(blddir, "jar -xf ../ext/"+extJarFiles[I], true);
  89:        }
  90:    }
  91:    
  92://-------------------------------------------------------------------
  93://==-- CREATE ONE JAR --==
  94:make.createPhonyRule("onejar", new String[]
  95:        {
  96:        "extractjars",
  97:        jardir+"/cpmake.jar"
  98:        }, null);
  99:
 100://-------------------------------------------------------------------
 101://==-- COMPILE TEST CODE --==
 102:make.createPhonyRule("test", "onejar", "test");
 103:void test(String target, String[] prereqs)
 104:    {
 105:    print("running test");
 106:    cwd = "test/c++";
 107:    make.exec(cwd, "java -cp ../../jar/cpmake.jar cpmake.CPMake -f build.bsh clean test", true);
 108:    make.exec(cwd, "java -cp ../../jar/cpmake.jar cpmake.CPMake -f build.py clean test clean", true);
 109:    //make.exec(cwd, "java -cp ../../jar/cpmake.jar cpmake.CPMake -f build.groovy clean test clean", true);
 110:    
 111:    cwd = "test/java";
 112:    make.exec(cwd, "java -cp ../../jar/cpmake.jar cpmake.CPMake -f build.bsh clean test", true);
 113:    make.exec(cwd, "java -cp ../../jar/cpmake.jar cpmake.CPMake -f build.py clean test clean", true);
 114:    //make.exec(cwd, "java -cp ../../jar/cpmake.jar cpmake.CPMake -f build.groovy clean test clean", true);
 115:    }
 116: