Skip to content

Commit

Permalink
Merge pull request #1 from bildhuus/fix_mixed_arch_build
Browse files Browse the repository at this point in the history
Fix mixed architecture builds
  • Loading branch information
s-ludwig authored Jun 14, 2024
2 parents 1324de4 + 4e2b410 commit af9b8b8
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 6 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI

# Only triggers on pushes/PRs to master
on:
pull_request:
branches:
- master
push:
branches:
- master
- github_actions

jobs:
test-linux:
name: Unittests Linux
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
dc: [dmd-latest, ldc-latest]
arch: [x86_64]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: Install D compiler
uses: dlang-community/setup-dlang@v1
with:
compiler: ${{ matrix.dc }}

- name: Install gcc-multilib
run: |
sudo apt update
sudo apt install gcc-multilib -y
- name: Run tests
env:
ARCH: ${{matrix.arch}}
run: ./test.sh
shell: bash
test-macos:
name: Unittests macOS
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [macOS-13]
dc: [dmd-latest, ldc-latest]
arch: [x86_64]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: Install D compiler
uses: dlang-community/setup-dlang@v1
with:
compiler: ${{ matrix.dc }}

- name: Run tests
env:
ARCH: ${{matrix.arch}}
run: ./test.sh
shell: bash
test-windows:
name: Unittests Windows
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [windows-latest]
dc: [dmd-latest, ldc-latest]
arch: [x86_64]
include:
- { os: windows-latest, dc: dmd-latest, arch: x86_mscoff }

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- uses: ilammy/msvc-dev-cmd@v1

- name: Install D compiler
uses: dlang-community/setup-dlang@v2
with:
compiler: ${{ matrix.dc }}

- name: Run tests
env:
ARCH: ${{matrix.arch}}
run: ./test.sh
shell: bash
20 changes: 14 additions & 6 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ targetType "library"
extraDependecyFiles "sqlite3.c"

# Build with MSVC on Windows
preBuildCommands "cl /nologo /c ${SQLITE3D_PACKAGE_DIR}/sqlite3.c" platform="windows"
sourceFiles "sqlite3.obj" platform="windows"
preBuildCommands "cl /nologo /Ox /MT /c ${SQLITE3D_PACKAGE_DIR}/sqlite3.c /Fo:sqlite3-${ARCH}.obj" platform="windows"
sourceFiles "sqlite3-${ARCH}.obj" platform="windows"
libs "kernel32" platform="windows"

# Use Clang on all other systems
preBuildCommands "clang -c ${SQLITE3D_PACKAGE_DIR}/sqlite3.c -arch=x86" platform="posix-x86"
preBuildCommands "clang -c ${SQLITE3D_PACKAGE_DIR}/sqlite3.c -arch=x86-64" platform="posix-x86_64"
preBuildCommands "clang -c ${SQLITE3D_PACKAGE_DIR}/sqlite3.c -arch=arm64" platform="posix-aarch64"
sourceFiles "sqlite3.o" platform="posix"
# Linux
preBuildCommands "clang -c ${SQLITE3D_PACKAGE_DIR}/sqlite3.c --target=i386 -fPIC -o sqlite3-${PLATFORM}-${ARCH}.o" platform="linux-x86"
preBuildCommands "clang -c ${SQLITE3D_PACKAGE_DIR}/sqlite3.c --target=x86_64 -fPIC -o sqlite3-${PLATFORM}-${ARCH}.o" platform="linux-x86_64"
preBuildCommands "clang -c ${SQLITE3D_PACKAGE_DIR}/sqlite3.c --target=arm64 -fPIC -o sqlite3-${PLATFORM}-${ARCH}.o" platform="linux-aarch64"
# macOS
preBuildCommands "xcrun clang -isysroot \"`xcrun --show-sdk-path`\" -c \"${SQLITE3D_PACKAGE_DIR}/sqlite3.c\" --target=x86_64-apple-darwin -fPIC -o sqlite3-${PLATFORM}-${ARCH}.o" platform="osx-x86_64"
preBuildCommands "xcrun clang -isysroot \"`xcrun --show-sdk-path`\" -c \"${SQLITE3D_PACKAGE_DIR}/sqlite3.c\" --target=arm64-apple-darwin -fPIC -o sqlite3-${PLATFORM}-${ARCH}.o" platform="osx-aarch64"
# iOS
preBuildCommands "xcrun clang -isysroot \"`xcrun --show-sdk-path`\" -c \"${SQLITE3D_PACKAGE_DIR}/sqlite3.c\" --target=x86_64-apple-ios-simulator -fPIC -o sqlite3-${PLATFORM}-${ARCH}.o" platform="ios-x86_64"
preBuildCommands "xcrun clang -isysroot \"`xcrun --show-sdk-path`\" -c \"${SQLITE3D_PACKAGE_DIR}/sqlite3.c\" --target=arm64-apple-ios -fPIC -o sqlite3-${PLATFORM}-${ARCH}.o" platform="ios-aarch64"

sourceFiles "sqlite3-${PLATFORM}-${ARCH}.o" platform="posix"
12 changes: 12 additions & 0 deletions test.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/+ dub.sdl:
dependency "sqlite3d" path="."
+/
import sqlite3;

void main()
{
if (sqlite3_initialize() != SQLITE_OK)
assert(false, "Failed to initialize sqlite3");

sqlite3_shutdown();
}
5 changes: 5 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -xe

dub --single test.d -a $ARCH

0 comments on commit af9b8b8

Please sign in to comment.