Skip to content

Commit 8e49fec

Browse files
committed
Move perform build to tsc instead of tsbuild
1 parent d2240a4 commit 8e49fec

File tree

2 files changed

+122
-122
lines changed

2 files changed

+122
-122
lines changed

src/compiler/tsbuild.ts

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -385,128 +385,6 @@ namespace ts {
385385
};
386386
}
387387

388-
const buildOpts: CommandLineOption[] = [
389-
{
390-
name: "verbose",
391-
shortName: "v",
392-
category: Diagnostics.Command_line_Options,
393-
description: Diagnostics.Enable_verbose_logging,
394-
type: "boolean"
395-
},
396-
{
397-
name: "dry",
398-
shortName: "d",
399-
category: Diagnostics.Command_line_Options,
400-
description: Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
401-
type: "boolean"
402-
},
403-
{
404-
name: "force",
405-
shortName: "f",
406-
category: Diagnostics.Command_line_Options,
407-
description: Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
408-
type: "boolean"
409-
},
410-
{
411-
name: "clean",
412-
category: Diagnostics.Command_line_Options,
413-
description: Diagnostics.Delete_the_outputs_of_all_projects,
414-
type: "boolean"
415-
},
416-
{
417-
name: "watch",
418-
category: Diagnostics.Command_line_Options,
419-
description: Diagnostics.Watch_input_files,
420-
type: "boolean"
421-
}
422-
];
423-
424-
export function performBuild(args: string[], compilerHost: CompilerHost, buildHost: BuildHost, system?: System): number | undefined {
425-
let verbose = false;
426-
let dry = false;
427-
let force = false;
428-
let clean = false;
429-
let watch = false;
430-
431-
const projects: string[] = [];
432-
for (const arg of args) {
433-
switch (arg.toLowerCase()) {
434-
case "-v":
435-
case "--verbose":
436-
verbose = true;
437-
continue;
438-
case "-d":
439-
case "--dry":
440-
dry = true;
441-
continue;
442-
case "-f":
443-
case "--force":
444-
force = true;
445-
continue;
446-
case "--clean":
447-
clean = true;
448-
continue;
449-
case "--watch":
450-
case "-w":
451-
watch = true;
452-
continue;
453-
454-
case "--?":
455-
case "-?":
456-
case "--help":
457-
printHelp(buildOpts, "--build ");
458-
return ExitStatus.Success;
459-
}
460-
// Not a flag, parse as filename
461-
addProject(arg);
462-
}
463-
464-
// Nonsensical combinations
465-
if (clean && force) {
466-
buildHost.error(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force");
467-
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
468-
}
469-
if (clean && verbose) {
470-
buildHost.error(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose");
471-
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
472-
}
473-
if (clean && watch) {
474-
buildHost.error(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch");
475-
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
476-
}
477-
if (watch && dry) {
478-
buildHost.error(Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry");
479-
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
480-
}
481-
482-
if (projects.length === 0) {
483-
// tsc -b invoked with no extra arguments; act as if invoked with "tsc -b ."
484-
addProject(".");
485-
}
486-
487-
const builder = createSolutionBuilder(compilerHost, buildHost, projects, { dry, force, verbose }, system);
488-
if (clean) {
489-
return builder.cleanAllProjects();
490-
}
491-
492-
if (watch) {
493-
builder.buildAllProjects();
494-
builder.startWatching();
495-
return undefined;
496-
}
497-
498-
return builder.buildAllProjects();
499-
500-
function addProject(projectSpecification: string) {
501-
const fileName = resolvePath(compilerHost.getCurrentDirectory(), projectSpecification);
502-
const refPath = resolveProjectReferencePath(compilerHost, { path: fileName });
503-
if (!compilerHost.fileExists(refPath)) {
504-
return buildHost.error(Diagnostics.File_0_does_not_exist, fileName);
505-
}
506-
projects.push(refPath);
507-
}
508-
}
509-
510388
/**
511389
* A SolutionBuilder has an immutable set of rootNames that are the "entry point" projects, but
512390
* can dynamically add/remove other projects based on changes on the rootNames' references

src/tsc/tsc.ts

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,128 @@ namespace ts {
172172
}
173173
}
174174

175+
const buildOpts: CommandLineOption[] = [
176+
{
177+
name: "verbose",
178+
shortName: "v",
179+
category: Diagnostics.Command_line_Options,
180+
description: Diagnostics.Enable_verbose_logging,
181+
type: "boolean"
182+
},
183+
{
184+
name: "dry",
185+
shortName: "d",
186+
category: Diagnostics.Command_line_Options,
187+
description: Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
188+
type: "boolean"
189+
},
190+
{
191+
name: "force",
192+
shortName: "f",
193+
category: Diagnostics.Command_line_Options,
194+
description: Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
195+
type: "boolean"
196+
},
197+
{
198+
name: "clean",
199+
category: Diagnostics.Command_line_Options,
200+
description: Diagnostics.Delete_the_outputs_of_all_projects,
201+
type: "boolean"
202+
},
203+
{
204+
name: "watch",
205+
category: Diagnostics.Command_line_Options,
206+
description: Diagnostics.Watch_input_files,
207+
type: "boolean"
208+
}
209+
];
210+
211+
function performBuild(args: string[], compilerHost: CompilerHost, buildHost: BuildHost, system?: System): number | undefined {
212+
let verbose = false;
213+
let dry = false;
214+
let force = false;
215+
let clean = false;
216+
let watch = false;
217+
218+
const projects: string[] = [];
219+
for (const arg of args) {
220+
switch (arg.toLowerCase()) {
221+
case "-v":
222+
case "--verbose":
223+
verbose = true;
224+
continue;
225+
case "-d":
226+
case "--dry":
227+
dry = true;
228+
continue;
229+
case "-f":
230+
case "--force":
231+
force = true;
232+
continue;
233+
case "--clean":
234+
clean = true;
235+
continue;
236+
case "--watch":
237+
case "-w":
238+
watch = true;
239+
continue;
240+
241+
case "--?":
242+
case "-?":
243+
case "--help":
244+
printHelp(buildOpts, "--build ");
245+
return ExitStatus.Success;
246+
}
247+
// Not a flag, parse as filename
248+
addProject(arg);
249+
}
250+
251+
// Nonsensical combinations
252+
if (clean && force) {
253+
buildHost.error(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force");
254+
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
255+
}
256+
if (clean && verbose) {
257+
buildHost.error(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose");
258+
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
259+
}
260+
if (clean && watch) {
261+
buildHost.error(Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch");
262+
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
263+
}
264+
if (watch && dry) {
265+
buildHost.error(Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry");
266+
return ExitStatus.DiagnosticsPresent_OutputsSkipped;
267+
}
268+
269+
if (projects.length === 0) {
270+
// tsc -b invoked with no extra arguments; act as if invoked with "tsc -b ."
271+
addProject(".");
272+
}
273+
274+
const builder = createSolutionBuilder(compilerHost, buildHost, projects, { dry, force, verbose }, system);
275+
if (clean) {
276+
return builder.cleanAllProjects();
277+
}
278+
279+
if (watch) {
280+
builder.buildAllProjects();
281+
builder.startWatching();
282+
return undefined;
283+
}
284+
285+
return builder.buildAllProjects();
286+
287+
function addProject(projectSpecification: string) {
288+
const fileName = resolvePath(compilerHost.getCurrentDirectory(), projectSpecification);
289+
const refPath = resolveProjectReferencePath(compilerHost, { path: fileName });
290+
if (!compilerHost.fileExists(refPath)) {
291+
return buildHost.error(Diagnostics.File_0_does_not_exist, fileName);
292+
}
293+
projects.push(refPath);
294+
}
295+
}
296+
175297
function performCompilation(rootNames: string[], projectReferences: ReadonlyArray<ProjectReference> | undefined, options: CompilerOptions, configFileParsingDiagnostics?: ReadonlyArray<Diagnostic>) {
176298
const host = createCompilerHost(options);
177299
enableStatistics(options);

0 commit comments

Comments
 (0)