Forums

Cobra Compiler options read from file

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Cobra Compiler options read from file

Postby hopscc » Tue Apr 13, 2010 4:50 am

This is a repost from memory of the discussion topic lost when the server turned to custard.

I've (re)posted a patch and description on ticket:200 for making the cobra compiler support reading its options from a file
(before or overridden by) in addition to options being specified on the compiler commandline.

I see this as useful for large projects to specify a set of common options that dont change much for the development duration of a project (-debug, trace,...) and/or for options that control desired backward compatibility behaviour ( getting a few of those now).

The idea is that the compiler will read options from a file in the current working directory, prior to reading command line options so that commandline entries override any duplicates also given in the optionsfile, normal processing ensues from that point.
The file used is the first filename found from the set
Code: Select all
['.cobrarc', 'cobra.rc', 'cobra.init' ]
to accommodate usual naming patterns from a range of platforms.
The file format is that of optionName: value trimming leading and trailing whitespace and ignoring lines starting with '#' or all whitespace

In addition there is a new commandline option to provide an explicit optionfile name or to suppress the default options file search and processing
Code: Select all
cobra -options-file:none ... # Suppress optionsfile search
cobra -options-file:defaultOptions.opt ... # read options from file defaultOptions.opt


e.g Here is an options file for building the compiler
Code: Select all
# = Cobra compiler options file for building compiler =
# make a copy of the compiler exe to do the compile (wdws wont allow overwrite of a running exe file)
#   cp cobra.exe cobraOld.exe
# 1) copy this file to .cobrarc
#   cp cobra.cobrarc .cobrarc
# and run compiler as follows
#   ./cobraOld cobra.cobra
# 2) or just run run compiler as follows
#   ./cobraOld -optfile:cobra.cobrarc cobra.cobra
# --------------------------------------------------

#compile Only (do not run the code post compilation )
compile:true

#Colorize any error messages and the messages "Compilation failed" and
# "Compilation succeeded" (as red, red and blue). default is false
color:true

#Embed the Cobra run-time support code in the assembly
embed-run-time:true

#Turn on generation of system debugging information.
# full enables attaching a debugger to a running program.
# Turning on implies -debugging-tips:no.  Default is 0
debug:1
#debug:pdbonly
#debug:full

#Emit the total duration (wall time) of this run of cobra
#  (including the target program, if it is to be run).
#Default is false.
#timeit:true

# file containing filenames for Cobra to process
#  One file per line; # comments and blank lines are ignored.
files:files-to-compile.text

# Initial filename(s) list
#cobra.cobra



This makes command line to build compiler on any platform
Code: Select all
cobra cobra.cobra

if the options file is named .cobrarc,
or something like
Code: Select all
cobra -options-file:myCompileOptions cobra.cobra

if the options file were named 'myCompileOptions'
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Cobra Compiler options read from file

Postby Charles » Tue Apr 13, 2010 7:12 am

Thanks! I have a little more work to do on the server and then I can take a look.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 85 guests