/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

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