Skip to content

Commit

Permalink
Unbundle libjq
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Sep 18, 2017
1 parent d0e517e commit fa24fe5
Show file tree
Hide file tree
Showing 52 changed files with 113 additions and 22,446 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ cran-comments.md
^src/.*\.a$
^docker$
.github

$src/Makevars$
^cran-comments\.md$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ jq-*.tar.gz
jqr_*.tar.gz
notes.md
src/*.dll
src/Makevars
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ matrix:
osx_image: xcode7.3

addons:
sources:
- sourceline: 'ppa:opencpu/jq'
apt:
packages:
- r-cran-lazyeval
- r-cran-magrittr
- r-cran-testthat
- r-cran-jsonlite
- r-cran-knitr
- libjq-dev
- valgrind

after_success:
- if [[ "${R_CODECOV}" ]]; then R -e 'covr::codecov()'; fi
Expand Down
9 changes: 1 addition & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ Authors@R: c(person("Rich", "FitzJohn", role = "aut",
email = "rich.fitzjohn@gmail.com"),
person("Jeroen", "Ooms", role = "aut"),
person("Scott", "Chamberlain", role = c("aut", "cre"),
email = "myrmecocystus@gmail.com"),
person("Stefan Milton Bache", role = "aut",
email = "stefan@stefanbache.dk"),
person("Stephen", "Dolan", role = c("aut","cph"), comment = "jq library"),
person(family = "jq contributors", role = "ctb",
comment = "jq library; authors listed in inst/AUTHORS.jq"),
person("Free Software Foundation", role = c("ctb","cph"), comment = "parser code in src/parser.c"),
person("David M", "Gay", role = c("ctb","cph"), comment = "code in src/jv_dtoa.c"))
email = "myrmecocystus@gmail.com"))
VignetteBuilder: knitr
URL: https://github.com/ropensci/jqr
BugReports: https://github.com/ropensci/jqr/issues
Expand Down
82 changes: 82 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash
# Anticonf (tm) script by Jeroen Ooms (2016)
# This script will query 'pkg-config' for the required cflags and ldflags.
# If pkg-config is unavailable or does not find the library, try setting
# INCLUDE_DIR and LIB_DIR manually via e.g:
# R CMD INSTALL --configure-vars='INCLUDE_DIR=/.../include LIB_DIR=/.../lib'

# Library settings
PKG_CONFIG_NAME="jq"
PKG_DEB_NAME="libjq-dev"
PKG_RPM_NAME="jq-devel"
PKG_CSW_NAME="libjq_dev"
PKG_BREW_NAME="jq"
PKG_TEST_HEADER="<jq.h>"
PKG_LIBS="-ljq"
PKG_LIBS_STATIC="-ljq -lonig"
PKG_CFLAGS=""

# Use pkg-config if available
if [ $(command -v pkg-config) ]; then
PKGCONFIG_CFLAGS=$(pkg-config --cflags --silence-errors ${PKG_CONFIG_NAME})
PKGCONFIG_LIBS=$(pkg-config --libs ${PKG_CONFIG_NAME})
fi

# Note that cflags may be empty in case of success
if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]; then
echo "Found INCLUDE_DIR and/or LIB_DIR!"
PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS"
PKG_LIBS="-L$LIB_DIR $PKG_LIBS"
elif [ "$PKGCONFIG_CFLAGS" ] || [ "$PKGCONFIG_LIBS" ]; then
echo "Found pkg-config cflags and libs!"
PKG_CFLAGS=${PKGCONFIG_CFLAGS}
PKG_LIBS=${PKGCONFIG_LIBS}
elif [[ "$OSTYPE" == "darwin"* ]]; then
if [ $(command -v brew) ]; then
BREWDIR=$(brew --prefix)
else
echo "Auto-brewing $PKG_BREW_NAME..."
BREWDIR="/tmp/homebrew"
rm -Rf $BREWDIR
mkdir -p $BREWDIR
curl -fsSL https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1 -C $BREWDIR
HOMEBREW_CACHE="/tmp" $BREWDIR/bin/brew install $PKG_BREW_NAME 2>&1 | perl -pe 's/Warning/Note/gi'
rm -f $BREWDIR/lib/*.dylib
fi
PKG_CFLAGS="-I$BREWDIR/opt/$PKG_BREW_NAME/include"
PKG_LIBS="-L$BREWDIR/lib $PKG_LIBS_STATIC"
fi

# For debugging
echo "Using PKG_CFLAGS=$PKG_CFLAGS"
echo "Using PKG_LIBS=$PKG_LIBS"

# Find compiler
CC=$(${R_HOME}/bin/R CMD config CC)
CFLAGS=$(${R_HOME}/bin/R CMD config CFLAGS)
CPPFLAGS=$(${R_HOME}/bin/R CMD config CPPFLAGS)

# Test configuration
echo "#include $PKG_TEST_HEADER" | ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E -xc - >/dev/null 2>&1 || R_CONFIG_ERROR=1;

# Customize the error
if [ $R_CONFIG_ERROR ]; then
echo "------------------------- ANTICONF ERROR ---------------------------"
echo "Configuration failed because $PKG_CONFIG_NAME was not found. Try installing:"
echo " * deb: $PKG_DEB_NAME (Debian, Ubuntu, etc)"
echo " * rpm: $PKG_RPM_NAME (Fedora, EPEL)"
echo " * csw: $PKG_CSW_NAME (Solaris)"
echo " * brew: $PKG_BREW_NAME (OSX)"
echo "If $PKG_CONFIG_NAME is already installed, check that 'pkg-config' is in your"
echo "PATH and PKG_CONFIG_PATH contains a $PKG_CONFIG_NAME.pc file. If pkg-config"
echo "is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:"
echo "R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'"
echo "--------------------------------------------------------------------"
exit 1;
fi

# Write to Makevars
sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" src/Makevars.in > src/Makevars

# Success
exit 0
37 changes: 0 additions & 37 deletions src/Makevars

This file was deleted.

2 changes: 2 additions & 0 deletions src/Makevars.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PKG_CPPFLAGS=@cflags@
PKG_LIBS=@libs@
12 changes: 12 additions & 0 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PKG_CPPFLAGS = -I../windows/jq-1.5/include
PKG_LIBS = -L../windows/jq-1.5/lib${R_ARCH} -ljq -lonig -lshlwapi

all: clean winlibs

winlibs:
"${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R"

clean:
rm -f $(OBJECTS) jqr.dll

.PHONY: all clean winlibs
59 changes: 0 additions & 59 deletions src/config.h

This file was deleted.

71 changes: 0 additions & 71 deletions src/jq/AUTHORS

This file was deleted.

Loading

0 comments on commit fa24fe5

Please sign in to comment.