Skip to content

Instantly share code, notes, and snippets.

@lemire
Last active September 7, 2021 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lemire/b34bf9b462463fcab447416d18a819a8 to your computer and use it in GitHub Desktop.
Save lemire/b34bf9b462463fcab447416d18a819a8 to your computer and use it in GitHub Desktop.
hacking rcppsimdjson

Here is how to test rcppsimdjson.

  • Install docker.
  • Grab rcppsimdjson from GitHub.

Next, you want to create a file called 'Dockerfile'. You may put this file inside the root rcppsimdjson repository.

The file may have the following content: (there are more examples at https://github.com/RcppCore/Rcpp/tree/master/docker/ci-3.4 )

 FROM ubuntu:18.04
 ARG USER_NAME
 ARG USER_ID
 ARG GROUP_ID
 # We install some useful packages
 RUN apt-get update -qq
 RUN apt-get install software-properties-common -qq
 RUN DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata g++ gcc
 RUN add-apt-repository -y ppa:c2d4u.team/c2d4u4.0+
 RUN apt-get -q update
 RUN apt-get install curl sudo make -qq
 RUN curl -OLs https://eddelbuettel.github.io/r-ci/run.sh && chmod 0755 run.sh
 RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
 RUN ./run.sh install_aptget r-cran-rcpp r-cran-bit64 r-cran-tinytest
 # setting the environment
 RUN addgroup --gid $GROUP_ID user; exit 0
 RUN adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID $USER_NAME; exit 0
 RUN echo "$USER_NAME:$USER_NAME" | chpasswd && adduser $USER_NAME sudo
 RUN echo '----->'
 RUN echo 'root:Docker!' | chpasswd
 ENV TERM xterm-256color
 USER $USER_NAME

You may create the container (once), as follows:

docker build --no-cache -f Dockerfile -t rcppsimdjson  --build-arg USER_NAME="$USER"  --build-arg USER_ID=$(id -u)  --build-arg GROUP_ID=$(id -g) .

Next, while being in the rcppsimdjson repository, you may run the following:

docker run -it -v $(pwd):$(pwd):Z  -w $(pwd)  rcppsimdjson  bash

This will start a bash shell. Inside the bash shell, you may want to issue the following commands (note that your password is your username inside the container):

./run.sh bootstrap
./run.sh run_tests

If you have problems, look for a file named like "RcppSimdJson_0.1.5.tar.gz". You may want to run R interactively over it. Type R (while in the container) and then... (assuming that the file is RcppSimdJson_0.1.5.tar.gz)

> install.packages("RcppSimdJson_0.1.5.tar.gz", repos = NULL, type="source")
> library('RcppSimdJson')
> json_string <- '{"a":[[1,null,3.0],["a","b",true],[10000000000,2,3]]}'
> fparse(json_string)

If you change some code and you would like to regenerate the "RcppSimdJson....tar.gz" file, type...

R CMD build --no-build-vignettes --no-manual .

Further tricks to speed up the process at eddelbuettel/rcppsimdjson#70 (comment)

Errors are found RcppSimdJson.Rcheck/tests/tinytest.Rout.fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment