modula3 / cm3

Critical Mass Modula-3
http://modula3.github.io/cm3/
Other
138 stars 25 forks source link

How to conveniently run compiled binary after compilation? #1083

Closed jpgpng closed 2 years ago

jpgpng commented 2 years ago

With gm2, it's just like gcc. You compile it with gm2 then ./binary (or just binary on Windows). With cm3, it's a bit more complicated as the binary was put in AMD64_MINGW directory (AMD64_MINGW/binary). I don't want to type the full AMD64_MINGW/binary just to run it. From what I saw on the file qinclude of m3-ui/qt I know quake could be told to call external program. Please help me add the needed code to m3makefile to automatically run the compiled binary after compilation. This means, when I typed cm3, it will compile the program and automatically run the compiled program for me. Thanks.

RodneyBates commented 2 years ago

On 9/19/22 08:51, jpgpng wrote:

With gm2, it's just like gcc. You compile it with gm2 then ./binary (or just binary on Windows). With cm3, it's a bit more complicated as the binary was put in AMD64_MINGW directory (AMD64_MINGW/binary). I don't want to type the full AMD64_MINGW/binary just to run it. From what I saw on the file qinclude of m3-ui/qt I know quake could be told to call external program. Please help me add the needed code to m3makefile to automatically run the compiled binary after compilation. This means, when I typed cm3, it will compile the program and automatically run the compiled program for me. Thanks.

Quake has the "exec" function, (I believe a Quake builtin,) that executes its arguments as a cli command.  On Linux, I have lines in m3makefiles, like this example:

  exec("cd", "../../schutzcommon/src", ";", "make", "all")

— Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/1083, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSVZNHGBOQANNKJJ7SKQRDV7BVWLANCNFSM6AAAAAAQQEDBNM. You are receiving this because you are subscribed to this thread.Message ID: @.***>

jpgpng commented 2 years ago

I'm on Windows so I will wait for @VictorMiasnikov, perhaps he could give me something that working out of the box.

VictorMiasnikov commented 2 years ago

} I don't want to type the full AMD64_MINGW/binary just to run it

Are You run "cm3 -ship" ?

P.S.

} wait V.V.M.

Thank of course, but I do "finishing works". It is tradition, simply ...

Not only I ( VVM) -) can solve problems

19.09.2022, 19:29, "jpgpng" @.***>: I'm on Windows so I will wait for @VictorMiasnikov, perhaps he could give me something.

VictorMiasnikov commented 2 years ago

} code to m3makefile to automatically run the compiled binary after compilation.

( I am on smartphone. I try remember details, sorry for "less detailed answer")

1) Inside cm3 "ecosystem" exist anolog of both bison and flex ( YACC/LEX).

This files started with "k" letter, they has written in Calltech (?) ...

m3makefile each of this contain running external ".exe" / binary file.

2022-09-20: Please, see file ( as example): caltech-parser\parserlib\klexlib\src\m3makefile

if not defined("_clean")
  if stale("RegExpLex.m3",  ".." & SL & "src" & SL & "boot" & SL & "RegExpLex.m3")
    if not defined("HOST_OS_TYPE")
        HOST_OS_TYPE = OS_TYPE
    end
    if equal(HOST_OS_TYPE, "WIN32")
        exec(["..\\src\\boot\\installcmd.cmd"])
    else
        exec(["sh -c ../src/boot/install"])
    end
  end
end

2)

You can look inside our "tests suite"

It'is contain 100 .. 1000 folders with e001 , p099 style naming of folders.

This is number 2 .. 3 subfolder by "total size"

2022-09-20:

DKnoto (on Jan 22): } Are unit tests performed when building the compiler, and if so, for what part of the code? There are they: m3-sys/m3tests/

19.09.2022, 19:29, "jpgpng" @.***>: I'm on Windows so I will wait for @VictorMiasnikov, perhaps he could give me something.

jpgpng commented 2 years ago

Are You run "cm3 -ship"?P.S. > wait V.V.M.Thank of course, but I do "finishing works".It is tradition, simply ... Not only I ( VVM) -) can solve problems

During development you have to run your program to see if it works as expected or not. I will do my own batch script to help it. You Pascal family languages are weird. The Eiffel language, generated a ridiculously bloated in size exe using their very outdated gcc shipped with the installer package that even after you "finalize" it (note: a compilation technique by them) the executable size is still very large. The binary is also put on an obscure location in the project's very complicated directory structure that I have to use Windows search to find out. But, Eiffel language has an IDE called Eiffel Studio. You have no IDE! Perhaps you all using an advanced editor like vim or emacs that has built-in feature to run external binary so it's not a problem for you. I will try configuring CudaText to do so. But I always prefer to open a separate Command Prompt window and compile and run manually from there. The text editor's virtual terminal is never as good as a real one.

jpgpng commented 2 years ago

code to m3makefile to automatically run the compiled binary after compilation.( I am on smartphone. I try remember details, sorry for "less detailed answer")1)Inside cm3 "ecosystem" exist anolog of both bison and flex ( YACC/LEX). This files started with "k" letter, they has written in Calltech (?) ... m3makefile each of this contain running external ".exe" / binary file.2) You can look inside our "tests suite"It'is contain 100 .. 1000 folders with e001 , p099 style naming of folders. This number 2 .. 3 subfolder by "total size"

I didn't see anything like that. Perhaps I will wait until you can use your PC and could give me sth more clear.

jpgpng commented 2 years ago

The m3makefile approach is just too cumbersome. My batch script approach is much simpler. The only problem is you have to copy the batch file to the top of each of your project (assume you have a simple project, for things more complicated there must be a more complicated solution too) :smile:

VictorMiasnikov commented 2 years ago

code to m3makefile to automatically run the compiled binary after compilation.( I am on smartphone. I try remember details, sorry for "less detailed answer")1)Inside cm3 "ecosystem" exist anolog of both bison and flex ( YACC/LEX). This files started with "k" letter, they has written in Calltech (?) ... m3makefile each of this contain running external ".exe" / binary file.2) You can look inside our "tests suite"It'is contain 100 .. 1000 folders with e001 , p099 style naming of folders. This number 2 .. 3 subfolder by "total size"

I didn't see anything like that. Perhaps I will wait until you can use your PC and could give me sth more clear.

1)

VVM}}} VVM}}} ( . . .) m3makefile each of this contain running external ".exe" / binary file. VVM}}}

Please, see file ( as example): caltech-parser\parserlib\klexlib\src\m3makefile

if not defined("_clean")
  if stale("RegExpLex.m3",  ".." & SL & "src" & SL & "boot" & SL & "RegExpLex.m3")
    if not defined("HOST_OS_TYPE")
        HOST_OS_TYPE = OS_TYPE
    end
    if equal(HOST_OS_TYPE, "WIN32")
        exec(["..\\src\\boot\\installcmd.cmd"])
    else
        exec(["sh -c ../src/boot/install"])
    end
  end
end

2)

VVM}}} You can look inside our "tests suite" VVM}}} It'is contain 100 .. 1000 folders with e001 , p099 style naming of folders. VVM}}} This is number 2 .. 3 subfolder by "total size"

DKnoto (on Jan 22): } Are unit tests performed when building the compiler, and if so, for what part of the code?

There are they: m3-sys/m3tests/

VictorMiasnikov commented 2 years ago

The m3makefile approach is just too cumbersome. My batch script approach is much simpler. The only problem is you have to copy the batch file to the top of each of your project (assume you have a simple project, for things more complicated there must be a more complicated solution too) 😄

"Alles gut zum Ende gut" (engl. All's Well That Ends Well)

IPA: [ˈɛndə ɡuːt aləs ˈɡuːt]

(

Arabisch: [1] كل شيء جيّد إذا كانت النهاية جيّدة () → ar Englisch: [1] all's well that ends well → en Französisch: [1] tout est bien qui finit bien → fr Hebräisch: [1] סוף טוב הכל טוב () → he Italienisch: [1] tutto è bene quel che finisce bene → it Niederländisch: [1] eind goed, al goed → nl Polnisch: [1] wszystko dobre, co się dobrze kończy → pl Schwedisch: [1] Slutet gott, allting gott → sv Slowakisch: [1] koniec dobrý, všetko dobré → sk Spanisch: [1] bien está lo que bien acaba → es Tschechisch: [1] konec dobrý, všechno dobré → cs Ungarisch: [1] minden jó, ha vége jó → hu

P.S.

Russisch: [1] вот и сказке конец, а кто слушал - молодец; все хорошо, что хорошо кончается (vot i skazke konec, a kto slušal - molodec; vse chorošo, čto chorošo končaetsja☆) → ru. /Das ist die Ende des Märchens, und wer es hörte is ein guter Mensch/

I fact, variant: "Всё хорошо, что хорошо кончается" is preferred. May be...

But this is beautifully: Das ist die Ende des Märchens, und wer es hörte is ein guter Mensch

)

VictorMiasnikov commented 2 years ago

Are You run "cm3 -ship"?P.S. > wait V.V.M.Thank of course, but I do "finishing works".It is tradition, simply ... Not only I ( VVM) -) can solve problems

During development you have to run your program to see if it works as expected or not. I will do my own batch script to help it. You Pascal family languages are weird. The Eiffel language, generated a ridiculously bloated in size exe using their very outdated gcc shipped with the installer package that even after you "finalize" it (note: a compilation technique by them) the executable size is still very large. The binary is also put on an obscure location in the project's very complicated directory structure that I have to use Windows search to find out. But, Eiffel language has an IDE called Eiffel Studio. You have no IDE! Perhaps you all using an advanced editor like vim or emacs that has built-in feature to run external binary so it's not a problem for you. I will try configuring CudaText to do so. But I always prefer to open a separate Command Prompt window and compile and run manually from there. The text editor's virtual terminal is never as good as a real one.

There is small restructuration:

Eiffel / cm3 }}}  During development you have to run your program to see if it works as expected or not. 
Eiffel / cm3 }}} I will ( VVM: done on 2022-09-20) do my own batch script to help it. 

Eiffel bad }}} You Pascal family languages are weird. 
Eiffel bad }}}  The Eiffel language, generated a ridiculously bloated in size exe
Eiffel bad }}} using their very outdated gcc shipped with the installer package  
Eiffel bad }}} that even after you "finalize" it (note: a compilation technique by them) 
Eiffel bad }}} the executable size is still very large. 
Eiffel bad }}}  The binary is also put on an obscure location in the project's very complicated directory structure 
Eiffel bad }}} that I have to use Windows search to find out. 
Eiffel good}}} But, Eiffel language has an IDE called Eiffel Studio. 

cm3 bad }}}  You have no IDE! Perhaps you all using an advanced editor like vim or emacs 
cm3 bad }}} that has built-in feature to run external binary so it's not a problem for you. 
cm3 good}}} I will try configuring CudaText to do so. 

Eiffel bad }}}  But I always prefer to open a separate Command Prompt window and compile and run manually from there. 
Eiffel bad }}} The text editor's virtual terminal is never as good as a real one.

But "cm3 ecosystem" has support using "a separate Command Prompt window" all time...

CudaText has support Modula-3 language.

P.S. It's publication of my analyzing steps. No more... May be should say: Sorry. I say.

VictorMiasnikov commented 2 years ago

P.S.

When run this mini-"batch" file

cmd /c PATH && cmd /c pause

are You see folder with cm3[.exe] in output?

VictorMiasnikov commented 2 years ago

P.P.S.

You Pascal family language ( . . .)

I prefer think about M3 as "M3/M2 family language".

(

Please, see doctor Fyodor V. Tkachov ( RIP :-( ) from "Theory Division of the Institute for Nuclear Research, Moscow" idea:

Pascal ( "classic") is Pascal-70 / Pascal-68 (?). Modula-2 is Pascal-79. ( F.V.Tkachov: Pascal-80. IMHO, 1979 is better variant) Oberon is Pascal-86.

As I remember, source is: Less is more. Why Oberon beats mainstream in complex applications

)

jpgpng commented 2 years ago

As I remember, source is: Less is more. Why Oberon beats mainstream in complex applications

Oberon is too minimalism not suitable for real life job. The modern successor of Oberon I consider to be Go. Go is also criticized by haters as too minimalism, but Google knows it well so they add for Go an intensive built-in standard library so developers' quality of life is much better. Go is widely adopted but unfortunately Google started the new thing called Carbon. As I know, no impl of Oberon has a good standard library as Go. If they have, they maybe a bit more realistic to be used on real life.

jpgpng commented 2 years ago

@VictorMiasnikov It turns out everything is easier than I think. I don't know why I messed this up in the first place. First, I inserted exec("dir") to know where is the current dir, it turns out it's already AMD64_MINGW. So what I have to do is just exec("binary") and done.

jpgpng commented 2 years ago

What is the different between exec and try_exec? What is the correct way to use try_exec? Where could I find the full document for quake and quake's built-in functions? Thanks.

olaf-wagner commented 2 years ago

On 21 Sep 2022, at 7:46, jpgpng wrote:

What is the different between exec and try_exec? What is the correct way to use try_exec? Where could I find the full document for quake and quake's built-in functions? Thanks.

-- Reply to this email directly or view it on GitHub: https://github.com/modula3/cm3/issues/1083#issuecomment-1253233958 You are receiving this because you are subscribed to this thread.

Message ID: @.***>

The old website for cm3 at elego is still online it seems: https://modula3.elegosoft.com/cm3/ I’m not sure if it has been replaced by something more advanced recently. But you’ll find quake documentation there.

Olaf -- Olaf Wagner -- elego Software Solutions GmbH -- http://www.elegosoft.com Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany Geschäftsführer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194

jpgpng commented 2 years ago

It seems the document is not fully migrated to github. The document on the old site is more abundant.

mikanystrom commented 2 years ago

Right, the compiler "runs" in the derived directory, so you can easily run a just-build binary.

 Mika

On Tue, Sep 20, 2022 at 7:46 AM jpgpng @.***> wrote:

@VictorMiasnikov https://github.com/VictorMiasnikov It turns out everything is easier than I think. I don't know why I messed this up in the first place. First, I inserted exec("dir") to know where is the current dir, it turns out it's already AMD64_MINGW. So what I have to do is just exec("binary") and done.

— Reply to this email directly, view it on GitHub https://github.com/modula3/cm3/issues/1083#issuecomment-1252464878, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKYNJKUWTMG24IDD2HGEXDV7HE2RANCNFSM6AAAAAAQQEDBNM . You are receiving this because you are subscribed to this thread.Message ID: @.***>