Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-01

FPC run (run program after compile)

13 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Lars

Is there a way to compile a program with fpc at the command line and run it right after?

Something like
fpc run project1.pas -Fu../

The only thing I could find was InstantFpc, which may serve similar purpose but not really the same as what I was thinking...

For some reason (I may remember incorrectly) I thought there was some work being done to compile a program and then run it afterward a while back... but maybe I'm confusing this idea with the InstantFPC idea.

Graeme Geldenhuys
to Lars
Lars wrote
The only thing I could find was InstantFpc, which may serve similar purpose but not really the same as what I was thinking...

If InstantFPC doesn't work for you, you could always compile the FPC Compiler into your "own" executable that does compilation and then running the resulting executable.

Alternatively, you could turn to a simple Bash script (if you are on a Unix/Linux platform) to accomplish the same task.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp
Lars
to Graeme Geldenhuys
Graeme Geldenhuys wrote 8 lines
On 2017-01-16 07:06, Lars wrote: > The only thing I could find was InstantFpc, which may serve similar > purpose but not really the same as what I was thinking... If InstantFPC doesn't work for you, you could always compile the FPC Compiler into your "own" executable that does compilation and then running the resulting executable.

Indeed, would not be too hard... even a shell script like you say..

If anyone finds this idea useful of seeing your program run, right after a compile, at the command line, it might be something to add to fpc. It is similar to how when you press F9 in delphi or compile a program in turbopascal/fpide it runs the program for you, without multiple link/compile/run steps like GCC and old C compilers required.

As for instantFPC, that would maybe make pascal programs run on a webserver just by uploading them.. which is very interesting.... more research to be done there as to what has to be installed on the server for that to work... some kind of fpc compiler will need to be on the server and in what directories.

Lars
to Mattias Gaertner: On Mon, 16 Jan 2017 00:06:59 -0700 instantfpc -Fu../ project1.pas And what are you…
Mattias Gaertner wrote 13 lines
On Mon, 16 Jan 2017 00:06:59 -0700 "Lars" wrote: > Is there a way to compile a program with fpc at the command line and > run it right after? > > Something like > fpc run project1.pas -Fu../ instantfpc -Fu../ project1.pas

Looks good...

Show quoted text 6 lines
> The only thing I could find was InstantFpc, which may serve similar > purpose but not really the same as what I was thinking... And what are you thinking?

That instantfpc has catch22 like you cant compule multiple projects with the same name, i.e. it caches file name only (caveat) whereas fpcrun would compile it in current directory, as normal, no special cache dir needed

Also I am thinking about 3 million two thousand and eight other ideas at the moment
Possibly a.d.h.d meds

Show quoted text 6 lines
Mattias _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Mattias Gaertner
to Lars
[...] That instantfpc has catch22 like you cant compule multiple projects with the same name, i.e. it caches file name only (caveat) whereas fpcrun would compile it in current directory, as normal, no special cache dir needed

Feel free to add an option like "--inplace" and send the patch.

Mattias

Mark Morgan Lloyd
to Mattias Gaertner
Mattias Gaertner wrote 9 lines
On Mon, 16 Jan 2017 05:22:14 -0700 "Lars" wrote: > [...] > That instantfpc has catch22 like you cant compule multiple projects with > the same name, i.e. it caches file name only (caveat) whereas fpcrun would > compile it in current directory, as normal, no special cache dir needed Feel free to add an option like "--inplace" and send the patch.

This works

#!/usr/local/bin/fpc.d/3.0.0/instantfpc --set-cache=./

program Test;
..

except that the original file's getting modified to put // in front of the shebang which means that a second instantfpc run fails.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
Lars
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 24 lines
On 16/01/17 13:30, Mattias Gaertner wrote: > On Mon, 16 Jan 2017 05:22:14 -0700 > "Lars" wrote: > > >> [...] >> That instantfpc has catch22 like you cant compule multiple projects >> with the same name, i.e. it caches file name only (caveat) whereas >> fpcrun would compile it in current directory, as normal, no special >> cache dir needed > > Feel free to add an option like "--inplace" and send the patch. > This works #!/usr/local/bin/fpc.d/3.0.0/instantfpc --set-cache=./ program Test; ..

Does instantfpc make it mandatory that you put this at the top of every source file:

#!/usr/local/bin/fpc.d/3.0.0/instantfpc --set-cache=./

fpcrun would not require this as it just compiles normally...

However making fpcrun.exe (trivial) would duplicate what instantfpc already kind of sort of does, so I do not want fpc to ship two executables that do the same thing (or similar)...

except that the original file's getting modified to put // in front of the shebang which means that a second instantfpc run fails.

Interesting idea, to just cache it in the original project directory.

Lars
to Sven Barth: No, FPC is a compiler, not a "runner" or debugger. That would even be one of the few…
Sven Barth wrote 12 lines
Am 16.01.2017 08:07 schrieb "Lars" : > > Is there a way to compile a program with fpc at the command line and > run it right after? > > Something like > fpc run project1.pas -Fu../ No, FPC is a compiler, not a "runner" or debugger. That would even be one of the few points where patches would *not* be welcome.

fpcrun.exe is an alternative to "fpc run"

fpcrun.exe is trivial, and I can copy it into my fpc directory.. but wondered if others needed it. But I don't want to duplicate what instantfpc does... so might be better to modify instantfpc. Still, fpcrun.exe would be trivial to make so that is still tempting... as instantfpc may require adding a parameter like Mattias was saying, whereas fpcrun.exe would require no parameters.

Mattias Gaertner
to Lars: Does instantfpc make it mandatory that you put this at the top of every source file:…
[...] Does instantfpc make it mandatory that you put this at the top of every source file: > #!/usr/local/bin/fpc.d/3.0.0/instantfpc --set-cache=./

No.
That's only needed if you want to run the Pascal file directly:

./project1.pas

Show quoted text 5 lines
fpcrun would not require this as it just compiles normally... However making fpcrun.exe (trivial) would duplicate what instantfpc already kind of sort of does, so I do not want fpc to ship two executables that do the same thing (or similar)...

fpc has a much slower startup time than instantfpc. That's why instantfpc is good for running Pascal scripts.

Mattias

Lars
to Lars: fpcrun.exe is an alternative to "fpc run" fpcrun.exe is trivial, and I can copy it into…

On Mon, January 16, 2017 1:21 pm, Lars wrote:
..

Show quoted text 9 lines
On Mon, January 16, 2017 3:59 am, Sven Barth wrote: > No, FPC is a compiler, not a "runner" or debugger. That would even be > one of the few points where patches would *not* be welcome. > fpcrun.exe is an alternative to "fpc run" fpcrun.exe is trivial, and I can copy it into my fpc directory.. but wondered if others needed it.

trivial indeed...

https://github.com/z505/fpcRun

Project started on github. Tested to work on Windows.

Now I just have to try Unix, as, executeprocess works slightly different on that system and some absolute path configuration to fpc might be needed.

So basically FPCRUN.EXE project is now known as fpr.exe... as fpr is easier to type at the command line for the lazy

Lars
to Lars
I previously wrote 9 lines
https://github.com/z505/fpcRun Project started on github. Tested to work on Windows. Now I just have to try Unix, as, executeprocess works slightly different on that system and some absolute path configuration to fpc might be needed.

Solution was to use fpSystem instead of ExecuteProcess on unix, and use ExecuteProcess on Windows

fpr or FPCRUN project seems to work good so far on linux and windows now.

Bsd/macos I have not tested