From 6ad8b5c8b473f834350b3501a3db30a2e875c7af Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 10 May 2024 12:58:28 +0000 Subject: [PATCH 1/4] chore: bump savvy to 0.6.3 --- .Rbuildignore | 3 +++ LICENSE.note | 8 +++--- R/{wrappers.R => 000-wrappers.R} | 19 +++++++++----- Taskfile.yml | 2 +- man/prql_get_targets.Rd | 2 +- src/init.c | 45 ++++++++++++++++++-------------- src/rust/Cargo.lock | 16 ++++++------ src/rust/Cargo.toml | 2 +- src/rust/api.h | 12 ++++----- tests/testthat/test-compile.R | 4 +-- 10 files changed, 64 insertions(+), 49 deletions(-) rename R/{wrappers.R => 000-wrappers.R} (71%) diff --git a/.Rbuildignore b/.Rbuildignore index 8712a853..fb4a02b4 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -17,3 +17,6 @@ ^src/rust/vendor$ ^src/Makevars$ ^tools/libprqlr\.a$ + +^src/rust/.cargo$ +^src/rust/target$ diff --git a/LICENSE.note b/LICENSE.note index a713eacf..8043d40b 100644 --- a/LICENSE.note +++ b/LICENSE.note @@ -516,7 +516,7 @@ License: Apache-2.0 OR BSL-1.0 ------------------------------------------------------------- Name: savvy -Version: 0.4.2 +Version: 0.6.3 Repository: https://github.com/yutannihilation/savvy/ Authors: Hiroaki Yutani License: MIT @@ -524,7 +524,7 @@ License: MIT ------------------------------------------------------------- Name: savvy-bindgen -Version: 0.4.2 +Version: 0.6.3 Repository: https://github.com/yutannihilation/savvy/ Authors: Hiroaki Yutani License: MIT @@ -532,7 +532,7 @@ License: MIT ------------------------------------------------------------- Name: savvy-ffi -Version: 0.4.2 +Version: 0.6.3 Repository: https://github.com/yutannihilation/savvy/ Authors: Hiroaki Yutani License: MIT @@ -540,7 +540,7 @@ License: MIT ------------------------------------------------------------- Name: savvy-macro -Version: 0.4.2 +Version: 0.6.3 Repository: https://github.com/yutannihilation/savvy/ Authors: Hiroaki Yutani License: MIT diff --git a/R/wrappers.R b/R/000-wrappers.R similarity index 71% rename from R/wrappers.R rename to R/000-wrappers.R index a602decf..ec0c09bc 100644 --- a/R/wrappers.R +++ b/R/000-wrappers.R @@ -1,3 +1,10 @@ +# Generated by savvy: do not edit by hand +# +# Note: +# This wrapper file is named as `000-wrappers.R` so that this file is loaded +# first, which allows users to override the functions defined here (e.g., a +# print() method for an enum). + #' @useDynLib prqlr, .registration = TRUE #' @keywords internal NULL @@ -20,29 +27,29 @@ NULL #' @return a list contains a SQL string or an error message. #' @noRd compile <- function(prql_query, target, format, signature_comment) { - .Call(compile__impl, prql_query, target, format, signature_comment) + .Call(savvy_compile__impl, prql_query, target, format, signature_comment) } #' @noRd prql_to_pl <- function(prql_query) { - .Call(prql_to_pl__impl, prql_query) + .Call(savvy_prql_to_pl__impl, prql_query) } #' @noRd pl_to_rq <- function(pl_json) { - .Call(pl_to_rq__impl, pl_json) + .Call(savvy_pl_to_rq__impl, pl_json) } #' @noRd rq_to_sql <- function(rq_json) { - .Call(rq_to_sql__impl, rq_json) + .Call(savvy_rq_to_sql__impl, rq_json) } #' @title prqlc's version #' @return a prqlc's version string #' @noRd compiler_version <- function() { - .Call(compiler_version__impl) + .Call(savvy_compiler_version__impl) } #' @title Get available target names @@ -52,7 +59,7 @@ compiler_version <- function() { #' prql_get_targets() #' @export prql_get_targets <- function() { - .Call(prql_get_targets__impl) + .Call(savvy_prql_get_targets__impl) } diff --git a/Taskfile.yml b/Taskfile.yml index 8291262c..5ea9ffc2 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -162,7 +162,7 @@ tasks: deps: - build-vendor-sources generates: - - R/wrappers.R + - R/000-wrappers.R cmds: - savvy-cli update . diff --git a/man/prql_get_targets.Rd b/man/prql_get_targets.Rd index 73c47f16..82df4948 100644 --- a/man/prql_get_targets.Rd +++ b/man/prql_get_targets.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/wrappers.R +% Please edit documentation in R/000-wrappers.R \name{prql_get_targets} \alias{prql_get_targets} \title{Get available target names} diff --git a/src/init.c b/src/init.c index 0f3b5442..d7ba346d 100644 --- a/src/init.c +++ b/src/init.c @@ -1,6 +1,8 @@ #include #include +#include + #include "rust/api.h" static uintptr_t TAGGED_POINTER_MASK = (uintptr_t)1; @@ -32,48 +34,51 @@ SEXP handle_result(SEXP res_) { return (SEXP)res; } -SEXP compile__impl(SEXP prql_query, SEXP target, SEXP format, SEXP signature_comment) { - SEXP res = compile(prql_query, target, format, signature_comment); +SEXP savvy_compile__impl(SEXP prql_query, SEXP target, SEXP format, SEXP signature_comment) { + SEXP res = savvy_compile__ffi(prql_query, target, format, signature_comment); return handle_result(res); } -SEXP prql_to_pl__impl(SEXP prql_query) { - SEXP res = prql_to_pl(prql_query); +SEXP savvy_prql_to_pl__impl(SEXP prql_query) { + SEXP res = savvy_prql_to_pl__ffi(prql_query); return handle_result(res); } -SEXP pl_to_rq__impl(SEXP pl_json) { - SEXP res = pl_to_rq(pl_json); +SEXP savvy_pl_to_rq__impl(SEXP pl_json) { + SEXP res = savvy_pl_to_rq__ffi(pl_json); return handle_result(res); } -SEXP rq_to_sql__impl(SEXP rq_json) { - SEXP res = rq_to_sql(rq_json); +SEXP savvy_rq_to_sql__impl(SEXP rq_json) { + SEXP res = savvy_rq_to_sql__ffi(rq_json); return handle_result(res); } -SEXP compiler_version__impl(void) { - SEXP res = compiler_version(); +SEXP savvy_compiler_version__impl(void) { + SEXP res = savvy_compiler_version__ffi(); return handle_result(res); } -SEXP prql_get_targets__impl(void) { - SEXP res = prql_get_targets(); +SEXP savvy_prql_get_targets__impl(void) { + SEXP res = savvy_prql_get_targets__ffi(); return handle_result(res); } static const R_CallMethodDef CallEntries[] = { - {"compile__impl", (DL_FUNC) &compile__impl, 4}, - {"prql_to_pl__impl", (DL_FUNC) &prql_to_pl__impl, 1}, - {"pl_to_rq__impl", (DL_FUNC) &pl_to_rq__impl, 1}, - {"rq_to_sql__impl", (DL_FUNC) &rq_to_sql__impl, 1}, - {"compiler_version__impl", (DL_FUNC) &compiler_version__impl, 0}, - {"prql_get_targets__impl", (DL_FUNC) &prql_get_targets__impl, 0}, + {"savvy_compile__impl", (DL_FUNC) &savvy_compile__impl, 4}, + {"savvy_prql_to_pl__impl", (DL_FUNC) &savvy_prql_to_pl__impl, 1}, + {"savvy_pl_to_rq__impl", (DL_FUNC) &savvy_pl_to_rq__impl, 1}, + {"savvy_rq_to_sql__impl", (DL_FUNC) &savvy_rq_to_sql__impl, 1}, + {"savvy_compiler_version__impl", (DL_FUNC) &savvy_compiler_version__impl, 0}, + {"savvy_prql_get_targets__impl", (DL_FUNC) &savvy_prql_get_targets__impl, 0}, {NULL, NULL, 0} }; void R_init_prqlr(DllInfo *dll) { - R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); - R_useDynamicSymbols(dll, FALSE); + R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); + R_useDynamicSymbols(dll, FALSE); + + // Functions for initialzation, if any. + } diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock index 0e2caf12..3af14e12 100644 --- a/src/rust/Cargo.lock +++ b/src/rust/Cargo.lock @@ -584,9 +584,9 @@ checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "savvy" -version = "0.5.3" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f11c90ffa1855fab767c6cf0719b6e94ad99d1bcfc39f884e4a70088fb91a9" +checksum = "f4d4a5517bc0a98643a040df2d8a58c7d47432a94c73c00afbaa9ac126c8b8e9" dependencies = [ "cc", "once_cell", @@ -596,9 +596,9 @@ dependencies = [ [[package]] name = "savvy-bindgen" -version = "0.5.3" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd580c399a6b8cd21b45307b0f308725e7c90a29d73911de3058d75a913148eb" +checksum = "e2d8e836c4b761f6a8d33506530fae929fef99e61b48df1cc0ebedafc5c3179e" dependencies = [ "proc-macro2", "quote", @@ -607,15 +607,15 @@ dependencies = [ [[package]] name = "savvy-ffi" -version = "0.5.3" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea169fa4740b73eeec2d4c3dc79c11d03347c459756eee90fd969ceeb353e035" +checksum = "3d642bfbcf199b181da3e150c36ad399812b96bca8a9a83f535143c22fec2325" [[package]] name = "savvy-macro" -version = "0.5.3" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8d2cfacbd719da22022636897950e1fc727dd6584d24419dc21003387d5a064" +checksum = "b8e6db2943cbe5e0bc92536d1142cf30c6fe480ab5c985902fbc04abbe751d17" dependencies = [ "proc-macro2", "quote", diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml index 7187ca23..89d6f4a3 100644 --- a/src/rust/Cargo.toml +++ b/src/rust/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ['staticlib'] name = "prqlr" [dependencies] -savvy = "0.5.3" +savvy = "0.6.3" # prqlc= { version = "0.11.2", default-features = false } # prqlc 0.11.2 is not compatible with Rust 1.65, so a slightly modified version is installed # See https://github.com/PRQL/prql/pull/4001 diff --git a/src/rust/api.h b/src/rust/api.h index eb484591..2de40757 100644 --- a/src/rust/api.h +++ b/src/rust/api.h @@ -1,6 +1,6 @@ -SEXP compile(SEXP prql_query, SEXP target, SEXP format, SEXP signature_comment); -SEXP prql_to_pl(SEXP prql_query); -SEXP pl_to_rq(SEXP pl_json); -SEXP rq_to_sql(SEXP rq_json); -SEXP compiler_version(void); -SEXP prql_get_targets(void); +SEXP savvy_compile__ffi(SEXP prql_query, SEXP target, SEXP format, SEXP signature_comment); +SEXP savvy_prql_to_pl__ffi(SEXP prql_query); +SEXP savvy_pl_to_rq__ffi(SEXP pl_json); +SEXP savvy_rq_to_sql__ffi(SEXP rq_json); +SEXP savvy_compiler_version__ffi(void); +SEXP savvy_prql_get_targets__ffi(void); diff --git a/tests/testthat/test-compile.R b/tests/testthat/test-compile.R index 858a7bf0..a865ba10 100644 --- a/tests/testthat/test-compile.R +++ b/tests/testthat/test-compile.R @@ -18,7 +18,7 @@ test_that("target set in the header ", { test_that("Not a string object", { expect_error( 1 |> prql_compile(), - "Expected character, got double" + "Unexpected type" ) expect_error( c("a", "a") |> prql_compile(), @@ -33,7 +33,7 @@ test_that("Unsupported target", { ) expect_error( prql_compile("from a | select {b}", NA), - "Expected character, got logical" + "Unexpected type" ) expect_error( prql_compile("from a | select {b}", NA_character_), From a009047392f802a290158ca4c718ae4cb995d5bf Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 10 May 2024 13:23:37 +0000 Subject: [PATCH 2/4] ci: needs R installed --- .github/workflows/release-lib.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/release-lib.yml b/.github/workflows/release-lib.yml index 59f3d306..6a43e72a 100644 --- a/.github/workflows/release-lib.yml +++ b/.github/workflows/release-lib.yml @@ -78,6 +78,14 @@ jobs: echo 'CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc' >>"$GITHUB_ENV" echo 'CC=aarch64-linux-gnu-gcc' >>"$GITHUB_ENV" + - name: Set for macOS + # macos latest runner does't have R + if: runner.os == 'macos' + uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + Ncpus: 2 + - name: build lib env: NOT_CRAN: "true" From 8fdb78881563735a5098f04ef5b2fcde1f5616c6 Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 10 May 2024 13:34:59 +0000 Subject: [PATCH 3/4] ci: fix macos build --- .github/workflows/release-lib.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-lib.yml b/.github/workflows/release-lib.yml index 6a43e72a..cebc78a4 100644 --- a/.github/workflows/release-lib.yml +++ b/.github/workflows/release-lib.yml @@ -98,7 +98,16 @@ jobs: LIB_PATH="$(pwd)/rust/target/${TARGET}/${PRQLR_PROFILE}/${LIB_NAME}.a" ARTIFACT_NAME="${LIB_NAME}-${LIB_VERSION}-${TARGET}.tar.gz" - make -f Makevars${{ runner.os == 'Windows' && '.win' || '.in' }} "${LIB_PATH}" + if [[ "${{ runner.os }}" == "macos" ]]; then + # Rinternals header is needed + pushd .. + Rscript -e 'install.packages("pkgbuild")' + Rscript -e 'pkgbuild::compile_dll()' + popd + else + make -f Makevars${{ runner.os == 'Windows' && '.win' || '.in' }} "${LIB_PATH}" + fi + tar -czf "../${ARTIFACT_NAME}" -C "rust/target/${TARGET}/${PRQLR_PROFILE}" "${LIB_NAME}.a" echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >>"$GITHUB_ENV" @@ -127,6 +136,9 @@ jobs: r: devel - os: macos-latest r: oldrel-1 + include: + - os: macos-12 + r: release permissions: contents: read From cb7c53bf50b716e42771acaadff7c79ed46f838b Mon Sep 17 00:00:00 2001 From: eitsupi Date: Fri, 10 May 2024 13:42:10 +0000 Subject: [PATCH 4/4] ci: fix typo --- .github/workflows/release-lib.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-lib.yml b/.github/workflows/release-lib.yml index cebc78a4..58d4b04e 100644 --- a/.github/workflows/release-lib.yml +++ b/.github/workflows/release-lib.yml @@ -80,7 +80,7 @@ jobs: - name: Set for macOS # macos latest runner does't have R - if: runner.os == 'macos' + if: runner.os == 'macOS' uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true @@ -98,7 +98,7 @@ jobs: LIB_PATH="$(pwd)/rust/target/${TARGET}/${PRQLR_PROFILE}/${LIB_NAME}.a" ARTIFACT_NAME="${LIB_NAME}-${LIB_VERSION}-${TARGET}.tar.gz" - if [[ "${{ runner.os }}" == "macos" ]]; then + if [[ "${{ runner.os }}" == "macOS" ]]; then # Rinternals header is needed pushd .. Rscript -e 'install.packages("pkgbuild")'