On Wed, 14 Oct 2009, [email protected] wrote:
Hi,
> 2009-10-14 13:43 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
> * utils/hbmk2/hbmk2.prg
> + Added 'gcc -MM' based C header dependency detection in -head=native
> mode.
> Please note that it's slower than regular methods, so for projects
> with many .c source files this setting may not be ideal.
Thank you very much.
-M* GCC switches were designed to use with static dependencies files
not to scan source code on each make call so the speed was less important
because dependencies list is created once at startup and then only rebuilt
if some files in the list is modified.
If you can add support for optional files with explicit dependencies then
it's possible to use this functionality in the same way with hbmk2 as with
GCC and GNU make, i.e. you can read .d files. They have format like:
<dstfile>: <srcfiles,...>
\ as last non blank character concatenates lines. To simplify the format
and resolve possible conflicts with '\' ad path separator in DOS/Windows
we can define that it has to follow blank (TAB or SPACE) character or is
the only one non blank character in the line.
Below I'm attaching code which creates hash array indexed by files with
array of dependent files so it's enough to check if given file is in
such array, i.e.:
if cFile $ hDeps
for each cDep in hDeps[ cFile ]
if hb_FGetDateTime( cDep, @tDepTime ) .and. tDepTime > tFileTime
lRebuild := .t.
exit
endif
next
endif
Can you add it?
best regards,
Przemek
static function deplst_read( cFileBody )
local cList := "", cLine
local nLine := 0
local hDeps := {=>}
cFileBody := StrTran( cFileBody, Chr( 13 ) + Chr( 10 ), Chr( 10 ) )
cFileBody := StrTran( cFileBody, Chr( 9 ), Chr( 32 ) )
for each cLine in hb_aTokens( cFileBody, Chr( 10 ) )
++nLine
cLine := AllTrim( cLine )
if cLine == "\" .or. right( cLine, 2 ) == " \"
cList += Left( cLine, Len( cLine ) - 1 )
else
cList += cLine
if !deplst_add( hDeps, cList )
? "error at line: ", nLine, cList
return nil
endif
cList := ""
endif
next
if !deplst_add( hDeps, cList )
? "error at line: ", nLine, cList
return nil
endif
return hDeps
static function deplst_add( hDeps, cList )
local cFile
local aList
local n
if !empty( cList )
n := At( ":", cList )
if n != 0 .and. !empty( cFile := AllTrim( Left( cList, n - 1 ) ) )
aList := hb_aTokens( SubStr( cList, n + 1 ) )
if cFile $ hDeps
AMerge( hDeps[ cFile ], aList )
else
hDeps[ cFile ] := aList
endif
else
return .f.
endif
endif
return .t.
static function AMerge( aDst, aSrc )
local item
for each item in aSrc
if hb_AScan( aDst, item,,, .T. ) == 0
AAdd( aDst, item )
endif
next
return aDst
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour