Skip to content
Closed
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
58 changes: 34 additions & 24 deletions ci/scripts/r_windows_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,28 @@

set -ex

: ${ARROW_HOME:=$(pwd)}
# SC2223: Quote the default assignment to prevent globbing
: "${ARROW_HOME:=$(pwd)}"
# Make sure it is absolute and exported
export ARROW_HOME="$(cd "${ARROW_HOME}" && pwd)"
# SC2155: Declare and assign separately to avoid masking return values
ARROW_HOME="$(cd "${ARROW_HOME}" && pwd)"
export ARROW_HOME

pacman --noconfirm -Syy

RWINLIB_LIB_DIR="lib"
: ${MINGW_ARCH:="mingw32 mingw64 ucrt64"}
# SC2034: Removed unused variable RWINLIB_LIB_DIR
# SC2223: Quote the default assignment to prevent globbing
: "${MINGW_ARCH:="mingw32 mingw64 ucrt64"}"

export MINGW_ARCH

cp $ARROW_HOME/ci/scripts/PKGBUILD .
# SC2086: Double quote to prevent globbing and word splitting
cp "$ARROW_HOME/ci/scripts/PKGBUILD" .
printenv
makepkg-mingw --noconfirm --noprogressbar --skippgpcheck --nocheck --syncdeps --cleanbuild

VERSION=$(grep Version $ARROW_HOME/r/DESCRIPTION | cut -d " " -f 2)
# SC2086: Double quote to prevent globbing and word splitting
VERSION=$(grep Version "$ARROW_HOME/r/DESCRIPTION" | cut -d " " -f 2)
DST_DIR="r-libarrow-windows-x86_64-$VERSION"

# Collect the build artifacts and make the shape of zip file that rwinlib expects
Expand All @@ -47,47 +53,51 @@ cd build
MSYS_LIB_DIR="/c/rtools${RTOOLS_VERSION}"

# Untar the builds we made
ls *.xz | xargs -n 1 tar -xJf
mkdir -p $DST_DIR
# SC2011: Use find -print0 | xargs -0 to handle non-alphanumeric filenames
# SC2035: Use ./* glob so names with dashes won't become options
find . -maxdepth 1 -name "*.xz" -print0 | xargs -0 -n 1 tar -xJf
# SC2086: Double quote to prevent globbing and word splitting
mkdir -p "$DST_DIR"
# Grab the headers from one, either one is fine
# (if we're building twice to combine old and new toolchains, this may already exist)
if [ ! -d $DST_DIR/include ]; then
mv $(echo $MINGW_ARCH | cut -d ' ' -f 1)/include $DST_DIR
# SC2046: Quote command substitution; SC2086: double-quote variables
if [ ! -d "$DST_DIR/include" ]; then
mv "$(echo "$MINGW_ARCH" | cut -d ' ' -f 1)/include" "$DST_DIR"
fi

# mingw64 -> x64
# mingw32 -> i386
# ucrt64 -> x64-ucrt

if [ -d mingw64/lib/ ]; then
ls $MSYS_LIB_DIR/mingw64/lib/
ls "$MSYS_LIB_DIR/mingw64/lib/"
# Make the rest of the directory structure
mkdir -p $DST_DIR/lib/x64
mkdir -p "$DST_DIR/lib/x64"
# Move the 64-bit versions of libarrow into the expected location
mv mingw64/lib/*.a $DST_DIR/lib/x64
mv mingw64/lib/*.a "$DST_DIR/lib/x64"
# These are from https://dl.bintray.com/rtools/mingw{32,64}/
cp $MSYS_LIB_DIR/mingw64/lib/lib{snappy,zstd,lz4,brotli*,bz2,crypto,curl,ss*,utf8proc,re2,nghttp2}.a $DST_DIR/lib/x64
cp "$MSYS_LIB_DIR"/mingw64/lib/lib{snappy,zstd,lz4,brotli*,bz2,crypto,curl,ss*,utf8proc,re2,nghttp2}.a "$DST_DIR/lib/x64"
fi

# Same for the 32-bit versions
if [ -d mingw32/lib/ ]; then
ls $MSYS_LIB_DIR/mingw32/lib/
mkdir -p $DST_DIR/lib/i386
mv mingw32/lib/*.a $DST_DIR/lib/i386
cp $MSYS_LIB_DIR/mingw32/lib/lib{snappy,zstd,lz4,brotli*,bz2,crypto,curl,ss*,utf8proc,re2,nghttp2}.a $DST_DIR/lib/i386
ls "$MSYS_LIB_DIR/mingw32/lib/"
mkdir -p "$DST_DIR/lib/i386"
mv mingw32/lib/*.a "$DST_DIR/lib/i386"
cp "$MSYS_LIB_DIR"/mingw32/lib/lib{snappy,zstd,lz4,brotli*,bz2,crypto,curl,ss*,utf8proc,re2,nghttp2}.a "$DST_DIR/lib/i386"
fi

# Do the same also for ucrt64
if [ -d ucrt64/lib/ ]; then
ls $MSYS_LIB_DIR/ucrt64/lib/
mkdir -p $DST_DIR/lib/x64-ucrt
mv ucrt64/lib/*.a $DST_DIR/lib/x64-ucrt
cp $MSYS_LIB_DIR/ucrt64/lib/lib{snappy,zstd,lz4,brotli*,bz2,crypto,curl,ss*,utf8proc,re2,nghttp2}.a $DST_DIR/lib/x64-ucrt
ls "$MSYS_LIB_DIR/ucrt64/lib/"
mkdir -p "$DST_DIR/lib/x64-ucrt"
mv ucrt64/lib/*.a "$DST_DIR/lib/x64-ucrt"
cp "$MSYS_LIB_DIR"/ucrt64/lib/lib{snappy,zstd,lz4,brotli*,bz2,crypto,curl,ss*,utf8proc,re2,nghttp2}.a "$DST_DIR/lib/x64-ucrt"
fi

# Create build artifact
zip -r ${DST_DIR}.zip $DST_DIR
zip -r "${DST_DIR}.zip" "$DST_DIR"

# Copy that to a file name/path that does not vary by version number so we
# can easily find it in the R package tests on CI
cp ${DST_DIR}.zip ../libarrow.zip
cp "${DST_DIR}.zip" ../libarrow.zip
Loading