Skip to content
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8038c00
add libimagequant
ericphanson Mar 28, 2025
77dde2f
use vendored openssl for cargo-c (build time dep)
ericphanson Mar 28, 2025
2a40636
use openssl jll
ericphanson Mar 29, 2025
c96c8bc
Update L/libimagequant/build_tarballs.jl
ericphanson Mar 29, 2025
eb13cdf
Update L/libimagequant/build_tarballs.jl
ericphanson Mar 29, 2025
3ac0b3b
fix?
ericphanson Mar 29, 2025
eeb13a4
try setting CARGO_HOME
ericphanson Mar 29, 2025
653781a
compile cargo-c for host
ericphanson Mar 29, 2025
a9f1673
rust_host?
ericphanson Mar 29, 2025
8172686
update path
ericphanson Mar 29, 2025
7fad338
missing `=`
ericphanson Apr 7, 2025
b08d655
fix cargo-c version so installable on rust 1.83
ericphanson Apr 7, 2025
4a7a9a3
unset envs
ericphanson Apr 7, 2025
18d1b69
try to avoid the wrapper
ericphanson Apr 7, 2025
8dd5fbd
rm /opt from path for cargo-c install
ericphanson Apr 7, 2025
9fb3d85
set `CARGO_BUILD_TARGET` instead of modifying PATH
ericphanson Apr 7, 2025
a2c6b78
try to set `RUSTC`
ericphanson Apr 7, 2025
da58b41
try using BBB PR
ericphanson Apr 8, 2025
ec077a6
Merge remote-tracking branch 'origin/master' into eph/libimagequant
ericphanson Apr 8, 2025
249b9fe
bump PR commit
ericphanson Apr 8, 2025
d9f06e6
use `--locked` to avoid too-new cargo-c deps
ericphanson Apr 8, 2025
8088047
Merge branch 'master' into eph/libimagequant
ericphanson Nov 24, 2025
70e64be
Update L/libimagequant/build_tarballs.jl
ericphanson Nov 24, 2025
6553ad5
switch back to branch
ericphanson Nov 27, 2025
5828214
bump commit
ericphanson Nov 27, 2025
515a266
up
ericphanson Nov 27, 2025
7adc969
try to skip wrappers
ericphanson Nov 27, 2025
7d6e8c6
fix?
ericphanson Nov 28, 2025
f68320e
try different approach
ericphanson Nov 29, 2025
68411df
apply patch in right spot (?)
ericphanson Nov 29, 2025
570c777
fix patch
ericphanson Nov 29, 2025
1de1218
fix
ericphanson Nov 29, 2025
0f16686
fixes
ericphanson Nov 29, 2025
49cc2dc
fix path
ericphanson Nov 29, 2025
b38643e
build for all platforms
ericphanson Nov 29, 2025
43c3662
switch to release
ericphanson Nov 29, 2025
0a50bcf
try disabling rayon
ericphanson Nov 29, 2025
37065d2
try
ericphanson Nov 29, 2025
9c6a3ac
fix patch
ericphanson Nov 29, 2025
8d3340f
fix?
ericphanson Nov 29, 2025
c12fc18
try macos
ericphanson Nov 29, 2025
677ad1e
try...
ericphanson Nov 29, 2025
5c29c00
patch out `links` too
ericphanson Nov 29, 2025
5f9192c
go back and try a different thing
ericphanson Nov 29, 2025
33618c0
ok run on all platforms!
ericphanson Nov 29, 2025
5662bbc
try to support musl
ericphanson Nov 29, 2025
bb02265
try to fix windows
ericphanson Nov 29, 2025
5615e56
rm openssl
ericphanson Nov 29, 2025
a5353ae
Update L/libimagequant/build_tarballs.jl
ericphanson Nov 29, 2025
c376773
Update L/libimagequant/build_tarballs.jl
ericphanson Nov 29, 2025
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
62 changes: 62 additions & 0 deletions L/libimagequant/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Note that this script can accept some limited command-line arguments, run
# `julia build_tarballs.jl --help` to see a usage message.
using BinaryBuilder, BinaryBuilderBase

name = "libimagequant"
version = v"4.4.1"

# Collection of sources required to complete build
sources = [
GitSource(
"https://github.com/ImageOptim/libimagequant.git",
"24e2956a37cd7ad1f4b81c0e20318e3239eb71dc"),
DirectorySource("./bundled"),
]

# following https://github.com/ImageOptim/libimagequant/tree/main/imagequant-sys#building-for-c
script = raw"""
cd $WORKSPACE/srcdir/libimagequant/

# patch to create a dynamic library
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/cdylib.patch

cd $WORKSPACE/srcdir/libimagequant/imagequant-sys

# avoid 'cannot create cdylib' error on musl targets
# see https://github.com/rust-lang/cargo/issues/8607
# https://github.com/rust-lang/rust/issues/59302
if [[ "${target}" == *-musl* ]]; then
export RUSTFLAGS="-C target-feature=-crt-static"
fi

cargo build --release
install_license COPYRIGHT

# Install under a consistent name
install -Dvm 755 ../target/${rust_target}/release/*imagequant_sys.${dlext} "${libdir}/libimagequant.${dlext}"

# Install the C header
install -Dvm 644 libimagequant.h ${includedir}/libimagequant.h
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = supported_platforms()
# # Rust toolchain for i686 Windows is unusable
filter!(p -> !Sys.iswindows(p) || arch(p) != "i686", platforms)
# # Rust toolchain seems to not be available for RISC-V or FreeBSD/aarch64
filter!(p -> arch(p) != "riscv64", platforms)
filter!(p -> os(p) != "freebsd" || arch(p) != "aarch64", platforms)

# The products that we will ensure are always built
products = [
LibraryProduct("libimagequant", :libimagequant),
]

# Dependencies that must be installed before this package can be built
dependencies = [
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
julia_compat="1.6", compilers=[:c, :rust], lock_microarchitecture=false)
13 changes: 13 additions & 0 deletions L/libimagequant/bundled/patches/cdylib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/imagequant-sys/Cargo.toml b/imagequant-sys/Cargo.toml
index 50cb6e9..c5d5162 100644
--- a/imagequant-sys/Cargo.toml
+++ b/imagequant-sys/Cargo.toml
@@ -17,7 +17,7 @@ build = "build.rs"
rust-version = "1.63"

[lib]
-crate-type = ["staticlib", "lib"]
+crate-type = ["staticlib", "lib", "cdylib"]
doctest = false
path = "src/ffi.rs"
name = "imagequant_sys"