Skip to content

Commit

Permalink
Prep for 1.1.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Jan 21, 2024
1 parent 0404805 commit 7e88be6
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 22 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: QuickJSR
Title: Interface for the 'QuickJS' Lightweight 'JavaScript' Engine
Version: 1.0.9.9000
Version: 1.1.0
Authors@R: c(
person(given = c("Andrew", "R."), family = "Johnson", role = c("aut", "cre"),
email = "[email protected]",
Expand All @@ -16,7 +16,7 @@ Description: An 'R' interface to the 'QuickJS' portable 'JavaScript' engine.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
NeedsCompilation: yes
SystemRequirements: GNU make
Imports:
Expand All @@ -25,7 +25,7 @@ Imports:
Rcpp
LinkingTo:
Rcpp
URL: https://github.com/andrjohns/QuickJSR https://bellard.org/quickjs/ (upstream)
URL: https://github.com/andrjohns/QuickJSR, https://bellard.org/quickjs/
BugReports: https://github.com/andrjohns/QuickJSR/issues
Suggests:
testthat (>= 3.0.0)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(JSContext)
export(cxxflags)
export(ldflags)
export(qjs_eval)
export(quickjs_version)
importFrom(R6,R6Class)
importFrom(Rcpp,Rcpp.plugin.maker)
importFrom(Rcpp,sourceCpp)
Expand Down
25 changes: 13 additions & 12 deletions R/flags.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,37 @@
#' and invisibly return NULL (for use in package Makevars or similar)
#' @export
ldflags <- function(to_console = FALSE) {
PKG_LIBS <- paste(
"-L", shQuote(system.file("lib", Sys.getenv("R_ARCH"), package = "QuickJSR", mustWork = TRUE)),
"-lquickjs"
)
libdir <- system.file("lib", Sys.getenv("R_ARCH"), package = "QuickJSR",
mustWork = TRUE)
pkglibs <- paste("-L", shQuote(libdir), "-lquickjs")
if (isTRUE(to_console)) {
cat(PKG_LIBS, " ")
cat(pkglibs, " ")
return(invisible(NULL))
}
PKG_LIBS
pkglibs
}

#' cxxflags
#'
#' Function for returning the C/C++ flags needed for compilation using the package's headers
#' Function for returning the C/C++ flags needed for compilation
#' using the package's headers
#'
#' @param to_console Whether the result should be returned as a string
#' @return Character string of CXX flags, or print flags to console
#' and invisibly return NULL (for use in package Makevars or similar)
#' @export
cxxflags <- function(to_console = FALSE) {
CXXFLAGS <- paste(
paste0("-I", shQuote(system.file("include", package = "QuickJSR", mustWork = TRUE))),
incdir <- system.file("include", package = "QuickJSR", mustWork = TRUE)
pkg_cxxflags <- paste(
paste0("-I", shQuote(incdir)),
"-D_GNU_SOURCE",
"-DCONFIG_VERSION=\"2021-03-27\"",
paste0("-DCONFIG_VERSION=\"", quickjs_version(), "\""),
"-DSTRICT_R_HEADERS",
"-DCONFIG_BIGNUM"
)
if (isTRUE(to_console)) {
cat(CXXFLAGS, " ")
cat(pkg_cxxflags, " ")
return(invisible(NULL))
}
CXXFLAGS
pkg_cxxflags
}
3 changes: 1 addition & 2 deletions R/quickjsr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#'
#' @description An interface to the QuickJS lightweight Javascript engine
#'
#' @docType package
#' @name QuickJSR-package
#' @aliases QuickJSR
#' @useDynLib QuickJSR, .registration = TRUE
Expand All @@ -11,4 +10,4 @@
#' @importFrom R6 R6Class
#' @importFrom Rcpp sourceCpp Rcpp.plugin.maker
#'
NULL
"_PACKAGE"
12 changes: 11 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ args_to_json <- function(...) {

parse_return <- function(qjs_return) {
if (qjs_return == "Error!") {
stop("Error in JS runtime, see error message above for more information!", call. = FALSE)
stop("Error in JS runtime, see error message above for more information!",
call. = FALSE)
}
jsonlite::fromJSON(qjs_return)
}

#' Get the version of the bundled QuickJS library
#'
#' @return Character string of the version of the bundled QuickJS library
#' @export
quickjs_version <- function() {
version_file <- system.file("VERSION", package = "QuickJSR", mustWork = TRUE)
readLines(version_file)
}
19 changes: 19 additions & 0 deletions man/QuickJSR-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/cxxflags.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions man/quickjs_version.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/Makevars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PKG_CPPFLAGS = -I"../inst/include/quickjs" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM
PKG_CPPFLAGS = -I"../inst/include/" -DSTRICT_R_HEADERS -D_GNU_SOURCE -DCONFIG_BIGNUM
PKG_CPPFLAGS += -DCONFIG_VERSION=\"$(shell cat quickjs/VERSION)\"
PKG_LIBS = ../inst/lib/$(R_ARCH)/libquickjs.a

Expand All @@ -24,8 +24,9 @@ all: package-quickjs $(SHLIB)
$(SHLIB): build-static

package-quickjs:
@mkdir -p ../inst/include/quickjs
@cp $(QUICKJS_C_HEADERS:%=quickjs/%) ../inst/include/quickjs
@mkdir -p ../inst/include
@cp $(QUICKJS_C_HEADERS:%=quickjs/%) ../inst/include
@cp quickjs/VERSION ../inst/

build-static: $(QUICKJS_OBJECTS)
@mkdir -p ../inst/lib/$(R_ARCH)
Expand Down

0 comments on commit 7e88be6

Please sign in to comment.