Skip to content

Latest commit

 

History

History
89 lines (65 loc) · 2.8 KB

building.md

File metadata and controls

89 lines (65 loc) · 2.8 KB

Building from source

FreSH builds from a checkout with a C11 compiler and Rust. The rust/core library holds the compute kernels the shell calls, so cargo is required.

On Windows that means GCC from MinGW-w64 or MSYS2. No other dependencies.

./build.sh

macOS and Linux

The same script, the same sources. On a Mac, Xcode's command line tools give you cc; on Linux, gcc or clang from your distribution. rustup gives you cargo on both:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
./build.sh
./build/fresh

It produces build/fresh, the shell, and build/fresh-setup, the installer with the shell embedded the same way FreSH-Setup.exe embeds FreSH.exe. There is no icon step, so the build finishes after those two links.

FRESH_STATIC=1 ./build.sh links the Linux binary statically, which is how the release binaries are built so they run on any libc. On a Mac, FRESH_TARGET_ARCH=x86_64 ./build.sh cross compiles the Intel binary on an Apple silicon machine, given rustup target add x86_64-apple-darwin.

Windows on ARM

MSYS2's CLANGARM64 environment builds it natively:

pacman -S mingw-w64-clang-aarch64-clang
rustup target add aarch64-pc-windows-gnullvm
CC=clang WINDRES=llvm-windres FRESH_RUST_TARGET=aarch64-pc-windows-gnullvm ./build.sh

Everything Windows specific sits behind src/platform.h: on Windows it is <windows.h>, on POSIX it is the small subset of that API FreSH uses, implemented over open, opendir, posix_spawn and termios in src/platform_posix.c. The shell logic is the same file on both.

or, in PowerShell:

.\build.ps1

On Windows both produce build/FreSH.exe and build/FreSH-Setup.exe. The two icons, the FreSH logo and the page that marks a .frsh script, are generated by tools/makeicon.c and compiled into FreSH.exe; the installer embeds FreSH.exe as a byte array generated by tools/bin2c.c, so the setup binary is self contained.

CMake works too:

cmake -B build && cmake --build build

Format before committing:

astyle --style=google --indent=spaces=4 --suffix=none src/*.c src/*.h

Tests

FreSH tests/run.frsh                       # the suite, written in FreSH
tests/diff/record.sh bash tests/diff/expected
tests/diff/record.sh "$PWD/build/FreSH.exe" tests/diff/actual
tests/diff/compare.sh tests/diff/expected tests/diff/actual
fuzz/build.sh && fuzz/build/fuzz_parser -runs=0 fuzz/corpus/parser

CI runs all three on every push: the suite, the bash differential, and the fuzz corpus under the address and undefined sanitizers. The suite and the differential run on every platform a release ships for: Windows x64 and ARM64, macOS on Apple silicon, Linux x86_64 and arm64. Every one of those binaries, plus the Intel macOS build, is attached to every release.

License