11// This file contains the build logic for the public repo
22
33var fs = require ( "fs" ) ;
4+ var os = require ( "os" ) ;
45var path = require ( "path" ) ;
56var child_process = require ( "child_process" ) ;
67
@@ -148,7 +149,7 @@ var compilerFilename = "tsc.js";
148149 * @param useBuiltCompiler: true to use the built compiler, false to use the LKG
149150 * @param noOutFile: true to compile without using --out
150151 */
151- function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , noOutFile , generateDeclarations ) {
152+ function compileFile ( outFile , sources , prereqs , prefixes , useBuiltCompiler , noOutFile , generateDeclarations , callback ) {
152153 file ( outFile , prereqs , function ( ) {
153154 var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory ;
154155 var options = "-removeComments --module commonjs -noImplicitAny " ;
@@ -180,6 +181,11 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
180181 prependFile ( prefixes [ i ] , outFile ) ;
181182 }
182183 }
184+
185+ if ( callback ) {
186+ callback ( ) ;
187+ }
188+
183189 complete ( ) ;
184190 } ) ;
185191 ex . addListener ( "error" , function ( ) {
@@ -224,7 +230,7 @@ compileFile(processDiagnosticMessagesJs,
224230 [ processDiagnosticMessagesTs ] ,
225231 [ processDiagnosticMessagesTs ] ,
226232 [ ] ,
227- false ) ;
233+ /*useBuiltCompiler*/ false ) ;
228234
229235// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task
230236file ( diagnosticInfoMapTs , [ processDiagnosticMessagesJs , diagnosticMessagesJson ] , function ( ) {
@@ -244,7 +250,6 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson],
244250 ex . run ( ) ;
245251} , { async : true } )
246252
247-
248253desc ( "Generates a diagnostic file in TypeScript based on an input JSON file" ) ;
249254task ( "generate-diagnostics" , [ diagnosticInfoMapTs ] )
250255
@@ -255,13 +260,24 @@ compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(co
255260
256261var servicesFile = path . join ( builtLocalDirectory , "typescriptServices.js" ) ;
257262var servicesDefinitionsFile = path . join ( builtLocalDirectory , "typescriptServices.d.ts" ) ;
258- compileFile ( servicesFile , servicesSources , [ builtLocalDirectory , copyright ] . concat ( servicesSources ) , [ copyright ] , /*useBuiltCompiler:*/ true , /*noOutFile:*/ false , /*generateDeclarations:*/ true ) ;
263+
264+ compileFile ( servicesFile ,
265+ servicesSources ,
266+ [ builtLocalDirectory , copyright ] . concat ( servicesSources ) ,
267+ [ copyright ] ,
268+ /*useBuiltCompiler*/ true ,
269+ /*noOutFile*/ false ,
270+ /*generateDeclarations*/ true ,
271+ /*callback*/ fixDeclarationFile ) ;
272+
273+ function fixDeclarationFile ( ) {
274+ fs . appendFileSync ( servicesDefinitionsFile , os . EOL + "export = ts;" )
275+ }
259276
260277// Local target to build the compiler and services
261278desc ( "Builds the full compiler and services" ) ;
262279task ( "local" , [ "generate-diagnostics" , "lib" , tscFile , servicesFile ] ) ;
263280
264-
265281// Local target to build the compiler and services
266282desc ( "Sets release mode flag" ) ;
267283task ( "release" , function ( ) {
@@ -278,7 +294,6 @@ task("clean", function() {
278294 jake . rmRf ( builtDirectory ) ;
279295} ) ;
280296
281-
282297// Generate Markdown spec
283298var word2mdJs = path . join ( scriptsDirectory , "word2md.js" ) ;
284299var word2mdTs = path . join ( scriptsDirectory , "word2md.ts" ) ;
@@ -292,7 +307,7 @@ compileFile(word2mdJs,
292307 [ word2mdTs ] ,
293308 [ word2mdTs ] ,
294309 [ ] ,
295- false ) ;
310+ /*useBuiltCompiler*/ false ) ;
296311
297312// The generated spec.md; built for the 'generate-spec' task
298313file ( specMd , [ word2mdJs , specWord ] , function ( ) {
@@ -444,7 +459,7 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
444459// Browser tests
445460var nodeServerOutFile = 'tests/webTestServer.js'
446461var nodeServerInFile = 'tests/webTestServer.ts'
447- compileFile ( nodeServerOutFile , [ nodeServerInFile ] , [ builtLocalDirectory , tscFile ] , [ ] , true , true ) ;
462+ compileFile ( nodeServerOutFile , [ nodeServerInFile ] , [ builtLocalDirectory , tscFile ] , [ ] , /*useBuiltCompiler:*/ true , /*noOutFile*/ true ) ;
448463
449464desc ( "Runs browserify on run.js to produce a file suitable for running tests in the browser" ) ;
450465task ( "browserify" , [ "tests" , builtLocalDirectory , nodeServerOutFile ] , function ( ) {
@@ -525,7 +540,7 @@ task("baseline-accept-test262", function() {
525540// Webhost
526541var webhostPath = "tests/webhost/webtsc.ts" ;
527542var webhostJsPath = "tests/webhost/webtsc.js" ;
528- compileFile ( webhostJsPath , [ webhostPath ] , [ tscFile , webhostPath ] . concat ( libraryTargets ) , [ ] , true ) ;
543+ compileFile ( webhostJsPath , [ webhostPath ] , [ tscFile , webhostPath ] . concat ( libraryTargets ) , [ ] , /*useBuiltCompiler*/ true ) ;
529544
530545desc ( "Builds the tsc web host" ) ;
531546task ( "webhost" , [ webhostJsPath ] , function ( ) {
@@ -535,7 +550,7 @@ task("webhost", [webhostJsPath], function() {
535550// Perf compiler
536551var perftscPath = "tests/perftsc.ts" ;
537552var perftscJsPath = "built/local/perftsc.js" ;
538- compileFile ( perftscJsPath , [ perftscPath ] , [ tscFile , perftscPath , "tests/perfsys.ts" ] . concat ( libraryTargets ) , [ ] , true ) ;
553+ compileFile ( perftscJsPath , [ perftscPath ] , [ tscFile , perftscPath , "tests/perfsys.ts" ] . concat ( libraryTargets ) , [ ] , /*useBuiltCompiler*/ true ) ;
539554desc ( "Builds augmented version of the compiler for perf tests" ) ;
540555task ( "perftsc" , [ perftscJsPath ] ) ;
541556
@@ -559,7 +574,7 @@ file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() {
559574
560575var instrumenterPath = harnessDirectory + 'instrumenter.ts' ;
561576var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js' ;
562- compileFile ( instrumenterJsPath , [ instrumenterPath ] , [ tscFile , instrumenterPath ] , [ ] , true ) ;
577+ compileFile ( instrumenterJsPath , [ instrumenterPath ] , [ tscFile , instrumenterPath ] , [ ] , /*useBuiltCompiler*/ true ) ;
563578
564579desc ( "Builds an instrumented tsc.js" ) ;
565580task ( 'tsc-instrumented' , [ loggedIOJsPath , instrumenterJsPath , tscFile ] , function ( ) {
0 commit comments