Page 1 of 4

Interface visual para Harbour hbmk2.exe

PostPosted: Sun Mar 17, 2013 10:35 pm
by Antonio Linares
Harbour proporciona una potente utilidad make hbmk2.exe pero esta diseñada para ser usado desde una ventana de consola, por lo que pensé en proporcionarle un interface visual para que su uso sea aún mas sencillo :-)

Este es un primer prototipo, muy incompleto, pero tal vez quieras probarlo, dar ideas, etc. gracias

vhb.prg
Code: Select all  Expand view
#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function BuildWindow()

   local oDlg, oGet1, cPrgName := Space( 20 ), oSay3, oFld1, oSay2, oBtn1, oBtn2
   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 oSay2 PROMPT "Main PRG" SIZE  30, 9 PIXEL OF oDlg

   @ 25, 16 GET oGet1 VAR cPrgName SIZE 120, 12 PIXEL OF oDlg ;
      ACTION oGet1:VarPut( cGetFile( "*.prg" ) )

   @ 50,  16 SAY oSay3 PROMPT "Additional" SIZE 30, 9 PIXEL OF oDlg

   @ 60, 16 FOLDER oFld1 PROMPTS "PRGs", "OBJs", "LIBs" ;
      SIZE 200, 100 PIXEL OF oDlg

   @ 22, 230 BUTTON oBtn1 PROMPT "&Build" ;
      SIZE 60, 20 PIXEL OF oDlg ;
      ACTION ( MemoWrit( "go.bat", "set path=c:\bcc582\bin" + CRLF + ;
                                   "c:\harbour\bin\hbmk2 " + ;
                                   "-comp=bcc " + ;
                                   "-ic:\fwteam\include " + ;
                                   "-lfiveh.lib " + ;
                                   "-lfivehc.lib " + ;
                                   "-Lc:\fwteam\lib " + ;
                                   "-lc:\bcc582\lib\psdk\psapi.lib " + ;
                                   "xhb.hbc " + ;
                                   "-gtgui " + ;
                                   AllTrim( cPrgName ) ),;
               nRetCode := WaitRun( "go.bat > out.log", 0 ),;
               oResult:SetText( GetError( nRetCode ) + CRLF + MemoRead( "out.log" ) ),;
               WaitRun( cFileNoExt( cPrgName ) ),;
               hb_SetEnv( "path", cPath ) )

   @ 48, 230 BUTTON oBtn2 PROMPT "&Cancel" ;
      SIZE 60, 20 PIXEL OF oDlg ;
      ACTION oDlg:End()

   @ 170, 16 SAY oSay3 PROMPT "Result" SIZE 30, 9 PIXEL OF oDlg

   @ 180, 16 GET oResult VAR cResult MEMO ;
      SIZE 200, 60 PIXEL OF oDlg

   ACTIVATE DIALOG oDlg CENTERED

return oDlg

//----------------------------------------------------------------------------//

function GetError( nError )

   do case
      case nError == 0
           return "Ok"
   
      case nError == 2
           return "unknown compiler"
           
      case nError == 6
           return "failed in compilation (Harbour, C compiler, Resource compiler)"
         
      case nError == 7
           return "failed in final assembly (linker or library manager)"        
         
   endcase
   
return Str( nError )

//----------------------------------------------------------------------------//          

Image

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Mon Mar 18, 2013 12:28 am
by compubrion
Saludos !
Se puede usar tambien com el compilador Mingw ?

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Mon Mar 18, 2013 1:35 am
by Daniel Garcia-Gil
Hola

esa herramienta se puede usar con cualquier compilador de C soportado por harbour

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Mon Mar 18, 2013 9:06 am
by Antonio Linares
Versión mejorada con soporte de múltiples PRGs:

Image

vhb.prg
Code: Select all  Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"

static oBrwPrgs, aPrgs := { { "", "", "" } }

//----------------------------------------------------------------------------//

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" ) )

   @ 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 ( MemoWrit( "go.bat", "set path=c:\bcc582\bin" + CRLF + ;
                                   "c:\harbour\bin\hbmk2 " + ;
                                   "-comp=bcc " + ;
                                   "-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" ) ),;
               WaitRun( cFileNoExt( cPrgName ) ) )

   @ 48, 230 BUTTON oBtnCancel PROMPT "&Cancel" ;
      SIZE 60, 20 PIXEL OF oDlg ;
      ACTION oDlg:End()

   @ 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

//----------------------------------------------------------------------------//                    

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Mon Mar 18, 2013 9:47 am
by Antonio Linares
Comenzamos la implementación de configuración:

Image

vmh.prg
Code: Select all  Expand view
#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

//----------------------------------------------------------------------------//                      

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Mon Mar 18, 2013 10:12 am
by Antonio Linares

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Mon Mar 18, 2013 9:06 pm
by Antonio Linares

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Mon Mar 18, 2013 10:35 pm
by sysctrl2
Antonio y para xhb no funciona?

saludos.

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Mon Mar 18, 2013 10:46 pm
by Antonio Linares
César,

Si no me equivoco, xHarbour no proporciona la herramienta hbmk2.exe por lo que solo puedes usarlo con Harbour.

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Tue Mar 19, 2013 12:46 am
by sysctrl2
Gracias Antonio,

de donde puedo bajar el Harbour y aprovechar esta herramienta?

gracias.

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Tue Mar 19, 2013 1:18 am
by Daniel Garcia-Gil
Hola

para usarla debes usar harbour...

descarga el svn de harbour cuando construyas harbour esta se construye automaticamente tambien

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Tue Mar 19, 2013 3:17 am
by Antonio Linares
César,

Desde aqui puedes descargar las versiones más recientes de Harbour y xHarbour que nosotros vamos construyendo y usando:

https://code.google.com/p/harbour-and-xharbour-builds/downloads/list

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Tue Mar 19, 2013 8:58 am
by Antonio Linares

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Tue Mar 19, 2013 2:13 pm
by George
Antonio,
Gracias por haber iniciado el desarrollo de este utilitario.
De seguro sera beneficioso para todos los que usamos Harbour y FWH.

Por otro lado, estoy tratando de compilar el ejemplo samples\alert.prg pero consigo el siguiente mensaje:
Code: Select all  Expand view
failed in compilation (Harbour, C compiler, Resource compiler)
C:\_VisualMake>set path=c:\bcc582\bin
C:\_VisualMake>c:\harbour\bin\hbmk2.exe -comp=bcc -ic:\fwteam\include -lfiveh.lib -lfivehc.lib -Lc:\fwteam\lib -lc:\bcc582\lib\psdk\psapi.lib xhb.hbc -gtgui C:\fwh\samples\alert.prg  
Harbour 3.2.0dev (Rev. 18881)
Copyright (c) 1999-2013, http://harbour-project.org/
Compiling 'C:\fwh\samples\alert.prg'...
 

He revisado los paths y parecen estar correctos.
Si uso el archivo buildh.bat, que esta dentro del folder fwh\samples, el programa compila correctamente.

Existe alguna forma de conseguir mas informacion sobre el error generado en VisualMake?
Alguna sugerencia?

George

Re: Interface visual para Harbour hbmk2.exe

PostPosted: Tue Mar 19, 2013 2:44 pm
by Antonio Linares
George,

En el código fuente de vmh.prg cambia esto:

-ic:\fwteam\include

por:

-ic:\fwh\include

de ahi el error. Se nos pasó modificarlo