Skip to content

static linux compilation #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 41 additions & 19 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,61 @@ name: tests

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
linux:
runs-on: ubuntu-24.04
name: Ubuntu 24.04
steps:
- name: Install Swift
uses: tayloraswift/swift-install-action@master
with:
swift-prefix: "swift-6.0.3-release/ubuntu2404/swift-6.0.3-RELEASE"
swift-id: "swift-6.0.3-RELEASE-ubuntu24.04"
- name: Install Swift
uses: tayloraswift/swift-install-action@master
with:
swift-prefix: "swift-6.0.3-release/ubuntu2404/swift-6.0.3-RELEASE"
swift-id: "swift-6.0.3-RELEASE-ubuntu24.04"

- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Install imagemagick
run: sudo apt install -y imagemagick
- name: Install imagemagick
run: sudo apt install -y imagemagick

- name: Run tests
run: Scripts/TestAll
- name: Run tests
run: Scripts/TestAll

linux-musl:
runs-on: ubuntu-24.04
name: Ubuntu 24.04
steps:
- name: Install Swift
uses: tayloraswift/swift-install-action@master
with:
swift-prefix: "swift-6.0.3-release/ubuntu2404/swift-6.0.3-RELEASE"
swift-id: "swift-6.0.3-RELEASE-ubuntu24.04"

- name: Checkout repository
uses: actions/checkout@v3

- name: Install imagemagick
run: sudo apt install -y imagemagick

- name: Install linux SDK
run: swift sdk install https://download.swift.org/swift-6.0.3-release/static-sdk/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz --checksum 67f765e0030e661a7450f7e4877cfe008db4f57f177d5a08a6e26fd661cdd0bd

- name: Run tests
run: Scripts/TestAll -b "--swift-sdk x86_64-swift-linux-musl"

macos:
runs-on: macos-15
name: macOS
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Install imagemagick
run: brew install imagemagick
- name: Install imagemagick
run: brew install imagemagick

- name: Run tests
run: Scripts/TestAll
- name: Run tests
run: Scripts/TestAll
27 changes: 25 additions & 2 deletions Scripts/TestAll
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,28 @@
set -e
swift --version

utils/tests
utils/examples -c release
DEFAULT_BUILD_FLAGS=""

usage()
{
echo "usage: Scripts/TestAll [OPTION...]
-b, --build-flags swift build additional command flags, default '$DEFAULT_BUILD_FLAGS'"
}

build_flags=$DEFAULT_BUILD_FLAGS

while [ "$1" != "" ] ; do
case $1 in
-b | --build-flags )
shift
build_flags=$1
;;
* )
usage
exit 1
esac
shift
done

utils/tests -b "$build_flags"
utils/examples -c release -b "$build_flags"
4 changes: 3 additions & 1 deletion Sources/JPEGSystem/os.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import JPEG

#if os(macOS)
import Darwin
#elseif os(Linux)
#elseif canImport(Glibc)
import Glibc
#elseif canImport(Musl)
import Musl
#elseif os(Android)
import Android
#else
Expand Down
11 changes: 9 additions & 2 deletions utils/examples
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash
DEFAULT_BUILD_CONFIGURATION="debug"
SCRIPT_NAME="examples"
DEFAULT_BUILD_FLAGS=""

usage()
{
echo "usage: utils/$SCRIPT_NAME [OPTION...]
-c, --configuration swift build configuration mode, default '$DEFAULT_BUILD_CONFIGURATION'"
-c, --configuration swift build configuration mode, default '$DEFAULT_BUILD_CONFIGURATION'
-b, --build-flags swift build additional command flags, default '$DEFAULT_BUILD_FLAGS'"
}

error()
Expand All @@ -23,21 +25,26 @@ check()
}

build_configuration=$DEFAULT_BUILD_CONFIGURATION
build_flags=$DEFAULT_BUILD_FLAGS

while [ "$1" != "" ] ; do
case $1 in
-c | --configuration )
shift
build_configuration=$1
;;
-b | --build-flags )
shift
build_flags=$1
;;
* )
usage
exit 1
esac
shift
done

swift build -c $build_configuration
swift build -c $build_configuration $build_flags

# run `DecodeBasic` example
check "error: runtime error" \
Expand Down
11 changes: 9 additions & 2 deletions utils/fuzz-test
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
DEFAULT_BUILD_CONFIGURATION="debug"
DEFAULT_COUNT="16"
DEFAULT_PREFIX="tests/fuzz/data"
DEFAULT_BUILD_FLAGS=""

usage()
{
echo "usage: utils/fuzz-test [OPTION...]
-c, --configuration swift build configuration mode, default '$DEFAULT_BUILD_CONFIGURATION'
-b, --build-flags swift build additional command flags, default '$DEFAULT_BUILD_FLAGS'
-n, --count number of 8x8 test jpegs to generate, default $DEFAULT_COUNT
-p, --prefix directory to write test images to, default '$DEFAULT_PREFIX'"
}
Expand Down Expand Up @@ -36,6 +38,7 @@ fi
prefix=$DEFAULT_PREFIX
count=$DEFAULT_COUNT
build_configuration=$DEFAULT_BUILD_CONFIGURATION
build_flags=$DEFAULT_BUILD_FLAGS

JPEG_DIRECTORY_NAME="jpeg"
YCC_DIRECTORY_NAME="ycc"
Expand All @@ -48,6 +51,10 @@ while [ "$1" != "" ] ; do
shift
build_configuration=$1
;;
-b | --build-flags )
shift
build_flags=$1
;;
-n | --count )
shift
count=$1
Expand All @@ -67,9 +74,9 @@ jpeg_pattern=$prefix/*.$JPEG_EXTENSION
ycc_pattern=$prefix/*.$YCC_EXTENSION

check "error: swift build failed" \
swift build -c $build_configuration --product JPEGFuzzer
swift build -c $build_configuration --product JPEGFuzzer $build_flags
check "error: swift build failed" \
swift build -c $build_configuration --product JPEGComparator
swift build -c $build_configuration --product JPEGComparator $build_flags

binaries=".build/$build_configuration"
if ! [ -f $binaries/JPEGFuzzer ]; then
Expand Down
11 changes: 9 additions & 2 deletions utils/integration-test
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash
DEFAULT_BUILD_CONFIGURATION="debug"
TOOL_NAME="JPEGIntegrationTests"
DEFAULT_BUILD_FLAGS=""

usage()
{
echo "usage: utils/$TOOL_NAME [OPTION...]
-c, --configuration swift build configuration mode, default '$DEFAULT_BUILD_CONFIGURATION'"
-c, --configuration swift build configuration mode, default '$DEFAULT_BUILD_CONFIGURATION'
-b, --build-flags swift build additional command flags, default '$DEFAULT_BUILD_FLAGS'"
}

error()
Expand All @@ -23,13 +25,18 @@ check()
}

build_configuration=$DEFAULT_BUILD_CONFIGURATION
build_flags=$DEFAULT_BUILD_FLAGS

while [ "$1" != "" ] ; do
case $1 in
-c | --configuration )
shift
build_configuration=$1
;;
-b | --build-flags )
shift
build_flags=$1
;;
* )
usage
exit 1
Expand All @@ -38,7 +45,7 @@ while [ "$1" != "" ] ; do
done

check "error: swift build failed" \
swift build -c $build_configuration --product $TOOL_NAME
swift build -c $build_configuration --product $TOOL_NAME $build_flags

binaries=".build/$build_configuration"
if ! [ -f $binaries/$TOOL_NAME ]; then
Expand Down
9 changes: 8 additions & 1 deletion utils/regression-test
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash
DEFAULT_BUILD_CONFIGURATION="debug"
TOOL_NAME="JPEGRegressionTests"
DEFAULT_BUILD_FLAGS=""

usage()
{
echo "usage: utils/$TOOL_NAME [OPTION...]
-c, --configuration swift build configuration mode, default '$DEFAULT_BUILD_CONFIGURATION'
-b, --build-flags swift build additional command flags, default '$DEFAULT_BUILD_FLAGS'
-u, --update remove and regenerate golden outputs (tests will fail)"
}

Expand All @@ -24,13 +26,18 @@ check()
}

build_configuration=$DEFAULT_BUILD_CONFIGURATION
build_flags=$DEFAULT_BUILD_FLAGS

while [ "$1" != "" ] ; do
case $1 in
-c | --configuration )
shift
build_configuration=$1
;;
-b | --build-flags )
shift
build_flags=$1
;;
-u | --update )
shift
gold=(tests/regression/gold/*.jpg.ycc)
Expand All @@ -51,7 +58,7 @@ while [ "$1" != "" ] ; do
done

check "error: swift build failed" \
swift build -c $build_configuration --product $TOOL_NAME
swift build -c $build_configuration --product $TOOL_NAME $build_flags

binaries=".build/$build_configuration"
if ! [ -f $binaries/$TOOL_NAME ]; then
Expand Down
31 changes: 27 additions & 4 deletions utils/tests
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
#!/bin/bash
SCRIPT_NAME="tests"
DEFAULT_BUILD_FLAGS=""

utils/unit-test || exit 1
utils/integration-test -c release || exit 1
utils/regression-test -c release || exit 1
utils/fuzz-test -c release -n 16 || exit 1
usage()
{
echo "usage: utils/$SCRIPT_NAME [OPTION...]
-b, --build-flags swift build additional command flags, default '$DEFAULT_BUILD_FLAGS'"
}

build_flags=$DEFAULT_BUILD_FLAGS

while [ "$1" != "" ] ; do
case $1 in
-b | --build-flags )
shift
build_flags=$1
;;
* )
usage
exit 1
esac
shift
done

utils/unit-test -b "$build_flags" || exit 1
utils/integration-test -c release -b "$build_flags" || exit 1
utils/regression-test -c release -b "$build_flags" || exit 1
utils/fuzz-test -c release -n 16 -b "$build_flags" || exit 1
26 changes: 25 additions & 1 deletion utils/unit-test
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash
TOOL_NAME="JPEGUnitTests"
SCRIPT_NAME="unit-test"
DEFAULT_BUILD_FLAGS=""

error()
{
echo $1
Expand All @@ -14,8 +17,29 @@ check()
"$@" || error "$message"
}

usage()
{
echo "usage: utils/$SCRIPT_NAME [OPTION...]
-b, --build-flags swift build additional command flags, default '$DEFAULT_BUILD_FLAGS'"
}

build_flags=$DEFAULT_BUILD_FLAGS

while [ "$1" != "" ] ; do
case $1 in
-b | --build-flags )
shift
build_flags=$1
;;
* )
usage
exit 1
esac
shift
done

check "error: swift build failed" \
swift build -c release --product $TOOL_NAME
swift build -c release --product $TOOL_NAME $build_flags

binaries=".build/release"
if ! [ -f $binaries/$TOOL_NAME ]; then
Expand Down