[Gambas-user] Make executable problem with .32

Benoit Minisini gambas at ...1...
Thu Jun 15 19:59:29 CEST 2006


On Thursday 15 June 2006 02:19, Ron Onstenk wrote:
> Make executable problem
>
> Using SuSE (not related) Configure --prefix=/opt/gb
> Running '/opt/gb/bin/gambas2.gambas' as master
>
> In home dir
> copy of /home/ron/src/gambas2-1.9.32/app/src/gambas2
> as      /home/ron/GBapp/A__source32/gambas2mdi
>
> src and GBapp are symlinks to /mnt/hda6/homeEX/ron/
>
> made fresh /home/ron/gb2 (for testing during this mail)
> copied the source of orginal app/src/gambas2 in it as gambas2mdi
>
> Start gambas as created by configure/make/make install in
>   /opt/gb/bin/gambas2.gambas
>
> open project
>   /home/ron/gb2/gambas2mdi
>
> Do menubar/project/Make executable and stay at
>   /home/ron/gb2/gambas2mdi
> Correct result and delete the gambas2mdi.gambas file
>
> Do menubar/project/Make executable and browse to
>   /home/ron/GBapp/A__source32/gambas2mdi
>
> But Gambas see the symlink and goes to
>   /mnt/hda6/homeEX/ron/GBapp/A__source32/gambas2mdi
>
> Then I click on save but no gambas2mdi.gambas created at destination.
> I found it at /home/ron/gb2/gambas2mdi
>
> Looks gambas does not respect the chosen path in the file/dir browser.
>
>
> Restart orginal gambas2 and select now project at
>   /home/ron/GBapp/A__source32/gambas2mdi
>
> Do menubar/project/Make executable and browse to
>   /home/ron/GBapp/A__source32/gambas2mdi
> gambas change path to
>   /mnt/hda6/homeEX/ron/GBapp/A__source32/gambas2mdi
>
> Then I click on save but no gambas2mdi.gambas created at destination.
> Found it at nowhere. Also not in /home/ron/gb2/gambas2mdi from previous.
>
> To get the executable I need to rename gambas2mdi.gambas to
> gambas2mdi2.gambas in the filename box.
> At least it seams to me the name part should be different to the directory
> name. But changes made in source and try to create again executable needs
> any time a new name. never overwrites the old one.
>
> It did work till and including version .29 (100%).
> the .30 version never used and with .31 I worked also.
>
> For version .32 it is the first time I found this problem.
> In fact the .29 still works correct.
> I just try with the .29 engine to make executable of the .32 IDE.
> Beside warning about the missing gb.form.mdi it creaeded the
> gambas2mdi.gambas and in
>   /mnt/hda6/homeEX/ron/GBapp/A__source32/gambas2mdi/ !!!
>
> Using gba2 (v .32) in /home/ron/GBapp/A__source32/gambas2mdi works correct.
>
> The 'IF NOT Exist(Dialog.Path) THEN' before 3--> does not work on symlinks
> ??? Make executable in '/mnt/hda6/homeEX/ron/GBapp/A__source32/gambas2mdi'
> (ExecPath) did it in '/home/ron/gb2/gambas2mdi' (sPath)
> instead of the wished place '/home/ron/GBapp/A__source32/gambas2mdi/'
>
> See s.v.p. the #--> marks
>
> Greets Ron
>
> from project.module:
>
> if in 4--> the file.ext (help say: Returns the extension of a file name. )
> then ExecPath <> sPath is always true
> Looks to me ExecPath is/should be the executable path/name without .gambas
> sPath is as in 1--> Project.Dir &/ Project.Name & ".gambas"
>
> ExecPath was the chosen place by me for the result in popup
> for selecting that place ?? This is with symlink the real path of it.
>   path:/mnt/hda6/homeEX/ron/GBapp/A__source32/gambas2mdi/ !!!
>   fullname:gambas2mdi (without .gambas by 4-->??)
>
> sPath however was the path of the same project but the symlink was not
> expanded to real path during open project.
>   path:/home/ron/GBapp/A__source32/gambas2mdi
>   fullname:gambas2mdi.gambas
>
> Question is what is supposed to happen with 4--> ???
>
>
>
> PUBLIC FUNCTION MakeExecutable(OPTIONAL bDoNotIncVersion AS Boolean,
> OPTIONAL bSilent AS Boolean) AS Boolean
>
>   DIM sExec AS String
>   DIM sPath AS String
>
>   IF CheckStartupClass() THEN RETURN TRUE
>
> 1-->  sPath = Project.Dir &/ Project.Name & ".gambas"
>
>   IF NOT bSilent THEN
>     Dialog.Title = ("Make executable")
> 2-->    Dialog.Path = ExecPath
>     Dialog.Filter = [("Gambas executable files") & " (*.gambas)", ("All
> files") & " (*)"] IF NOT Exist(Dialog.Path) THEN
> 3-->      Dialog.Path = sPath
>     ENDIF
>     IF Dialog.SaveFile() THEN RETURN TRUE
> 4-->    ExecPath = File.Ext(Dialog.Path, "gambas")
>   ENDIF
>
>   EXEC ["rm", "-rf", Project.Dir &/ ".gambas.save"]
>   TRY MOVE Project.Dir &/ ".gambas" TO Project.Dir &/ ".gambas.save"
>
>   IF Compile(TRUE, NOT KeepDebugInfo) THEN RETURN TRUE
>
>   SetMessage(("Making executable..."))
>
>   sExec = System.Path &/ "bin/gba" & System.Version & " " &
> Quote(Project.Dir) & " > " & OUTPUT_FILE & " 2>&1"
>
>   'PRINT sExec
>
>   SHELL sExec WAIT
> 5-->  IF ExecPath <> sPath THEN
>     TRY KILL ExecPath
>     TRY MOVE sPath TO ExecPath
>   ENDIF
>
>   'Stat(OUTPUT_FILE)
>   SetMessage(("OK"))
>
>
>   'Compile(TRUE, FALSE)
>   EXEC ["rm", "-rf", Project.Dir &/ ".gambas"]
>   TRY MOVE Project.Dir &/ ".gambas.save" TO Project.Dir &/ ".gambas"
>
>   IF NOT bDoNotIncVersion THEN INC ReleaseVersion
>   WriteProject(TRUE)
>
> END
>

The problem comes from the following line:

     TRY MOVE sPath TO ExecPath

It tries to silently move the executable path from the place it is compiled in 
(inside the project) to the place selected by the user.

But this does not work if ExecPath is not on the same device (hd partition) 
than sPath! I fixed that by replacing this line by:

    TRY COPY sPath TO ExecPath
    IF NOT ERROR THEN TRY KILL sPath

As for File.Ext() with two parameters, it does not return the file extension, 
but the complete path with a new extension specified as second parameter.

To prevent the confusion, I have replaced this syntax by new methods: 
File.SetExt, File.SetName, File.SetDir, File.SetBaseName. It is clearer!

Regards,

-- 
Benoit Minisini




More information about the User mailing list