make BMK do preprocessing via GCC

BlitzMax Forums/BlitzMax Module Tweaks/make BMK do preprocessing via GCC

grable(Posted 2006) [#1]
I made a small adition to the BMK utility, to preprocess *.bmx files using GCC.

Just replace the function CompileBMX() in bmk_util.bmx
with this:

Function CompileBMX( src$,obj$,opts$ )
	DeleteFile obj	
	
?MacOs
	Local azm$=StripExt(obj)+".s"
	Local cmd$=CQuote(BlitzMaxPath()+"/bin/bcc")+opts+" -o "+CQuote(azm)+" "+CQuote(src)
?Win32
	Local azm$ = StripExt(obj) + ".s"
	Local cmd$ = CQuote(BlitzMaxPath() + "/bin/bcc.exe") + opts + " -o " + CQuote(azm) + " " + CQuote(src)	
?Linux	
	Local azm$=StripExt(obj)+".s"
	Local cmd$=CQuote(BlitzMaxPath()+"/bin/bcc")+opts+" -o "+CQuote(azm)+" "+CQuote(src)
?

	If opt_preprocess Then
		Local ppc:String = StripExt(src) + ".ppc"
		RenameFile( src, ppc)
		If Sys( "cpp -E -P -C " + CQuote(ppc) + " -O " + CQuote(src)) Then
			DeleteFile( src)
			RenameFile( ppc,src)
			Throw "Build Error: failed to preprocess " + src
		EndIf
		If Sys( cmd ) Then
			DeleteFile( src)
			RenameFile( ppc,src)
			Throw "Build Error: failed to compile " + src
		Else
			DeleteFile( src)
			RenameFile( ppc,src)
		EndIf		
	Else
		If Sys( cmd ) Then Throw "Build Error: failed to compile " + src
	EndIf

	Assemble azm,obj

End Function

and add a this to bmk_config.bmx somewhere
Global opt_preprocess = False '(or True if you want it on by default)

and this must be added to the Select statement inside the function ParseConfigArgs() allso in bmk_config.bmx
   Case "c"  opt_preprocess = True

compile bmk.bmx and replace the executable in the /bin dir and your set =)


grable(Posted 2006) [#2]
Btw, since its just calling on GCC's preprocessor, it uses C rules for parsing so there may be bad output from this.

Since labels allso use # as a starting char you wont be able to use them with preprocessing :/

Yes im to lazy to make my own bmax preprocessor ;)