aoineko-fr/MSXgl

Skipping already compiled files

Closed this issue · 2 comments

Hi,

I admire your great DOS batch file skills (seriously), but I managed to make an improvement, that makes SDCC skip files for which the compiled output is newer than the source file. This makes compiles instantaneous if only small changes were made, which helps me drink less coffee. Here is the relevant snippet:

rem ***************************************************************************
rem * COMPILE C SOURCE                                                        *
rem ***************************************************************************
if /I %FileExt%==.c (

	rem Find out if the source file changed:
	copy %File% %OutDir% /Y >NUL
	cd %OutDir%
	for /F %%i in ('dir /B /O:D %FileName%.c %FileName%.sym') do set Newest=%%i
	cd ..

	if /I !Newest! NEQ %FileName%.c ( 

		echo Skipping !FileName!.c: up-to-date.
		goto :SkipThisFile
	)

	set AddOpt=%CompileOpt%
	if /I %Optim%==Speed (set AddOpt=!AddOpt! --opt-code-speed)
	if /I %Optim%==Size (set AddOpt=!AddOpt! --opt-code-size)

	set SDCCParam=-c -mz80 --vc -DTARGET=TARGET_%Target% -DMSX_VERSION=MSX_%Machine% -I%ProjDir% -I%LibDir%\src -I%LibDir%\content !AddOpt! %File% -o %OutDir%\

	echo %BLUE%Compiling %1 using SDCC C compiler...%RESET%
	
	echo SDCC !SDCCParam!
	%Compiler% !SDCCParam!

        if errorlevel 1 ( goto :Error )

)

:SkipThisFile

Information from stackoverflow was used:
https://stackoverflow.com/questions/1687014/how-do-i-compare-timestamps-of-files-in-a-batch-script
https://stackoverflow.com/questions/14686330/how-do-i-make-a-windows-batch-script-completely-silent
because I don't know much about batch files. ;)

Greets,
Jacco.

Good tip.
I thought about this kind of optimization, but I don't know if it's a good idea to try to recreate the Makefile system in batch. ^^
I hesitate a lot, but I'm more inclined to rewrite the Build tool in python to make it more easily modifiable and functional on all OS.
In the meantime, I will integrate a date time check as you suggest.

I added an option in the Build Tool CompileSkip to skip compiling file if build data is newer than source
39194dc

There are many things that would be so much easier to do in Python... I'll look into it.