Skip to content

michelou/simplelanguage-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Playing with SimpleLanguage on Windows

GraalVM project In the following we describe how to modify the SimpleLanguage (aka SL) example project on a Windows machine.
In particular we show how to add new builtins, extend the SL parser.

Ada, Akka, Deno, Golang, GraalVM, Haskell, Kotlin, LLVM, Node.js, Rust, Scala 3, Spring and TruffleSqueak are other topics we are currently investigating.

Project dependencies

This project depends on several external software for the Microsoft Windows platform:

Optionally one may also install the following software:

🔎 Git for Windows provides a BASH emulation used to run git from the command line (as well as over 250 Unix commands like awk, diff, file, grep, more, mv, rmdir, sed and wc.

For instance our development environment looks as follows (Augustl 2023) [4] :

C:\opt\apache-maven-3.9.4\                            ( 10 MB)
C:\opt\graalvm-ce-java11-22.0.0.2\                    (869 MB)
C:\opt\graalvm-ce-java17-22.0.0.2\                    (937 MB)
C:\opt\Git-2.41.0\                                    (279 MB)
C:\Program Files\Microsoft SDKs\Windows\v7.1\         (333 MB)
C:\Program Files (x86)\Microsoft Visual Studio 10.0\  (555 MB)

Installation policy
When possible we install software from a Zip archive rather than via a Windows installer. In our case we defined C:\opt\ as the installation directory for optional software tools (in reference to the /opt/ directory on Unix).

Directory structure

This project is organized as follows:

bin\simplelanguage\
docs\
simplelanguage\  (Git submodule)
BUILD.md
README.md
setenv.bat

where

We also define a virtual drive S: in our working environment in order to reduce/hide the real path of our project directory (see article "Windows command prompt limitation" from Microsoft Support).

🔎 We use the Windows external command subst to create virtual drives; for instance:

> subst S: %USERPROFILE%\workspace\simplelanguage-examples

In the next section we give a brief description of the batch files present in this project.

Batch/Bash commands

We distinguish different sets of batch commands:

  1. setenv.bat - This batch command makes external tools such as javac.exe, mvn.cmd or cl.exe directly available from the command prompt (see section Project dependencies).

    > setenv help
    Usage: setenv { <option> | <subcommand> }
     
      Options:
        -bash       start Git bash shell instead of Windows command prompt
        -debug      show commands executed by this script
        -java11     use Java 11 installation of GraalVM (instead of Java 8)
        -sdk        setup Windows SDK environment (SetEnv.cmd)
        -verbose    display progress messages
     
      Subcommands:
        help        display this help message
    
  2. bin\simplelanguage\build.bat - This batch command generates the SL component.

    > build help
    Usage: build { <option> | <subcommand> }
     
      Options:
        -debug      show commands executed by this script
        -native     generate native executable (native-image)
        -timer      display total execution time
        -verbose    display progress messages
     
     Subcommands:
        clean       delete generated files
        dist        generate binary distribution
        help        display this help message
        parser      generate ANTLR parser for SL
    
  3. bin\simplelanguage\build - This bash script is functionally equivalent to the batch file build.bat.

Usage examples

setenv.bat

Command setenv is run once to setup our development environment; it makes external tools such as mvn.cmd, git.exe and cl.exe directly available from the command prompt:

> setenv
Tool versions:
   javac 1.8.0_322, mvn 3.9.4, cl 19.36.32532,
   dumpbin 14.36.32532.0, link 14.36.32532.0, uuidgen 2.35.2,
   git 2.41.0.windows.1, diff 3.8, bash 5.2.15(1)-release

> where javac mvn
C:\opt\graalvm-ce-java11-21.3.0\bin\javac.exe
C:\opt\apache-maven-3.9.4\bin\mvn
C:\opt\apache-maven-3.9.4\bin\mvn.cmd

Command setenv -verbose also displays the tool paths:

> setenv -verbose
Tool versions:
   javac 17.0.8, mvn 3.9.4, cl 19.36.32532,
   dumpbin 14.36.32532.0, link 14.36.32532.0, uuidgen 2.35.2,
   git 2.41.0.windows.1, diff 3.9, bash 5.2.15(1)-release
Tool paths:
   C:\opt\jdk-graalvm-ce-17.0.8_7.1\bin\javac.exe
   C:\opt\apache-maven-3.9.4\bin\mvn.cmd
   X:\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\cl.exe
   X:\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\dumpbin.exe
   X:\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\link.exe
   C:\opt\msys64\usr\bin\uuidgen.exe
   C:\opt\Git-2.41.0\bin\git.exe
   C:\opt\Git-2.41.0\usr\bin\diff.exe
   C:\opt\Git-2.41.0\bin\bash.exe
Environment variables:
   "GIT_HOME=C:\opt\Git-2.41.0"
   "GRAAL_HOME=C:\opt\jdk-graalvm-ce-17.0.8_7.1"
   "JAVA_HOME=C:\opt\jdk-graalvm-ce-17.0.8_7.1"
   "MAVEN_HOME=C:\opt\apache-maven-3.9.4"
   "MSVC_HOME=X:\VC\Tools\MSVC\14.36.32532"
   "MSVS_HOME=X:"
   "MSYS_HOME=C:\opt\msys64\"
   "WINSDK_HOME=C:\Program Files (x86)\Windows Kits\10"
Path associations:
   O:\: => %USERPROFILE%\workspace-perso\simplelanguage-examples
   X:\: => C:\Program Files\Microsoft Visual Studio\2022\Community

Command setenv -sdk is aimed to users who prefer to rely on the "Windows SDK 7.1 Command Prompt" shortcut (target C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd) to setup their development environment.

simplelanguage\build.bat

Usage of batch file build.bat and bash script build is presented in document BUILD.md.

simplelanguage\generate_parser.bat

Batch file generate_parser.bat is functionally equivalent to the bash script generate_parser.

Usage of batch file generate_parser.bat is presented in document BUILD.md.

simplelanguage\sl.bat

Batch file sl.bat is functionally equivalent to the bash script sl.

Usage of batch file sl.bat is presented in document BUILD.md.

Footnotes

[1] 2 GraalVM editions

The GraalVM software is available as Community Edition (CE) and Enterprise Edition (EE).
Starting with version 22, GraalVM is based on OpenJDK 11 or on OpenJDK 17 (previous versions are based on OpenJDK 8 or on OpenJDK 11).

[2] 2018-09-24

The two Microsoft software are listed in the Windows Specifics section of the oracle/graal README file. That's fine but... what version should we download ?! We found the answer (April 2014 !) on StackOverflow:
GRMSDK_EN_DVD.iso is a version for x86 environment.
GRMSDKX_EN_DVD.iso is a version for x64 environment.
GRMSDKIAI_EN_DVD.iso is a version for Itanium environment.

[3] ANTLR distributions

There exists two binary distributions of ANTLR 4: ANTLR tool and ANTLR runtime (with bindings to Java, JavaScript, C# and C++). Batch command generate_parser requires ANTLR tool (and will download it if not present in output directory target\parser\libs\).
> %JAVA_HOME%\bin\java -cp target\parser\libs\antlr-4.10.1-complete.jar org.antlr.v4.Tool | findstr Version
ANTLR Parser Generator  Version 4.10.1

[4] Downloads

In our case we downloaded the following installation files (see section Project dependencies):
apache-maven-3.9.4-bin.zip                  (  8 MB)
graalvm-ce-java11-windows-amd64-21.3.0.zip  (268 MB)
GRMSDKX_EN_DVD.iso                          (570 MB)
PortableGit-2.41.0-64-bit.7z.exe            ( 41 MB)
VC-Compiler-KB2519277.exe                   (121 MB)

mics/April 2022  

About

Running and building SL examples on Windows

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages