Skip to content

michelou/ada-examples

Repository files navigation

Playing with Ada on Windows

Ada project This repository gathers Ada code examples coming from various websites and books.
It also includes several build scripts (bash scripts, batch files, Make scripts) for experimenting with Ada on a Windows machine.

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

Read the document "Ada Comparison Chart" for an overview of evolution of the major features of the Ada programming language.

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 (December 2024) 4:

C:\opt\adactl\       ( 79 MB)
C:\opt\ConEmu\       ( 26 MB)
C:\opt\Git\          (391 MB)
C:\opt\GNAT\2019\    (1.1 GB)
C:\opt\GNAT\2021\    (2.8 GB)
C:\opt\GWindows\     ( 15 MB)
C:\opt\msys64\       (2.8 GB)
C:\opt\VSCode\       (381 MB)

🔎 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 has the following directory structure :

aunit-examples\{README.md, calculator, etc.}
bin\
docs\
examples\{README.md, Greetings, etc.}
gwindows-examples\{README.md, tutorial1, etc.}
hac-examples{README.md, Ackermann, ..}
intro-to-ada\{README.md, Greet, Week, etc.}
pchapin-examples{README.md, Rationals, Tagged, Vowels, etc.}
shvets-examples\{README.md, ch02, ch03, etc.}
QUICKREF.md
README.md
RESOURCES.md
setenv.bat
SETUP.md

where

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

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

Batch commands

setenv.bat 5

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

> setenv
Tool versions:
   adactl 1.22r16c, alr 2.0.2, gcc 13.3.0, gnat Community 2021,
   Gwindows 13-Apr-2024, make 4.4.1, code 1.95.3,
   git 2.47.1, diff 3.10, bash 5.2.37(1)

> where code diff git make
C:\opt\VSCode\Code.exe
C:\opt\Git\usr\bin\diff.exe
C:\opt\Git\bin\git.exe
C:\opt\msys64\usr\bin\make.exe

Footnotes

[1] Alire

Alire is a source-based package manager for the Ada and SPARK programming languages.

We install Alire from the Zip file alr-2.0.2-bin-x86_64-windows.zip; the archive contains the two files bin\alr.exe and LICENSE.txt (GNU license). We simply copy them to directory %GNAT_HOME%\bin\ (in our case GNAT_HOME=C:\opt\GNAT\2021\).

[2] GNAT 2019

GNAT CE 2019 is the latest version of GNAT CE that supports ASIS, which is required for running AdaControl 1.22.

[3] GNAT tools in MSYS2

The MSYS64 software distribution also includes GNAT tools whose versions may differ from the GNAT CE distribution:
  > where /r c:\opt\msys64 gnat.exe gnatmake.exe
  c:\opt\msys64\mingw64\bin\gnat.exe
  c:\opt\msys64\mingw64\bin\gnatmake.exe
   
  > where /r c:\opt\msys64 gcc.exe make.exe pacman.exe
  c:\opt\msys64\mingw64\bin\gcc.exe
  c:\opt\msys64\usr\bin\make.exe
  c:\opt\msys64\usr\bin\pacman.exe
gnat.exe/gnatmake.exe
  > c:\opt\msys64\mingw64\bin\gnat.exe --version | findstr GNAT
  GNAT 14.2.0
 
  > c:\opt\msys64\mingw64\bin\gnatmake.exe --version | findstr GNAT
  GNATMAKE 14.2.0
gcc.exe/make.exe
  > c:\opt\msys64\mingw64\bin\gcc.exe --version | findstr gcc
  gcc.exe (Rev6, Built by MSYS2 project) 14.2.0
   
  > c:\opt\msys64\usr\bin\make.exe --version | findstr Make
  GNU Make 4.4.1
pacman.exe helps us to keep our MSYS2 package mingw-w64-x86_64-gcc-ada up-to-date:
   > c:\opt\msys64\usr\bin\pacman.exe -Syu mingw-w64-x86_64-gcc-ada
   :: Synchronizing package databases...
   [...]
   :: Running post-transaction hooks...
   (1/3) Compiling GSettings XML schema files...
   (2/3) Updating icon theme caches...
   (3/3) Updating the info directory file...

[4] Downloads

In our case we downloaded the following installation files (see section 1):
adactl-1.22r16c-exe_windows_ce2019.zip              ( 26 MB)
alr-2.0.2-bin-x86_64-windows.zip                    ( 11 MB)
ConEmuPack.230724.7z                                (  5 MB)
gnat-community-2019-20190517-x86_64-windows-bin.exe (380 MB)
gnat-2021-20210519-x86_64-windows64-bin.exe         (562 MB)
gtkada-2021-x86_64-windows64-bin.exe                ( 59 MB)
GWindows Archive 13-Apr-2024.zip                    (  4 MB)
msys2-x86_64-20240727.exe                           ( 83 MB)
PortableGit-2.47.1-64-bit.7z.exe                    ( 46 MB)
VSCode-win32-x64-1.95.3.zip                         (131 MB)

[5] 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/December 2024  

About

Playing with Ada on Windows

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published