Ticket #14: min-build.patch
File min-build.patch, 15.2 KB (added by hopscc, 15 years ago) |
---|
-
Source/BackEndObjC/ObjcGenerator.cobra
10 10 11 11 class Compiler is partial 12 12 13 def computeOutNameObjc as String 14 outName ='' 15 if .options.boolValue('test') 16 outName = _modules[_modules.count-1].fileName 17 else if .options.containsKey('out') 18 outName = .options.getDefault('out', '') 19 if outName == '', outName = .defaultOutName to ! 20 if outName.endsWith('.objc') or outName.endsWith('.OBJC'), outName = outName[:-5] 21 if outName.endsWith('.cobra') or outName.endsWith('.COBRA'), outName = outName[:-6] 22 _baseExeFileName = outName 23 24 #outName = Utils.forceExtension(outName, '.class') # No extn ?? 25 _fullExeFileName = outName 26 return outName 27 13 28 def writeObjc 14 29 Node.setCompiler(this) 15 30 try -
Source/BackEndObjC/ObjcBackEnd.cobra
7 7 phases.add(GenerateObjcCodePhase(.compiler)) 8 8 phases.add(CompileObjcCodePhase(.compiler)) 9 9 10 def computeOutName as String is override 11 return .compiler.computeOutNameObjc 10 12 13 11 14 class GenerateObjcCodePhase inherits Phase 12 15 13 16 cue init(c as Compiler) -
Source/Phases/BindRunTimeLibraryPhase.cobra
10 10 return 'Binding Cobra run-time library' 11 11 12 12 def innerRun is override 13 # TODO-BACKEND14 .compiler.defaultOutName = if(.options.buildStandardLibrary, 'Cobra.Lang.dll', .compiler.pathsToCompile[0])15 16 13 if .options.boolValue('embed-run-time') 17 14 _embedRunTime 18 15 else -
Source/BackEndClr/SharpGenerator.cobra
69 69 70 70 get platform from var 71 71 72 def computeOutNameSharp as String 73 outName = '' 74 if .options.boolValue('test') 75 outName = _modules[_modules.count-1].sharpFileName 76 else if .options.containsKey('out') 77 outName = .options.getDefault('out', '') 78 if outName == '', outName = .defaultOutName to ! 79 if outName.endsWith('.cs') or outName.endsWith('.CS'), outName = outName[:-3] 80 if outName.endsWith('.cobra') or outName.endsWith('.COBRA'), outName = outName[:-6] 81 _baseExeFileName = outName 82 83 target = .options.getDefault('target', '') to String 84 if target.length 85 # TODO: what is the output for a module? 86 branch target 87 on 'exe' or 'winexe', outName = Utils.forceExtension(outName, '.exe') 88 on 'lib', outName = Utils.forceExtension(outName, '.dll') 89 on 'module', outName = Utils.forceExtension(outName, '.netmodule') # http://msdn2.microsoft.com/en-us/library/58scf68s(VS.80).aspx 90 else, throw FallThroughException(target) 91 else 92 outName = Utils.forceExtension(outName, '.exe') 93 _fullExeFileName = outName 94 return outName 95 72 96 def compileSharp 73 97 .compileSharp('') 74 98 … … 98 122 optChar = if(platform=='ms', '/', '-') # option prefix character 99 123 100 124 # exe names 101 outName = '' 102 if options.boolValue('test') 103 outName = _modules[_modules.count-1].sharpFileName 104 else if options.containsKey('out') 105 outName = options.getDefault('out', '') 106 if outName == '', outName = .defaultOutName to ! 107 if outName.endsWith('.cs') or outName.endsWith('.CS'), outName = outName[:-3] 108 if outName.endsWith('.cobra') or outName.endsWith('.COBRA'), outName = outName[:-6] 109 _baseExeFileName = outName 110 125 outName = .computeOutNameSharp 126 111 127 # compute backEndOptions 112 128 backEndOptions = '' 113 114 129 target = options.getDefault('target', '') to String 115 130 if target.length 116 131 if target=='lib', target = 'library' 117 132 backEndOptions += ' [optChar]target:[target]' 118 # TODO: what is the output for a module? 119 branch target 120 on 'exe' or 'winexe', outName = Utils.forceExtension(outName, '.exe') 121 on 'library', outName = Utils.forceExtension(outName, '.dll') 122 on 'module', outName = Utils.forceExtension(outName, '.netmodule') # http://msdn2.microsoft.com/en-us/library/58scf68s(VS.80).aspx 123 else, throw FallThroughException(target) 124 else 125 outName = Utils.forceExtension(outName, '.exe') 126 _fullExeFileName = outName 127 133 128 134 delaySign = options.boolValue('delay-sign') 129 135 if delaySign 130 136 backEndOptions += ' [optChar]delaysign+' -
Source/BackEndClr/ClrBackEnd.cobra
7 7 phases.add(GenerateSharpCodePhase(.compiler)) 8 8 phases.add(CompileSharpCodePhase(.compiler)) 9 9 10 def computeOutName as String is override 11 return .compiler.computeOutNameSharp 12 10 13 11 14 class GenerateSharpCodePhase inherits Phase 12 15 -
Source/BackEndJvm/JvmBackEnd.cobra
6 6 def makePhases(phases as IList<of Phase>) is override 7 7 phases.add(GenerateJavaCodePhase(.compiler)) 8 8 phases.add(CompileJavaCodePhase(.compiler)) 9 10 def computeOutName as String is override 11 return .compiler.computeOutNameJava 12 9 13 10 11 14 class GenerateJavaCodePhase inherits Phase 12 15 13 16 cue init(c as Compiler) -
Source/BackEndJvm/JavaGenerator.cobra
10 10 11 11 class Compiler is partial 12 12 13 def computeOutNameJava as String 14 outName ='' 15 if .options.boolValue('test') 16 outName = _modules.last.javaFileName 17 else if .options.containsKey('out') 18 outName = .options.getDefault('out', '') 19 if outName == '', outName = .defaultOutName to ! 20 if outName.endsWith('.java') or outName.endsWith('.JAVA'), outName = outName[:-5] 21 if outName.endsWith('.cobra') or outName.endsWith('.COBRA'), outName = outName[:-6] 22 _baseExeFileName = outName 23 24 outName = Utils.forceExtension(outName, '.class') 25 _fullExeFileName = outName 26 return outName 27 13 28 def writeJava 14 29 Node.setCompiler(this) 15 30 try … … 53 68 optChar = '-' 54 69 55 70 # exeNames 56 outName = '' 57 if options.boolValue('test') 58 outName = _modules.last.javaFileName 59 else if options.containsKey('out') 60 outName = options.getDefault('out', '') 61 if outName == '', outName = .defaultOutName to ! 62 if outName.endsWith('.java') or outName.endsWith('.JAVA'), outName = outName[:-3] 63 if outName.endsWith('.cobra') or outName.endsWith('.COBRA'), outName = outName[:-6] 64 _baseExeFileName = outName 71 outName = .computeOutNameJava 65 72 66 73 # compute backEndOptions 67 74 backEndOptions = '' 68 outName = Utils.forceExtension(outName, '.class')69 _fullExeFileName = outName70 75 # -optimize isn't supported by JVM, but it could potentially be used by Cobra itself 71 76 72 77 # TODO: -
Source/Compiler.cobra
52 52 Given a list of core phases for compilation complete it with additions (or even removals and 53 53 rearrangements if necessary) for this given backend. 54 54 """ 55 56 def computeOutName as String is abstract 57 """ 58 Return outout Target name for compilation of files for this backend 59 """ 55 60 56 57 61 class Compiler implements ITypeProvider, IWarningRecorder, IErrorRecorder, ICompilerForNodes is partial 58 62 """ 59 63 General notes: … … 311 315 .compileFilesNamed(paths, false) 312 316 313 317 def compileFilesNamed(paths as IList<of String>, writeTestInvocation as bool) 318 _initBackEnd 319 .defaultOutName = if(.options.buildStandardLibrary, 'Cobra.Lang.dll', paths[0]) 320 if .options.boolValue('minimize-build') # Do only on single file compile ?? 321 outName = .backEnd.computeOutName 322 #elide compile if all src files younger than existing out file 323 if .allYounger(outName, paths) 324 return 325 314 326 if .options.boolValue('reveal-internal-exceptions') 315 327 _compileFilesNamed(paths, writeTestInvocation) 316 328 .printMessages 317 329 return 318 else 319 try 320 _compileFilesNamed(paths, writeTestInvocation) 321 catch StopCompilation 322 throw 323 catch exc as Exception 324 # unexpected exception -- only StopCompilation should be thrown 325 if exc inherits SourceException 326 if exc.hasSourceSite 327 .recordError(InternalError(exc.fileName, exc.lineNum, exc.message, exc)) 328 else 329 .recordError(InternalError(exc.message, exc)) 330 else if exc inherits AssertException 331 sn as SyntaxNode? 332 if exc.this inherits SyntaxNode 333 sn = exc.this to SyntaxNode 334 else if exc.info inherits SyntaxNode 335 sn = exc.info to SyntaxNode 336 if sn 337 .recordError(InternalError(sn.token.fileName, sn.token.lineNum, exc.message, exc)) 338 else 339 .recordError(InternalError(exc.message, exc)) 330 331 try 332 _compileFilesNamed(paths, writeTestInvocation) 333 catch StopCompilation 334 throw 335 catch exc as Exception 336 # unexpected exception -- only StopCompilation should be thrown 337 if exc inherits SourceException 338 if exc.hasSourceSite 339 .recordError(InternalError(exc.fileName, exc.lineNum, exc.message, exc)) 340 340 else 341 341 .recordError(InternalError(exc.message, exc)) 342 .printMessages 343 throw StopCompilation(this) 344 success 345 .printMessages 342 else if exc inherits AssertException 343 sn as SyntaxNode? 344 if exc.this inherits SyntaxNode 345 sn = exc.this to SyntaxNode 346 else if exc.info inherits SyntaxNode 347 sn = exc.info to SyntaxNode 348 if sn 349 .recordError(InternalError(sn.token.fileName, sn.token.lineNum, exc.message, exc)) 350 else 351 .recordError(InternalError(exc.message, exc)) 352 else 353 .recordError(InternalError(exc.message, exc)) 354 .printMessages 355 throw StopCompilation(this) 356 success 357 .printMessages 346 358 347 359 def _compileFilesNamed(paths as IList<of String>, writeTestInvocation as bool) 348 360 .willWriteTestInvocation = writeTestInvocation 349 _initBackEnd350 361 _pathsToCompile = paths 351 362 for phase in .makePhases 352 363 .runPhase(phase) … … 360 371 .options = options 361 372 bar = '----------------------------------------------------------------------------------------------------' 362 373 _initBackEnd 374 .defaultOutName = if(.options.buildStandardLibrary, 'Cobra.Lang.dll', fileNames[0]) 363 375 _pathsToCompile = fileNames 364 376 for phase in .makePhases 365 377 if verbose, print 'Testify phase:', phase.description … … 375 387 .printMessages 376 388 print bar 377 389 390 def allYounger(outName as String, paths as IList<of String>) as bool 391 """ 392 True if write timestamps on all path items younger than write timestamp on outName 393 """ 394 if .verbosity, print 'Doing minimal-build checking' 395 if not File.exists(outName) 396 if .verbosity, print ' outName [outName] does not yet exist.' 397 return false 398 targetTime = File.getLastWriteTime(outName) 399 if .verbosity, print ' outName [outName] lastWriteTime:[targetTime].' 400 for f in paths 401 srcTime = File.getLastWriteTime(f) 402 if .verbosity, print ' [f] lastWriteTime:[srcTime].' 403 if srcTime.compareTo(targetTime) >= 0 404 if .verbosity, print ' [f] older than [outName], compiling...' 405 return false 406 if .verbosity 407 print ' All source files are younger than [outName], compile shortcircuited...' 408 return true 409 378 410 def addRunTimeRef(opts as OptionValues) 379 411 if not opts.containsKey('reference') 380 412 opts['reference'] = List<of String>() -
Source/CommandLine.cobra
309 309 'args': 'TYPENAME', 310 310 }, 311 311 { 312 'name': 'minimize-build', # 'make' mode 313 'synonyms': ['m'], 314 'type': 'bool', 315 'description': 'Compile only if all source files are older than an existing output file.', 316 }, 317 { 312 318 'name': 'namespace', 313 319 'synonyms': ['name-space', 'ns'], 314 320 'type': 'string', -
Tests/700-command-line/114-compile-min.cobra
1 # test minimal-build compilation (single file) 2 class RunMin 3 shared 4 def main 5 file='110-hello' 6 src = '[file].cobra' 7 exe = '[file].exe' 8 9 .rm(exe) 10 assert not File.exists(exe) 11 cobraPath = CobraCore.findCobraExe to ! 12 13 14 p as System.Diagnostics.Process? 15 # No exe - compile 16 output = CobraCore.runCobraExe(cobraPath, '-m -c -v [src]', out p) 17 assert 'minimal-build checking' in output 18 assert '[exe] does not yet exist' in output 19 assert 'Compiling to produce' in output 20 assert p.exitCode == 0 21 assert File.exists(exe) 22 #print '.' stop 23 24 # src younger than exe - no compile 25 output = CobraCore.runCobraExe(cobraPath, '-m -c -v [src]', out p) 26 assert 'minimal-build checking' in output 27 assert 'All source files are younger than [exe]' in output 28 assert p.exitCode == 0 29 assert File.exists(exe) 30 #print '.' stop 31 32 .touch(src) 33 # src older than exe - compile 34 output = CobraCore.runCobraExe(cobraPath, '-m -c -v [src]', out p) 35 assert 'minimal-build checking' in output 36 assert '[src] older than [exe], compiling' in output 37 assert 'Compiling to produce' in output 38 assert p.exitCode == 0 39 assert File.exists(exe) 40 #print '.' stop 41 42 output = CobraCore.runCobraExe(cobraPath, '-c -v [src]', out p) 43 assert 'minimal-build checking' not in output 44 assert 'Compiling to produce' in output 45 assert p.exitCode == 0 46 assert File.exists(exe) 47 #print '.' stop 48 49 #print 50 51 def rm(fileName as String) 52 try 53 File.delete(fileName) 54 catch 55 pass 56 57 def touch(fileName as String) 58 File.setLastWriteTime(fileName, DateTime.now) -
Developer/IntermediateReleaseNotes.text
33 33 34 34 * The + operator can now be used to concatenate lists. 35 35 36 * Compiler switch -m (-minimal-build) to do src vs exe file timestamp checks and 37 short circuit compilation if unneeded. ticket#14 36 38 39 37 40 ================================================================================ 38 41 Library 39 42 ================================================================================