Wiki

Ticket #200: options-file.patch

File options-file.patch, 32.4 KB (added by hopscc, 14 years ago)
  • Source/cobra.cobrarc

     
     1# = Cobra compiler options file for building compiler = 
     2# make a copy of the compiler exe to do the compile (wdws wont allow overwrite of a running exe file) 
     3#   cp cobra.exe cobraOld.exe 
     4# 1) copy this file to .cobrarc  
     5#   cp cobra.cobrarc .cobrarc 
     6# and run compiler as follows 
     7#   ./cobraOld cobra.cobra 
     8# 2) or just run run compiler as follows 
     9#   ./cobraOld -optfile:cobra.cobrarc cobra.cobra 
     10# -------------------------------------------------- 
     11 
     12#compile Only (do not run the code post compilation ) 
     13compile:true 
     14 
     15#Colorize any error messages and the messages "Compilation failed" and  
     16# "Compilation succeeded" (as red, red and blue). default is false 
     17color:true 
     18 
     19#Embed the Cobra run-time support code in the assembly 
     20embed-run-time:true 
     21 
     22#Turn on generation of system debugging information.  
     23# full enables attaching a debugger to a running program.  
     24# Turning on implies -debugging-tips:no.  Default is 0 
     25debug:1 
     26#debug:pdbonly 
     27#debug:full 
     28 
     29#Emit the total duration (wall time) of this run of cobra  
     30#  (including the target program, if it is to be run).  
     31#Default is false. 
     32#timeit:true 
     33 
     34# file containing filenames for Cobra to process 
     35#  One file per line; # comments and blank lines are ignored. 
     36files:files-to-compile.text 
     37 
     38# Initial filename(s) list  
     39cobra.cobra 
  • Source/.cobrarc

     
     1# = Cobra compiler template options file =  
     2# This file is read and processed for compiler options before any commandline options are processed 
     3# Any specified commandline options will override any active settings made in this file 
     4#---------------------------------------------------------------------------------------- 
     5 
     6#Specify to only compile (do not run the code post compilation ) 
     7#compile:true 
     8 
     9#Compile sources if any source file is newer than the existing output file  
     10# (or there is no output file). default is false 
     11#compile-if-needed:true 
     12 
     13#Specify form of code generation for contracts. 
     14# choices: 'none', 'inline', 'methods'.  
     15#Default is 'inline'. none suppresses contracts code entirely 
     16#contracts:none 
     17#contracts:methods 
     18 
     19#Turn on generation of system debugging information.  
     20# full enables attaching a debugger to a running program.  
     21# Turning on implies -debugging-tips:no.  Default is 0 
     22#debug:0 
     23#debug:1 
     24#debug:pdbonly 
     25#debug:full 
     26 
     27#Say to embed the Cobra run-time support code in the assembly so that no reference to an  
     28#  external Cobra.Lang.dll is required. Adds approximately 85KB - 130KB overhead depending on  
     29#  other options such as -include-asserts or -turbo 
     30#  default is false 
     31#embed-run-time:true 
     32 
     33#Include code for assert statements in the program. Default is true 
     34#include-asserts:false 
     35 
     36#Include checks on non-nilable class variables, method arguments and "to !" casts.  
     37# Default is true 
     38#include-nil-checks:false 
     39 
     40#Include unit tests for classes and members in the output assembly. Default is true 
     41#include-tests:false 
     42 
     43#Include trace statements in the output assembly. Default is true 
     44#include-traces:false 
     45 
     46#When a class does not provide initializers, Cobra will mirror each initializer in the base class.  
     47# The old behavior was to provide one parameterless initializer.  
     48# Use this option to switch to the old behavior. 
     49#legacy-one-default-initializer:true 
     50 
     51#Specify additional directories to search in for references.  
     52# Maps to -lib: on .NET and -classpath on JVM 
     53#library-directory:PATH 
     54#library-directory:PATH2 
     55 
     56#Specify the name of the type containing the "main" method 
     57#main:TYPENAME   
     58 
     59#Set the namespace for all Cobra source files as if each one started with "namespace <name>".  
     60#Can be a qualified name. 
     61#namespace:My.Name.Space 
     62 
     63# Set the real numeric type for both the 'number' type and fractional literals such as '1.0'. 
     64# choices are decimal, float, float32, float64.    Default is decimal 
     65#number:float 
     66#number:float64 
     67 
     68#Enable optimizations. Default is false 
     69#optimize:true 
     70 
     71# Specify a file containing filenames for Cobra to process 
     72#  One file per line; # comments and blank lines are ignored. 
     73#files:FILENAME 
     74 
     75#Specify the output file name (default: base name of first file). 
     76# -test overrides this with a temporary program that runs only the unit tests and is then removed afterwards.', 
     77#out:FILENAME 
     78 
     79#Reference package via "pkg-config --libs". (Mono only.) 
     80#pkg:NAME 
     81 
     82#Specify a DLL to reference to resolve imports ('use' clause) in the sourcefiles 
     83#reference:DLL-NAME 
     84#reference:DLL-NAME2 
     85 
     86#Provide commandline args to be passed to the built executable,  
     87# Supports single or dbl quoting to preserve whitespace 
     88#run-args: args to pass to cmdline of built exe 
     89#run-args:'test args' to pass to cmdline of "built exe" file. 
     90 
     91#Build a specific target type 
     92# choices are exe, winexe, lib and module, Default is exe 
     93# specific to .Net 
     94#target:exe 
     95#target:winexe 
     96#target:lib 
     97 
     98#Emit the total duration (wall time) of running cobra  
     99#  (including the target program, if it is to be run).  
     100#Default is false. 
     101#timeit:true 
     102 
     103# Compile for Maximum run-time performance.  
     104# This is a convenience for contracts:none include-asserts:no include-nil-checks:no include-tests:no include-traces:no optimize 
     105#turbo:true 
     106 
     107#Enable extra output from Cobra. Mostly useful for debugging Cobra and reporting problems. Values 0 - 5. 
     108# Warning: Level 5 causes megabytes of output.', 
     109#verbosity:1 
     110#verbosity:2 
     111 
     112#Enable extra output from Cobra regarding the resolution of references to libraries.  
     113#Mostly useful for debugging Cobra and reporting problems. Values 0 - 5.', 
     114#verbosity-ref:2 
     115 
     116#------------------------ 
     117 
     118#Colorizes any error messages and the messages "Compilation failed" and  
     119# "Compilation succeeded" (as red, red and blue). default is false 
     120#color:true 
     121 
     122#Rewrite source files with corrections, only when unambiguous.  
     123#For example, "string" --> "String". Default is 'none' 
     124#correct-source:none 
     125#correct-source:case 
     126#correct-source:all 
     127 
     128#Specify an editor and command line options to invoke if there is a compile-time error.  
     129#Use underscore (_) for space in the specification. Can also set via COBRA_EDITOR environment variable (in which case spaces work fine).', 
     130#editor:me_-l_LINE_FILE 
     131#editor:uedit32_FILE/LINE 
     132#editor:mate_FILE_-l_LINE 
     133 
     134#------------------------ 
     135 
     136#Display debugging tips when an unhandled exception occurs. Overridden by -exception-report. 
     137#  Default is yes 
     138#debugging-tips:no 
     139 
     140# Enable a detailed stack trace which gives postmortem information for uncaught exceptions, 
     141#  but slows execution. Works in combination with -exception-report 
     142#detailed-stack-trace:true 
     143 
     144#Turn on an informative HTML report that will be generated if the program throws an uncaught exception.  
     145# default is false 
     146#exception-report:true 
     147 
     148#Specify to output the command line in HTML 
     149#output-html:true 
     150 
     151#------------------------ 
     152 
     153#Keep any intermediate files that Cobra generates, which are normally deleted.  
     154# Example intermediate files are *.cobra.cs.  Default is false 
     155#keep-intermediate-files:true 
     156 
     157#Specify the back-end of the compiler, possibly different than the build platform. Used for cross-compilation. 
     158#back-end:clr 
     159#back-end:jvm 
     160 
     161#Specify the path to the back-end native compiler.  
     162#This can be an executable (such as csc.exe or javac), a library (such as Cobra.Sharp.dll),  
     163#  "auto" or "provider".  Default is 'auto' 
     164#native-compiler:path/to/native-compiler 
     165 
     166#Pass additional arguments to the native back-end compiler (such as C# or Java) 
     167#native-compiler-args:ARGS 
     168 
     169#Tell cobra compiler to build the standard library 
     170#build-standard-library:true 
     171 
     172#Specify the method to invoke to run the unit tests. The method must be "shared".  
     173# Typically the method will make use of classes in Cobra.Lang.Test to set up and initiate the test run. 
     174# default is Cobra.Lang.CobraCore.runAllTests 
     175#test-runner:QUALIFIED-METHOD-NAME|nil 
     176 
     177#------------------------ 
     178 
     179#Delay-sign the assembly using only the public portion of the strong name key 
     180# specific to .Net only 
     181#delay-sign:true 
     182 
     183#Specify a strong name key container used to strongname the output assembly 
     184# specific to .Net only 
     185#key-container:FILENAME 
     186 
     187#Specify a strong name key file used to sign the output assembly 
     188# specific to .Net only 
     189#key-file:FILENAME 
     190 
  • Source/CommandLine.cobra

     
    343343            'description': "Set the real numeric type for both the 'number' type and fractional literals such as '1.0'.", 
    344344        }, 
    345345        { 
     346            'name': 'options-file', 
     347            'synonyms': ['optfile', 'of'], 
     348            'isAccumulator': true, 
     349            'description': 'Name an options file to read cmdline options from. Specify "none" to suppress default probe for first of ".cobrarc", "cobra.rc", "cobra.init"', 
     350            'args': 'filename', 
     351        }, 
     352        { 
    346353            'name': 'optimize', 
    347354            'synonyms': ['o'], 
    348355            'type': 'bool', 
     
    562569            .error(ape.message) 
    563570        _verbosity = _argParser.verbosity 
    564571        CobraMain.willTimeIt = _argParser.willTimeIt 
    565          
     572     
     573    def parseOptFile 
     574        """ 
     575        Load OptionValues obtained from reading a cwd options file into _options 
     576        """ 
     577        defaultOptFiles = ['.cobrarc', 'cobra.rc', 'cobra.init'] 
     578        optFiles = _options.getDefault('options-file', defaultOptFiles ) to List<of String> 
     579        if optFiles[0] == 'none' 
     580            return # suppress reading any (or default) optionsFile 
     581        paths = List<of String>() 
     582        try 
     583            fileOptions = _argParser.parseOptionsFile(optFiles, inout paths) 
     584        catch ape as ArgParseException 
     585            fileOptions = OptionValues() 
     586            .error(ape.message) 
     587        _verbosity = _argParser.verbosity 
     588        CobraMain.willTimeIt = _argParser.willTimeIt 
     589        # merge in fileOptions values unless have one from cmdline setting 
     590        _options.combineNew(fileOptions) 
     591        if paths.count  # if paths from optionsfile, append after any from cmdline 
     592            _pathList.addRange(paths) 
     593             
    566594    def run 
    567595        """ 
    568596        Run the command line using the command line arguments. 
     
    578606            .doAbout 
    579607            return 
    580608        .parseArgs(args) 
    581  
     609        .parseOptFile 
     610         
    582611        if _options.boolValue('output-html') 
    583612            _htmlWriter = HtmlWriter(Console.out) 
    584613            dest = _htmlWriter to TextWriter 
     
    763792     
    764793        exeFileName as String? = nil 
    765794        runArgs = .options.getStringList('run-args') 
    766         # TODO: what's this? 
    767         # exeArgs = .options.getDefaultLOStr('exe-args') 
    768         # if exeArgs.count 
    769         #   exeFileName = exeArgs[0] 
    770         #   runArgs = exeArgs[1:] 
    771795        p = c.runProcess(exeFileName, runArgs) 
    772796        if _verbosity >= 1 
    773797            print 'Running: [p.startInfo.fileName] [p.startInfo.arguments]' 
     
    10131037        paths = List<of String>() 
    10141038        # TODO: mark which opts as unusable in this context and filter out 
    10151039        _optsOnly = true 
    1016         .parseArgs(args, out opts, out paths) 
     1040        if args.count 
     1041            .parseArgs(args, out opts, out paths) 
    10171042        if .verbosity or opts.getDefault('verbosity', 0) to int 
    10181043            print 'parseToOptions Option Dictionary:' 
    10191044            opts.print 
    10201045        return opts 
    10211046         
     1047    def parseFileOptions(args as IList<of String>, paths as inout List<of String> ) as OptionValues 
     1048        """ 
     1049        Reuse ArgParser to parse string option args and filenames read from optionsfile.  
     1050        Return new set of Options and paths from given args list 
     1051        """ 
     1052        opts = OptionValues() 
     1053        _optsOnly = false # allow filenames in optionsfile 
     1054        if args.count 
     1055            .parseArgs(args, out opts, out paths) 
     1056        if .verbosity or opts.getDefault('verbosity', 0) to int 
     1057            print 'parseFileOptions Option Dictionary:' 
     1058            opts.print 
     1059        return opts 
     1060 
    10221061    def parseArgs(args as IList<of String>, options as out OptionValues?, paths as out List<of String>?) 
    10231062        """ 
    10241063        Parse command line arguments: options and files. 
     
    10921131                _error('Cannot have these main options at the same time: [mainOptions.join(", ")]') 
    10931132 
    10941133            _unpackOptions(valueDict, fileList)  
    1095  
     1134             
    10961135            # set the out parameters 
    10971136            options = OptionValues(valueDict) 
    10981137            options.setSpecified(didSpecify) 
     
    13611400    def _error(msg as String) 
    13621401        throw ArgParseException(msg) 
    13631402 
     1403         
     1404    def parseOptionsFile(optFiles as IList<of String>, paths as inout List<of String>) as OptionValues 
     1405        """ 
     1406        Find first existing OptionsFile from given list of names, read its contents and  
     1407        process to an OptionValues object. 
     1408        """ 
     1409        args = List<of String>() 
     1410        runArgs = '' 
     1411        #print 'optionFilesList = [optFiles]' 
     1412        for fileName in optFiles 
     1413            if  not File.exists(fileName), continue 
     1414            #print 'Processing optionsFile [fileName]...' 
     1415            try 
     1416                for line in File.readAllLines(fileName) 
     1417                    line = line.trim 
     1418                    if line.length==0 or line.startsWith('#'), continue 
     1419                    if _verbosity, print '[fileName]: [line]' 
     1420                    if line.startsWith('run-args:') 
     1421                        runArgs = line[9:] 
     1422                        continue 
     1423                    if not line[0] == '-' and ':' in line  # looks like optionkey:value pair 
     1424                        line = '-' + line 
     1425                    args.add(line) 
     1426            catch IOException 
     1427                print 'Cannot open optionsFile "[fileName]".' 
     1428            break   # do first file found only   
     1429        if runArgs.length 
     1430            args.add('-run-args') 
     1431            args.addRange(.cmdLineSplit(runArgs))  
     1432        options = .parseFileOptions(args, inout paths) 
     1433        return options       
    13641434 
    1365  
     1435    def cmdLineSplit(line as String) as List<of String> 
     1436        """ 
     1437        Split line into tokens same as a cmdline tokeniser. 
     1438        Break into words on whitespace preserving single or double quoted  
     1439        sequences but removing the quotes. 
     1440        """ 
     1441        #TODO: move into utils 
     1442        words=List<of String>() 
     1443        word = StringBuilder() 
     1444        inStringSingle = inStringDouble = false 
     1445        for c in line 
     1446            if c in [c' ', c'\t'] and not (inStringSingle or inStringDouble) 
     1447                if word.length 
     1448                    words.add(word.toString) 
     1449                    word.remove(0,word.length) 
     1450                continue     
     1451            if c == c'"' and not inStringSingle  
     1452                inStringDouble = not inStringDouble 
     1453                continue 
     1454            if c == c"'" and not inStringDouble  
     1455                inStringSingle = not inStringSingle 
     1456                continue 
     1457            word.append(c) 
     1458        if word.length 
     1459            words.add(word.toString) 
     1460        return words         
     1461         
    13661462class HtmlWriter 
    13671463    inherits TextWriter 
    13681464    """ 
  • Source/CobraParser.cobra

     
    23962396        return ThrowStmt(token, expr) 
    23972397 
    23982398    def tryStmt as Stmt 
    2399         # try... except... success... finally... 
     2399        # try... catch... success... finally... 
    24002400        token = .expect('TRY') 
    24012401        tryBlock = .block 
    24022402        catchBlocks = List<of CatchBlock>() 
  • Tests/700-command-line/optFile/520-debug.cobra

     
     1# .skip. driven from 520-debugTest.cobra using args -debug 
     2 
     3# This test covers: 
     4# * That Cobra executables have the correct filname and line number embedded in them (see SharpWriter.cobra) 
     5# * That passing -debug to cobra results in stack traces that have file name and line number information. 
     6# * On Mono, that passing -debug to cobra also passes --debug to mono when running the program. 
     7 
     8 
     9# non-debug stack trace:   at Test.Main () [0x00000]  
     10# debug stack trace:   at Test.Main () [0x00022] in /Users/chuck/Projects/Cobra/Workspace-Misc/Source/foo.cobra:5 
     11#                or:   at Test.Main () [0x00022] in /Users/chuck/Projects/Cobra/Workspace-Misc/Source/foo.cobra:line 5 
     12 
     13class Test 
     14 
     15    def main is shared 
     16        try 
     17            assert false 
     18        catch exc as Exception 
     19            assert 'debug.cobra:17' in exc.stackTrace or '520-debug.cobra:line 17' in exc.stackTrace 
  • Tests/700-command-line/optFile/520-debugTest.cobra

     
     1class DebugTestDrvr 
     2 
     3    def main is shared 
     4        # needs to use args debug 
     5        sub = '520-debug.cobra' 
     6        optFile = '.cobrarc' 
     7        optFileLines = @[ 
     8            '# optFile/520-debugTest', 
     9            'debug:true', 
     10            ] 
     11        File.writeAllLines(optFile, optFileLines) 
     12         
     13        p as System.Diagnostics.Process? 
     14        CobraCore.runCobraExe(sub, out p) 
     15        assert p.exitCode == 0 
     16        File.delete(optFile)     
  • Tests/700-command-line/optFile/620-turboTest.cobra

     
     1class TurboDrvr 
     2 
     3    def main is shared 
     4        # needs to use args turbo:true 
     5        sub = '621-turbo.cobra' 
     6        optFile = '.cobrarc' 
     7        optFileLines = @[ 
     8            '# optFile/620-turboTest', 
     9            'turbo:true', 
     10            ] 
     11        File.writeAllLines(optFile, optFileLines) 
     12         
     13        p as System.Diagnostics.Process? 
     14        output = CobraCore.runCobraExe(sub, out p) 
     15        assert p.exitCode == 0 
     16        assert output.trim.length == 0 
     17        File.delete(optFile)     
  • Tests/700-command-line/optFile/621-turbo.cobra

     
     1# .skip. driven from 620-turboTest.cobra 
     2# needs args -turbo 
     3 
     4class Program 
     5 
     6    def main is shared 
     7        assert false 
     8        trace  
     9        x = 1 
     10        trace all 
     11        trace x 
  • Tests/700-command-line/optFile/700-run-args.cobra

     
     1# Test compile+run execution specifying args to run compiled prog with  
     2 
     3class Test  
     4 
     5    def main is shared  
     6        cobraPath = CobraCore.findCobraExe to ! 
     7        if 'Snapshot' in cobraPath 
     8            # TODO 2008-10-19: Not sure why this is happening yet. 
     9            print 'WARNING: Snapshot in cobra path:', cobraPath 
     10            cobraPath = cobraPath.replace('\\Snapshot\\', '\\') 
     11            cobraPath = cobraPath.replace('/Snapshot/', '/') 
     12 
     13        echo = '702-echo' 
     14        exp = 'argA argB argC' 
     15        .verify(cobraPath, '[echo]', exp, exp) 
     16 
     17        arg = '"1argA 2argB 3argC"' 
     18        exp =  '1argA 2argB 3argC :1'  
     19        .verify(cobraPath, '[echo]', arg, exp) 
     20         
     21         
     22    def verify(cobraPath as String, prog as String, args as String, expectedText as String) is shared 
     23        p as System.Diagnostics.Process?  
     24        optFile = '.cobrarc' 
     25        optFileLines = @[ 
     26            '# optFile/700-run-args', 
     27            'run-args:[args]', 
     28            ] 
     29        File.writeAllLines(optFile, optFileLines) 
     30         
     31        output = CobraCore.runCobraExe(cobraPath, prog, out p)  
     32        File.delete(optFile)     
     33        #print output  
     34        assert 'Unhandled Exception' not in output  
     35        assert expectedText in output  
     36        assert p.exitCode == 0  
  • Tests/700-command-line/optFile/110-hello.cobra

     
     1class Hello 
     2    def main 
     3        print 'Hello' 
  • Tests/700-command-line/optFile/610-include-tracesTest.cobra

     
     1class IncludeAssertsDrvr 
     2 
     3    def main is shared 
     4        # needs to use args include-traces:false 
     5        sub = '611-include-traces.cobra' 
     6        optFile = '.cobrarc' 
     7        optFileLines = @[ 
     8            '# optFile/610-include-tracesTest', 
     9            'include-traces:false', 
     10            ] 
     11        File.writeAllLines(optFile, optFileLines) 
     12         
     13        p as System.Diagnostics.Process? 
     14        output = CobraCore.runCobraExe(sub, out p) 
     15        assert p.exitCode == 0 
     16        assert output.trim.length == 0 
     17        File.delete(optFile)     
  • Tests/700-command-line/optFile/611-include-traces.cobra

     
     1# .skip. driven from 610-include-tracesTest.cobra 
     2# needs args  -include-traces:no 
     3 
     4class Program 
     5 
     6    def main is shared 
     7        tracer = CobraCore.tracer 
     8        tracer.destination = StringWriter() 
     9        x = 1 
     10        trace  
     11        trace all 
     12        trace x 
     13        trace off 
     14        trace 'hello' 
     15        trace on 
     16        assert tracer.destination.toString == '' 
  • Tests/700-command-line/optFile/600-include-assertsTest.cobra

     
     1class IncludeAssertsDrvr 
     2 
     3    def main is shared 
     4        # needs to use args include-asserts:false 
     5        sub = '601-include-asserts.cobra' 
     6        optFile = '.cobrarc' 
     7        optFileLines = @[ 
     8            '# optFile/600-include-assertsTest', 
     9            'include-asserts:false', 
     10            ] 
     11        File.writeAllLines(optFile, optFileLines) 
     12         
     13        p as System.Diagnostics.Process? 
     14        CobraCore.runCobraExe(sub, out p) 
     15        assert p.exitCode == 0 
     16        File.delete(optFile)     
  • Tests/700-command-line/optFile/601-include-asserts.cobra

     
     1# .skip. driven from 600-include-assertsTest.cobra  
     2# needs to run with args -include-asserts:no 
     3 
     4class Program 
     5 
     6    def main is shared 
     7        assert false 
  • Tests/700-command-line/optFile/400-foolib.cobra

     
     1# .args. -t:lib -embed-run-time:no 
     2 
     3class Foo 
     4 
     5    get one as int 
     6        return 1 
     7 
     8    get two as int 
     9        return 2 
     10 
     11    get name as String 
     12        return .getType.name 
     13 
     14    def computeString as String 
     15        return 'aoeuaoeu' 
     16 
     17    def checkInts(args as vari int) as int 
     18        for arg in args 
     19            assert arg 
     20        return args.length 
  • Tests/700-command-line/optFile/116-highlight.cobra

     
     1# test -highlight option set in options file 
     2# . especially on a file with "def main" with no "is shared" 
     3 
     4class Test 
     5 
     6    def main 
     7        sourceFile = '110-hello.cobra' 
     8 
     9        source = File.readAllText(sourceFile) 
     10        assert 'is shared' not in source 
     11         
     12        optFile = '.cobrarc' 
     13        hdr = '# optFile/116-highlight' 
     14         
     15        File.writeAllLines(optFile, @[hdr,'highlight:true']) 
     16         
     17        p as System.Diagnostics.Process? 
     18        output = CobraCore.runCobraExe('[sourceFile]', out p) 
     19        File.delete(optFile)     
     20        assert p.exitCode == 0 
     21        # trace output  # on mac: output='Writing gen-html/110-hello.cobra.html\n\n\n 
     22        assert 'Writing ' in output and 'hello.cobra' in output 
     23        genFile = Path.combine('gen-html', '110-hello.cobra.html') 
     24        assert File.exists(genFile) 
     25        File.delete(genFile) 
  • Tests/700-command-line/optFile/401-fooprogTest.cobra

     
     1# args to use are -embed-run-time:no -ref:400-foolib.dll 
     2class FooProgDriver 
     3 
     4    def main 
     5        sub = '402-fooprog.cobra' 
     6        optFile = '.cobrarc' 
     7        optFileLines = @[ 
     8            '# optFile/401-fooprogTest', 
     9            'embed-run-time:no', 
     10            'ref:400-foolib.dll' 
     11            ] 
     12        File.writeAllLines(optFile, optFileLines) 
     13         
     14        output = .runCobraExe('[sub]') 
     15        assert 'f.one is 1' in output 
     16        assert 'f.two is 2' in output 
     17        File.delete(optFile)     
     18     
     19    def runCobraExe(args as String) as String 
     20        p as System.Diagnostics.Process? 
     21        return CobraCore.runCobraExe(args, out p) 
  • Tests/700-command-line/optFile/800-options-file.cobra

     
     1class OptionsFileDrvr 
     2 
     3    def main is shared 
     4        # needs to use args turbo:true 
     5        optFile = 'myOpt' 
     6        sub = '-options-file:[optFile] 621-turbo.cobra ' 
     7        optFileLines = @[ 
     8            '# optFile/800-options-file', 
     9            'turbo:true', 
     10            'out:turboWithopts', 
     11            ] 
     12        File.writeAllLines(optFile, optFileLines) 
     13         
     14        p as System.Diagnostics.Process? 
     15        output = CobraCore.runCobraExe(sub, out p) 
     16        assert p.exitCode == 0 
     17        assert output.trim.length == 0 
     18        File.delete(optFile)     
  • Tests/700-command-line/optFile/402-fooprog.cobra

     
     1# .skip. driven from 401-fooprogTest 
     2# args are: embed-run-time:no    ref: 400-foolib.dll 
     3 
     4class Program 
     5 
     6    def main is shared 
     7        f = Foo() 
     8        print 'f.one is', f.one 
     9        print 'f.two is', f.two 
     10        name = f.name 
     11        .checkName(name) 
     12        s = f.computeString 
     13        .checkName(s) 
     14        assert f.checkInts(2, 4, 6) == 3 
     15 
     16    def checkName(name as String) is shared 
     17        assert name.length 
  • Tests/700-command-line/optFile/510-lib-optionTest.cobra

     
     1class LibOptionDrvr 
     2 
     3    def main is shared 
     4        oldName = '400-foolib.dll' 
     5        newName = 'foolib.dll' 
     6        assert File.exists(oldName) 
     7 
     8        # put foolib.dll in a subdir         
     9        libDir = Path.combine('..', 'libdir') 
     10        path = Path.combine(libDir, newName) 
     11        if File.exists(path) 
     12            File.delete(path) 
     13        File.copy(oldName, path) 
     14         
     15        # needs to use args .compile-only, -lib:libdir -ref:foolib  
     16        sub = '512-lib-option.cobra' 
     17        optFile = '.cobrarc' 
     18        optFileLines = @[ 
     19            '# optFile/510-lib-optionTest', 
     20            'compile:true', 
     21            'lib:[libDir]', 
     22            'ref:foolib' 
     23            ] 
     24        File.writeAllLines(optFile, optFileLines) 
     25         
     26        p as System.Diagnostics.Process? 
     27        CobraCore.runCobraExe(sub, out p) 
     28        assert p.exitCode == 0 
     29        File.delete(optFile)     
     30     
  • Tests/700-command-line/optFile/118-time-it.cobra

     
     1class TimeIt 
     2 
     3    def main 
     4        sub = '110-hello.cobra' 
     5        optFile = '.cobrarc' 
     6        hdr = '# optFile/118-timeit' 
     7         
     8        File.writeAllLines(optFile, @[hdr,'#empty options file']) 
     9        output = .runCobraExe('[sub]') 
     10        assert 'timeit =' not in output 
     11        assert 'Hello' in output 
     12             
     13        File.writeAllLines(optFile, @[hdr, 'timeit:true']) 
     14        output = .runCobraExe('[sub]') 
     15        assert 'total' in output 
     16        assert 'execute =' in output 
     17        assert 'compile =' in output 
     18        assert 'lines compiled' in output 
     19        assert 'nodes compiled' in output 
     20        assert 'tokens compiled' in output 
     21        assert 'Hello' in output 
     22        File.delete(optFile)     
     23         
     24    def runCobraExe(args as String) as String 
     25        p as System.Diagnostics.Process? 
     26        return CobraCore.runCobraExe(args, out p) 
  • Tests/700-command-line/optFile/801-options-fileName.cobra

     
     1# test options file with embedded filename to compile 
     2class OptionsFileDrvr 
     3 
     4    def main is shared 
     5        optFile = 'myOptwName' 
     6        sub = '-options-file:[optFile] ' 
     7        optFileLines = @[ 
     8            '# optFile/801-options-fileName', 
     9            'turbo:true', 
     10            'out:nameFmOpts', 
     11            '621-turbo.cobra', 
     12            ] 
     13        File.writeAllLines(optFile, optFileLines) 
     14         
     15        p as System.Diagnostics.Process? 
     16        output = CobraCore.runCobraExe(sub, out p) 
     17        assert p.exitCode == 0 
     18        assert output.trim.length == 0 
     19        File.delete(optFile)     
  • Tests/700-command-line/optFile/512-lib-option.cobra

     
     1# .skip.  driven from 510-lib-optionTest.cobra 
     2# needs to use args -compile, -lib:libdir -ref:foolib  
     3 
     4class Test 
     5 
     6    def main is shared 
     7        assert Foo().two == 2 
  • Tests/700-command-line/optFile/702-echo.cobra

     
     1# .skip. Driven from 700-run-args 
     2class Echo 
     3    def main is shared 
     4        args = CobraCore.commandLineArgs 
     5        sep = '' 
     6        for a in args[1:] 
     7            print '[sep][a]' stop 
     8            sep = ' ' 
     9        if args.count > 1 
     10            print ' :[args.count-1]' stop 
     11        print 
  • Tests/700-command-line/optFile/650-out-option.cobra

     
     1# .skip. driven from 652-out-option-verify 
     2# needs args -compile  -out:outoption.exe 
     3 
     4class OutOption 
     5 
     6    def main is shared 
     7        print 'DateTime Now is', DateTime.now 
  • Tests/700-command-line/optFile/652-out-option-verify.cobra

     
     1class OutOptionVerify 
     2 
     3    def main is shared 
     4        # needs to use args  -compile  -out:outoption.exe 
     5        sub = '650-out-option.cobra' 
     6        optFile = '.cobrarc' 
     7        optFileLines = @[ 
     8            '# optFile/652-out-option-verify', 
     9            'compile:true', 
     10            'out:outoption.exe', 
     11            ] 
     12        File.writeAllLines(optFile, optFileLines) 
     13         
     14        p as System.Diagnostics.Process? 
     15        output = CobraCore.runCobraExe(sub, out p) 
     16        assert p.exitCode == 0 
     17        assert 'Compilation succeeded' in output 
     18        File.delete(optFile)     
     19         
     20         
     21        name = 'outoption.exe' 
     22        p1 = System.Diagnostics.Process() 
     23        p1.startInfo.fileName = name 
     24        output = CobraCore.runAndCaptureAllOutput(p1) 
     25        assert 'DateTime Now is' in output 
     26 
     27         
     28 No newline at end of file 
  • Developer/IntermediateReleaseNotes.text

     
    5858 
    5959    An above error about numeric types indicates that you may want to set the default numeric type with "@number [expectedType]" in a source file or "cobra -number:[expectedType]" at the command line. 
    6060 
     61* Added support for a cwd default options file (.cobrarc, cobra.rc, cobra.init) to store multiple 
     62(optionally commented) cmdline options in.  
     63Any options set on the commandline explicitly will override these.  
     64Provide new commandline option     -options-file/-optfile/-of 
     65to allow to disable options file processing (-options-file:none) or to specify an alternative filename  
     66to read from (-options-file:FILENAME). 
    6167 
     68 
    6269================================================================================ 
    6370Library 
    6471================================================================================