Skip to content

Commit

Permalink
Add -onlyparse and -onlycheck command-line options (to go with -onlygen)
Browse files Browse the repository at this point in the history
and their description in Help. <3 nixeagle. Closes #92
  • Loading branch information
nddrylliog committed Jun 23, 2010
1 parent d4fc433 commit dd450aa
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 63 deletions.
3 changes: 3 additions & 0 deletions source/rock/frontend/BuildParams.ooc
Expand Up @@ -47,6 +47,9 @@ BuildParams: class {
// threads used by the sequence driver
sequenceThreads := 1

// if true, only parse the given module
onlyparse := false

// list of symbols defined e.g. by -Dblah
defines := ArrayList<String> new()

Expand Down
33 changes: 17 additions & 16 deletions source/rock/frontend/CommandLine.ooc
Expand Up @@ -243,6 +243,15 @@ CommandLine: class {
} else {
params compiler = Clang new()
}
} else if (option == "onlyparse") {

driver = null
params onlyparse = true

} else if (option == "onlycheck") {

driver = null

} else if (option == "onlygen") {

driver = DummyDriver new(params)
Expand All @@ -251,21 +260,6 @@ CommandLine: class {

params binaryPath = arg substring(arg indexOf('=') + 1)

} else if (option == "help-backends" || option == "-help-backends") {

Help printHelpBackends()
exit(0)

} else if (option == "help-gcc" || option == "-help-gcc") {

Help printHelpGcc()
exit(0)

} else if (option == "help-make" || option == "-help-make") {

Help printHelpMake()
exit(0)

} else if (option == "slave") {

params slave = true
Expand Down Expand Up @@ -359,6 +353,13 @@ CommandLine: class {

// phase 1: parse
AstBuilder new(modulePath, module, params)

if(params onlyparse) {
// Oookay, we're done here.
success()
return 0
}

if(params slave && !first) {
// slave and non-first = cache is filled, we must re-parse every import.
for(dep in module collectDeps()) {
Expand Down Expand Up @@ -388,7 +389,7 @@ CommandLine: class {

if(params backend == "c") {
// c phase 3: launch the driver
if(params compiler) {
if(params compiler != null && driver != null) {
result := driver compile(module)
if(result == 0) {
if(params shout) success()
Expand Down
64 changes: 17 additions & 47 deletions source/rock/frontend/Help.ooc
Expand Up @@ -12,7 +12,10 @@ Help: class {

println("Usage: rock [options] files\n")
println(
"-v, -verbose
"The default rock options are:
rock yourmodule.ooc -backend=c -driver=sequence -gc=static -libcache -outpath=rock_tmp/ -o=yourmodule
-v, -verbose
Print more information during the build process, useful for
debugging.
-vv, -veryVerbose
Expand All @@ -25,23 +28,31 @@ Help: class {
-backend=[c]
Choose the rock backend. Currently, only the default backend c is
supported.
-gcc,-tcc,-icc,-clang,-onlygen
-gcc,-tcc,-icc,-clang
Choose the compiler backend. (default=gcc) Available compilers
are the GNU Compiler Collection, TinyCC, Intel C++ Compiler and
the LLVM’s clang frontend. Also, you can pass onlygen to only
generate the code and not to run any compiler.
-gc=[dynamic,static,off]
Link dynamically, link statically, or don’t link with the boehm
GC at all.
-driver=[combine,sequence,make]
-driver=[combine,sequence,make,dummy]
Choose the compile driver to use. combine compiles all C files
combined, sequence compiles them sequentially, make creates a
Makefile.
Makefile. dummy only generates the .c sources to rock_tmp/ (or whatever
you set your -outpath to)
-onlyparse
Only parse the given source file, fail on syntax errors only.
-onlycheck
Parse the given source files and its dependencies, check everything,
but don't generate C files.
-onlygen
Equivalent to -driver=dummy. See above.
-sourcepath=PATH
Pass the location of your source files. (default=current
directory)
-nolibcache
Don’t use a library cache. By default, rock compiles related
-libcache, -nolibcache
Use (or not) a library cache. By default, rock compiles related
bunches of .ooc files to a static library for further compilation
processes speedups in the .libs/ directory. When the source files
change, the static library will be recompiled automatically.
Expand Down Expand Up @@ -90,46 +101,5 @@ Help: class {
\nFor help about the backend options, run 'ooc -help-backends'"
)
}

/**
* Print a helpful help message that helps about backends
*/
printHelpBackends: static func {
println(
"The available backends are: [none,gcc,make] and the default is gcc
none just outputs the c/ h files (be sure to have a main func)
gcc call the GNU C compiler with appropriate options
make generate a Makefile in the default output directory (ooc_tmp)
\nFor help about a specific backend, run 'ooc -help-gcc' for example"
)
}

/**
* Print a helpful help message that helps about gcc
*/
printHelpGcc: static func {
println(
"gcc backend options:
-clean=[yes,no] delete (or not) temporary files default: yes
overriden by the global option -noclean
-verbose=[yes,no] print the gcc command lines called from the backend
overriden by the global options -v, -verbose
-shout=[yes,no], -s prints a big fat [ OK ] at the end of the compilation
if it was successful (in green, on Linux platforms)
any other option passed to gcc\n"
)
}

/**
* Print a helpful help message that helps about make
*/
printHelpMake: static func {
println(
"make backend options:
-cc=[gcc,icl] write a Makefile to be compatible with the said compiler
-link=libname a link with the static library libname a
any other option passed to the compiler\n"
)
}

}

0 comments on commit dd450aa

Please sign in to comment.