Build.bat

Source code related resources

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Build.bat

Post by Pablo César »

Dear Rathinagiri,

I do not know if anothers coleagues are having same dificulties with Build.bat at all HMG samples. Build.bat can be used at line command prompt passing the right first parameter which is always the main module to be compiled. But when we tried to use this Build.bat in any sub-folder of samples thru "Windows Explorer" by clicking with mouse, so we can not build the HMG example. But I have a suggestion to correct only on each Build.bat for all samples cases (not for main Build of HMG folder). See how we can avoid for missing parameter at simple Build.bat for samples. Normally we have in Build.bat like this:

Code: Select all

call ..\..\..\build.bat %*
The I propose to change for this one:

Code: Select all

@Echo off
if "%1"=="" Goto WithOutPar
SET MainFile=%1
Goto Continue
:WithOutPar
for /R %~dp0%~1 %%f in (*.hbp) do (Set MainFile="%%~nf")
Goto Continue
:Continue
call ..\..\..\build.bat %MainFile%
This is pure batch command from OS and will takes the last .hbp file as part of main file name. The only problem is you will need to re-edit all Build.bat at samples folder (..\hfcl\samples and ..\samples), but it beneficts are so great. What do you think ?

I believe I am not the only one which has this difficulties when click Build.bat of samples, is It good idea or not ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Build.bat

Post by Rathinagiri »

Ok. I will change it then.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Build.bat

Post by esgici »

Pablo César wrote:Dear Rathinagiri,

I do not know if anothers coleagues are having same dificulties with Build.bat at all HMG samples. Build.bat can be used at line command prompt passing the right first parameter which is always the main module to be compiled. But when we tried to use this Build.bat in any sub-folder of samples thru "Windows Explorer" by clicking with mouse, so we can not build the HMG example. But I have a suggestion to correct only on each Build.bat for all samples cases (not for main Build of HMG folder). See how we can avoid for missing parameter at simple Build.bat for samples. Normally we have in Build.bat like this:

Code: Select all

call ..\..\..\build.bat %*
The I propose to change for this one:

Code: Select all

@Echo off
if "%1"=="" Goto WithOutPar
SET MainFile=%1
Goto Continue
:WithOutPar
for /R %~dp0%~1 %%f in (*.hbp) do (Set MainFile="%%~nf")
Goto Continue
:Continue
call ..\..\..\build.bat %MainFile%
This is pure batch command from OS and will takes the last .hbp file as part of main file name. The only problem is you will need to re-edit all Build.bat at samples folder (..\hfcl\samples and ..\samples), but it beneficts are so great. What do you think ?

I believe I am not the only one which has this difficulties when click Build.bat of samples, is It good idea or not ?
Agreed verbatim.
Viva INTERNATIONAL HMG :D
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Build.bat

Post by Pablo César »

Thanks colleagues, for your support !!!
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Build.bat

Post by danielmaximiliano »

Hola Pablo :
hace tiempo modifique Buil.bat para que funcione en otras carpetas, puede usted arrastrar y soltar su archivo .PRG o el archivo de proyecto .HBP sobre MiBuild.bat para compilar, sino puede hacer doble click encima de MiBuild.bat entrar solamente el nombre del archivo, intentara compilar primeramente ese mismo archivo si fuera el proyecto sino se compilara el .prg
despues pedira el paramentro para esa compilacion.

espero que le sirva, si tiene alguna duda modificare el mismo para ampliar la capacidad de este archivo por lotes.

Google Translate

Hi Pablo:
modify Buil.bat long to work in other folders, you can drag and drop your file .PRG or the project file .HBP on MiBuild.bat to compile, but you can double click over MiBuild.bat enter only the name file, first try to compile the .prg the same file project .HBP

then ask the paramentro for this compilation.

I hope it works for you, if you have questions modifies it to expand the capacity of this batch file.

Code: Select all

@echo off
SET HMGPATH=C:\hmg.3.1.1\
cls
Title HMG --New MiBuild.bat -- 
@echo 
if "%1"=="" goto Input                                                                                                                                        
if not EXIST %1 Goto Noexist

:Build  
@Echo Compiling %*                                                                            
call %HMGPATH%build.bat %*
@echo.
goto Finish

:Noexist
echo  El archivo %1  no existe,  revise el nombre
@echo  
Goto Finish

:Input

Color 04
@echo ********************************************************************************
@echo   Este Batch pasa informacion a hbmk2 para un compilacion facil y limpia       
@echo   se distribuye como esta y no garantiza que este libre de errores             
@echo   si encuentra una puede escribirme a danielmaximiliano@yahoo.com.ar            
@echo   Basado un Build.bat distribuido en el Proyecto HMG de Roberto Lopez           
@echo ********************************************************************************
@echo.
@echo Entre el nombre del proyecto a compilar, asume la extension .HBP si este existe
@echo en la carpeta del proyecto, sino compila el .PRG
@echo. 
@echo "<Enter>" sale del Batch
@echo.
color 07
Set /p Filename=Nombre de la Aplicacion:=
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.

if {%Filename%}=={} goto :Finish
if EXIST %Filename%.hbp (Set Extension=.hbp&&Goto Enterparameters)
if EXIST %Filename%.prg (Set Extension=.prg&&Goto Enterparameters)
goto Cleanvar


:EnterParameters
@echo *******************************************************************************
@echo  Parametros Extras para compilar %Filename%%extension%
@echo. 
@echo                           /n	No EJECUTAR desdepues de compilar
@echo                           /d	Habilita DEBUG
@echo                           /c	Modo CONSOLA DOS
@echo. 
@echo Nota: " Con un <Enter> ningun parametro es pasado "
@echo *******************************************************************************
@echo.
Set /p Parameter=Parametros :=
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
@echo.
If "%Parameter%"== "" goto Continue
If /I "%Parameter%"=="/n" Goto Withparameters
If /I "%Parameter%"=="/d" Goto Withparameters
If /I "%Parameter%"=="/c" Goto Withparameters
cls
Goto EnterParameters


:Withparameters
@echo compilando con parametros
if EXIST %Filename%.hbp Goto HBPParameters 
if EXIST %Filename%.prg Goto PRGParameters
goto Cleanvar



:HBPParameters
@Echo Compilando %Filename%.hbp %Parameter%
call %HMGPATH%build.bat  %filename%.hbp %Parameter%
goto Cleanvar

:PRGParameters
Echo Compilando %Filename%.PRG %Parameter%
call %HMGPATH%build.bat %filename%.prg %Parameter%
goto Cleanvar


:Continue
@echo no parameters compilation
if EXIST %Filename%.hbp Goto HBP 
if EXIST %Filename%.prg Goto PRG


:HBP
@Echo Compile %Filename%.hbp
call %HMGPATH%build.bat %filename%.hbp 
goto Cleanvar

:PRG
@Echo Compile %Filename%.prg
call %HMGPATH%build.bat %filename%.prg
goto Cleanvar

:CleanVar
@echo Cleaning variable´s
(SET HMGPATH=)
(SET Filename=)
(SET Parameter=)
Goto Input 

:Finish
@echo Cleaning variable´s
set "bar="
set "percent=0"
set "count=0"
for /l %%i in (1,1,20) do set "bar=!bar!±"
:loop
set /p "= %bar:~0,20% %percent%%%"<nul
ping -n 1 -w 1 localhost>nul
for /l %%i in (1,1,26) do set /p "="<nul
set "bar=Û%bar%"
set /a "count+=1"
set /a "percent+=5"
if %count% leq 20 goto:loop
echo.
echo.
(SET HMGPATH=)
(SET Filename=)
(SET Parameter=)
(set bar=)
(set percent=)
(set count=)

*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Build.bat

Post by esgici »

Moreover: this

..\..\ ..

notation require every project should be in the same disk and three level sub of HMG root folder.

There isn't any way to referring HMG root folder in the batch level; such as %~dp0 or anything else.

( Without adding a line like SET HMGROOT=... at top of build.bat or course )
Viva INTERNATIONAL HMG :D
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Build.bat

Post by Pablo César »

Dear Rathi, there is another suggest/request. But this is for main Build.bat at hmg folder.

At "DELETE FILES FROM PREVIOUS BUILD" comment step there is:
rem ******************************************************************************
rem DELETE FILES FROM PREVIOUS BUILD
rem ******************************************************************************

if exist build.log del build.log
if exist error.log del error.log
So I propose to include one important question each time we need to use Debug option. Normally we found problems we use debug option upto the problem be solved, then no more is required. But each time we need to used it thru IDE compiling, we need to pass before in "Reset Project Incremental Data". This menu IDE option, attends for normal rebuilding and for rebuild with "debug" option. But with this line, shall works with more efficient and practicall way:
******************************************************************************
rem DELETE FILES FROM PREVIOUS BUILD
rem ******************************************************************************

if exist build.log del build.log
if exist error.log del error.log
if exist init.cld del init.cld
Added line here in RED COLOR.

What do you think about it for next releases too ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Build.bat - Copying executable file of project

Post by Pablo César »

Copying executable file of project to the correct place of your system

Hi all,

I want to share an experience and new feature that got to change the file Build.bat.

When we compile our application we do it in an appropriate folder where we keep the source code of the project. But we often need to copy the executable that was generated for the right system folder (in use), i.e. where the data files are placed. So we need to use Windows Explorer to copy/paste the executable in that one. Then I had an idea to do this in an automated way.

The idea is to create in the project folder one text file called "Dat" (without extension name) in that contains the path where the system is. Then the Build.bat will detect it and will copy and execute in the right folder without problem.

Procedure:

1. Create at current folder of your system a file called Dat (no extension file).
2. Write inside only the fullpath where your system is (with databases, ready for users).
    Example: C:\Program Files\MySystem (without slash bar at end of fullpath)

That's so ! And making your computer to work for you ! ;)

(Now is already implemented with this HMG.3.3.0 Patch 2 (32 and 64-bits), so in this version and later do not need to do the following instructions).

To get this for happing. You have just to change the main C:\hmg.3.1.5\build.bat the last line (under "RUN APPLICATION") where:

if "%runafterbuild%"==".t." if exist %~n1.exe %~n1.exe

And replace it by these lines:

Code: Select all

	if [%runafterbuild%]==[.f.] goto END
	if exist dat GOTO OTHER
	if exist "%~n1".exe "%~n1".exe
	GOTO END
	:OTHER
	SET /p "OTHER=" <dat
	COPY "%~n1".exe %other%
	if errorlevel 1 goto END
	if exist "%~n1".exe %other%\"%~n1".exe
	:END
If you like this optional procedure, we could include it in the next version releases.

Dear Claudio Soto, do you think this could be done also in the RUN/BUILD button of the IDE ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Build.bat - Copying executable file of project

Post by srvet_claudio »

Pablo César wrote:Copying executable file of project to the correct place of your system

Hi all,

I want to share an experience and new feature that got to change the file Build.bat.

When we compile our application we do it in an appropriate folder where we keep the source code of the project. But we often need to copy the executable that was generated for the right system folder (in use), i.e. where the data files are placed. So we need to use Windows Explorer to copy/paste the executable in that one. Then I had an idea to do this in an automated way.

The idea is to create in the project folder one text file called "Dat" (without extension name) in that contains the path where the system is. Then the Build.bat will detect it and will copy and execute in the right folder without problem.

Procedure:

1. Create at current folder of your system a file called Dat (no extension file).
2. Write inside only the fullpath where your system is (with databases, ready for users).
    Example: C:\Program Files\MySystem (without slash bar at end of fullpath)

That's so ! And making your computer to work for you ! ;)

(Now is already implemented with this HMG.3.3.0 Patch 2 (32 and 64-bits), so in this version and later do not need to do the following instructions).

To get this for happing. You have just to change the main C:\hmg.3.1.5\build.bat the last line (under "RUN APPLICATION") where:

if "%runafterbuild%"==".t." if exist %~n1.exe %~n1.exe

And replace it by these lines:

Code: Select all

	if [%runafterbuild%]==[.f.] goto END
	if exist dat GOTO OTHER
	if exist "%~n1".exe "%~n1".exe
	GOTO END
	:OTHER
	SET /p "OTHER=" <dat
	COPY "%~n1".exe %other%
	if errorlevel 1 goto END
	if exist "%~n1".exe %other%\"%~n1".exe
	:END
If you like this optional procedure, we could include it in the next version releases.

Dear Claudio Soto, do you think this could be done also in the RUN/BUILD button of the IDE ?
Maybe, I would have to review the code of the IDE.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Build.bat

Post by Pablo César »

Claudio para esta situación opcional de uso del archivo Dat o sea para que ejecute una copia del ejecutable en un segundo lugar. No precisaria hacer alteracion ninguna en la IDE porque la IDE se utiliza del Build.bat.

Valeria si el cambio en la IDE para la cuestión de la IDE aceptar nombres largos en los nombres de los proyectos, carpetas, nombre de archivos prg y hbp conteniendo espacio y/o caracteres especiales.

Los cambios sugeridos para alterar la IDE son en los siguientes itens:
  • La IDE utilizando el Build.bat de la carpeta principal de HMG (esto ya lo hace)
     
  • La IDE precisaria generar cada módulo PRG entre comillas en los archivos hbp que hoy genera.
    Y esto no iria afectar la retro-compatibilidad de los antiguos proyectos, porque funciona para ambas situaciones.
     
  • La IDE cuando ejecute el Build.bat principal, deberá pasar el parámetro entre comillas para que el Build.bat pueda entender que se trata de un archivo cuando contega espacio y no como segundo parametro.

    Actualmente la IDE pasa tres parametros:
                                                             /n
                                                             <Nombre_del_projecto.hbp>
                                                             <Nombre_del_projecto.hbc>

    Tendrá entonces que ir entre comillas el segundo y el tercer parametro.
     
  • La IDE precisará remover el mensaje de restricción con respecto a archivos con espacio o caracteres especiales verificando la existencia de dichos nombres largos.

    Image
Afirmo que toda esta alteración no irá a prejudicar con los proyectos antiguos de los usuários, mismo que precisen re-compilarlos con las version posteriores de HMG.

Saludos,

For English translation, please access this: http://hmgforum.com/viewtopic.php?p=35087#p35087

HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply