Skip to content
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

Remove executable products and rename executable targets to kebab-case (fixes #21) #22

Open
wants to merge 3 commits 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
45 changes: 15 additions & 30 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,42 @@ let package = Package(
name: "jpeg",
products:
[
.library( name: "JPEG", targets: ["JPEG"]),
.executable(name: "fuzzer", targets: ["JPEGFuzzer"]),
.executable(name: "comparator", targets: ["JPEGComparator"]),
.executable(name: "unit-test", targets: ["JPEGUnitTests"]),
.executable(name: "regression-test", targets: ["JPEGRegressionTests"]),
.executable(name: "integration-test", targets: ["JPEGIntegrationTests"]),

.executable(name: "decode-basic", targets: ["JPEGDecodeBasic"]),
.executable(name: "encode-basic", targets: ["JPEGEncodeBasic"]),
.executable(name: "decode-advanced", targets: ["JPEGDecodeAdvanced"]),
.executable(name: "encode-advanced", targets: ["JPEGEncodeAdvanced"]),
.executable(name: "in-memory", targets: ["JPEGInMemory"]),
.executable(name: "decode-online", targets: ["JPEGDecodeOnline"]),
.executable(name: "recompress", targets: ["JPEGRecompress"]),
.executable(name: "rotate", targets: ["JPEGRotate"]),
.executable(name: "custom-color", targets: ["JPEGCustomColor"]),
.library(name: "JPEG", targets: ["JPEG"])
],
targets:
[
.target( name: "JPEG", path: "sources/jpeg"),
.executableTarget(name: "JPEGFuzzer", dependencies: ["JPEG"], path: "tests/fuzz",
.executableTarget(name: "fuzzer", dependencies: ["JPEG"], path: "tests/fuzz",
exclude:
[
"data/",
]
),
.executableTarget(name: "JPEGComparator", dependencies: ["JPEG"], path: "tests/compare"),
.executableTarget(name: "JPEGUnitTests", dependencies: ["JPEG"], path: "tests/unit"),
.executableTarget(name: "JPEGRegressionTests", dependencies: ["JPEG"], path: "tests/regression",
.executableTarget(name: "comparator", dependencies: ["JPEG"], path: "tests/compare"),
.executableTarget(name: "unit-test", dependencies: ["JPEG"], path: "tests/unit"),
.executableTarget(name: "regression-test", dependencies: ["JPEG"], path: "tests/regression",
exclude:
[
"gold/",
]
),
.executableTarget(name: "JPEGIntegrationTests", dependencies: ["JPEG"], path: "tests/integration",
.executableTarget(name: "integration-test", dependencies: ["JPEG"], path: "tests/integration",
exclude:
[
"decode/",
"encode/",
]
),

.executableTarget(name: "JPEGDecodeBasic", dependencies: ["JPEG"], path: "examples/decode-basic",
.executableTarget(name: "decode-basic", dependencies: ["JPEG"], path: "examples/decode-basic",
exclude:
[
"karlie-kwk-2019.jpg.rgb",
"karlie-kwk-2019.jpg",
"karlie-kwk-2019.jpg.rgb.png",
]
),
.executableTarget(name: "JPEGEncodeBasic", dependencies: ["JPEG"], path: "examples/encode-basic",
.executableTarget(name: "encode-basic", dependencies: ["JPEG"], path: "examples/encode-basic",
exclude:
[
"karlie-milan-sp12-2011-4-4-0-4.0.jpg",
Expand Down Expand Up @@ -94,7 +79,7 @@ let package = Package(
"karlie-milan-sp12-2011-4-4-4-0.125.jpg",
]
),
.executableTarget(name: "JPEGDecodeAdvanced", dependencies: ["JPEG"], path: "examples/decode-advanced",
.executableTarget(name: "decode-advanced", dependencies: ["JPEG"], path: "examples/decode-advanced",
exclude:
[
"karlie-2019.jpg-0.640x432.gray",
Expand All @@ -108,15 +93,15 @@ let package = Package(
"karlie-2019.jpg-0.640x432.gray.png",
]
),
.executableTarget(name: "JPEGEncodeAdvanced", dependencies: ["JPEG"], path: "examples/encode-advanced",
.executableTarget(name: "encode-advanced", dependencies: ["JPEG"], path: "examples/encode-advanced",
exclude:
[
"karlie-cfdas-2011.png.rgb",
"karlie-cfdas-2011.png",
"karlie-cfdas-2011.png.rgb.jpg",
]
),
.executableTarget(name: "JPEGInMemory", dependencies: ["JPEG"], path: "examples/in-memory",
.executableTarget(name: "in-memory", dependencies: ["JPEG"], path: "examples/in-memory",
exclude:
[
"karlie-2011.jpg.rgb.png",
Expand All @@ -125,7 +110,7 @@ let package = Package(
"karlie-2011.jpg.jpg",
]
),
.executableTarget(name: "JPEGDecodeOnline", dependencies: ["JPEG"], path: "examples/decode-online",
.executableTarget(name: "decode-online", dependencies: ["JPEG"], path: "examples/decode-online",
exclude:
[
"karlie-oscars-2017.jpg-9.rgb.png",
Expand Down Expand Up @@ -171,15 +156,15 @@ let package = Package(
"karlie-oscars-2017.jpg-difference-1.rgb",
]
),
.executableTarget(name: "JPEGRecompress", dependencies: ["JPEG"], path: "examples/recompress",
.executableTarget(name: "recompress", dependencies: ["JPEG"], path: "examples/recompress",
exclude:
[
"recompressed-requantized.jpg",
"original.jpg",
"recompressed-full-cycle.jpg",
]
),
.executableTarget(name: "JPEGRotate", dependencies: ["JPEG"], path: "examples/rotate",
.executableTarget(name: "rotate", dependencies: ["JPEG"], path: "examples/rotate",
exclude:
[
"karlie-kwk-wwdc-2017.jpg",
Expand All @@ -188,7 +173,7 @@ let package = Package(
"karlie-kwk-wwdc-2017-iv.jpg",
]
),
.executableTarget(name: "JPEGCustomColor", dependencies: ["JPEG"], path: "examples/custom-color",
.executableTarget(name: "custom-color", dependencies: ["JPEG"], path: "examples/custom-color",
exclude:
[
"output.jpg",
Expand Down
34 changes: 12 additions & 22 deletions utils/examples
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,9 @@ while [ "$1" != "" ] ; do
shift
done

for path in examples/*/ ; do
product=$(basename $path)
check "error: swift build failed" \
swift build -c $build_configuration --product $product

binaries=".build/$build_configuration"
if ! [ -f $binaries/$product ]; then
error "error: missing '$product' product"
fi
done

# run `decode-basic` example
check "error: runtime error" \
.build/$build_configuration/decode-basic
swift run -c $build_configuration decode-basic

for file in examples/decode-basic/*.jpg ; do
size=$(identify -format "%wx%h" jpg:$file)
Expand All @@ -59,11 +48,11 @@ done

# run `encode-basic` example
check "error: runtime error" \
.build/$build_configuration/encode-basic
swift run -c $build_configuration encode-basic

# run `decode-advanced` example
check "error: runtime error" \
.build/$build_configuration/decode-advanced
swift run -c $build_configuration decode-advanced

for file in examples/decode-advanced/*.gray ; do
size=$(echo $file | sed -r 's/.*\.([0-9]+)x([0-9]+)\.gray/\1x\2/')
Expand All @@ -76,11 +65,11 @@ done

# run `encode-advanced` example
check "error: runtime error" \
.build/$build_configuration/encode-advanced
swift run -c $build_configuration encode-advanced

# run `in-memory` example
check "error: runtime error" \
.build/$build_configuration/in-memory
swift run -c $build_configuration in-memory
for file in examples/in-memory/*.jpg ; do
if [ -f $file.rgb ]; then
size=$(identify -format "%wx%h" jpg:$file)
Expand All @@ -90,7 +79,7 @@ done

# run `decode-online` example
check "error: runtime error" \
.build/$build_configuration/decode-online
swift run -c $build_configuration decode-online
for file in examples/decode-online/*.jpg ; do
size=$(identify -format "%wx%h" jpg:$file)
done
Expand All @@ -100,19 +89,20 @@ done

# run `recompress` example
check "error: runtime error" \
.build/$build_configuration/recompress
swift run -c $build_configuration recompress

# run `rotate` example
check "error: runtime error" \
.build/$build_configuration/rotate examples/rotate/karlie-kwk-wwdc-2017.jpg examples/rotate/karlie-kwk-wwdc-2017-ii.jpg --rotation ii
swift run -c $build_configuration rotate examples/rotate/karlie-kwk-wwdc-2017.jpg examples/rotate/karlie-kwk-wwdc-2017-ii.jpg --rotation ii
recompress
check "error: runtime error" \
.build/$build_configuration/rotate examples/rotate/karlie-kwk-wwdc-2017.jpg examples/rotate/karlie-kwk-wwdc-2017-iii.jpg --rotation iii
swift run -c $build_configuration rotate examples/rotate/karlie-kwk-wwdc-2017.jpg examples/rotate/karlie-kwk-wwdc-2017-iii.jpg --rotation iii
check "error: runtime error" \
.build/$build_configuration/rotate examples/rotate/karlie-kwk-wwdc-2017.jpg examples/rotate/karlie-kwk-wwdc-2017-iv.jpg --rotation iv
swift run -c $build_configuration rotate examples/rotate/karlie-kwk-wwdc-2017.jpg examples/rotate/karlie-kwk-wwdc-2017-iv.jpg --rotation iv

# run `custom-color` example
check "error: runtime error" \
.build/$build_configuration/custom-color
swift run -c $build_configuration custom-color
for file in examples/custom-color/*.rgb ; do
convert -depth 16 -endian msb -size 1000x200 rgb:$file -depth 16 png:$file-16.png
convert -depth 16 -endian msb -size 1000x200 rgb:$file -depth 8 png:$file-8.png
Expand Down
14 changes: 2 additions & 12 deletions utils/fuzz-test
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,11 @@ done
jpeg_pattern=$prefix/*.$JPEG_EXTENSION
ycc_pattern=$prefix/*.$YCC_EXTENSION

check "error: swift build failed" \
swift build -c $build_configuration --product fuzzer
check "error: swift build failed" \
swift build -c $build_configuration --product comparator

binaries=".build/$build_configuration"
if ! [ -f $binaries/fuzzer ]; then
error "error: missing fuzzer tool"
fi

mkdir $prefix &> /dev/null
rm $jpeg_pattern &> /dev/null

check "error: test image generation failed" \
$binaries/fuzzer --count $count --path $prefix
swift run -c $build_configuration fuzzer --count $count --path $prefix

rm $ycc_pattern &> /dev/null

Expand All @@ -89,4 +79,4 @@ for file in $jpeg_pattern ; do
convert -depth 8 -define jpeg:dct-method=float "jpeg:$file" "ycbcr:$file.$YCC_EXTENSION"
done

$binaries/comparator $jpeg_pattern
swift run -c $build_configuration comparator $jpeg_pattern
10 changes: 1 addition & 9 deletions utils/integration-test
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,8 @@ while [ "$1" != "" ] ; do
shift
done

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

binaries=".build/$build_configuration"
if ! [ -f $binaries/$TOOL_NAME ]; then
error "error: missing $TOOL_NAME tool"
fi

check "error: test failures" \
$binaries/$TOOL_NAME
swift run -c $build_configuration $TOOL_NAME

data=(tests/integration/decode/*.jpg)
for file in ${data[@]} ; do
Expand Down
10 changes: 1 addition & 9 deletions utils/regression-test
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,5 @@ while [ "$1" != "" ] ; do
shift
done

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

binaries=".build/$build_configuration"
if ! [ -f $binaries/$TOOL_NAME ]; then
error "error: missing $TOOL_NAME tool"
fi

check "error: test failures" \
$binaries/$TOOL_NAME
swift run -c $build_configuration $TOOL_NAME
10 changes: 1 addition & 9 deletions utils/unit-test
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,5 @@ check()
"$@" || error "$message"
}

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

binaries=".build/debug"
if ! [ -f $binaries/$TOOL_NAME ]; then
error "error: missing $TOOL_NAME tool"
fi

check "error: test failures" \
$binaries/$TOOL_NAME
swift run -c debug $TOOL_NAME
Loading