How to turn a newLISP script into EXE

Started by newBert, May 13, 2006, 09:48:38 AM

Previous topic - Next topic

newBert

I wonder wether there's nothing new in this :

an example of how to use NSIS to make a newLISP script executable on Windows (inspired by http://nsis.sourceforge.net/How_to_turn_a_REBOL_script_into_EXE">//http://nsis.sourceforge.net/How_to_turn_a_REBOL_script_into_EXE)


; NULLsoft Scriptable Install System
; make a newLISP Script executable

; Name of the installer (don't really care here because of silent below)
Name "Demo"

; Don't want a window, just unpack files and execute
SilentInstall silent

; Set a name for the resulting executable
OutFile "tcltk-app.exe"

; Set an icon (optional)
Icon "C:Program Filesnewlispnewlisp.ico"

; The installation directory
InstallDir "$TEMPtemp_NSIS"

; The stuff to install
Section ""
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR

  ; put here requiered files
  File "C:Program Filesnewlispnewlisp-tk.exe" ; newLISP-tk interpreter
  File "C:Program Filesnewlisptcltk-app.lsp"    ; put the newLISP script

  ; Execute and wait for the newLISP script to end
  ExecWait '"$INSTDIRnewlisp-tk.exe" "-s" "tcltk-app.lsp"'

  ; Delete unpacked files from hard drive
  RMDir /r $INSTDIR
SectionEnd


It works on a PC without newLISP installed.

EXE size = 1.35 Mo (less than the only newLISP-tk.exe)



Can we do that in another way (maybe with "Innosetup" or other for instance) ?
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

Lutz

#1
This method using the NULLsoft installer also requires the newlisp.exe executable in the execution path of Windows. newlisp-tk.exe alone will not work, because it calls newlisp.exe on startup.



newlisp-tk.exe is only required if you script requires Tcl/Tk for doing graphics or windows, like tcltk-app.lsp in your example and it only contains the Tcl/Tk part but not the newlisp.exe executable itself.



If your script does not require graphics you can use a method described in the manual here: http://newlisp.org/downloads/newlisp_manual.html#linking">http://newlisp.org/downloads/newlisp_ma ... ml#linking">http://newlisp.org/downloads/newlisp_manual.html#linking to link newlisp.exe with a script. This will also result in much smaller executables, because the Tcl/Tk overhead of almost 2Mbyte from newlisp-tk.exe is not required.



Lutz

newBert

#2
Thanks for the reply.



Is there a "link.lsp" script which includes the tk-part of newLISP ?



I got in the (bad ?) habit of working with GUI and most often I don't use newLISP.exe (without -tk) unless I need to test quickly a procedure.
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

Lutz

#3
There is no link script when including the tk executable. For that your Nullsoft solution is a good way to do it. But you might also look into http://freewrap.sourceforge.net/">http://freewrap.sourceforge.net/ this is the program I use to produce newlisp-tk.exe. The instructions how to use it are somewhere here on the discussion group. I think HPW here on the discusson board has worked with it too.



Freewrap would allow you to wrap the tcl/tk + newisp-tk.tcl + yourownapp.lsp + newlisp.exe in to one executable containing all files needed. newlisp-tk.exe is basically a linked tcl/tk + newlisp-tk.tcl.



You can find newlisp-tk.tcl in the source distribution at newlisp-8.x.x/newlisp-tk/newlisp-tk.tcl. There is a script in newlisp-8.x.x/Makefile, wich does it all, including producing the Nullsoft installer NSIS to deliver the Win32 installer when calling it with 'make win-tk', and you find the NSIS script here: newlisp-8.x.x/newlisp-tk/newlisp-tk.nsi



Lutz

newBert

#4
Thank you very much,  I didn't dare to explore the sources because I'm just a novice in programming.



I really have fun using newLISP. I don't understand all is written in this forum ([size=75]I'm  French-speaking not talented for english language, sorry[/size]) but it's a source of very interesting things about newLISP, LISP and programming.
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

newBert

#5
I think I found an incomplete solution for (almost)-standalone EXE with newLISP.



Using :

 - NSIS ( still :) )

 - 'runtk.lsp'

 - 'tclkit.exe' (or another implementation of Tcl-Tk)

 - and the script to be converted into a "pseudo-exe"

 

Modifying 'runtk.lsp' like this  (mainly -> (process "tclkit.exe" tcin tcout)):


#!/usr/bin/newlisp
; --- runtk v 1.1 ---
;
; original version bye Fanda:
;        http://www.volny.cz/fsodomka/newlisp/
;
; Run programs written for newlisp-tk without without it
; Only newLISP and a installation of Tcl/Tk is required.
;
; EXAMPLE on Linux/UNIX and Win32:
;
;   runtk myprog.lsp
;
; myprog.lsp could also be directly embedded
; inside this wrapper (see bottom of this file).

; setup communications to Tcl/Tk
(map set '(myin tcout) (pipe))
(map set '(tcin myout) (pipe))
(process "tclkit.exe" tcin tcout)

; tk function to pass commands to Tcl/Tk
(define (tk)
  (write-line (append "if { [catch { puts ["
              (apply string (args)) "] }] } { "
              [text] tk_messageBox -message $errorInfo; exit }
    [/text]) myout)

  (let (str "")
    (while (starts-with (setq str (read-line myin)) "newLISP:")
      (eval-string ((length "newLISP: ") -1 str)))
    str))
(global 'tk)

;; this is for compatibility with newlisp-tk for running
;; the Demo.lsp programs distributed with newlisp-tk
;; for new programs just use 'puts' without the 'Newlisp' wrapper
(tk "proc Newlisp { command } { puts $command }")

;; exit when main window is closed
(tk "bind . <Destroy> {puts {(exit)}}")

;; get program from command line or insert the program here
(load (main-args 2))

;; process incoming newLISP requests
(while (read-line myin)
    (eval-string (current-line)))

;; eof


And here is the NSIS script :


; NULLsoft Scriptable Install System
; make a newLISP-tk Script executable

; Name of the installer (don't really care here because of silent below)
Name "Animation"

; Don't want a window, just unpack files and execute
SilentInstall silent

; Set a name for the resulting executable
OutFile "Test.exe"

; Set an icon (optional)
Icon "C:Program Filesnewlispnewlisp.ico"

; The installation directory
InstallDir "$TEMP_tmpNSIS"

; The stuff to install
Section ""
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR

  ; put here requiered files
  File "C:Program Filesnewlispnewlisp.exe"  ; newLISP interpreter
  File "C:Tcltclkit.exe"                     ; Tcl-Tk

  File "C:Program Filesnewlispruntk.lsp"    ; runtk.lsp (copied in newlisp directory before)
  File "C:Program Filesnewlisptcltk-app.lsp"; THE newlisp-tk script
 
  ; Execute and wait for the newLISP script to end
  ExecWait '"$INSTDIRnewlisp.exe" "runtk.lsp" "tcltk-app.lsp"'

  ; Delete unpacked files from hard drive
  RMDir /r $INSTDIR
SectionEnd


It seems it works. There is still a dos-window which appears when launching the application. Is it possible to hide it ? I don't know and I can't ;)
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

HPW

#6
QuoteI think I found an incomplete solution for (almost)-standalone EXE with newLISP.


I have 2 complete solutions working. Unfourtunatly not free.



1. The EXE-Version using TclApp from Activstate's Tcl Dev Kit

(Working similar to the newLISP-TK-Frontend)

http://www.activestate.com/Products/Tcl_Dev_Kit/?mp=1">http://www.activestate.com/Products/Tcl_Dev_Kit/?mp=1



2. The Dll-Version using neobook with my newLISP-plugin.

http://www.hpwsoft.de/anmeldung/html1/neobook/neobook14.html">http://www.hpwsoft.de/anmeldung/html1/n ... ook14.html">http://www.hpwsoft.de/anmeldung/html1/neobook/neobook14.html
Hans-Peter

HPW

#7
Of cource the EXE-Version is also possible to build with freewrap exactly like the newLISP-TK-Frontend.
Hans-Peter

newBert

#8
QuoteOf cource the EXE-Version is also possible to build with freewrap exactly like the newLISP-TK-Frontend.


I'd like to use FreeWrap in this case, but it's not very easy to implement.



First, I don't manage to build a full .exe with FreeWrap. It does not work probably because of my minimalist Tcl-Tk installation : tclkit.exe (which moreover does not handle the "BWidgets").



What is required for FreeWrap ?

- a full Tcl-Tk installation (like Active Tcl, for instance) ?

- NewLISP-tk source : Is it necessary to modifiy the newlisp-tk.tcl script (I am not a Tcl programmer. Tcl seems difficult to me, unlike Tk) ?



What is the procedure, which must submit to the following criteria : a single, as light as possible, stand-alone executable file from a NewLISP-tk script, without having to write some Tcl code (if possible) ... and that's all !



I'm rather a little demanding (so to speak : hard to please), am I ? ;-)
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

HPW

#9
My Statement about Freewrap was wrong. Besides the freewrap-made EXE you need also newLISP.exe!


Quote
What is required for FreeWrap ?

- a full Tcl-Tk installation (like Active Tcl, for instance) ?


No Tcl-Tk installation, only freewrap. (It contains a complete TK-runtime). I have not tested with the latest freewrap version and I am not sure what Lutz use for the latest newLISP-Tk wrapping. You may also need the Bwidget-extension when you want to use them (http://www.newlisp.org/downloads/TclTk/">http://www.newlisp.org/downloads/TclTk/).



A wrap-bat-file could be:
freewrap MyApp.tcl -f images.txt -f bwidget.txt -f MyApp.txt

(MyApp.txt can be a list of Lisp-Sources to embed into the EXE.)

Example in txt:

/freewrap/MyApp/MyLisp.lsp



In your MyApp.tcl near the end you do:



set fle [open /freewrap/MyApp/MyLisp.lsp r]; NewlispEvaluateBuffer [read $fle] 0


Quote
- NewLISP-tk source : Is it necessary to modifiy the newlisp-tk.tcl script (I am not a Tcl programmer. Tcl seems difficult to me, unlike Tk) ?


I think so. Everything has its price. The NewLISP-tk source is a good start to learn how to mix the both worlds.


Quote
What is the procedure, which must submit to the following criteria : a single, as light as possible, stand-alone executable file from a NewLISP-tk script, without having to write some Tcl code (if possible) ... and that's all !


I think you have to do some TCl/TK-code because you define your interface with it and connect the events with it. The event-code then can call newLISP for processing.
Hans-Peter

HPW

#10
You might also make a forum search with 'freewrap' to get some older readings.
Hans-Peter