Skip to content

Commit

Permalink
Adding solaris build artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
kenshaw committed Jan 18, 2024
1 parent ead81ac commit d3e2d9e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 10 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,26 @@ Build Darwin images:
$ git clone https://github.com/cross-rs/cross.git
$ cd cross && git submodule update --init --remote


# grab sdk
$ cd cross/docker/cross-toolchains/docker
$ export SDK='https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz'
$ curl -O -J -L "$SDK"

# NOTE: 14.2 (what's generated below) doesn't seem to work with the
# NOTE: build-docker-image command below

# download sdk from apple at https://developer.apple.com/download/all/?q=xcode
# then use osxcross to generate the sdk
# https://github.com/tpoechtrager/osxcross?tab=readme-ov-file#packaging-the-sdk
$ git clone https://github.com/tpoechtrager/osxcross.git && cd osxcross
$ ./tools/gen_sdk_package_pbzx.sh ~/Downloads/Xcode_15.2.xip

# build containers
$ cd cross
$ cargo build-docker-image x86_64-apple-darwin-cross --build-arg "MACOS_SDK_FILE='$(basename $SDK)'"
$ cargo build-docker-image aarch64-apple-darwin-cross --build-arg "MACOS_SDK_FILE='$(basename $SDK)'"
$ mv /path/to/MacOSX11.3.sdk.tar.xz docker/
$ cargo build-docker-image x86_64-apple-darwin-cross --build-arg 'MACOS_SDK_FILE=MacOSX11.3.sdk.tar.xz'
$ cargo build-docker-image aarch64-apple-darwin-cross --build-arg 'MACOS_SDK_FILE=MacOSX11.3.sdk.tar.xz'

# add rust toolchains
$ rustup target add x86_64-apple-darwin
Expand Down
44 changes: 36 additions & 8 deletions gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ SRC=$(realpath $(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd))

set -e

WORKDIR=$HOME/src/vega
WORKDIR=$HOME/src/charts

BUILD_TARGETS=""

OPTIND=1
while getopts "t:" opt; do
case "$opt" in
t) BUILD_TARGETS="$OPTARG" ;;
esac
done

mkdir -p $WORKDIR

Expand Down Expand Up @@ -38,14 +47,27 @@ git_checkout_reset() {
git_checkout_reset resvg "https://github.com/${REPO}.git"

declare -A TARGETS=(
[darwin_amd64]=x86_64-apple-darwin
[darwin_arm64]=aarch64-apple-darwin
# [darwin_amd64]=x86_64-apple-darwin
# [linux_amd64]=x86_64-unknown-linux-gnu
# [linux_arm64]=aarch64-unknown-linux-gnu
# [linux_arm]=armv7-unknown-linux-gnueabihf
# [windows_amd64]=x86_64-pc-windows-gnu
[freebsd_amd64]=x86_64-unknown-freebsd
[linux_amd64]=x86_64-unknown-linux-gnu
[linux_arm64]=aarch64-unknown-linux-gnu
[linux_arm]=armv7-unknown-linux-gnueabihf
[netbsd_amd64]=x86_64-unknown-netbsd
[solaris_amd64]=x86_64-sun-solaris
[windows_amd64]=x86_64-pc-windows-gnu
[windows_arm64]=aarch64-pc-windows-msvc
)

#[openbsd_amd64]=
#[dragonfly_amd64]=

if [ -z "$BUILD_TARGETS" ]; then
BUILD_TARGETS="${!TARGETS[@]}"
fi

BUILD_TARGETS=$(sed -e 's/\s\+/\n/g' <<< "$BUILD_TARGETS" | sort -i |tr '\n' ' ')

for f in $(find $WORKDIR/resvg -type f -name Cargo.toml); do
cat > $(dirname "$f")/Cross.toml << __END__
[target.x86_64-apple-darwin]
Expand All @@ -57,12 +79,18 @@ __END__
done

pushd $WORKDIR/resvg/crates/c-api &> /dev/null
for TARGET in "${!TARGETS[@]}"; do
for TARGET in $BUILD_TARGETS; do
DEST=$SRC/libresvg/$TARGET
mkdir -p $DEST
RUST_TARGET="${TARGETS[$TARGET]}"
(set -x;
if [ -z "$(rustup target list|grep "$RUST_TARGET"|grep installed)" ]; then
(set -x;
rustup target add $RUST_TARGET
)
fi
(
export "CARGO_TARGET_$(sed -e 's/-/_/g' <<< "$RUST_TARGET"|tr [:lower:] [:upper:])_RUSTFLAGS"="--print=native-static-libs"
set -x
cross build \
--verbose \
--release \
Expand Down
Binary file added libresvg/solaris_amd64/libresvg.a
Binary file not shown.
1 change: 1 addition & 0 deletions resvg.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package resvg
#cgo linux,amd64 LDFLAGS: -L${SRCDIR}/libresvg/linux_amd64 -lresvg -lm
#cgo linux,arm64 LDFLAGS: -L${SRCDIR}/libresvg/linux_arm64 -lresvg -lm
#cgo linux,arm LDFLAGS: -L${SRCDIR}/libresvg/linux_arm -lresvg -lm
#cgo solaris,amd64 LDFLAGS: -L${SRCDIR}/libresvg/solaris_amd64 -lresvg -lm
#cgo windows,amd64 LDFLAGS: -L${SRCDIR}/libresvg/windows_amd64 -lresvg -lm -lkernel32 -ladvapi32 -lbcrypt -lntdll -luserenv -lws2_32
#include <stdlib.h>
Expand Down

0 comments on commit d3e2d9e

Please sign in to comment.