PageRenderTime 83ms CodeModel.GetById 40ms app.highlight 10ms RepoModel.GetById 30ms app.codeStats 1ms

/src/org/ooc/frontend/BuildParams.java

http://github.com/nddrylliog/ooc
Java | 130 lines | 62 code | 40 blank | 28 comment | 2 complexity | e1d00a06fc5f4f4045c887a5edbf92b9 MD5 | raw file
  1package org.ooc.frontend;
  2
  3import java.io.File;
  4import java.util.ArrayList;
  5import java.util.List;
  6
  7import org.ooc.frontend.compilers.AbstractCompiler;
  8import org.ooc.libs.DistLocator;
  9import org.ooc.libs.SdkLocator;
 10import org.ooc.utils.ReadEnv;
 11
 12public class BuildParams {
 13
 14	public AbstractCompiler compiler = null;
 15	
 16	/** If no compiler is specified, use gcc by default (or not) */
 17	public boolean gccByDefault = true;
 18	
 19	// if non-null, use 'linker' as the last step of the compile process, with driver=sequence
 20	public String linker = null;
 21	
 22	public File distLocation = DistLocator.locate();
 23	public File sdkLocation = SdkLocator.locate();
 24	
 25	public final PathList sourcePath = new PathList();
 26	public final PathList libPath = new PathList();
 27	public final PathList incPath = new PathList();
 28	
 29	// FIXME make it portable, make it use the OOC_LIBS env variable too.
 30	public File libsPath = getLibsPath();
 31		
 32	public File outPath = new File("ooc_tmp");
 33	
 34	// list of symbols defined e.g. by -Dblah
 35	public List<String> defines = new ArrayList<String>();
 36	
 37	// Path of the text editor to run when an error is encountered in an ooc file 
 38	public String editor = "";
 39	
 40	// Remove the ooc_tmp/ directory after the C compiler has finished
 41	public boolean clean = true;
 42	
 43	// Add debug info to the generated C files (e.g. -g switch for gcc)
 44	public boolean debug = false;
 45	
 46	// Displays which files it parses, and a few debug infos
 47	public boolean verbose = false;
 48	
 49	// More debug messages
 50	public boolean veryVerbose = false;
 51	
 52	// Displays [ OK ] or [FAIL] at the end of the compilation
 53	public boolean shout = true;
 54	
 55	// If false, output .o files. Otherwise output exectuables
 56	public boolean link = true;
 57	
 58	// Run files after compilation
 59	public boolean run = false;
 60	
 61	// Display compilation times for all .ooc files passed to the compiler
 62	public boolean timing = false;
 63	
 64	// Compile once, then wait for the user to press enter, then compile again, etc.
 65	public boolean slave = false;
 66
 67	// Should link with libgc at all.
 68	public boolean enableGC = true;
 69	
 70	// link dynamically with libgc (Boehm)
 71	public boolean dynGC = false;
 72	
 73	// add #line directives in the generated .c for debugging.
 74	// depends on "debug" flag
 75	public boolean lineDirectives = true;
 76	
 77	// if non-null, will create a static library with 'ar rcs <outlib> <all .o files>'
 78	public String outlib = null;
 79	
 80	// add a main method if there's none in the specified ooc file
 81	public boolean defaultMain = true;
 82	
 83	// either "32" or "64"
 84	public String arch = "";
 85	
 86	public String[] fatArchitectures;
 87	public String osxSDKAndDeploymentTarget;
 88	
 89	// maximum number of rounds the {@link Tinkerer} will do before blowing up.
 90	public int blowup = 256;
 91
 92	// name of the backend, either "c" or "json".
 93	public String backend = "c";
 94	
 95	// the entry point. for most apps, it will be main,
 96	// but for libraries, kernels, Win32 apps, etc. it can have another name
 97	public String entryPoint = "main";
 98	
 99	public List<String> dynamicLibs = new ArrayList<String>();
100	public List<String> additionals = new ArrayList<String>();
101	public List<String> compilerArgs = new ArrayList<String>();
102
103	// how many threads to use with the sequence driver
104	public int sequenceThreads = Runtime.getRuntime().availableProcessors();
105
106	/* Builtin defines */
107	public static final String GC_DEFINE = "__OOC_USE_GC__";
108
109	private File getLibsPath() {
110		String path = ReadEnv.getEnv().get("OOC_LIBS");
111		return path == null ? new File("/usr/lib/ooc/") : new File(path);
112	}
113	
114	
115	public BuildParams() {
116		// use the GC by default =)
117		defines.add(GC_DEFINE);
118	}
119	
120	public void defineSymbol(String symbol) {
121		if(!defines.contains(symbol)) {
122			defines.add(symbol);
123		}
124	}
125	
126	public void undefineSymbol(String symbol) {
127		defines.remove(symbol);
128	}
129	
130}