@@ -4,19 +4,18 @@ import { sync as globSync } from 'glob';
44
55import { determineCdsCommand } from './src/cds' ;
66import { orchestrateCompilation } from './src/cds/compiler' ;
7- import { buildEnhancedCdsProjectDependencyGraph } from './src/cds/parser' ;
7+ import { buildCdsProjectDependencyGraph } from './src/cds/parser' ;
88import { runJavaScriptExtractor } from './src/codeql' ;
99import { addCompilationDiagnostic } from './src/diagnostics' ;
1010import { configureLgtmIndexFilters , setupAndValidateEnvironment } from './src/environment' ;
1111import {
1212 cdsExtractorLog ,
13- endPerformanceTracking ,
14- logExtractorStop ,
1513 logExtractorStart ,
16- logMemoryUsage ,
14+ logExtractorStop ,
1715 logPerformanceMilestone ,
16+ logPerformanceTrackingStart ,
17+ logPerformanceTrackingStop ,
1818 setSourceRootDirectory ,
19- startPerformanceTracking ,
2019} from './src/logging' ;
2120import { installDependencies } from './src/packageManager' ;
2221import { validateArguments } from './src/utils' ;
@@ -37,21 +36,19 @@ setSourceRootDirectory(sourceRoot);
3736
3837// Log the start of the CDS extractor session as a whole.
3938logExtractorStart ( sourceRoot ) ;
40- // We log the memory usage at the start of the extractor to track memory growth.
41- logMemoryUsage ( 'Extractor Start' ) ;
4239
4340// Setup the environment and validate all requirements first, before changing
4441// directory back to the "sourceRoot" directory. This ensures we can properly locate
4542// the CodeQL tools.
46- startPerformanceTracking ( 'Environment Setup' ) ;
43+ logPerformanceTrackingStart ( 'Environment Setup' ) ;
4744const {
4845 success : envSetupSuccess ,
4946 errorMessages,
5047 codeqlExePath,
5148 autobuildScriptPath,
5249 platformInfo,
5350} = setupAndValidateEnvironment ( sourceRoot ) ;
54- endPerformanceTracking ( 'Environment Setup' ) ;
51+ logPerformanceTrackingStop ( 'Environment Setup' ) ;
5552
5653if ( ! envSetupSuccess ) {
5754 const codeqlExe = platformInfo . isWindows ? 'codeql.exe' : 'codeql' ;
@@ -75,7 +72,7 @@ cdsExtractorLog(
7572 `CodeQL CDS extractor using autobuild mode for scan of project source root directory '${ sourceRoot } '.` ,
7673) ;
7774
78- cdsExtractorLog ( 'info' , 'Building enhanced CDS project dependency graph...' ) ;
75+ cdsExtractorLog ( 'info' , 'Building CDS project dependency graph...' ) ;
7976
8077// Build the CDS project `dependencyGraph` as the foundation for the extraction process.
8178// This graph will contain all discovered CDS projects, their dependencies, the `.cds`
@@ -88,22 +85,21 @@ cdsExtractorLog('info', 'Building enhanced CDS project dependency graph...');
8885let dependencyGraph ;
8986
9087try {
91- startPerformanceTracking ( 'Dependency Graph Build' ) ;
92- dependencyGraph = buildEnhancedCdsProjectDependencyGraph ( sourceRoot , __dirname ) ;
93- endPerformanceTracking ( 'Dependency Graph Build' ) ;
88+ logPerformanceTrackingStart ( 'Dependency Graph Build' ) ;
89+ dependencyGraph = buildCdsProjectDependencyGraph ( sourceRoot , __dirname ) ;
90+ logPerformanceTrackingStop ( 'Dependency Graph Build' ) ;
9491
9592 logPerformanceMilestone (
9693 'Dependency graph created' ,
9794 `${ dependencyGraph . projects . size } projects, ${ dependencyGraph . statusSummary . totalCdsFiles } CDS files` ,
9895 ) ;
99- logMemoryUsage ( 'After Dependency Graph' ) ;
10096
10197 // Log details about discovered projects for debugging
10298 if ( dependencyGraph . projects . size > 0 ) {
10399 for ( const [ projectDir , project ] of dependencyGraph . projects . entries ( ) ) {
104100 cdsExtractorLog (
105101 'info' ,
106- `Enhanced Project: ${ projectDir } , Status: ${ project . status } , CDS files: ${ project . cdsFiles . length } , Files to compile: ${ project . cdsFilesToCompile . length } ` ,
102+ `Project: ${ projectDir } , Status: ${ project . status } , CDS files: ${ project . cdsFiles . length } , Files to compile: ${ project . cdsFilesToCompile . length } ` ,
107103 ) ;
108104 }
109105 } else {
@@ -148,15 +144,15 @@ try {
148144 process . exit ( 1 ) ;
149145 }
150146} catch ( error ) {
151- cdsExtractorLog ( 'error' , `Failed to build enhanced dependency graph: ${ String ( error ) } ` ) ;
147+ cdsExtractorLog ( 'error' , `Failed to build CDS dependency graph: ${ String ( error ) } ` ) ;
152148 // Exit with error since we can't continue without a proper dependency graph
153149 logExtractorStop ( false , 'Terminated: Dependency graph build failed' ) ;
154150 process . exit ( 1 ) ;
155151}
156152
157- startPerformanceTracking ( 'Dependency Installation' ) ;
153+ logPerformanceTrackingStart ( 'Dependency Installation' ) ;
158154const projectCacheDirMap = installDependencies ( dependencyGraph , sourceRoot , codeqlExePath ) ;
159- endPerformanceTracking ( 'Dependency Installation' ) ;
155+ logPerformanceTrackingStop ( 'Dependency Installation' ) ;
160156
161157// Check if dependency installation resulted in any usable project mappings
162158if ( projectCacheDirMap . size === 0 ) {
@@ -184,7 +180,7 @@ if (projectCacheDirMap.size === 0) {
184180
185181const cdsFilePathsToProcess : string [ ] = [ ] ;
186182
187- // Use the enhanced dependency graph to collect all `.cds` files from each project.
183+ // Use the dependency graph to collect all `.cds` files from each project.
188184// We want to "extract" all `.cds` files from all projects so that we have a copy
189185// of each `.cds` source file in the CodeQL database.
190186for ( const project of dependencyGraph . projects . values ( ) ) {
@@ -193,13 +189,13 @@ for (const project of dependencyGraph.projects.values()) {
193189
194190// Initialize CDS command cache early to avoid repeated testing during compilation.
195191// This is a critical optimization that avoids testing commands for every single file.
196- startPerformanceTracking ( 'CDS Command Cache Initialization' ) ;
192+ logPerformanceTrackingStart ( 'CDS Command Cache Initialization' ) ;
197193try {
198194 determineCdsCommand ( undefined , sourceRoot ) ;
199- endPerformanceTracking ( 'CDS Command Cache Initialization' ) ;
195+ logPerformanceTrackingStop ( 'CDS Command Cache Initialization' ) ;
200196 cdsExtractorLog ( 'info' , 'CDS command cache initialized successfully' ) ;
201197} catch ( error ) {
202- endPerformanceTracking ( 'CDS Command Cache Initialization' ) ;
198+ logPerformanceTrackingStop ( 'CDS Command Cache Initialization' ) ;
203199 cdsExtractorLog ( 'warn' , `CDS command cache initialization failed: ${ String ( error ) } ` ) ;
204200}
205201
@@ -209,7 +205,7 @@ cdsExtractorLog(
209205 `Found ${ cdsFilePathsToProcess . length } total CDS files, ${ dependencyGraph . statusSummary . totalCdsFiles } CDS files in dependency graph` ,
210206) ;
211207
212- startPerformanceTracking ( 'CDS Compilation' ) ;
208+ logPerformanceTrackingStart ( 'CDS Compilation' ) ;
213209try {
214210 // Use the new orchestrated compilation approach (autobuild mode, no debug)
215211 orchestrateCompilation ( dependencyGraph , projectCacheDirMap , codeqlExePath ) ;
@@ -229,11 +225,10 @@ try {
229225 // Don't exit with error - let the JavaScript extractor run on whatever was compiled
230226 }
231227
232- endPerformanceTracking ( 'CDS Compilation' ) ;
228+ logPerformanceTrackingStop ( 'CDS Compilation' ) ;
233229 logPerformanceMilestone ( 'CDS compilation completed' ) ;
234- logMemoryUsage ( 'After CDS Compilation' ) ;
235230} catch ( error ) {
236- endPerformanceTracking ( 'CDS Compilation' ) ;
231+ logPerformanceTrackingStop ( 'CDS Compilation' ) ;
237232 cdsExtractorLog ( 'error' , `Compilation orchestration failed: ${ String ( error ) } ` ) ;
238233
239234 // Add diagnostic for the overall failure
@@ -251,9 +246,9 @@ configureLgtmIndexFilters();
251246
252247// Run CodeQL's JavaScript extractor to process the .cds source files and
253248// the compiled .cds.json files.
254- startPerformanceTracking ( 'JavaScript Extraction' ) ;
249+ logPerformanceTrackingStart ( 'JavaScript Extraction' ) ;
255250const extractorResult = runJavaScriptExtractor ( sourceRoot , autobuildScriptPath , codeqlExePath ) ;
256- endPerformanceTracking ( 'JavaScript Extraction' ) ;
251+ logPerformanceTrackingStop ( 'JavaScript Extraction' ) ;
257252
258253if ( ! extractorResult . success && extractorResult . error ) {
259254 cdsExtractorLog ( 'error' , `Error running JavaScript extractor: ${ extractorResult . error } ` ) ;
0 commit comments