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

Add x86_64-apple-darwin target #480

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 18 additions & 0 deletions docker/Dockerfile.x86_64-apple-darwin
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM ubuntu:20.04

COPY common.sh /
RUN /common.sh

COPY cmake.sh /
RUN /cmake.sh

COPY xargo.sh /
RUN /xargo.sh

COPY darwin.sh /
RUN /darwin.sh

ENV CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=x86_64-apple-darwin14-clang \
CARGO_TARGET_X86_64_APPLE_DARWIN_AR=x86_64-apple-darwin14-ar \
CC_x86_64_apple_darwin=o64-clang \
CXX_x86_64_apple_darwin=o64-clang++
56 changes: 56 additions & 0 deletions docker/darwin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

set -x
set -euo pipefail

main() {
local dependencies=(
clang
curl
gcc
g++
make
patch
libmpc-dev
libmpfr-dev
libgmp-dev
libssl-dev
libxml2-dev
xz-utils
zlib1g-dev
)

apt-get update

# this must be installed first, otherwise an interactive prompt is
# triggered by another package install
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata

for dep in "${dependencies[@]}"; do
if ! dpkg -L "${dep}"; then
apt-get install --assume-yes --no-install-recommends "${dep}"
fi
done

cd /opt
git clone https://github.com/tpoechtrager/osxcross
cd osxcross
curl -L https://s3.dockerproject.org/darwin/v2/MacOSX10.10.sdk.tar.xz -o tarballs/MacOSX10.10.sdk.tar.xz
UNATTENDED=yes OSX_VERSION_MIN=10.7 ./build.sh
ln -s /opt/osxcross/target/bin/* /usr/local/bin/

local purge_list=(
curl
gcc
g++
make
patch
xz-utils
)

if (( ${#purge_list[@]} )); then
apt-get purge --assume-yes --auto-remove "${purge_list[@]}"
fi
}

main "${@}"
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Host {
if *self == Host::X86_64AppleDarwin {
target.map(|t| t.is_apple() || t.needs_docker()).unwrap_or(false)
} else if *self == Host::X86_64UnknownLinuxGnu {
target.map(|t| t.needs_docker()).unwrap_or(true)
target.map(|t| t.is_apple() || t.needs_docker()).unwrap_or(true)
} else if *self == Host::X86_64PcWindowsMsvc {
target.map(|t| t.triple() != Host::X86_64PcWindowsMsvc.triple() && t.needs_docker()).unwrap_or(false)
} else {
Expand Down Expand Up @@ -296,7 +296,12 @@ fn run() -> Result<ExitStatus> {
args.all.clone()
};

if image_exists && target.needs_docker() &&
let needs_docker = match host {
Host::X86_64UnknownLinuxGnu => target.needs_docker() || target.is_apple(),
_ => target.needs_docker(),
};

if image_exists && needs_docker &&
args.subcommand.map(|sc| sc.needs_docker()).unwrap_or(false) {
if version_meta.needs_interpreter() &&
needs_interpreter &&
Expand Down