Skip to content

Commit

Permalink
Add build script and windows installer
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamRagstad committed Aug 9, 2021
1 parent 48eda52 commit 916663d
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.project
.settings/org.eclipse.jdt.core.prefs
*.jar
.all-contributorsrc
.all-contributorsrc
dist/bin/
2 changes: 1 addition & 1 deletion Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* languages like JavaScript, C++ or Python.
*/
public class Cli {
private static final String VERSION = "2.1.0";
private static final String VERSION = "2.2.0";
private static final String DESCRIPTION = "A command line interface tool for the RustScript language.";
private static final String COPYRIGHT = "Copyright (c) 2021 William Rågstad";
private static final String HELP = String.format("""
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,25 @@

### 🔌Run

See CLI user manual/help by running `rsc` with the `--help` or `-h` options.
Run a script using the following command.
> Don't forget to download the latest version from above, and install the RustScript toolchain as described in the `README.md` installation instructions file that comes pre-packaged.
Run the `rsc` command with either the `--help` or `-h` option to show the user manual or help page for the CLI tool.
Execute scripts using the following command.

```shell
java -jar rsc.jar <script>
rsc hello.rs world.rs
```

### 🔨 Build

If you want to build RustScript on your own, run the command below to build the `Runner.java` class into a standalone executable.
Or if you haven't installed the native CLI binaries, run the `rsc.jar` file using:

```shell
jar -cvmf manifest.txt rsc.jar *.class core/*.class
java -jar rsc.jar hello.rs
```

### 🔨 Build

If you want to build RustScript on your own. Install the **WiX Toolset** (`dist/tools/wix311.exe`) and run the `build` command from the root directory to build the `Cli.java` class into the standalone executables to `dist/bin/`.

---

## Examples
Expand Down
Binary file added assets/file.ico
Binary file not shown.
Binary file added assets/file.pdn
Binary file not shown.
Binary file added assets/icon.ico
Binary file not shown.
Binary file added assets/icon.pdn
Binary file not shown.
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off
REM Build the RustScript CLI
echo Have you updated the VERSION constant in Cli.java?
set /p version=Version:
@echo on
rmdir dist\bin /S /Q
mkdir dist\bin
javac *.java core/*.java core/formatting/*.java
jar -cvmf manifest.txt dist\bin\rsc.jar *.class core/*.class core/formatting/*.class
cd dist\bin
echo Building native binary...
jpackage --name rsc --input . --main-jar rsc.jar --main-class Cli --type msi --vendor "William Rågstad" --description "The RustScript CLI tool" --app-version %version% --icon ../icon.ico --file-associations ../assoc.properties --win-console
copy ..\README.md .

@echo off
cd ..\..
echo.
echo Done!
pause
34 changes: 34 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# RustScript CLI (rsc)
Hello and welcome!
Thanks for installing the RustScript CLI toolchain.

## Usage

Install the CLI tool to path as shown in a chapter below. Then run:

```shell
rsc
```

This should work from anywhere.

[Read more](https://github.com/WilliamRagstad/RustScript).

## Pre-packaged
The `.msi` installer alreay adds file associations for RustScript files, hence you can double click them
to execute them directly in explorer!

## Install to PATH
Only follow these installation steps if you have installed RustScript in `C:\Program Files\rsc`!

* Search for `env` in windows and open edit environment variables
* Click on the environment variables button
* Scroll down in the upper (or lower) variable list until you find PATH
* Click edit
* Make sure the current PATH ends with a `;`
* Paste in `C:\Program Files\rsc;`
* OK
* Done!

You should now be able to open up a new console window and type in the command `rsc` to access
the RustScript CLI from anywhere!
4 changes: 4 additions & 0 deletions dist/assoc.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extension=rs
mime-type=application/rustscript
icon=../file.ico
description=RustScript Executable Script File
Binary file added dist/file.ico
Binary file not shown.
Binary file added dist/icon.ico
Binary file not shown.
Binary file added dist/tools/wix311.exe
Binary file not shown.

0 comments on commit 916663d

Please sign in to comment.