@@ -123,6 +123,8 @@ function concatenateFiles(destinationFile, sourceFiles) {
123
123
}
124
124
125
125
var useDebugMode = false ;
126
+ var host = ( process . env . host || process . env . TYPESCRIPT_HOST || "node" ) ;
127
+ var compilerFilename = "tsc.js" ;
126
128
/* Compiles a file from a list of sources
127
129
* @param outFile: the target file name
128
130
* @param sources: an array of the names of the source files
@@ -134,10 +136,9 @@ var useDebugMode = false;
134
136
function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , noOutFile ) {
135
137
file ( outFile , prereqs , function ( ) {
136
138
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory ;
137
- var compilerFilename = "tsc.js" ;
138
139
var options = "-removeComments --module commonjs -noImplicitAny " ; //" -propagateEnumConstants "
139
140
140
- var cmd = ( process . env . host || process . env . TYPESCRIPT_HOST || "node" ) + " " + dir + compilerFilename + " " + options + " " ;
141
+ var cmd = host + " " + dir + compilerFilename + " " + options + " " ;
141
142
if ( useDebugMode ) {
142
143
cmd = cmd + " " + path . join ( harnessDirectory , "external/es5compat.ts" ) + " " + path . join ( harnessDirectory , "external/json2.ts" ) + " " ;
143
144
}
@@ -230,7 +231,7 @@ task("generate-diagnostics", [diagnosticInfoMapTs])
230
231
231
232
232
233
// Local target to build the compiler and services
233
- var tscFile = path . join ( builtLocalDirectory , "tsc.js" ) ;
234
+ var tscFile = path . join ( builtLocalDirectory , compilerFilename ) ;
234
235
compileFile ( tscFile , compilerSources , [ builtLocalDirectory , copyright ] . concat ( compilerSources ) , [ copyright ] , /*useBuiltCompiler:*/ false ) ;
235
236
236
237
var servicesFile = path . join ( builtLocalDirectory , "typescriptServices.js" ) ;
@@ -473,3 +474,36 @@ var perftscJsPath = "built/local/perftsc.js";
473
474
compileFile ( perftscJsPath , [ perftscPath ] , [ tscFile , perftscPath , "tests/perfsys.ts" ] . concat ( libraryTargets ) , [ ] , true ) ;
474
475
desc ( "Builds augmented version of the compiler for perf tests" ) ;
475
476
task ( "perftsc" , [ perftscJsPath ] ) ;
477
+
478
+ // Instrumented compiler
479
+ var loggedIOpath = harnessDirectory + 'loggedIO.ts' ;
480
+ var loggedIOJsPath = builtLocalDirectory + 'loggedIO.js' ;
481
+ file ( loggedIOJsPath , [ builtLocalDirectory ] , function ( ) {
482
+ var temp = builtLocalDirectory + 'temp' ;
483
+ jake . mkdirP ( temp ) ;
484
+ var options = "--outdir " + temp + ' ' + loggedIOpath ;
485
+ var cmd = host + " " + LKGDirectory + compilerFilename + " " + options + " " ;
486
+ console . log ( cmd + "\n" ) ;
487
+ var ex = jake . createExec ( [ cmd ] ) ;
488
+ ex . addListener ( "cmdEnd" , function ( ) {
489
+ fs . renameSync ( temp + '/harness/loggedIO.js' , loggedIOJsPath ) ;
490
+ jake . rmRf ( temp ) ;
491
+ } ) ;
492
+ ex . run ( ) ;
493
+ } , { async : true } ) ;
494
+
495
+ var instrumenterPath = harnessDirectory + 'instrumenter.ts' ;
496
+ var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js' ;
497
+ compileFile ( instrumenterJsPath , [ instrumenterPath ] , [ tscFile , instrumenterPath ] , [ ] , true ) ;
498
+
499
+ desc ( "Builds an instrumented tsc.js" ) ;
500
+ task ( 'tsc-instrumented' , [ loggedIOJsPath , instrumenterJsPath , tscFile ] , function ( ) {
501
+ var cmd = host + ' ' + instrumenterJsPath + ' record iocapture ' + builtLocalDirectory + compilerFilename ;
502
+ console . log ( cmd ) ;
503
+ var ex = jake . createExec ( [ cmd ] ) ;
504
+ ex . addListener ( "error" , function ( e ) {
505
+ console . log ( 'error running instrumenter' ) ;
506
+ console . log ( e ) ;
507
+ } ) ;
508
+ ex . run ( ) ;
509
+ } , { async : true } ) ;
0 commit comments