#include "FiveWin.ch"
#include "xbrowse.ch"
static oBrwPrgs, aPrgs := { { "", "", "" } }
static cHbmkPath := "c:\harbour\bin\hbmk2.exe"
static cCCompiler := "Borland"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oGetName, cPrgName := Space( 20 ), oFldAdditional
local oBtnBuild, oBtnCancel
local cResult, oResult, cPath, nRetCode
SetDlgGradient( { { 1, RGB( 199, 216, 237 ), RGB( 237, 242, 248 ) } } )
DEFINE DIALOG oDlg TITLE "Visual make for Harbour" ;
SIZE 600, 500
@ 16, 16 SAY "Main PRG" SIZE 30, 9 PIXEL OF oDlg
@ 25, 16 GET oGetName VAR cPrgName SIZE 120, 12 PIXEL OF oDlg ;
ACTION oGetName:VarPut( cGetFile( "*.prg" ) ) ;
VALID If( Empty( cPrgName ), ( MsgAlert( "please select a PRG file" ), .F. ), .T. )
@ 50, 16 SAY "Additional" SIZE 30, 9 PIXEL OF oDlg
@ 60, 16 FOLDER oFldAdditional PROMPTS "PRGs", "OBJs", "LIBs" ;
SIZE 200, 100 PIXEL OF oDlg
BuildBrwPrgs( oFldAdditional )
@ 22, 230 BUTTON oBtnBuild PROMPT "&Build" ;
SIZE 60, 20 PIXEL OF oDlg ;
ACTION ( If( ! File( "c:\harbour\bin\hbmk2.exe" ), MsgAlert( "can't find hbmk2.exe" ),),;
MemoWrit( "go.bat", "set path=c:\bcc582\bin" + CRLF + ;
cHbmkPath + " " + ;
"-comp=" + If( cCCompiler == "Borland", "bcc", "" ) + ;
If( cCCompiler == "Microsoft", "msvc", "" ) + ;
If( cCCompiler == "MinGW", "mingw", "" ) + " " + ;
"-ic:\fwteam\include " + ;
"-lfiveh.lib " + ;
"-lfivehc.lib " + ;
"-Lc:\fwteam\lib " + ;
"-lc:\bcc582\lib\psdk\psapi.lib " + ;
"xhb.hbc " + ;
"-gtgui " + ;
AllTrim( cPrgName ) + ;
AToStr( aPrgs ) ),;
nRetCode := WaitRun( "go.bat > out.log", 0 ),;
oResult:SetText( GetError( nRetCode ) + CRLF + MemoRead( "out.log" ) ),;
If( nRetCode == 0, WaitRun( cFileNoExt( cPrgName ) ),) )
@ 48, 230 BUTTON oBtnCancel PROMPT "&Cancel" ;
SIZE 60, 20 PIXEL OF oDlg ;
ACTION oDlg:End() CANCEL
@ 74, 230 BUTTON "&Settings..." ;
SIZE 60, 20 PIXEL OF oDlg ;
ACTION ( Settings(), oGetName:SetFocus() ) CANCEL
@ 170, 16 SAY "Result" SIZE 30, 9 PIXEL OF oDlg
@ 180, 16 GET oResult VAR cResult MEMO ;
SIZE 200, 60 PIXEL OF oDlg
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT BuildFldButtons( oFldAdditional )
return oDlg
//----------------------------------------------------------------------------//
function GetError( nError )
do case
case nError == 0
return "Ok"
case nError == 1
return "unknown platform"
case nError == 2
return "unknown compiler"
case nError == 3
return "failed Harbour detection"
case nError == 5
return "failed stub creation"
case nError == 6
return "failed in compilation (Harbour, C compiler, Resource compiler)"
case nError == 7
return "failed in final assembly (linker or library manager)"
case nError == 8
return "unsupported"
case nError == 9
return "failed to create working directory"
case nError == 10
return "dependency missing or disabled"
case nError == 19
return "help"
case nError == 20
return "plugin initialization"
case nError == 30
return "too deep nesting"
case nError == 50
return "stop requested"
endcase
return Str( nError )
//----------------------------------------------------------------------------//
function BuildBrwPrgs( oFld )
@ 0, 0 XBROWSE oBrwPrgs ARRAY aPrgs SIZE 300, 180 PIXEL OF oFld:aDialogs[ 1 ]
// oBrwPrgs:SetFont( ::oFontBrw )
ADD TO oBrwPrgs HEADER "Name" DATA oBrwPrgs:aArrayData[ oBrwPrgs:nArrayAt ][ 1 ] SIZE 200
ADD TO oBrwPrgs HEADER "Size" DATA oBrwPrgs:aArrayData[ oBrwPrgs:nArrayAt ][ 2 ] SIZE 80
ADD TO oBrwPrgs HEADER "Date" DATA oBrwPrgs:aArrayData[ oBrwPrgs:nArrayAt ][ 3 ] SIZE 70
oBrwPrgs:nMarqueeStyle = MARQSTYLE_HIGHLROW
oBrwPrgs:nRowHeight = 17
oBrwPrgs:bClrSel = { || { CLR_WHITE, CLR_BLUE } }
oBrwPrgs:CreateFromCode()
oFld:aDialogs[ 1 ]:SetControl( oBrwPrgs )
return oBrwPrgs
//----------------------------------------------------------------------------//
function BuildFldButtons( oFld )
local cMask := { "*.prg", "*.obj", "*.lib" }[ oFld:nOption ]
local cTitle := "Please select a " + { "PRG", "OBJ", "LIB" }[ oFld:nOption ] + " file"
local oBtn, cFileName
@ 1, 350 BUTTON oBtn PROMPT "+" OF oFld SIZE 18, 18 PIXEL ;
ACTION ( cFileName := cGetFile( cMask, cTitle ),;
If( ! Empty( cFileName ),;
( If( aPrgs[ 1 ][ 1 ] == "", ASize( aPrgs, 0 ),),;
AAdd( aPrgs, { cFileName, Directory( cFileName )[ 1 ][ 2 ],;
Directory( cFileName )[ 1 ][ 3 ] } ),;
oFld:aDialogs[ 1 ]:aControls[ 1 ]:GoBottom(),;
oFld:aDialogs[ 1 ]:aControls[ 1 ]:SetFocus() ), ) )
oBtn:cTooltip = "Add"
@ 1, 372 BUTTON "--" OF oFld SIZE 18, 18 PIXEL
return nil
//----------------------------------------------------------------------------//
function AToStr( aFiles )
local cResult := ""
AEval( aFiles, { | aFile | cResult += " " + aFile[ 1 ] } )
return cResult
//----------------------------------------------------------------------------//
function Settings()
local oDlg, oHbmkPath, cMakePath := cHbmkPath
local cCompiler := cCCompiler
DEFINE DIALOG oDlg TITLE "Settings" SIZE 500, 400
@ 15, 16 SAY "hbmk2.exe path" OF oDlg SIZE 80, 10 PIXEL
@ 25, 16 GET oHbmkPath VAR cMakePath SIZE 120, 12 PIXEL OF oDlg ;
ACTION oHbmkPath:VarPut( cGetFile( cHbmkPath ) ) ;
VALID If( Empty( cHbmkPath ), ( MsgAlert( "please select hbmk2.exe path" ), .F. ), .T. )
@ 49, 16 SAY "C compiler" OF oDlg SIZE 80, 10 PIXEL
@ 59, 16 COMBOBOX oCbx VAR cCompiler ITEMS { "Borland", "Microsoft", "MinGW" } ;
OF oDlg SIZE 120, 100 PIXEL
@ 22, 180 BUTTON "&Save" ;
SIZE 60, 20 PIXEL OF oDlg ;
ACTION ( cHbmkPath := cMakePath, cCCompiler := cCompiler, oDlg:End() )
@ 48, 180 BUTTON "&Cancel" ;
SIZE 60, 20 PIXEL OF oDlg ;
ACTION oDlg:End() CANCEL
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------//