Compare commits

..

41 Commits

Author SHA1 Message Date
William Bell
fb8b6a89ae build for more architectures 2025-08-16 03:41:32 +01:00
William Bell
6ddf9953e7 change windows builds to tar.gz 2025-08-16 03:23:01 +01:00
William Bell
1609227a42 add bcrypt for windows 2025-08-16 03:10:50 +01:00
William Bell
51f6a88ce8 add profile to build 2025-08-16 03:00:01 +01:00
William Bell
f420273471 fix backslashes 2025-08-16 02:46:33 +01:00
William Bell
4b2a747338 use msys/flex 2025-08-16 02:36:47 +01:00
William Bell
5277814af0 fix conan 2025-08-16 02:31:15 +01:00
William Bell
8928ab2d99 add cmake as dependency 2025-08-16 02:20:57 +01:00
William Bell
d08b307c6e add python as a dependency 2025-08-16 02:12:55 +01:00
William Bell
6474329afc switch to conan for windows 2025-08-16 02:08:56 +01:00
William Bell
c49e67c839 switch windows to use conan 2025-08-16 02:04:00 +01:00
William Bell
25cb96e473 try get it to be static 2025-08-16 01:57:56 +01:00
William Bell
f11890a8b3 fix linking for linux and macos 2025-08-16 01:39:44 +01:00
William Bell
59b1d222c2 fix cmake 2025-08-16 01:32:57 +01:00
William Bell
2fba132016 make gc and gmp static and math dynamic 2025-08-16 01:22:08 +01:00
William Bell
bddc2cdc79 fix release to merge multiple 2025-08-16 01:06:06 +01:00
William Bell
e1b80b42d9 fix make release 2025-08-16 01:02:48 +01:00
William Bell
dab86925b4 fix winblows 2025-08-16 00:58:56 +01:00
William Bell
0f45052dce fix for winblows 2025-08-16 00:56:35 +01:00
William Bell
68f4207216 fix for winblows 2025-08-16 00:54:33 +01:00
William Bell
f9f8ca08c6 fix bug for windows 2025-08-16 00:50:23 +01:00
William Bell
0666b02c13 fix flex tool 2025-08-16 00:44:00 +01:00
William Bell
1654507835 fix for windows 2025-08-16 00:42:13 +01:00
William Bell
d054ece8e2 release 2025-08-16 00:39:37 +01:00
William Bell
4937942d6e fix release 2025-08-16 00:35:48 +01:00
William Bell
82ea92183f fix release 2025-08-16 00:28:08 +01:00
William Bell
5fb15b476f fix release 2025-08-16 00:26:26 +01:00
William Bell
d1a455dbbe fix release.yml 2025-08-16 00:07:10 +01:00
William Bell
a81640747d fix release.yml 2025-08-15 22:07:25 +01:00
William Bell
4a1ed23f96 fix release.yml 2025-08-15 22:05:57 +01:00
William Bell
eb36d02fcb fix release.yml 2025-08-15 22:03:23 +01:00
William Bell
7b3a1e1835 fix release.yml 2025-08-15 21:52:16 +01:00
William Bell
8e53579682 fix release.yml 2025-08-15 21:36:51 +01:00
William Bell
0d8f262185 this thing is really annoying me now 2025-08-15 21:34:31 +01:00
William Bell
fc6f41d89b fix release.yml 2025-08-15 21:30:01 +01:00
William Bell
6a7ce72eb7 fix cmake 2025-08-15 21:23:08 +01:00
William Bell
f84e5429a5 fix release.yml 2025-08-15 21:16:48 +01:00
William Bell
f4c7294267 fix release.yml 2025-08-15 21:14:17 +01:00
William Bell
be4b04a286 fix release.yml 2025-08-15 20:59:49 +01:00
William Bell
9d11122e93 fix conanfile.py 2025-08-15 20:50:58 +01:00
William Bell
241e447da0 fix release.yml 2025-08-15 20:30:54 +01:00
6 changed files with 231 additions and 139 deletions

View File

@@ -1,147 +1,215 @@
# 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:
runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] arch: [x86_64, arm64]
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
# Windows
- name: Install build tools (Windows)
if: runner.os == 'Windows'
run: |
choco install winflexbison mingw -y
shell: pwsh
- name: Checkout code
uses: actions/checkout@v3
with: with:
submodules: recursive submodules: recursive
- name: Setup Python (needed for Conan) - name: Install build tools
run: |
sudo apt-get update
sudo apt-get install -y flex bison make cmake build-essential
if [ "${{ matrix.arch }}" = "arm64" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
fi
- 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: | run: |
python -m pip install --upgrade pip BUILD_DIR="build_${{ matrix.arch }}"
pip install conan mkdir -p "$BUILD_DIR"
shell: pwsh cd "$BUILD_DIR"
- name: Configure Conan (Linux/macOS) if [ "${{ matrix.arch }}" = "arm64" ]; then
if: runner.os != 'Windows' export CC=aarch64-linux-gnu-gcc
run: conan profile detect export CXX=aarch64-linux-gnu-g++
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: |
conan install . --build=missing
conan build .
shell: bash
- name: Install dependencies and build (Windows)
if: runner.os == 'Windows'
run: |
conan install . \
-s compiler=gcc \
-s compiler.version=13 \
-s compiler.libcxx=libstdc++11 \
-s arch=x86_64 \
-s os=Windows \
--build=missing
conan install . \
-s compiler=gcc \
-s compiler.version=13 \
-s compiler.libcxx=libstdc++11 \
-s arch=x86_64 \
-s os=Windows \
--build=missing
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 fi
echo "prerelease=$(cat prerelease.txt)" >> $GITHUB_OUTPUT
shell: bash
- name: Determine if prerelease (Windows) conan install .. --build=missing
if: runner.os == 'Windows' conan build ..
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) cd ..
if: runner.os != 'Windows'
- name: Package
run: | run: |
TAG=${GITHUB_REF##refs/tags/} TAG=${GITHUB_REF##refs/tags/}
OS=$(uname -s | tr '[:upper:]' '[:lower:]') OS="linux"
ARCH=$(uname -m) ARCH="${{ matrix.arch }}"
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_${ARCH}/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-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: | run: |
$TAG = $env:GITHUB_REF -replace 'refs/tags/', '' python -m pip install --upgrade pip
$ARCH = if ([Environment]::Is64BitOperatingSystem) { 'x64' } else { 'x86' } pip install conan
$FOLDER_NAME = "chloride-$TAG-windows-$ARCH" conan profile detect
$TAR_NAME = "$FOLDER_NAME.zip"
Rename-Item build\bin $FOLDER_NAME - name: Build
Copy-Item LICENSE.txt $FOLDER_NAME run: |
Compress-Archive -Path $FOLDER_NAME -DestinationPath $TAR_NAME # Create a build directory per arch
echo "TAR_NAME=$TAR_NAME" >> $env:GITHUB_ENV BUILD_DIR="build_${{ matrix.arch }}"
shell: pwsh mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# Use the matrix architecture for the build
export CFLAGS="-arch ${{ matrix.arch }}"
export CXXFLAGS="-arch ${{ matrix.arch }}"
export LDFLAGS="-arch ${{ matrix.arch }}"
conan install .. --build=missing
conan build ..
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_${ARCH}/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
strategy:
matrix:
arch: [x86_64, arm64]
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup MSYS2
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: |
BUILD_DIR="build_${{ matrix.arch }}"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
if [ "${{ matrix.arch }}" = "arm64" ]; then
# Use the ARM64 cross-compiler
export CC=aarch64-w64-mingw32-gcc
export CXX=aarch64-w64-mingw32-g++
fi
conan install .. --profile mingw-profile.txt --build=missing
conan build .. --profile mingw-profile.txt
cd ..
- name: Package
run: |
TAG=${GITHUB_REF##refs/tags/}
OS="windows"
ARCH="${{ matrix.arch }}"
FOLDER="chloride-$TAG-$OS-$ARCH"
ZIP="$FOLDER.zip"
mv build_${ARCH}/bin "$FOLDER"
cp LICENSE.txt "$FOLDER"
powershell Compress-Archive -Path "$FOLDER" -DestinationPath "$ZIP"
echo "TAR_NAME=$ZIP" >> $GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.arch }}-artifact
path: ${{ env.TAR_NAME }}
release:
runs-on: ubuntu-latest
needs: [build-linux, 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
@@ -150,7 +218,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 }}

View File

@@ -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

View File

@@ -2,26 +2,43 @@
# #
# 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
ifeq ($(MAKECMDGOALS),windows)
LDFLAGS = -Wl,-Bstatic -lgc -lgmp -Wl,-Bdynamic -lm
endif
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
windows: $(CFILES) $(LEXER_C) $(LEXER_H)
(echo -n "external/xxhash/xxhash.c " ; \
echo -n "external/cwalk/src/cwalk.c " ; \
echo -n "external/libdye/src/dye.c " ; \
find src -name '*.c' -print0 | xargs -0 echo -n) > sources.txt
mkdir -p bin
gcc -O3 -march=native -o $(BINARY) @sources.txt $(CFLAGS) -lbcrypt
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 +46,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:

View File

@@ -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
View 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

View File

@@ -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;