Skip to content

michelou/zig-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Playing with Zig on Windows

Rust project This repository gathers Zig code examples coming from various websites and books.
It also includes several build scripts (batch files, Make scripts) for experimenting with Zig 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 two 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 (August 2024) 1:

C:\opt\ConEmu\           ( 26 MB)
C:\opt\Git\              (367 MB)
C:\opt\SDL2\             (  9 MB)
C:\opt\zig-0.13.0\       (293 MB)
C:\opt\zig-0.14.0-dev\   (269 MB)
C:\opt\VSCode\           (341 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 (similar to the /opt/ directory on Unix).

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 H: – 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 H: %USERPROFILE%\workspace\zig-examples

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

Batch commands

setenv.bat

We execute command setenv.bat once to setup our development environment:

> setenv
Tool versions:
   zig 0.13.0, make 3.81, SDL2 2.30.6.0,
   git 2.46.0, diff 3.10, bash 5.2.26(1)

Usage examples

setenv.bat

Command setenv.bat with option -verbose displays additional information:

  • the tool paths (which may not contain the version suffix, i.e. C:\opt\Git\bin\git.exe in some installations),
  • the environment variables defined locally within this session,
  • and the path associations (i.e. H:\ in this case, but other drive names may be displayed as path associations are globally defined).
> setenv -verbose
Tool versions:
   zig 0.13.0, make 3.81, SDL2 2.30.6.0,
   git 2.46.0, diff 3.10, bash 5.2.26(1)
Tool paths:
   C:\opt\zig-0.13.0\zig.exe
   C:\opt\make-3.81\bin\make.exe
   C:\opt\Git\bin\git.exe
   C:\opt\Git\usr\bin\diff.exe
   C:\opt\Git\bin\bash.exe
Environment variables:
   "GIT_HOME=C:\opt\Git"
   "MAKE_HOME=C:\opt\make-3.81"
   "MSYS_HOME=C:\opt\msys64"
   "SDL2_HOME=C:\opt\sdl2"
   "ZIG_HOME=C:\opt\zig-0.13.0"
Path associations:
   H:\: => %USERPROFILE%\workspace-perso\zig-examples

Footnotes

[1] Downloads

In our case we downloaded the following installation files (see section 1):
ConEmuPack.230724.7z              (  5 MB)
PortableGit-2.46.0-64-bit.7z.exe  ( 41 MB)
SDL2-devel-2.30.6-VC.zip          (  8 MB)
VSCode-win32-x64-1.92.1.zip       (131 MB)
zig-windows-x86_64-0.13.0.zip     ( 75 MB)

mics/August 2024  

About

Playing with Zig on Windows

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published