-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from rstudio/system-libuv
Use system copy of libuv if found
- Loading branch information
Showing
7 changed files
with
136 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, rc-**] | ||
pull_request: | ||
schedule: | ||
- cron: '0 6 * * 1' # every monday | ||
|
||
name: Test system libuv | ||
|
||
jobs: | ||
R-CMD-check: | ||
# Ubuntu 22.04 has libuv1-dev version 1.43, which is sufficient | ||
runs-on: ubuntu-latest | ||
name: Installed=${{ matrix.config.install }} Bundled=${{ matrix.config.use }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
# This one should test that we've used system and everything runs ok | ||
- {install: true} | ||
# This one should test for bundling log message | ||
- {install: true, use: true} | ||
# This one should test for failure | ||
- {install: false, use: false} | ||
|
||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::rcmdcheck | ||
needs: check | ||
|
||
- name: Install libuv | ||
if: ${{ matrix.config.install }} | ||
# If we add tests for e.g. rhel/centos, we couldn't assume apt-get | ||
run: | | ||
sudo apt-get update -y | ||
sudo apt-get install -y libuv1-dev | ||
- name: Ensure libuv is not on the system | ||
if: ${{ !matrix.config.install }} | ||
run: | | ||
sudo apt-get remove -y libuv1-dev || true | ||
- uses: r-lib/actions/check-r-package@v2 | ||
if: ${{ matrix.config.install }} | ||
env: | ||
USE_BUNDLED_LIBUV: ${{ matrix.config.use }} | ||
with: | ||
upload-snapshots: true | ||
|
||
- name: Confirm that USE_BUNDLED_LIBUV was respected | ||
if: ${{ matrix.config.install }} | ||
env: | ||
USE_BUNDLED_LIBUV: ${{ matrix.config.use }} | ||
run: | | ||
if [ "$USE_BUNDLED_LIBUV" = "true" ]; then | ||
grep "Using bundled copy of libuv" check/httpuv.Rcheck/00install.out | ||
else | ||
grep "Using libuv found by pkg-config" check/httpuv.Rcheck/00install.out | ||
fi | ||
- name: Confirm error if system libuv missing and use=false | ||
if: ${{ !matrix.config.install && !matrix.config.use }} | ||
env: | ||
USE_BUNDLED_LIBUV: ${{ matrix.config.use }} | ||
run: | | ||
R CMD INSTALL . > install.log || true | ||
grep "Did not find suitable libuv on your system" install.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env sh | ||
|
||
rm -f src/Makevars configure.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env sh | ||
|
||
PKG_CONFIG_NAME="libuv" | ||
LIBUV_VERSION_REQUIRED="$PKG_CONFIG_NAME >= 1.43 $PKG_CONFIG_NAME < 2" | ||
|
||
# If unset (default), will try to find libuv on system and fall back to bundled | ||
# If true (case insensitive), will not look for system library | ||
# If false, will not fall back to bundled if system library not found | ||
USE_BUNDLED_LIBUV=`echo $USE_BUNDLED_LIBUV | tr '[:upper:]' '[:lower:]'` | ||
|
||
if [ `uname -s` = "Darwin" ]; then | ||
# Always do static linking on macOS | ||
PKG_CONFIG="pkg-config --static" | ||
else | ||
PKG_CONFIG="pkg-config" | ||
fi | ||
|
||
# First, look for suitable libuv installed on the system | ||
if [ "${USE_BUNDLED_LIBUV}" != "true" ] && ${PKG_CONFIG} --exists ''"${LIBUV_VERSION_REQUIRED}"'' 2>&1; then | ||
echo "** Using libuv found by pkg-config in `${PKG_CONFIG} --variable=prefix --silence-errors ${PKG_CONFIG_NAME}`" | ||
PKG_CFLAGS=`${PKG_CONFIG} --cflags --silence-errors ${PKG_CONFIG_NAME}` | ||
PKG_LIBS=`${PKG_CONFIG} --libs ${PKG_CONFIG_NAME}` | ||
DEPS="" | ||
elif [ "${USE_BUNDLED_LIBUV}" != "false" ]; then | ||
# If not found, use the bundled copy (unless directed otherwise) | ||
echo "** Using bundled copy of libuv" | ||
PKG_CFLAGS="-Ilibuv/include" | ||
PKG_LIBS="./libuv/.libs/libuv.a" | ||
# By setting DEPS, this triggers the libuv build in src/Makevars | ||
DEPS="libuv/.libs/libuv.a" | ||
else | ||
echo "** Did not find suitable libuv on your system," | ||
echo "** and not building from source because USE_BUNDLED_LIBUV=false." | ||
echo "** Please install ${LIBUV_VERSION_REQUIRED} or unset USE_BUNDLED_LIBUV" | ||
exit 1 | ||
fi | ||
|
||
# For debugging | ||
echo "** PKG_CFLAGS=$PKG_CFLAGS" | ||
echo "** PKG_LIBS=$PKG_LIBS" | ||
# Write to Makevars | ||
sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" -e "s|@deps@|$DEPS|" src/Makevars.in > src/Makevars | ||
|
||
# Success | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters