Compare commits
48 Commits
prerelease
...
prerelease
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb285b6e8f | ||
|
|
78a1edd572 | ||
|
|
b905026010 | ||
|
|
677afd9433 | ||
|
|
757da3f973 | ||
|
|
5a86510c3b | ||
|
|
fb8b6a89ae | ||
|
|
6ddf9953e7 | ||
|
|
1609227a42 | ||
|
|
51f6a88ce8 | ||
|
|
f420273471 | ||
|
|
4b2a747338 | ||
|
|
5277814af0 | ||
|
|
8928ab2d99 | ||
|
|
d08b307c6e | ||
|
|
6474329afc | ||
|
|
c49e67c839 | ||
|
|
25cb96e473 | ||
|
|
f11890a8b3 | ||
|
|
59b1d222c2 | ||
|
|
2fba132016 | ||
|
|
bddc2cdc79 | ||
|
|
e1b80b42d9 | ||
|
|
dab86925b4 | ||
|
|
0f45052dce | ||
|
|
68f4207216 | ||
|
|
f9f8ca08c6 | ||
|
|
0666b02c13 | ||
|
|
1654507835 | ||
|
|
d054ece8e2 | ||
|
|
4937942d6e | ||
|
|
82ea92183f | ||
|
|
5fb15b476f | ||
|
|
d1a455dbbe | ||
|
|
a81640747d | ||
|
|
4a1ed23f96 | ||
|
|
eb36d02fcb | ||
|
|
7b3a1e1835 | ||
|
|
8e53579682 | ||
|
|
0d8f262185 | ||
|
|
fc6f41d89b | ||
|
|
6a7ce72eb7 | ||
|
|
f84e5429a5 | ||
|
|
f4c7294267 | ||
|
|
be4b04a286 | ||
|
|
9d11122e93 | ||
|
|
241e447da0 | ||
|
|
dd750ab164 |
308
.github/workflows/release.yml
vendored
308
.github/workflows/release.yml
vendored
@@ -1,136 +1,232 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 William Bell
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
name: Build and Release
|
name: Build and Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- '*' # Trigger on any tag push
|
- '*' # Any tag
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_and_release:
|
build-linux-x86_64:
|
||||||
strategy:
|
runs-on: ubuntu-latest
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Linux
|
- uses: actions/checkout@v3
|
||||||
- name: Install build tools (Linux)
|
|
||||||
if: runner.os == 'Linux'
|
|
||||||
run: sudo apt-get update && sudo apt-get install -y flex bison
|
|
||||||
|
|
||||||
# macOS
|
|
||||||
- name: Install build tools (macOS)
|
|
||||||
if: runner.os == 'macOS'
|
|
||||||
run: brew install flex bison
|
|
||||||
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
# Windows
|
- name: Install build tools
|
||||||
- name: Install build tools (Windows)
|
run: sudo apt-get update && sudo apt-get install -y flex bison
|
||||||
if: runner.os == 'Windows'
|
|
||||||
run: |
|
|
||||||
choco install winflexbison mingw -y
|
|
||||||
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
- name: Setup Python (needed for Conan)
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
|
|
||||||
- name: Install Conan (Linux/macOS)
|
- name: Install Conan
|
||||||
if: runner.os != 'Windows'
|
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install conan
|
pip install conan
|
||||||
shell: bash
|
conan profile detect
|
||||||
|
|
||||||
- name: Install Conan (Windows)
|
- name: Build
|
||||||
if: runner.os == 'Windows'
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install conan
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
- name: Configure Conan (Linux/macOS)
|
|
||||||
if: runner.os != 'Windows'
|
|
||||||
run: conan profile detect
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Configure Conan (Windows)
|
|
||||||
if: runner.os == 'Windows'
|
|
||||||
run: conan profile detect
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
- name: Install dependencies and build (Linux/macOS)
|
|
||||||
if: runner.os != 'Windows'
|
|
||||||
run: |
|
run: |
|
||||||
conan install . --build=missing
|
conan install . --build=missing
|
||||||
conan build .
|
conan build .
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Install dependencies and build (Windows)
|
- name: Package
|
||||||
if: runner.os == 'Windows'
|
|
||||||
run: |
|
|
||||||
conan install . --build=missing
|
|
||||||
conan build . --config Release
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
- name: Determine if prerelease (Linux/macOS)
|
|
||||||
if: runner.os != 'Windows'
|
|
||||||
id: prerelease_check_unix
|
|
||||||
run: |
|
|
||||||
TAG=${GITHUB_REF##refs/tags/}
|
|
||||||
if [[ "$TAG" == prerelease-* ]]; then
|
|
||||||
echo "true" > prerelease.txt
|
|
||||||
else
|
|
||||||
echo "false" > prerelease.txt
|
|
||||||
fi
|
|
||||||
echo "prerelease=$(cat prerelease.txt)" >> $GITHUB_OUTPUT
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Determine if prerelease (Windows)
|
|
||||||
if: runner.os == 'Windows'
|
|
||||||
id: prerelease_check_win
|
|
||||||
run: |
|
|
||||||
$TAG = $env:GITHUB_REF -replace 'refs/tags/', ''
|
|
||||||
if ($TAG -like 'prerelease-*') {
|
|
||||||
echo "true" > prerelease.txt
|
|
||||||
} else {
|
|
||||||
echo "false" > prerelease.txt
|
|
||||||
}
|
|
||||||
echo "prerelease=$(Get-Content prerelease.txt)" >> $env:GITHUB_OUTPUT
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
- name: Archive build folder (Linux/macOS)
|
|
||||||
if: runner.os != 'Windows'
|
|
||||||
run: |
|
run: |
|
||||||
TAG=${GITHUB_REF##refs/tags/}
|
TAG=${GITHUB_REF##refs/tags/}
|
||||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
FOLDER_NAME="chloride-$TAG-$OS-$ARCH"
|
FOLDER="chloride-$TAG-$OS-$ARCH"
|
||||||
TAR_NAME="$FOLDER_NAME.tar.gz"
|
TAR="$FOLDER.tar.gz"
|
||||||
mv build/bin "$FOLDER_NAME"
|
mv build/bin "$FOLDER"
|
||||||
cp LICENSE.txt "$FOLDER_NAME"
|
cp LICENSE.txt "$FOLDER"
|
||||||
tar -czf "$TAR_NAME" "$FOLDER_NAME"
|
tar -czf "$TAR" "$FOLDER"
|
||||||
echo "TAR_NAME=$TAR_NAME" >> $GITHUB_ENV
|
echo "TAR_NAME=$TAR" >> $GITHUB_ENV
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Archive build folder (Windows)
|
- name: Upload artifact
|
||||||
if: runner.os == 'Windows'
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: linux-${{ matrix.arch }}-artifact
|
||||||
|
path: ${{ env.TAR_NAME }}
|
||||||
|
|
||||||
|
build-linux-arm64:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Run build in arm64 container
|
||||||
run: |
|
run: |
|
||||||
$TAG = $env:GITHUB_REF -replace 'refs/tags/', ''
|
docker run --rm --platform linux/arm64 \
|
||||||
$ARCH = if ([Environment]::Is64BitOperatingSystem) { 'x64' } else { 'x86' }
|
-v $PWD:/work -w /work \
|
||||||
$FOLDER_NAME = "chloride-$TAG-windows-$ARCH"
|
ubuntu:latest \
|
||||||
$TAR_NAME = "$FOLDER_NAME.zip"
|
bash -c "
|
||||||
Rename-Item build\bin $FOLDER_NAME
|
apt-get update && apt-get install -y python3-pip g++ flex bison &&
|
||||||
Copy-Item LICENSE.txt $FOLDER_NAME
|
pip install conan &&
|
||||||
Compress-Archive -Path $FOLDER_NAME -DestinationPath $TAR_NAME
|
conan profile detect --force &&
|
||||||
echo "TAR_NAME=$TAR_NAME" >> $env:GITHUB_ENV
|
conan install . --build=missing &&
|
||||||
shell: pwsh
|
conan build .
|
||||||
|
"
|
||||||
|
|
||||||
|
- name: Package
|
||||||
|
run: |
|
||||||
|
TAG=${GITHUB_REF##refs/tags/}
|
||||||
|
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
|
ARCH=arm64
|
||||||
|
FOLDER="chloride-$TAG-$OS-$ARCH"
|
||||||
|
TAR="$FOLDER.tar.gz"
|
||||||
|
mv build/bin "$FOLDER"
|
||||||
|
cp LICENSE.txt "$FOLDER"
|
||||||
|
tar -czf "$TAR" "$FOLDER"
|
||||||
|
echo "TAR_NAME=$TAR" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: linux-${{ matrix.arch }}-artifact
|
||||||
|
path: ${{ env.TAR_NAME }}
|
||||||
|
|
||||||
|
build-macos:
|
||||||
|
runs-on: macos-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
arch: [x86_64, arm64] # build both architectures
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Install build tools
|
||||||
|
run: brew install flex bison
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
|
||||||
|
- name: Install Conan
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install conan
|
||||||
|
if [ "${{ matrix.arch }}" = "x86_64" ] && [ "$(uname -m)" = "arm64" ]; then
|
||||||
|
arch -x86_64 conan profile detect
|
||||||
|
else
|
||||||
|
conan profile detect
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
BUILD_DIR="build_${{ matrix.arch }}"
|
||||||
|
mkdir -p "$BUILD_DIR"
|
||||||
|
cd "$BUILD_DIR"
|
||||||
|
|
||||||
|
# Use Rosetta for x86_64 builds on Apple Silicon
|
||||||
|
if [ "${{ matrix.arch }}" = "x86_64" ] && [ "$(uname -m)" = "arm64" ]; then
|
||||||
|
arch -x86_64 bash -c "
|
||||||
|
export CMAKE_OSX_ARCHITECTURES=x86_64
|
||||||
|
conan install .. --build=missing
|
||||||
|
conan build ..
|
||||||
|
"
|
||||||
|
else
|
||||||
|
export CMAKE_OSX_ARCHITECTURES="${{ matrix.arch }}"
|
||||||
|
conan install .. --build=missing
|
||||||
|
conan build ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
- name: Package
|
||||||
|
run: |
|
||||||
|
TAG=${GITHUB_REF##refs/tags/}
|
||||||
|
OS="macos"
|
||||||
|
ARCH="${{ matrix.arch }}"
|
||||||
|
FOLDER="chloride-$TAG-$OS-$ARCH"
|
||||||
|
TAR="$FOLDER.tar.gz"
|
||||||
|
mv build/bin "$FOLDER"
|
||||||
|
cp LICENSE.txt "$FOLDER"
|
||||||
|
tar -czf "$TAR" "$FOLDER"
|
||||||
|
echo "TAR_NAME=$TAR" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: macos-${{ matrix.arch }}-artifact
|
||||||
|
path: ${{ env.TAR_NAME }}
|
||||||
|
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: msys2 {0}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- uses: msys2/setup-msys2@v2
|
||||||
|
with:
|
||||||
|
msystem: MINGW64
|
||||||
|
update: true
|
||||||
|
install: >
|
||||||
|
base-devel
|
||||||
|
mingw-w64-x86_64-gcc
|
||||||
|
mingw-w64-x86_64-make
|
||||||
|
mingw-w64-x86_64-cmake
|
||||||
|
mingw-w64-x86_64-python
|
||||||
|
mingw-w64-x86_64-python-pip
|
||||||
|
msys/flex
|
||||||
|
|
||||||
|
- name: Install Conan
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install conan
|
||||||
|
conan profile detect
|
||||||
|
|
||||||
|
- name: Build Project
|
||||||
|
run: |
|
||||||
|
conan install . --profile mingw-profile.txt --build=missing
|
||||||
|
conan build . --profile mingw-profile.txt
|
||||||
|
|
||||||
|
- name: Package
|
||||||
|
run: |
|
||||||
|
TAG=${GITHUB_REF##refs/tags/}
|
||||||
|
OS="windows"
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
FOLDER="chloride-$TAG-$OS-$ARCH"
|
||||||
|
TAR="$FOLDER.tar.gz"
|
||||||
|
mv build/bin "$FOLDER"
|
||||||
|
cp LICENSE.txt "$FOLDER"
|
||||||
|
tar -czf "$TAR" "$FOLDER"
|
||||||
|
echo "TAR_NAME=$TAR" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: windows-artifact
|
||||||
|
path: ${{ env.TAR_NAME }}
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build-linux-x86_64, build-linux-arm64, build-macos, build-windows]
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
path: ./artifacts
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
uses: ncipollo/release-action@v1
|
uses: ncipollo/release-action@v1
|
||||||
@@ -139,7 +235,5 @@ jobs:
|
|||||||
name: Release ${{ github.ref_name }}
|
name: Release ${{ github.ref_name }}
|
||||||
body: Automated release based on tag ${{ github.ref_name }}
|
body: Automated release based on tag ${{ github.ref_name }}
|
||||||
draft: false
|
draft: false
|
||||||
updateOnlyUnreleased: true
|
prerelease: ${{ startsWith(github.ref_name, 'prerelease-') }}
|
||||||
replacesArtifacts: true
|
artifacts: "./artifacts/*"
|
||||||
prerelease: ${{ runner.os == 'Windows' && steps.prerelease_check_win.outputs.prerelease || steps.prerelease_check_unix.outputs.prerelease }}
|
|
||||||
artifacts: ${{ env.TAR_NAME }}
|
|
||||||
@@ -52,14 +52,12 @@ find_package(BDWgc REQUIRED)
|
|||||||
find_package(gmp REQUIRED)
|
find_package(gmp REQUIRED)
|
||||||
|
|
||||||
target_compile_options(argon PRIVATE -O3 -Wall -Wextra -Wno-unused-function -s)
|
target_compile_options(argon PRIVATE -O3 -Wall -Wextra -Wno-unused-function -s)
|
||||||
if(NOT APPLE)
|
|
||||||
target_link_options(argon PRIVATE -static)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(argon PRIVATE
|
target_link_libraries(argon PRIVATE
|
||||||
BDWgc::BDWgc
|
BDWgc::BDWgc
|
||||||
gmp::gmp
|
gmp::gmp
|
||||||
m
|
m
|
||||||
|
$<$<PLATFORM_ID:Windows>:bcrypt>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(argon PRIVATE
|
target_include_directories(argon PRIVATE
|
||||||
|
|||||||
23
Makefile
23
Makefile
@@ -2,26 +2,31 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
# Default FLEX tool
|
||||||
|
BINARY = bin/argon
|
||||||
|
FLEX_TOOL = flex
|
||||||
|
|
||||||
|
CFILES = external/xxhash/xxhash.c external/cwalk/src/cwalk.c external/libdye/src/dye.c $(shell find src -name '*.c')
|
||||||
|
|
||||||
LEXER_SRC = src/lexer/lex.l
|
LEXER_SRC = src/lexer/lex.l
|
||||||
LEXER_C = src/lexer/lex.yy.c
|
LEXER_C = src/lexer/lex.yy.c
|
||||||
LEXER_H = src/lexer/lex.yy.h
|
LEXER_H = src/lexer/lex.yy.h
|
||||||
|
|
||||||
CFILES = external/xxhash/xxhash.c external/cwalk/src/cwalk.c external/libdye/src/dye.c $(shell find src -name '*.c')
|
|
||||||
CFLAGS = $(ARCHFLAGS) -lm -lgc -lgmp -Wall -Wextra -Wno-unused-function -Werror=unused-result -Iexternal/cwalk/include -Iexternal/libdye/include
|
CFLAGS = $(ARCHFLAGS) -lm -lgc -lgmp -Wall -Wextra -Wno-unused-function -Werror=unused-result -Iexternal/cwalk/include -Iexternal/libdye/include
|
||||||
BINARY = bin/argon
|
LDFLAGS = -lgc -lgmp -lm
|
||||||
|
|
||||||
all: $(BINARY)
|
all: $(BINARY)
|
||||||
|
|
||||||
|
|
||||||
$(LEXER_C) $(LEXER_H): $(LEXER_SRC)
|
$(LEXER_C) $(LEXER_H): $(LEXER_SRC)
|
||||||
flex --header-file=$(LEXER_H) -o $(LEXER_C) $(LEXER_SRC)
|
$(FLEX_TOOL) --header-file=$(LEXER_H) -o $(LEXER_C) $(LEXER_SRC)
|
||||||
|
|
||||||
$(BINARY): $(CFILES) $(LEXER_C) $(LEXER_H)
|
$(BINARY): $(CFILES) $(LEXER_C) $(LEXER_H)
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
gcc -O3 -o $(BINARY) $(CFILES) $(CFLAGS) -s
|
gcc -O3 -o $(BINARY) $(CFILES) $(CFLAGS) ${LDFLAGS} -s
|
||||||
|
|
||||||
native: $(CFILES) $(LEXER_C) $(LEXER_H)
|
native: $(CFILES) $(LEXER_C) $(LEXER_H)
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
gcc -O3 -march=native -o $(BINARY) $(CFILES) $(CFLAGS)
|
gcc -O3 -march=native -o $(BINARY) $(CFILES) $(CFLAGS) ${LDFLAGS}
|
||||||
|
|
||||||
debug: $(CFILES) $(LEXER_C) $(LEXER_H)
|
debug: $(CFILES) $(LEXER_C) $(LEXER_H)
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
@@ -29,13 +34,13 @@ debug: $(CFILES) $(LEXER_C) $(LEXER_H)
|
|||||||
|
|
||||||
full-debug: $(CFILES) $(LEXER_C) $(LEXER_H)
|
full-debug: $(CFILES) $(LEXER_C) $(LEXER_H)
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
gcc -g -O0 -fsanitize=address -fno-omit-frame-pointer -o $(BINARY) $(CFILES) $(CFLAGS)
|
gcc -g -O0 -fsanitize=address -fno-omit-frame-pointer -o $(BINARY) $(CFILES) $(CFLAGS) ${LDFLAGS}
|
||||||
|
|
||||||
optimised: $(CFILES) $(LEXER_C) $(LEXER_H)
|
optimised: $(CFILES) $(LEXER_C) $(LEXER_H)
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
gcc -O3 -fprofile-generate -o $(BINARY) $(CFILES) $(CFLAGS)
|
gcc -O3 -fprofile-generate -o $(BINARY) $(CFILES) $(CFLAGS) ${LDFLAGS}
|
||||||
${BINARY} rand_test.ar
|
${BINARY} rand_test.ar
|
||||||
gcc -O3 -fprofile-use -o $(BINARY) $(CFILES) $(CFLAGS)
|
gcc -O3 -fprofile-use -o $(BINARY) $(CFILES) $(CFLAGS) ${LDFLAGS}
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
12
conanfile.py
12
conanfile.py
@@ -30,16 +30,12 @@ class ArgonConan(ConanFile):
|
|||||||
self.folders.generators = "build"
|
self.folders.generators = "build"
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
|
os.environ["CONAN_NON_INTERACTIVE"] = "1"
|
||||||
tc = CMakeToolchain(self)
|
tc = CMakeToolchain(self)
|
||||||
|
|
||||||
if os.name == "nt": # Windows
|
flex_path = which("flex")
|
||||||
flex_path = which("win_flex") or which("win_flex.exe")
|
if not flex_path:
|
||||||
if not flex_path:
|
raise Exception("Flex not found in system PATH. Please install flex on Linux/macOS.")
|
||||||
raise Exception("win_flex not found in PATH. Install winflexbison via choco.")
|
|
||||||
else:
|
|
||||||
flex_path = which("flex")
|
|
||||||
if not flex_path:
|
|
||||||
raise Exception("Flex not found in system PATH. Please install flex on Linux/macOS.")
|
|
||||||
|
|
||||||
tc.variables["FLEX_EXECUTABLE"] = flex_path.replace("\\", "\\\\")
|
tc.variables["FLEX_EXECUTABLE"] = flex_path.replace("\\", "\\\\")
|
||||||
tc.generate()
|
tc.generate()
|
||||||
|
|||||||
12
mingw-profile.txt
Normal file
12
mingw-profile.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[settings]
|
||||||
|
os=Windows
|
||||||
|
compiler=gcc
|
||||||
|
compiler.version=12
|
||||||
|
compiler.libcxx=libstdc++11
|
||||||
|
compiler.threads=posix
|
||||||
|
compiler.exception=seh
|
||||||
|
arch=x86_64
|
||||||
|
build_type=Release
|
||||||
|
|
||||||
|
[tool_requires]
|
||||||
|
mingw-builds/12.2.0
|
||||||
95
src/main.c
95
src/main.c
@@ -11,6 +11,7 @@
|
|||||||
#include "lexer/token.h"
|
#include "lexer/token.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "parser/parser.h"
|
#include "parser/parser.h"
|
||||||
|
#include "returnTypes.h"
|
||||||
#include "runtime/runtime.h"
|
#include "runtime/runtime.h"
|
||||||
#include "translator/translator.h"
|
#include "translator/translator.h"
|
||||||
|
|
||||||
@@ -66,8 +67,9 @@ static inline uint64_t htole64(uint64_t x) { return x; }
|
|||||||
#define htole64(x) OSSwapHostToLittleInt64(x)
|
#define htole64(x) OSSwapHostToLittleInt64(x)
|
||||||
#define le64toh(x) OSSwapLittleToHostInt64(x)
|
#define le64toh(x) OSSwapLittleToHostInt64(x)
|
||||||
// Add others as needed
|
// Add others as needed
|
||||||
#else
|
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||||
#error "Unsupported platform"
|
#include <stdlib.h>
|
||||||
|
#include <sys/endian.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *get_current_directory() {
|
char *get_current_directory() {
|
||||||
@@ -158,7 +160,7 @@ int load_cache(Translated *translated_dest, char *joined_paths, uint64_t hash,
|
|||||||
char *source_path) {
|
char *source_path) {
|
||||||
FILE *bytecode_file = fopen(joined_paths, "rb");
|
FILE *bytecode_file = fopen(joined_paths, "rb");
|
||||||
if (!bytecode_file) {
|
if (!bytecode_file) {
|
||||||
fprintf(stderr,"cache doesnt exist... compiling from source.\n");
|
fprintf(stderr, "cache doesnt exist... compiling from source.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +196,7 @@ int load_cache(Translated *translated_dest, char *joined_paths, uint64_t hash,
|
|||||||
XXH64_freeState(state);
|
XXH64_freeState(state);
|
||||||
|
|
||||||
if (calc_hash != stored_hash) {
|
if (calc_hash != stored_hash) {
|
||||||
fprintf(stderr,"cache hash mismatch (corrupted?)\n");
|
fprintf(stderr, "cache hash mismatch (corrupted?)\n");
|
||||||
goto FAILED;
|
goto FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,27 +270,29 @@ int load_cache(Translated *translated_dest, char *joined_paths, uint64_t hash,
|
|||||||
goto FAILED;
|
goto FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr,"cache exists and is valid, so will be used.\n");
|
fprintf(stderr, "cache exists and is valid, so will be used.\n");
|
||||||
fclose(bytecode_file);
|
fclose(bytecode_file);
|
||||||
return 0;
|
return 0;
|
||||||
FAILED:
|
FAILED:
|
||||||
fprintf(stderr,"cache is invalid... compiling from source.\n");
|
fprintf(stderr, "cache is invalid... compiling from source.\n");
|
||||||
fclose(bytecode_file);
|
fclose(bytecode_file);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Execution execute(char *path, Stack *stack) {
|
Translated load_argon_file(char *path, ArErr *err) {
|
||||||
clock_t start, end;
|
clock_t start, end;
|
||||||
|
clock_t beginning = clock();
|
||||||
double time_spent, total_time_spent = 0;
|
double time_spent, total_time_spent = 0;
|
||||||
|
|
||||||
const char *basename_ptr;
|
const char *basename_ptr;
|
||||||
size_t basename_length;
|
size_t basename_length;
|
||||||
cwk_path_get_basename(path, &basename_ptr, &basename_length);
|
cwk_path_get_basename(path, &basename_ptr, &basename_length);
|
||||||
|
|
||||||
if (!basename_ptr)
|
if (!basename_ptr) {
|
||||||
return (Execution){create_err(0, 0, 0, NULL, "Path Error",
|
*err = create_err(0, 0, 0, NULL, "Path Error", "path has no basename '%s'",
|
||||||
"path has no basename '%s'", path),
|
path);
|
||||||
(Stack){NULL, NULL}};
|
return (Translated){};
|
||||||
|
}
|
||||||
|
|
||||||
char basename[FILENAME_MAX];
|
char basename[FILENAME_MAX];
|
||||||
memcpy(basename, basename_ptr, basename_length);
|
memcpy(basename, basename_ptr, basename_length);
|
||||||
@@ -312,9 +316,9 @@ Execution execute(char *path, Stack *stack) {
|
|||||||
|
|
||||||
FILE *file = fopen(path, "r");
|
FILE *file = fopen(path, "r");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return (Execution){create_err(0, 0, 0, NULL, "File Error",
|
*err = create_err(0, 0, 0, NULL, "File Error", "Unable to open file '%s'",
|
||||||
"Unable to open file '%s'", path),
|
path);
|
||||||
(Stack){NULL, NULL}};
|
return (Translated){};
|
||||||
}
|
}
|
||||||
|
|
||||||
XXH3_state_t *hash_state = XXH3_createState();
|
XXH3_state_t *hash_state = XXH3_createState();
|
||||||
@@ -338,15 +342,14 @@ Execution execute(char *path, Stack *stack) {
|
|||||||
|
|
||||||
LexerState state = {path, file, 0, 0, &tokens};
|
LexerState state = {path, file, 0, 0, &tokens};
|
||||||
start = clock();
|
start = clock();
|
||||||
ArErr err = lexer(state);
|
*err = lexer(state);
|
||||||
if (err.exists) {
|
if (err->exists) {
|
||||||
darray_free(&tokens, free_token);
|
darray_free(&tokens, free_token);
|
||||||
return (Execution){err, (Stack){NULL, NULL}};
|
return (Translated){};
|
||||||
}
|
}
|
||||||
end = clock();
|
end = clock();
|
||||||
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
|
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
|
||||||
total_time_spent += time_spent;
|
fprintf(stderr, "Lexer time taken: %f seconds\n", time_spent);
|
||||||
fprintf(stderr,"Lexer time taken: %f seconds\n", time_spent);
|
|
||||||
fclose(state.file);
|
fclose(state.file);
|
||||||
|
|
||||||
DArray ast;
|
DArray ast;
|
||||||
@@ -354,33 +357,31 @@ Execution execute(char *path, Stack *stack) {
|
|||||||
darray_init(&ast, sizeof(ParsedValue));
|
darray_init(&ast, sizeof(ParsedValue));
|
||||||
|
|
||||||
start = clock();
|
start = clock();
|
||||||
err = parser(path, &ast, &tokens, false);
|
*err = parser(path, &ast, &tokens, false);
|
||||||
if (err.exists) {
|
if (err->exists) {
|
||||||
darray_free(&tokens, free_token);
|
darray_free(&tokens, free_token);
|
||||||
darray_free(&ast, free_parsed);
|
darray_free(&ast, free_parsed);
|
||||||
return (Execution){err, (Stack){NULL, NULL}};
|
return (Translated){};
|
||||||
}
|
}
|
||||||
end = clock();
|
end = clock();
|
||||||
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
|
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
|
||||||
total_time_spent += time_spent;
|
fprintf(stderr, "Parser time taken: %f seconds\n", time_spent);
|
||||||
fprintf(stderr,"Parser time taken: %f seconds\n", time_spent);
|
|
||||||
darray_free(&tokens, free_token);
|
darray_free(&tokens, free_token);
|
||||||
|
|
||||||
start = clock();
|
start = clock();
|
||||||
|
|
||||||
translated = init_translator(path);
|
translated = init_translator(path);
|
||||||
err = translate(&translated, &ast);
|
*err = translate(&translated, &ast);
|
||||||
if (err.exists) {
|
if (err->exists) {
|
||||||
darray_free(&translated.bytecode, NULL);
|
darray_free(&translated.bytecode, NULL);
|
||||||
free(translated.constants.data);
|
free(translated.constants.data);
|
||||||
hashmap_free(translated.constants.hashmap, NULL);
|
hashmap_free(translated.constants.hashmap, NULL);
|
||||||
darray_free(&ast, free_parsed);
|
darray_free(&ast, free_parsed);
|
||||||
return (Execution){err, (Stack){NULL, NULL}};
|
return (Translated){};
|
||||||
}
|
}
|
||||||
end = clock();
|
end = clock();
|
||||||
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
|
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
|
||||||
total_time_spent += time_spent;
|
fprintf(stderr, "Translation time taken: %f seconds\n", time_spent);
|
||||||
fprintf(stderr,"Translation time taken: %f seconds\n", time_spent);
|
|
||||||
|
|
||||||
darray_free(&ast, free_parsed);
|
darray_free(&ast, free_parsed);
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
@@ -444,18 +445,10 @@ Execution execute(char *path, Stack *stack) {
|
|||||||
gc_translated.constants.capacity = translated.constants.capacity;
|
gc_translated.constants.capacity = translated.constants.capacity;
|
||||||
darray_free(&translated.bytecode, NULL);
|
darray_free(&translated.bytecode, NULL);
|
||||||
free(translated.constants.data);
|
free(translated.constants.data);
|
||||||
|
total_time_spent = (double)(clock() - beginning) / CLOCKS_PER_SEC;
|
||||||
start = clock();
|
fprintf(stderr, "total time taken loading file (%s): %f seconds\n", path,
|
||||||
RuntimeState state = init_runtime_state(gc_translated, path);
|
total_time_spent);
|
||||||
Stack *main_scope = create_scope(stack);
|
return gc_translated;
|
||||||
ArErr err = runtime(gc_translated, state, main_scope);
|
|
||||||
end = clock();
|
|
||||||
time_spent = (double)(end - start) / CLOCKS_PER_SEC;
|
|
||||||
total_time_spent += time_spent;
|
|
||||||
fprintf(stderr,"Execution time taken: %f seconds\n", time_spent);
|
|
||||||
fprintf(stderr,"total time taken: %f seconds\n", total_time_spent);
|
|
||||||
|
|
||||||
return (Execution){err, *main_scope};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
@@ -472,11 +465,25 @@ int main(int argc, char *argv[]) {
|
|||||||
char path[FILENAME_MAX];
|
char path[FILENAME_MAX];
|
||||||
cwk_path_get_absolute(CWD, path_non_absolute, path, sizeof(path));
|
cwk_path_get_absolute(CWD, path_non_absolute, path, sizeof(path));
|
||||||
free(CWD);
|
free(CWD);
|
||||||
Execution resp = execute(path, Global_Scope);
|
ArErr err;
|
||||||
|
Translated translated = load_argon_file(path, &err);
|
||||||
|
if (err.exists) {
|
||||||
|
output_err(err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
clock_t start = clock(), end;
|
||||||
|
RuntimeState state = init_runtime_state(translated, path);
|
||||||
|
Stack *main_scope = create_scope(Global_Scope);
|
||||||
|
err = runtime(translated, state, main_scope);
|
||||||
|
|
||||||
|
end = clock();
|
||||||
|
double time_spent = (double)(end - start) / CLOCKS_PER_SEC;
|
||||||
|
fprintf(stderr, "Execution time taken: %f seconds\n", time_spent);
|
||||||
|
|
||||||
if (runtime_hash_table)
|
if (runtime_hash_table)
|
||||||
hashmap_free(runtime_hash_table, NULL);
|
hashmap_free(runtime_hash_table, NULL);
|
||||||
if (resp.err.exists) {
|
if (err.exists) {
|
||||||
output_err(resp.err);
|
output_err(err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// Your main thread code
|
// Your main thread code
|
||||||
|
|||||||
@@ -20,9 +20,4 @@ typedef struct ArErr {
|
|||||||
char type[32];
|
char type[32];
|
||||||
char message[ERR_MSG_MAX_LEN];
|
char message[ERR_MSG_MAX_LEN];
|
||||||
} ArErr;
|
} ArErr;
|
||||||
|
|
||||||
typedef struct Execution {
|
|
||||||
ArErr err;
|
|
||||||
Stack stack;
|
|
||||||
} Execution;
|
|
||||||
#endif // RETURN_TYPES_
|
#endif // RETURN_TYPES_
|
||||||
@@ -16,8 +16,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <psapi.h>
|
#ifndef _WIN32_WINNT
|
||||||
|
#define _WIN32_WINNT 0x0602
|
||||||
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <psapi.h>
|
||||||
|
|
||||||
double get_memory_usage_mb() {
|
double get_memory_usage_mb() {
|
||||||
PROCESS_MEMORY_COUNTERS pmc;
|
PROCESS_MEMORY_COUNTERS pmc;
|
||||||
|
|||||||
@@ -8,3 +8,8 @@ let say_hi(name) = do
|
|||||||
return "hello "+u+", how are you?"
|
return "hello "+u+", how are you?"
|
||||||
|
|
||||||
term.log(say_hi("william"))
|
term.log(say_hi("william"))
|
||||||
|
|
||||||
|
let a = 9
|
||||||
|
let b = 10
|
||||||
|
|
||||||
|
term.log(string(a)+'+'+string(b)+'='+string(a+b))
|
||||||
Reference in New Issue
Block a user