michelou / erlang-examples

Playing with Erlang on Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Playing with Erlang on Windows

Erlang project This repository gathers Erlang code examples coming from various websites - mostly from the Erlang project - or written by ourself.
In particular it includes several build scripts (bash scripts, batch files, Make scripts) for experimenting with the Erlang language on a Windows machine.

Ada, Akka, C++, COBOL, Dart, Deno, Docker, Flix, Golang, GraalVM, Haskell, Kafka, Kotlin, LLVM, Modula-2, Node.js, Rust, Scala 3, Spark, Spring, TruffleSqueak and WiX Toolset are other topics we are continuously monitoring.

Project dependencies

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

Optionally one may also install the following software:

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).

For instance our development environment looks as follows (May 2024) 1:

C:\opt\ConEmu\                ( 26 MB)
C:\opt\elvis\                 (2.4 MB)
C:\opt\Git\                   (367 MB)
C:\opt\VSCode\                (341 MB)
C:\Program Files\Erlang OTP\  (246 MB) (451 MB with docs)

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

Directory structure

This project is organized as follows:

docs\
examples\{README.md, hello, ..}
README.md
RESOURCES.md
setenv.bat

where

We also define a virtual drive – e.g. drive M: – 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 M: %USERPROFILE%\workspace\erlang-examples

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

Batch/Bash commands

setenv.bat 2

We execute command setenv.bat once to setup our development environment; it makes external tools such as git.exe and sh.exe directly available from the command prompt.

   > setenv
   Tool versions:
   erl 14.2.5, dialyzer v5.1.3, make 4.4.1,
   git 2.45.0, diff 3.10, bash 5.2.26(1)-release
    
   > where git sh
   C:\opt\Git\bin\git.exe
   C:\opt\Git\mingw64\bin\git.exe
   C:\opt\Git\bin\sh.exe
   C:\opt\Git\usr\bin\sh.exe
   

Footnotes

[1] Downloads

In our case we downloaded the following installation files (see section 1):

elvis                             (2.4 MB)
otp_win64_26.2.5.exe              (145 MB)
PortableGit-2.45.0-64-bit.7z.exe  ( 41 MB)
VSCode-win32-x64-1.89.1.zip       (131 MB)

[2] setenv.bat usage

Batch file setenv.bat has specific environment variables set that enable us to use command-line developer tools more easily.
It is similar to the setup scripts described on the page "Visual Studio Developer Command Prompt and Developer PowerShell" of the Visual Studio online documentation.
For instance we can quickly check that the two scripts Launch-VsDevShell.ps1 and VsDevCmd.bat are indeed available in our Visual Studio 2019 installation :
> where /r "C:\Program Files (x86)\Microsoft Visual Studio" *vsdev*
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\Launch-VsDevShell.ps1
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\vsdevcmd\core\vsdevcmd_end.bat
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\vsdevcmd\core\vsdevcmd_start.bat
Concretely, in our GitHub projects which depend on Visual Studio (e.g. michelou/cpp-examples), setenv.bat does invoke VsDevCmd.bat (resp. vcvarall.bat for older Visual Studio versions) to setup the Visual Studio tools on the command prompt.

mics/May 2024  

About

Playing with Erlang on Windows