A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pascalcombier/plain-starter below:

pascalcombier/plain-starter: A lightweight starter for Microsoft Windows programs

A lot of programs are written using some kind of virtual machine or interpreter: Java, Python, Perl, Lua and many others.

This make it non-trivial to distribute such programs. For that reason, many of these programs simply includes a script file usually named "start.bat" or "program.bat" which call the underlying executable with the proper parameters. Plainstarter is a generic project aiming to replace these "start.bat" scripts with a proper executable file, containing the project's icon and project's meta-data.

Note that the project's icon and the project's meta-data need to be updated by the project's developers, it's obviously outside the scope of plainstarter.

Let's see an example of plainstarter usage, more examples are available in the release area (Lua, Tcl/Tk, Common Lisp, etc). Let's implement the UNIX cat command using Lua on Windows.

A trivial UNIX cat implementation will take a list of filenames in the parameters and print the files content on the standard output.

local Filenames = arg

for Index = 1, #Filenames do
  for Line in io.lines(Filenames[Index]) do
    io.write(Line)
    io.write("\n")
  end
end

There are 2 binary files in the bin64 directory of plainstarter:

plainstarter-x86-64-console.exe
plainstarter-x86-64-gui.exe

The program UNIX cat is a command line program, so we simply copy plainstarter-x86-64-console.exe and rename it into lua-cat.exe. When lua-cat.exe will start, it will look for the configuration file configs/lua-cat.cfg, then config/lua-cat.cfg, and finally lua-cat.cfg. The first configuration file found will be used, the others will be ignored.

To run Lua scripts, we need to get the Lua binaries files. To make it clear that these binary files are outside the scope of lua-cat project, we copy them in the directory third-party.

lua-cat
├───lua-cat.exe (duplicate of plainstarter-x86-64-console.exe)
│
├───config
│    └─── lua-cat.cfg
│
├───sources
│    └─── cat.lua
│
└───third-party
    └───bin
         ├───lua54.dll
         ├───lua54.exe
         ├───luac54.exe
         └───wlua54.exe

The configuration file need to override the %PATH% variable, to make Lua binaries available to lua-cat.exe. To make it more portable, third-party\bin is prefixed to %PATH% instead of postfixed.

lua-cat.cfg

PLAINSTARTER_OPTIONS=monitor-process show-console
PATH=%PLAINSTARTER_DIRECTORY%\third-party\bin;%PATH%
PLAINSTARTER_CMD_LINE=lua54 %PLAINSTARTER_DIRECTORY%\sources\cat.lua

PLAINSTARTER_CMD_LINE defines the command line to execute. Note that all the parameters provided to plainstarter will be appended to PLAINSTARTER_CMD_LINE implicitly. If lua-cat.exe PARAM1 PARAM2 PARAM3 is executed, the command line lua54 %PLAINSTARTER_DIRECTORY%\sources\cat.lua PARAM1 PARAM2 PARAM3 will be executed.

Note that to get a really portable program, it is important to prefix the Lua script with %PLAINSTARTER_DIRECTORY%. Doing that allow the script to work properly regardless the value of the working directory (aka %CD%, $pwd). To give a specific example, calling something like "..\lua-cat.exe test\test.txt" will work if the files and directories matches.

If one need to modify the icon, he can change the file art/plainstarter.ico from plainstarter project and recompile the source code. He can also use the cost-free software Resource Hacker to edit the binary without recompilation.

One need to modify the resource file src/resources.rc from plainstarter project. Then a new plainstarter compilation is needed.

With the help of plain-toolchain-x86-64, plainstarter's compilation should be straight-forward:

This can be achieved by using Windows's Notepad to save the file:

For other problems, the errors have a specific identifier so that it can be easy to find the location in the source code.

A technical reference is available in a dedicated page.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4