@@ -123,6 +123,8 @@ function concatenateFiles(destinationFile, sourceFiles) {
123123}
124124
125125var useDebugMode = false ;
126+ var host = ( process . env . host || process . env . TYPESCRIPT_HOST || "node" ) ;
127+ var compilerFilename = "tsc.js" ;
126128/* Compiles a file from a list of sources
127129 * @param outFile: the target file name
128130 * @param sources: an array of the names of the source files
@@ -134,10 +136,9 @@ var useDebugMode = false;
134136function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , noOutFile ) {
135137 file ( outFile , prereqs , function ( ) {
136138 var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory ;
137- var compilerFilename = "tsc.js" ;
138139 var options = "-removeComments --module commonjs -noImplicitAny " ; //" -propagateEnumConstants "
139140
140- var cmd = ( process . env . host || process . env . TYPESCRIPT_HOST || "node" ) + " " + dir + compilerFilename + " " + options + " " ;
141+ var cmd = host + " " + dir + compilerFilename + " " + options + " " ;
141142 if ( useDebugMode ) {
142143 cmd = cmd + " " + path . join ( harnessDirectory , "external/es5compat.ts" ) + " " + path . join ( harnessDirectory , "external/json2.ts" ) + " " ;
143144 }
@@ -230,7 +231,7 @@ task("generate-diagnostics", [diagnosticInfoMapTs])
230231
231232
232233// Local target to build the compiler and services
233- var tscFile = path . join ( builtLocalDirectory , "tsc.js" ) ;
234+ var tscFile = path . join ( builtLocalDirectory , compilerFilename ) ;
234235compileFile ( tscFile , compilerSources , [ builtLocalDirectory , copyright ] . concat ( compilerSources ) , [ copyright ] , /*useBuiltCompiler:*/ false ) ;
235236
236237var servicesFile = path . join ( builtLocalDirectory , "typescriptServices.js" ) ;
@@ -312,9 +313,9 @@ function exec(cmd, completeHandler) {
312313 complete ( ) ;
313314 } ) ;
314315 ex . addListener ( "error" , function ( e , status ) {
315- process . stderr . write ( status ) ;
316- process . stderr . write ( e ) ;
317- complete ( ) ;
316+ process . stderr . write ( status ) ;
317+ process . stderr . write ( e ) ;
318+ complete ( ) ;
318319 } )
319320 try {
320321 ex . run ( ) ;
@@ -382,9 +383,9 @@ task("runtests", ["tests", builtLocalDirectory], function() {
382383
383384desc ( "Generates code coverage data via instanbul" )
384385task ( "generate-code-coverage" , [ "tests" , builtLocalDirectory ] , function ( ) {
385- var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run ;
386- console . log ( cmd ) ;
387- exec ( cmd ) ;
386+ var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run ;
387+ console . log ( cmd ) ;
388+ exec ( cmd ) ;
388389} , { async : true } ) ;
389390
390391// Browser tests
@@ -469,7 +470,7 @@ compileFile(webhostJsPath, [webhostPath], [tscFile, webhostPath].concat(libraryT
469470
470471desc ( "Builds the tsc web host" ) ;
471472task ( "webhost" , [ webhostJsPath ] , function ( ) {
472- jake . cpR ( path . join ( builtLocalDirectory , "lib.d.ts" ) , "tests/webhost/" , { silent : true } ) ;
473+ jake . cpR ( path . join ( builtLocalDirectory , "lib.d.ts" ) , "tests/webhost/" , { silent : true } ) ;
473474} ) ;
474475
475476// Perf compiler
@@ -478,3 +479,36 @@ var perftscJsPath = "built/local/perftsc.js";
478479compileFile ( perftscJsPath , [ perftscPath ] , [ tscFile , perftscPath , "tests/perfsys.ts" ] . concat ( libraryTargets ) , [ ] , true ) ;
479480desc ( "Builds augmented version of the compiler for perf tests" ) ;
480481task ( "perftsc" , [ perftscJsPath ] ) ;
482+
483+ // Instrumented compiler
484+ var loggedIOpath = harnessDirectory + 'loggedIO.ts' ;
485+ var loggedIOJsPath = builtLocalDirectory + 'loggedIO.js' ;
486+ file ( loggedIOJsPath , [ builtLocalDirectory , loggedIOpath ] , function ( ) {
487+ var temp = builtLocalDirectory + 'temp' ;
488+ jake . mkdirP ( temp ) ;
489+ var options = "--outdir " + temp + ' ' + loggedIOpath ;
490+ var cmd = host + " " + LKGDirectory + compilerFilename + " " + options + " " ;
491+ console . log ( cmd + "\n" ) ;
492+ var ex = jake . createExec ( [ cmd ] ) ;
493+ ex . addListener ( "cmdEnd" , function ( ) {
494+ fs . renameSync ( temp + '/harness/loggedIO.js' , loggedIOJsPath ) ;
495+ jake . rmRf ( temp ) ;
496+ complete ( ) ;
497+ } ) ;
498+ ex . run ( ) ;
499+ } , { async : true } ) ;
500+
501+ var instrumenterPath = harnessDirectory + 'instrumenter.ts' ;
502+ var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js' ;
503+ compileFile ( instrumenterJsPath , [ instrumenterPath ] , [ tscFile , instrumenterPath ] , [ ] , true ) ;
504+
505+ desc ( "Builds an instrumented tsc.js" ) ;
506+ task ( 'tsc-instrumented' , [ loggedIOJsPath , instrumenterJsPath , tscFile ] , function ( ) {
507+ var cmd = host + ' ' + instrumenterJsPath + ' record iocapture ' + builtLocalDirectory + compilerFilename ;
508+ console . log ( cmd ) ;
509+ var ex = jake . createExec ( [ cmd ] ) ;
510+ ex . addListener ( "cmdEnd" , function ( ) {
511+ complete ( ) ;
512+ } ) ;
513+ ex . run ( ) ;
514+ } , { async : true } ) ;
0 commit comments