From a88c0e2e81d8b0e5b6584dfb6573cd1a892bd254 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 29 Nov 2009 21:53:06 +0000 Subject: [PATCH] 2009-11-29 22:51 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg + Added -xhp= option which will attempt to read xMate project file and save it as .hbp file. This is experimental and I'd like to ask xMate users to update/extend this converter code as I'm not xMate user. Moreover the only .xhp file sample I have is pretty slim, limited, so it may easily be possible that some features are not imported or imported wrongly. --- harbour/ChangeLog | 10 ++++ harbour/utils/hbmk2/hbmk2.prg | 97 +++++++++++++++++++++++++++++++++-- 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cbbfe46cc2..6d1ab7188a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,16 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-11-29 22:51 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * utils/hbmk2/hbmk2.prg + + Added -xhp= option which will attempt to + read xMate project file and save it as .hbp file. + This is experimental and I'd like to ask xMate users to + update/extend this converter code as I'm not xMate user. + Moreover the only .xhp file sample I have is pretty slim, + limited, so it may easily be possible that some features + are not imported or imported wrongly. + 2009-11-29 22:07 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg + Added -xbp= option which will attempt to diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index fabebd1714..cc5b93fbbe 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -832,6 +832,11 @@ FUNCTION hbmk( aArgs, /* @ */ lPause ) convert_xbp_to_hbp( SubStr( cParam, 6 ) ) RETURN 0 + CASE Left( cParamL, 5 ) == "-xhp=" + + convert_xhp_to_hbp( SubStr( cParam, 6 ) ) + RETURN 0 + CASE cParamL == "--version" ShowHeader( hbmk ) @@ -7514,7 +7519,7 @@ STATIC PROCEDURE convert_xbp_to_hbp( cSrcName, cDstName ) LOCAL lGlobalSection := .T. - hbmk_OutStd( hb_StrFormat( I_( "Loading xbp project file: %1$s" ), cSrcName ) ) + hbmk_OutStd( hb_StrFormat( I_( "Loading xbp (xbuild) project file: %1$s" ), cSrcName ) ) IF Empty( cDstName ) cDstName := FN_ExtSet( cSrcName, ".hbp" ) @@ -7562,7 +7567,7 @@ STATIC PROCEDURE convert_xbp_to_hbp( cSrcName, cDstName ) EXIT CASE "TARGETFOLDER" IF ! Empty( cValue ) - AAdd( aDst, "-o" + FN_DirGet( cValue ) ) + AAdd( aDst, "-o" + DirAddPathSep( cValue ) ) ENDIF EXIT CASE "LIBFOLDERS" @@ -7615,6 +7620,88 @@ STATIC PROCEDURE convert_xbp_to_hbp( cSrcName, cDstName ) hb_MemoWrit( cDstName, cDst ) + RETURN +STATIC PROCEDURE convert_xhp_to_hbp( cSrcName, cDstName ) + LOCAL cSrc := MemoRead( cSrcName ) + LOCAL cDst + LOCAL aDst := {} + LOCAL tmp + LOCAL cLine + LOCAL cSetting + LOCAL cValue + LOCAL aValue + + LOCAL cMAIN := NIL + + LOCAL lFileSection := .F. + + hbmk_OutStd( hb_StrFormat( I_( "Loading xhp (xMate) project file: %1$s" ), cSrcName ) ) + + cSrc := StrTran( cSrc, Chr( 13 ) + Chr( 10 ), Chr( 10 ) ) + cSrc := StrTran( cSrc, Chr( 9 ), Chr( 32 ) ) + + FOR EACH cLine IN hb_ATokens( cSrc, Chr( 10 ) ) + IF cLine == "[Files]" + lFileSection := .T. + ELSEIF lFileSection + tmp := At( "=", cLine ) + IF tmp > 0 + AAdd( aDst, StrTran( AllTrim( Left( cLine, tmp - 1 ) ), "%HOME%\" ) ) + ENDIF + ELSE + tmp := At( "=", cLine ) + IF tmp > 0 + cSetting := AllTrim( Left( cLine, tmp - 1 ) ) + cValue := AllTrim( SubStr( cLine, tmp + Len( "=" ) ) ) + aValue := hb_ATokens( cValue ) + IF ! Empty( cValue ) + SWITCH cSetting + CASE "Create Map/List File" + IF cValue == "Yes" + AAdd( aDst, "-map" ) + ENDIF + EXIT + CASE "Final Path" + IF ! Empty( cValue ) + AAdd( aDst, "-o" + DirAddPathSep( StrTran( cValue, "%HOME%\" ) ) ) + ENDIF + EXIT + CASE "Include" + FOR EACH tmp IN aValue + IF Left( tmp, 2 ) == "-I" + tmp := SubStr( tmp, 3 ) + ENDIF + AAdd( aDst, "-incpath=" + StrTran( StrTran( tmp, Chr( 34 ) ), "%HOME%\" ) ) + NEXT + EXIT + CASE "Define" + FOR EACH tmp IN aValue + IF Left( tmp, 2 ) == "-D" + tmp := SubStr( tmp, 3 ) + ENDIF + AAdd( aDst, "-D" + tmp ) + NEXT + EXIT + CASE "Params" + FOR EACH tmp IN aValue + AAdd( aDst, "-runflag=" + tmp ) + NEXT + EXIT + ENDSWITCH + ENDIF + ENDIF + ENDIF + NEXT + + cDst := "" + FOR EACH tmp IN aDst + cDst += tmp + hb_osNewLine() + NEXT + + hbmk_OutStd( hb_StrFormat( I_( "Saving as .hbp file: %1$s" ), cDstName ) ) + + hb_MemoWrit( cDstName, cDst ) + RETURN STATIC PROCEDURE GetUILangCDP( /* @ */ cLNG, /* @ */ cCDP ) @@ -7778,12 +7865,14 @@ STATIC PROCEDURE ShowHelp( lLong ) { "-hb10" , I_( "enable Harbour 1.0.x compatibility mode (experimental)" ) },; { "-xhb" , I_( "enable xhb mode (experimental)" ) },; { "-hbc" , I_( "enable pure C mode (experimental)" ) },; - { "-hbmake=" , I_( "convert hbmake project file to .hbp file (experimental)" ) },; - { "-xbp=" , I_( "convert .xbp project file to .hbp file (experimental)" ) },; { "-rtlink" , "" },; { "-blinker" , "" },; { "-exospace" , I_( "emulate Clipper compatible linker behavior\ncreate link/copy hbmk2 to rtlink/blinker/exospace for the same effect" ) },; NIL,; + { "-hbmake=" , I_( "convert hbmake project file to .hbp file (experimental)" ) },; + { "-xbp=" , I_( "convert .xbp (xbuild) project file to .hbp file (experimental)" ) },; + { "-xhp=" , I_( "convert .xhp (xMate) project file to .hbp file (experimental)" ) },; + NIL,; { "--hbdirbin" , I_( "output Harbour binary directory" ) },; { "--hbdirdyn" , I_( "output Harbour dynamic library directory" ) },; { "--hbdirlib" , I_( "output Harbour static library directory" ) },;