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

Unbundle libjq [WIP !!] #59

Merged
merged 4 commits into from
Sep 19, 2017
Merged
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
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
14 changes: 8 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: r
cache: packages
latex: false
dist: trusty
latex: false
sudo: required

matrix:
include:
Expand All @@ -14,17 +15,18 @@ matrix:
env: R_CODECOV=true
- os: osx
osx_image: xcode8.3
brew_packages: jq
- os: osx
osx_image: xcode7.3
disable_homebrew: true

addons:
apt:
sources:
- sourceline: 'ppa:opencpu/jq'
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
19 changes: 6 additions & 13 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,19 @@ Description: Client for 'jq', a 'JSON' processor (<https://stedolan.github.io/jq
written in C. 'jq' allows the following with 'JSON' data: index into, parse,
do calculations, cut up and filter, change key names and values, perform
conditionals and comparisons, and more.
Version: 0.3.0
Version: 0.9000
Depends:
R (>= 3.1.2)
License: MIT + file LICENSE
LazyData: true
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"))
Authors@R: c(person("Rich", "FitzJohn", role = "aut", email = "rich.fitzjohn@gmail.com"),
person("Jeroen", "Ooms", role = "aut", email = "jeroen@berkeley.edu"),
person("Scott", "Chamberlain", role = c("aut", "cre"), email = "myrmecocystus@gmail.com"),
person("Stefan Milton Bache", role = "aut", email = "stefan@stefanbache.dk"))
VignetteBuilder: knitr
URL: https://github.com/ropensci/jqr
BugReports: https://github.com/ropensci/jqr/issues
SystemRequirements: libjq: jq-devel (rpm) or libjq-dev (deb)
Imports:
magrittr,
lazyeval
Expand Down
56 changes: 45 additions & 11 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,56 @@ means that the eventual loading into R can be quicker.

[Introduction](vignettes/jqr_vignette.md)

## Install
## Installation

Stable version:
Binary packages for __OS-X__ or __Windows__ can be installed directly from CRAN:

```{r eval=FALSE}
```r
install.packages("jqr")
```

Development version:
Installation from source on Linux or OSX requires [`libjq`](https://stedolan.github.io/jq/). On __Ubuntu 14.04 and 16.04 lower__ use [libjq-dev](https://launchpad.net/~opencpu/+archive/ubuntu/jq) from Launchpad:

```{r eval=FALSE}
devtools::install_github("ropensci/jqr")
```
sudo add-apt-repository -y ppa:opencpu/jq
sudo apt-get update -q
sudo apt-get install -y libjq-dev
```

More __recent Debian or Ubuntu__ install [libjq-dev](https://packages.debian.org/testing/libjq-dev) directly from Universe:

```
sudo apt-get install -y libjq-dev
```

On __Fedora__ we need [jq-devel](https://apps.fedoraproject.org/packages/jq-devel):

```
sudo yum install jq-devel
````

On __CentOS / RHEL__ we install [libsodium-devel](https://apps.fedoraproject.org/packages/jq-devel) via EPEL:

```
sudo yum install epel-release
sudo yum install jq-devel
```

On __OS-X__ use [jq](https://github.com/Homebrew/homebrew-core/blob/master/Formula/jq.rb) from Homebrew:

```
brew install jq
```

On __Solaris__ we can have [libjq_dev](https://www.opencsw.org/packages/libjq_dev) from [OpenCSW](https://www.opencsw.org/):
```
pkgadd -d http://get.opencsw.org/now
/opt/csw/bin/pkgutil -U
/opt/csw/bin/pkgutil -y -i libjq_dev
```

```{r}
library("jqr")
library(jqr)
```

## Interfaces
Expand Down Expand Up @@ -216,10 +250,10 @@ Select variables by name, and rename
'{"foo": 5, "bar": 7}' %>% select(a = .foo)
```

More complicated `select()`, using the included dataset `githubcommits`
More complicated `select()`, using the included dataset `commits`

```{r}
githubcommits %>%
commits %>%
index() %>%
select(sha = .sha, name = .commit.committer.name)
```
Expand Down Expand Up @@ -290,7 +324,7 @@ find maximum
This outputs a few pieces of JSON

```{r}
(x <- githubcommits %>%
(x <- commits %>%
index() %>%
select(sha = .sha, name = .commit.committer.name))
```
Expand All @@ -308,4 +342,4 @@ combine(x)
* Get citation information for `jqr` in R doing `citation(package = 'jqr')`
* Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.

[![rofooter](http://ropensci.org/public_images/github_footer.png)](http://ropensci.org)
[![rofooter](http://www.ropensci.org/public_images/github_footer.png)](http://ropensci.org)
54 changes: 43 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,57 @@ means that the eventual loading into R can be quicker.

[Introduction](vignettes/jqr_vignette.md)

## Install

Stable version:
## Installation

Binary packages for __OS-X__ or __Windows__ can be installed directly from CRAN:

```r
install.packages("jqr")
```

Development version:
Installation from source on Linux or OSX requires [`libjq`](https://stedolan.github.io/jq/). On __Ubuntu 14.04 and 16.04 lower__ use [libjq-dev](https://launchpad.net/~opencpu/+archive/ubuntu/jq) from Launchpad:

```
sudo add-apt-repository -y ppa:opencpu/jq
sudo apt-get update -q
sudo apt-get install -y libjq-dev
```

```r
devtools::install_github("ropensci/jqr")
More __recent Debian or Ubuntu__ install [libjq-dev](https://packages.debian.org/testing/libjq-dev) directly from Universe:

```
sudo apt-get install -y libjq-dev
```

On __Fedora__ we need [jq-devel](https://apps.fedoraproject.org/packages/jq-devel):

```
sudo yum install jq-devel
````

On __CentOS / RHEL__ we install [libsodium-devel](https://apps.fedoraproject.org/packages/jq-devel) via EPEL:

```
sudo yum install epel-release
sudo yum install jq-devel
```

On __OS-X__ use [jq](https://github.com/Homebrew/homebrew-core/blob/master/Formula/jq.rb) from Homebrew:

```
brew install jq
```

On __Solaris__ we can have [libjq_dev](https://www.opencsw.org/packages/libjq_dev) from [OpenCSW](https://www.opencsw.org/):
```
pkgadd -d http://get.opencsw.org/now
/opt/csw/bin/pkgutil -U
/opt/csw/bin/pkgutil -y -i libjq_dev
```


```r
library("jqr")
library(jqr)
```

## Interfaces
Expand Down Expand Up @@ -381,11 +413,11 @@ Select variables by name, and rename
#> }
```

More complicated `select()`, using the included dataset `githubcommits`
More complicated `select()`, using the included dataset `commits`


```r
githubcommits %>%
commits %>%
index() %>%
select(sha = .sha, name = .commit.committer.name)
#> [
Expand Down Expand Up @@ -590,7 +622,7 @@ This outputs a few pieces of JSON


```r
(x <- githubcommits %>%
(x <- commits %>%
index() %>%
select(sha = .sha, name = .commit.committer.name))
#> [
Expand Down Expand Up @@ -693,4 +725,4 @@ combine(x)
* Get citation information for `jqr` in R doing `citation(package = 'jqr')`
* Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.

[![rofooter](http://ropensci.org/public_images/github_footer.png)](http://ropensci.org)
[![rofooter](http://www.ropensci.org/public_images/github_footer.png)](http://ropensci.org)
2 changes: 2 additions & 0 deletions cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
rm -f src/Makevars
65 changes: 65 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
# Anticonf (tm) script by Jeroen Ooms (2017)
# 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_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=""

# 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 [[ "$OSTYPE" == "darwin"* ]]; then
if [ $(command -v brew) ]; then
BREWDIR=$(brew --prefix)
else
# autobrew in /tmp
curl -sfL "https://jeroen.github.io/autobrew/$PKG_BREW_NAME" > autobrew
source autobrew
fi
PKG_CFLAGS="-I$BREWDIR/opt/$PKG_BREW_NAME/include"
PKG_LIBS="-L$BREWDIR/lib $PKG_LIBS"
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

# Customize the error
if [ $? -ne 0 ]; 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 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.

7 changes: 7 additions & 0 deletions src/Makevars.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PKG_CPPFLAGS=@cflags@
PKG_LIBS=@libs@

all: clean

clean:
rm -f $(SHLIB) $(OBJECTS)
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
Loading