diff --git a/ChangeLog.txt b/ChangeLog.txt index ec1b33ee11..fe05929f80 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,17 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-03-31 04:46 UTC+0200 Viktor Szakats (harbour syenar.net) + * utils/hbmk2/_md_make.hb + * utils/hbmk2/_po_pull.hb + * utils/hbmk2/_po_push.hb + % much faster .md generation + + internals modified to ease moving the scripts to other dir + + better feedback + + * utils/hbmk2/hbmk2.prg + * formatting and minor + 2013-03-30 16:43 UTC+0100 Viktor Szakats (harbour syenar.net) * utils/hbmk2/hbmk2.prg * -> in help for better clarity diff --git a/utils/hbmk2/_md_make.hb b/utils/hbmk2/_md_make.hb index 6f8de65970..12595a91b7 100644 --- a/utils/hbmk2/_md_make.hb +++ b/utils/hbmk2/_md_make.hb @@ -14,25 +14,44 @@ PROCEDURE Main() + LOCAL cBase := hb_DirBase() + LOCAL file LOCAL cLang + LOCAL cTemp - FOR EACH file IN Directory( hb_DirBase() + hb_DirSepToOS( "po/*.po" ) ) + ? "preparing" + + FOR EACH file IN Directory( cBase + hb_DirSepToOS( "po/*.po" ) ) hb_run( hb_StrFormat( "hbi18n -q -g -o%1$s %2$s", ; - hb_DirBase() + hb_FNameName( file[ F_NAME ] ) + ".hbl", ; - hb_DirSepToOS( hb_DirBase() + "po/" + file[ F_NAME ] ) ) ) + cBase + hb_FNameName( file[ F_NAME ] ) + ".hbl", ; + cBase + hb_DirSepToOS( "po/" + file[ F_NAME ] ) ) ) NEXT - FOR EACH cLang IN hb_ATokens( "en," + hb_regexAll( "-lng=([a-zA-Z0-9_,]*)", hb_MemoRead( hb_DirBase() + "hbmk2.hbp" ),,,,, .T. )[ 1 ][ 2 ], "," ) - ? file := hb_DirSepToOS( hb_DirBase() + "doc/hbmk2." + cLang + ".md" ) - hb_run( hb_StrFormat( "hbrun %1$s -lang=%2$s -longhelpmd > %3$s", hb_DirBase() + "hbmk2.prg", cLang, file ) ) - hb_MemoWrit( file, StrTran( hb_MemoRead( file ), e"\n", hb_eol() ) ) + cTemp := cBase + "hbmk2.hrb" - ? file := hb_DirSepToOS( hb_DirBase() + "../../contrib/hbrun/doc/hbrun." + cLang + ".md" ) - hb_run( hb_StrFormat( "hbrun %1$s -lang=%2$s -longhelpmdsh > %3$s", hb_DirBase() + "hbmk2.prg", cLang, file ) ) - hb_MemoWrit( file, StrTran( hb_MemoRead( file ), e"\n", hb_eol() ) ) + hb_run( hb_StrFormat( "hbmk2 -hbraw -q0 -gh %1$s -o%2$s", cBase + "hbmk2.prg", cTemp ) ) + + ? "generating .md help:" + + FOR EACH cLang IN hb_ATokens( "en," + hb_regexAll( "-lng=([a-zA-Z0-9_,]*)", hb_MemoRead( cBase + "hbmk2.hbp" ),,,,, .T. )[ 1 ][ 2 ], "," ) + + ?? "", cLang + + file := cBase + hb_DirSepToOS( "doc/hbmk2." + cLang + ".md" ) + hb_run( hb_StrFormat( "hbrun %1$s -lang=%2$s -longhelpmd > %3$s", cTemp, cLang, file ) ) + FToNativeEOL( file ) + + file := cBase + hb_DirSepToOS( "../../contrib/hbrun/doc/hbrun." + cLang + ".md" ) + hb_run( hb_StrFormat( "hbrun %1$s -lang=%2$s -longhelpmdsh > %3$s", cTemp, cLang, file ) ) + FToNativeEOL( file ) NEXT - AEval( Directory( hb_DirBase() + "*.hbl" ), {| tmp | FErase( hb_DirBase() + tmp[ F_NAME ] ) } ) + FErase( cTemp ) + + AEval( Directory( cBase + "*.hbl" ), {| tmp | FErase( cBase + tmp[ F_NAME ] ) } ) RETURN + +STATIC FUNCTION FToNativeEOL( cFile ) + RETURN hb_MemoWrit( cFile, StrTran( hb_MemoRead( cFile ), e"\n", hb_eol() ) ) diff --git a/utils/hbmk2/_po_pull.hb b/utils/hbmk2/_po_pull.hb index eefb18b2b5..eed8255386 100644 --- a/utils/hbmk2/_po_pull.hb +++ b/utils/hbmk2/_po_pull.hb @@ -13,6 +13,8 @@ PROCEDURE Main( cLogin ) + LOCAL cBase := hb_DirBase() + LOCAL json LOCAL cLang LOCAL cTemp @@ -23,9 +25,11 @@ PROCEDURE Main( cLogin ) FClose( hb_FTempCreateEx( @cTemp ) ) - FOR EACH cLang IN hb_ATokens( hb_regexAll( "-lng=([a-zA-Z0-9_,]*)", hb_MemoRead( hb_DirBase() + "hbmk2.hbp" ),,,,, .T. )[ 1 ][ 2 ], "," ) + ? "pulling .po files:" - ? cLang + FOR EACH cLang IN hb_ATokens( hb_regexAll( "-lng=([a-zA-Z0-9_,]*)", hb_MemoRead( cBase + "hbmk2.hbp" ),,,,, .T. )[ 1 ][ 2 ], "," ) + + ?? "", cLang hb_run( hb_StrFormat( "curl -s -i -L --user %1$s -X " + ; "GET https://www.transifex.com/api/2/project/harbour/resource/hbmk2/translation/%2$s/ " + ; @@ -33,9 +37,9 @@ PROCEDURE Main( cLogin ) cLogin, cLang, cTemp ) ) IF hb_jsonDecode( GetJSON( hb_MemoRead( cTemp ) ), @json ) > 0 - hb_MemoWrit( hb_DirSepToOS( hb_DirBase() + "po/hbmk2." + cLang + ".po" ), StrTran( json[ "content" ], e"\n", hb_eol() ) ) + hb_MemoWrit( hb_DirSepToOS( cBase + "po/hbmk2." + cLang + ".po" ), StrTran( json[ "content" ], e"\n", hb_eol() ) ) ELSE - ? "error" + ? "API error" ENDIF NEXT diff --git a/utils/hbmk2/_po_push.hb b/utils/hbmk2/_po_push.hb index e838c3c976..b8b9b9da3b 100644 --- a/utils/hbmk2/_po_push.hb +++ b/utils/hbmk2/_po_push.hb @@ -13,7 +13,10 @@ PROCEDURE Main( cLogin ) - LOCAL cTemp + LOCAL cBase := hb_DirBase() + + LOCAL json + LOCAL cTemp, cTemp2 LOCAL cContent IF Empty( cLogin ) @@ -21,10 +24,11 @@ PROCEDURE Main( cLogin ) ENDIF FClose( hb_FTempCreateEx( @cTemp, , , ".pot" ) ) + FClose( hb_FTempCreateEx( @cTemp2 ) ) ? "generating pot" - hb_run( hb_StrFormat( "harbour -q0 %1$s -j%2$s -i%3$s -s", hb_DirBase() + "hbmk2.prg", cTemp, hb_DirSepToOS( hb_DirBase() + "../../include" )) ) + hb_run( hb_StrFormat( "harbour -q0 %1$s -j%2$s -i%3$s -s", cBase + "hbmk2.prg", cTemp, hb_DirSepToOS( cBase + "../../include" )) ) ? "saving locally" @@ -39,17 +43,33 @@ PROCEDURE Main( cLogin ) '"Content-Transfer-Encoding: 8bit\n"' + hb_eol() + hb_eol() + ; hb_MemoRead( cTemp ) - hb_MemoWrit( hb_DirSepToOS( hb_DirBase() + "po/hbmk2.en.po" ), cContent ) + hb_MemoWrit( hb_DirSepToOS( cBase + "po/hbmk2.en.po" ), cContent ) - ? "uploading" + ? "uploading", "size", Len( cContent ) + ? hb_MemoWrit( cTemp, hb_jsonEncode( { "content" => StrTran( cContent, hb_eol(), e"\n" ) } ) ) hb_run( hb_StrFormat( 'curl -s -i -L --user %1$s -X ' + ; 'PUT -d @%2$s -H "Content-Type: application/json" ' + ; - 'https://www.transifex.com/api/2/project/harbour/resource/hbmk2/content/', ; - cLogin, cTemp ) ) + 'https://www.transifex.com/api/2/project/harbour/resource/hbmk2/content/' + ; + ' -o %3$s', ; + cLogin, cTemp, cTemp2 ) ) + + IF hb_jsonDecode( GetJSON( hb_MemoRead( cTemp2 ) ), @json ) > 0 + ? hb_ValToExp( json ) + ELSE + ? "API error" + ENDIF FErase( cTemp ) + FErase( cTemp2 ) RETURN + +STATIC FUNCTION GetJSON( cString ) + + cString := SubStr( cString, At( "{", cString ) ) + cString := Left( cString, RAt( "}", cString ) ) + + RETURN cString diff --git a/utils/hbmk2/hbmk2.prg b/utils/hbmk2/hbmk2.prg index addf052910..cf2334552d 100644 --- a/utils/hbmk2/hbmk2.prg +++ b/utils/hbmk2/hbmk2.prg @@ -1548,7 +1548,7 @@ STATIC FUNCTION __hbmk( aArgs, nArgTarget, nLevel, /* @ */ lPause, /* @ */ lExit IF tmp > 40 hbmk[ _HBMK_nMaxCol ] := tmp ELSEIF tmp == 0 - hbmk[ _HBMK_nMaxCol ] := 65535 + hbmk[ _HBMK_nMaxCol ] := 32767 ENDIF CASE cParamL == "-hbrun" ; lSkipBuild := .T. ; hbmk[ _HBMK_lRUN ] := .T. @@ -13918,8 +13918,14 @@ STATIC PROCEDURE __hbshell( cFile, ... ) NEXT /* We can use this function as this is a GPL licenced application */ - cFile := hb_compileBuf( hbmk_CoreHeaderFiles(), hb_ProgName(), "-n2", "-w", "-es2", "-q0", ; - hb_ArrayToParams( aOPTPRG ), "-D" + _HBMK_SHELL, cFile ) + cFile := hb_compileBuf( ; + hbmk_CoreHeaderFiles(), ; + hb_ProgName(), ; + "-n2", "-w", "-es2", "-q0", ; + hb_ArrayToParams( aOPTPRG ), ; + "-D" + _HBMK_SHELL, ; + cFile ) + IF cFile == NIL ErrorLevel( _EXIT_COMPPRG ) EXIT