@@ -29,11 +29,6 @@ spawnChecked("git", ["config", "--global", "--add", "safe.directory", __dirname]
2929 stdio : "inherit" ,
3030} ) ;
3131
32- if ( currentPlatform ( ) == "macOS" ) {
33- // Make sure the main executable gets rebuilt with the new build ID.
34- spawnChecked ( "touch" , [ `${ __dirname } /chrome/app/chrome_exe_main_mac.cc` ] ) ;
35- }
36-
3732const archSuffix = buildArm ? "-arm" : "" ;
3833
3934if ( ! REPLAY_LOCAL_DRIVER_DIR ) {
@@ -97,7 +92,7 @@ const buildSuffix =
9792 : process . env [ "LOCAL_DEVELOPER_BUILD_EXTENSION" ] || "" ;
9893const buildId = `${ computeBuildId ( driverDate , driverRevision ) } ${ buildSuffix } ` ;
9994
100- fs . writeFileSync (
95+ writeFileSyncIfChanged (
10196 `${ __dirname } /base/record_replay_driver.cc` ,
10297 `
10398namespace recordreplay {
@@ -108,7 +103,7 @@ namespace recordreplay {
108103`
109104) ;
110105
111- fs . writeFileSync (
106+ const drived_h_changed = writeFileSyncIfChanged (
112107 `${ __dirname } /base/record_replay_driver.h` ,
113108 `
114109#ifndef BASE_RECORD_REPLAY_DRIVER_H_
@@ -120,6 +115,11 @@ fs.writeFileSync(
120115`
121116) ;
122117
118+ if ( currentPlatform ( ) == "macOS" && drived_h_changed ) {
119+ // Make sure the main executable gets rebuilt with the new build ID.
120+ spawnChecked ( "touch" , [ `${ __dirname } /chrome/app/chrome_exe_main_mac.cc` ] ) ;
121+ }
122+
123123// ensure that build configuration is written with correct paths
124124const gn = currentPlatform ( ) == "windows" ? "gn.bat" : "gn" ;
125125spawnChecked ( gn , [ "gen" , outdir ] , { stdio : "inherit" } ) ;
@@ -152,6 +152,24 @@ spawnChecked(
152152
153153console . log ( `Build finished.` ) ;
154154
155+ function writeFileSyncIfChanged ( filename , newContents ) {
156+ let changed = false ;
157+ try {
158+ const oldContents = fs . readFileSync ( filename , "utf8" ) ;
159+ changed = oldContents != newContents ;
160+ } catch ( e ) {
161+ changed = true ;
162+ }
163+
164+ if ( ! changed ) {
165+ console . log ( `Skipping ${ filename } because it hasn't changed.` ) ;
166+ } else {
167+ fs . writeFileSync ( filename , newContents ) ;
168+ }
169+
170+ return changed ;
171+ }
172+
155173function spawnChecked ( cmd , args , options ) {
156174 const prettyCmd = [ cmd ] . concat ( args ) . join ( " " ) ;
157175 console . error ( "$ " + prettyCmd ) ;
0 commit comments