From acefc0332e5a2354bd19203823987be873a9c1ba Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 16 Apr 2009 14:08:11 +0000 Subject: [PATCH] 2009-04-16 16:01 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * utils/hbmk2/hbmk2.prg + Added support for wildcarded input files for Harbour, C, resource compiler and object input files. This also works in .hbm files. Note: You must specify the extension, so *.* won't work, but *.prg and *.c will. Use with care, as hbmk2 will pickup everything and this may not be what you want to do f.e. in our tests dirs, but it can be useful if you store source files belonging to the same project in one dir, or with some unique filename prefix. (some of these may be unnecessary on *nix platforms, where the shell does such expansion already, it's still useful though, as *nix users can also benefit from wildcard usage inside .hbm files) --- harbour/ChangeLog | 16 +++++++++ harbour/utils/hbmk2/hbmk2.prg | 68 +++++++++++++++++++++++++++-------- 2 files changed, 69 insertions(+), 15 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index decd327a86..8f9e027df9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,22 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-04-16 16:01 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * utils/hbmk2/hbmk2.prg + + Added support for wildcarded input files for Harbour, + C, resource compiler and object input files. + This also works in .hbm files. Note: You must specify + the extension, so *.* won't work, but *.prg and *.c will. + Use with care, as hbmk2 will pickup everything and this + may not be what you want to do f.e. in our tests dirs, + but it can be useful if you store source files belonging + to the same project in one dir, or with some unique + filename prefix. + (some of these may be unnecessary on *nix platforms, where + the shell does such expansion already, it's still useful + though, as *nix users can also benefit from wildcard usage + inside .hbm files) + 2009-04-16 15:47 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * utils/hbmk2/hbmk2.prg % Skipping duplicate headers while walking the inclusion tree. diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index f9cd8b70b2..b9da332fe3 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -1215,14 +1215,18 @@ PROCEDURE Main( ... ) CASE FN_ExtGet( cParamL ) == ".prg" - cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) - AAdd( s_aPRG , PathSepToTarget( cParam ) ) - DEFAULT s_cFIRST TO PathSepToSelf( cParam ) + FOR EACH cParam IN FN_Expand( cParam ) + cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) + AAdd( s_aPRG , PathSepToTarget( cParam ) ) + DEFAULT s_cFIRST TO PathSepToSelf( cParam ) + NEXT CASE FN_ExtGet( cParamL ) == ".rc" - cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) - AAdd( s_aRESSRC , PathSepToTarget( cParam ) ) + FOR EACH cParam IN FN_Expand( cParam ) + cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) + AAdd( s_aRESSRC , PathSepToTarget( cParam ) ) + NEXT CASE FN_ExtGet( cParamL ) == ".res" @@ -1230,11 +1234,15 @@ PROCEDURE Main( ... ) /* For MinGW family add .res files as source input, as they will need to be converted to coff format with windres (just like plain .rc files) before feeding them to gcc. */ - cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) - AAdd( s_aRESSRC , PathSepToTarget( cParam ) ) + FOR EACH cParam IN FN_Expand( cParam ) + cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) + AAdd( s_aRESSRC , PathSepToTarget( cParam ) ) + NEXT ELSE - cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) - AAdd( s_aRESCMP , PathSepToTarget( cParam ) ) + FOR EACH cParam IN FN_Expand( cParam ) + cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) + AAdd( s_aRESCMP , PathSepToTarget( cParam ) ) + NEXT ENDIF CASE FN_ExtGet( cParamL ) == ".a" @@ -1244,15 +1252,19 @@ PROCEDURE Main( ... ) CASE FN_ExtGet( cParamL ) $ ".o|.obj" - cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) - AAdd( s_aOBJUSER, PathSepToTarget( cParam ) ) - DEFAULT s_cFIRST TO PathSepToSelf( cParam ) + FOR EACH cParam IN FN_Expand( cParam ) + cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) + AAdd( s_aOBJUSER, PathSepToTarget( cParam ) ) + DEFAULT s_cFIRST TO PathSepToSelf( cParam ) + NEXT CASE FN_ExtGet( cParamL ) $ ".c|.cpp" - cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) - AAdd( s_aC , PathSepToTarget( cParam ) ) - DEFAULT s_cFIRST TO PathSepToSelf( cParam ) + FOR EACH cParam IN FN_Expand( cParam ) + cParam := PathProc( cParam, aParam[ _PAR_cFileName ] ) + AAdd( s_aC , PathSepToTarget( cParam ) ) + DEFAULT s_cFIRST TO PathSepToSelf( cParam ) + NEXT OTHERWISE @@ -3548,6 +3560,32 @@ STATIC FUNCTION FN_DirExtSet( cFileName, cDirNew, cExtNew ) RETURN hb_FNameMerge( cDir, cName, cExt ) +STATIC FUNCTION FN_Expand( cFileName ) + LOCAL aFileList + LOCAL aFile + LOCAL aDir + LOCAL cExt + + IF ! FN_HasWildcard( cFileName ) + RETURN { cFileName } + ENDIF + + aFileList := {} + + cExt := FN_ExtGet( cFileName ) + aDir := Directory( cFileName ) + FOR EACH aFile IN aDir + IF FN_ExtGet( aFile[ F_NAME ] ) == cExt /* Workaround to not find 'hello.prga' when looking for '*.prg' */ + AAdd( aFilelist, aFile[ F_NAME ] ) + ENDIF + NEXT + + RETURN aFileList + +STATIC FUNCTION FN_HasWildcard( cFileName ) + RETURN "?" $ cFileName .OR. ; + "*" $ cFileName + #define HBMK_CFG_NAME "hbmk.cfg" STATIC PROCEDURE HBP_ProcessAll( lConfigOnly,;