Skip to content

Commit

Permalink
Revert "Generate 32 bit native engine binaries."
Browse files Browse the repository at this point in the history
This reverts commit 62beaf5.
  • Loading branch information
jsirois committed Nov 14, 2016
1 parent 62beaf5 commit 23f05de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 46 deletions.
44 changes: 9 additions & 35 deletions build-support/bin/native/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ function calculate_current_hash() {
git hash-object -t blob --stdin-paths | fingerprint_data
}

function ensure_build_prerequisites() {
# Control a pants-specific rust toolchain, optionally ensuring the given target toolchain is
# installed.
local readonly target=$1

function ensure_prerequisites() {
# Control a pants-specific rust toolchain.
export CARGO_HOME=${CACHE_ROOT}/rust-toolchain
export RUSTUP_HOME=${CARGO_HOME}

Expand All @@ -43,49 +40,26 @@ function ensure_build_prerequisites() {
rm -f ${rustup}
${RUSTUP_HOME}/bin/rustup override set stable 1>&2
fi

if [[ -n "${target}" ]]
then
if ! ${RUSTUP_HOME}/bin/rustup target list | grep -E "${target} \((default|installed)\)" &> /dev/null
then
${RUSTUP_HOME}/bin/rustup target add ${target}
fi
fi
}

function build_native_code() {
# Builds the native code, optionally taking an explicit target triple arg, and echos the path of
# the built binary.
local readonly target=$1
ensure_build_prerequisites ${target}

local readonly cargo="${CARGO_HOME}/bin/cargo"
local readonly build_cmd="${cargo} build --manifest-path ${NATIVE_ROOT}/Cargo.toml ${MODE_FLAG}"
if [[ -z "${target}" ]]
then
${build_cmd} || die
echo "${NATIVE_ROOT}/target/${MODE}/libengine.${LIB_EXTENSION}"
else
${build_cmd} --target ${target} || echo "FAILED to build for target ${target}"
echo "${NATIVE_ROOT}/target/${target}/${MODE}/libengine.${LIB_EXTENSION}"
fi
}

function bootstrap_native_code() {
# Bootstraps the native code and overwrites the native_engine_version to the resulting hash
# Bootstraps the native code and sets overwrites the native_engine_version to the resulting hash
# version if needed.

ensure_prerequisites

local native_engine_version="$(calculate_current_hash)"
local target_binary="${CACHE_TARGET_DIR}/${native_engine_version}/native-engine"
if [ ! -f "${target_binary}" ]
then
local readonly native_binary="$(build_native_code)"
${CARGO_HOME}/bin/cargo build --manifest-path ${NATIVE_ROOT}/Cargo.toml ${MODE_FLAG} || die

# Pick up Cargo.lock changes if any caused by the `cargo build`.
native_engine_version="$(calculate_current_hash)"
target_binary="${CACHE_TARGET_DIR}/${native_engine_version}/native-engine"

mkdir -p "$(dirname ${target_binary})"
cp "${native_binary}" ${target_binary}
mkdir -p $(dirname ${target_binary})
cp ${NATIVE_ROOT}/target/${MODE}/libengine.${LIB_EXTENSION} ${target_binary}

# NB: The resource file emitted/over-written below is used by the `Native` subsystem to default
# the native engine library version used by pants. More info can be read here:
Expand Down
17 changes: 6 additions & 11 deletions build-support/bin/native/generate-bintray-manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

readonly REPO_ROOT=$(cd $(dirname "${BASH_SOURCE[0]}") && cd ../../.. && pwd -P)

# Indirectly exports:
# Exports:
# + LIB_EXTENSION: The extension of native libraries.
# + OS_NAME: The name of the OS as seen by pants.
# + OS_ID: The ID of the current OS as seen by pants.
# Exposes `build_native_code` for building target-specific native engine binaries.
source ${REPO_ROOT}/build-support/bin/native/bootstrap.sh
source ${REPO_ROOT}/build-support/bin/native/detect_os.sh

# Bump this when there is a new OSX released:
readonly OSX_MAX_VERSION=12
Expand Down Expand Up @@ -75,16 +74,12 @@ EOF
}

function emit_linux_files() {
native_engine_32="$(build_native_code i686-unknown-linux-gnu)"
native_engine_64="$(build_native_code x86_64-unknown-linux-gnu)"
# TODO(John Sirois): We should either have a 32 bit linux node, or use docker to get this or
# use rustup to install a 32 bit rust platfrm and generate a second binary.
cat << EOF >> ${REPO_ROOT}/native-engine.bintray.json
{
"includePattern": "${native_engine_32}",
"uploadPattern": "build-support/bin/native-engine/linux/i386/${NATIVE_ENGINE_VERSION}/native-engine"
},
{
"includePattern": "${native_engine_64}",
"uploadPattern": "build-support/bin/native-engine/linux/x86_64/${NATIVE_ENGINE_VERSION}/native-engine"
"includePattern": "${CACHE_TARGET_DIR}/${OS_ID}/${NATIVE_ENGINE_VERSION}/native-engine",
"uploadPattern": "build-support/bin/native-engine/${OS_ID}/${NATIVE_ENGINE_VERSION}/native-engine"
}
EOF
}
Expand Down

0 comments on commit 23f05de

Please sign in to comment.