07 Ago 2019 13:38
/*
BUILD - PRE-COMPILACAO
José Quintas
*/
REQUEST errorsys
#include "directry.ch"
FUNCTION Main( ... )
LOCAL aParams
SetMode( 38, 132 )
aParams := hb_AParams()
CheckPath()
checkHbmkHbc()
CheckGetEnv()
CheckBuild()
WriteBat( aParams )
Inkey(2)
RETURN NIL
STATIC FUNCTION WriteBat( aParams )
LOCAL oElement, cPath, cCmd := "", cBatFile := "d:\tools\util\c.bat"
cPath := Upper( hb_cwd() )
DO CASE
CASE "\HMGE\" $ cPath ; AAdd( aParams, "hmge.hbc" )
CASE "\HMG3\" $ cPath ; AAdd( aParams, "hmg3.hbc" )
CASE "\OOHG" $ cPath ; AAdd( aParams, "oohg.hbc" )
CASE "\HWGUI\" $ cPath ; AAdd( aParams, "hwgui.hbc" )
ENDCASE
IF Len( aParams ) != 0 .AND. aParams[ 1 ] == "/cmd"
hb_ADel( aParams, 1, .T. )
ELSEIF Len( Directory( "*.hbp" ) ) != 0
AAdd( aParams, "*.hbp" )
ELSEIF Len( Directory( "*.prg" ) ) != 0
Aadd( aParams, "*.prg" )
AAdd( aParams, "*.rc" )
ELSE
? hb_cwd()
Inkey(0)
ENDIF
AAdd( aParams, "-workdir=c:\temp" )
//AAdd( aParams, "-quiet" )
AAdd( aParams, "-q" )
AAdd( aParams, "-I" + hb_FNameDir( hb_ProgName() ) )
cCmd += "HBMK2 "
FOR EACH oElement IN aParams
cCmd += oElement + " "
NEXT
cCmd := hb_ProgName() + " %*" + hb_Eol() + cCmd + hb_Eol()
DO CASE
CASE "\SJPA\" $ cPath .AND. File( "..\sjpa.exe" ); cCmd += "assina ..\sjpa.exe" + hb_Eol()
CASE "\HAROLDO\" $ cPath .AND. File( "hl.exe" ); cCmd += "assina hl.exe" + hb_Eol()
CASE "\LABOROIL\" $ cPath .AND. File( "nfe.exe" ); cCmd += "assina nfe.exe" + hb_Eol()
CASE "\BUILD\" $ cPath .AND. File( "build.exe" ); cCmd += "assina build.exe" + hb_Eol()
CASE "\INTEGRA\" $ cPath .AND. File( "jpa.exe" ); cCmd += "assina jpa.exe" + hb_Eol()
ENDCASE
? "Atualizando " + cBatFile
hb_MemoWrit( cBatFile, cCmd )
RETURN NIL
STATIC FUNCTION CheckHbmkHbc()
LOCAL lUpdate := .F., cParam, cTxt := "", cFileHbmk, cPath
LOCAL aParams := { ;
"mt=yes", ;
"gui=yes", ;
"strip=yes", ;
"compr=yes", ;
"libpaths=d:/cdrom/fontes/integra/sefazclass", ;
"libpaths=d:/cdrom/fontes/integra/josequintas", ;
"libpaths=d:/cdrom/fontes/integra/josequintas/bostaurus", ;
"libpaths=d:/github/allgui/hmg3", ;
"libpaths=d:/github/allgui/hmge", ;
"libpaths=d:/github/allgui/hwgui", ;
"libpaths=d:/github/allgui/oohg", ;
"CFLAGS=-Wno-implicit-fallthrough -Wno-cast-function-type -Wno-misleading-indentation", ;
"PRGFLAGS=-m -n -w3 -es2 -ge1" }
cPath := CheckFileOnPath( "hbmk2.exe" )
IF Empty( cPath )
? "hbmk2.exe not found on path to check hbmk.hbc"
RETURN NIL
ENDIF
IF Right( cPath, 1 ) != "\"
cPath += "\"
ENDIF
cFileHbmk := cPath + "hbmk.hbc"
IF File( cFileHbmk )
cTxt := MemoRead( cFileHbmk )
IF Right( cTxt, 2 ) != hb_Eol()
cTxt += hb_Eol()
ENDIF
ENDIF
IF "xharbour" $ Lower( cPath )
AAdd( aParams, "-xhb" )
ENDIF
FOR EACH cParam IN aParams
IF ! cParam $ cTxt
cTxt += cParam + hb_Eol()
lUpdate := .T.
ENDIF
NEXT
IF lUpdate
hb_MemoWrit( cFileHbmk, cTxt )
ENDIF
RETURN NIL
STATIC FUNCTION CheckGetEnv()
LOCAL oElement
LOCAL aList := { ;
{ "HB_BUILD_DYN", "no" }, ;
{ "HB_BUILD_CONTRIB_DYN", "no" }, ;
{ "HB_BUILD_STRIP", "all" }, ;
{ "HB_COMPILER", "mingw" }, ;
{ "HB_INSTALL_PREFIX", "" } }
FOR EACH oElement IN aList
IF GetEnv( oElement[ 1 ] ) != oElement[ 2 ] .OR. Empty( GetEnv( oElement[ 1 ] ) )
? "Not found SET " + oElement[ 1 ] + "=" + oElement[ 2 ]
ENDIF
NEXT
RETURN NIL
STATIC FUNCTION CheckPath()
LOCAL cFile
FOR EACH cFile IN { "hbmk2.exe", "gcc.exe", "harbour.exe", "upx.exe", "c.bat" }
IF Empty( CheckFileOnPath( cFile ) )
? cFile + " not in PATH"
ENDIF
NEXT
RETURN NIL
STATIC FUNCTION CheckFileOnPath( cFile )
LOCAL cPath, cPathFile
cFile := Lower( cFile )
FOR EACH cPath IN hb_RegExSplit( ";", GetEnv( "PATH" ) )
IF Right( cPath, 1 ) != "\"
cPath := cPath + "\"
ENDIF
IF File( cPath + cFile )
cPathFile := cPath
EXIT
ENDIF
NEXT
RETURN cPathFile
STATIC FUNCTION CheckBuild()
LOCAL cDateTime, cTxt, nBuildNum, cFileName, cLastPath
cFileName := hb_FNameDir( hb_ProgName() ) + hb_FNameName( hb_ProgName() )
cDateTime := Dtos( Date() ) + Substr( Time(), 1, 2 ) + Substr( Time(), 4, 2 )
cTxt := MemoRead( cFileName + ".xml" )
nBuildNum := Val( XmlNode( cTxt, "BuildNum" ) ) + 1
cLastPath := XmlNode( cTxt, "LastPath" )
IF ! Upper( cLastPath ) == Upper( hb_cwd() )
DeleteContent( "c:\temp", .F. )
// DeleteContent( "c:\users\joseq\appdata\local\temp", .F. )
ENDIF
cTxt := "#define JOSEQUINTAS_VERSAO " + ["] + Transform( cDateTime, "@R 9999.99.99.9999" ) + ["] + hb_Eol()
cTxt += "#define JOSEQUINTAS_VERSAO_RC " + Transform( cDateTime, "@R 9999,99,99,9999" ) + hb_Eol()
hb_MemoWrit( cFileName + ".ch", cTxt )
IF File( "build.ch" ) // BHP ou projeto extra
hb_MemoWrit( "build.ch", cTxt )
ENDIF
cTxt := XmlTag( "BuildNum", nBuildNum, 0 ) + hb_Eol()
cTxt += XmlTag( "LastPath", hb_cwd() ) + hb_Eol()
cTxt += XmlTag( "BuildDate", Dtos( Date() ) ) + hb_Eol()
cTxt += XmlTag( "BuildTime", Time() ) + hb_Eol()
hb_MemoWrit( cFileName + ".xml", cTxt )
? "Build atual " + cDateTime
RETURN NIL
STATIC FUNCTION DeleteContent( cFolder, lDeleteFolder )
LOCAL oFiles, oFile, lDelete
hb_Default( @lDeleteFolder, .F. )
? "Delete on " + cFolder
oFiles := Directory( cFolder + "*.*" )
FOR EACH oFile IN oFiles
IF oFile[ F_ATTR ] == "D"
IF oFile[ F_NAME ] != "." .AND. oFile[ F_NAME ] != ".."
DeleteContent( cFolder + "\" + oFile[ F_NAME ], .T. )
ENDIF
ELSE
lDelete := .T.
DO CASE
CASE hb_FNameExt( oFile[ F_NAME ] ) == ".c"
CASE hb_FNameExt( oFile[ F_NAME ] ) == ".o"
CASE oFile[ F_DATE ] != Date()
CASE Left( oFile[ F_TIME ], 4 ) != Left( Time(), 4 )
OTHERWISE
lDelete := .F.
ENDCASE
IF lDelete
? "Deleting " + cFolder + "\" + oFile[ F_NAME ]
fErase( cFolder + "\" + oFile[ F_NAME ] )
ENDIF
ENDIF
NEXT
IF lDeleteFolder
DirRemove( cFolder )
ENDIF
RETURN NIL
FUNCTION HB_GT_SYS()
REQUEST HB_GT_WVG_DEFAULT
RETURN NIL
FUNCTION AppVersaoExe()
RETURN ""
---c.bat----
d:\cdrom\fontes\build\build.exe %*
07 Ago 2019 13:43
@echo off
echo.
d:
if "%1" == "f" cd \cdrom\fontes\integra\sefazclass
if "%1" == "gera" cd \cdrom\fontes\util\gerador
if "%1" == "h" cd \cdrom\fontes\haroldo
if "%1" == "hl" cd \cdrom\fontes\haroldo
if "%1" == "i" cd \cdrom\fontes\integra
if "%1" == "in" cd \cdrom\fontes\integra
if "%1" == "jpa" cd \cdrom\dados\sistemas
if "%1" == "j" cd \cdrom\fontes\integra\josequintas
if "%1" == "j50" cd \cdrom\fontes\util\j50
if "%1" == "js" cd \cdrom\fontes\integra\josequintas\source
if "%1" == "l" cd \cdrom\fontes\laboroil
if "%1" == "s" cd \cdrom\fontes\integra\sefazclass
if "%1" == "build" cd \cdrom\fontes\build
if "%1" == "a" cd \cvsfiles\allgui\allgui
if "%1" == "oohg" cd \cvsfiles\oohg
if "%1" == "hmg3" cd \cvsfiles\hmg3
if "%1" == "hmge" cd \cvsfiles\hmge
if "%1" == "hwgui" cd \cvsfiles\hwgui
if "%1" == "b" cd \cdrom\fontes\bhp\bhp
07 Ago 2019 13:48
@echo off
pushd .
if "%1" == "" goto :continue
if not exist %1 cd \cdrom\fontes\integra\sefazclass\source
if not exist %1 cd \cdrom\fontes\integra\josequintas\source
if not exist %1 cd \cdrom\fontes\integra\josequintas\prg
if not exist %1 cd \cdrom\fontes\integra\josequintas\main
if not exist %1 cd \cdrom\fontes\haroldo
if not exist %1 cd \cdrom\fontes\integra
:continue
start d:\tools\pnotepad\pn.exe %*
popd
07 Ago 2019 13:59
07 Ago 2019 18:19