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

chore: bump savvy to 0.6.3 #289

Merged
merged 4 commits into from
May 10, 2024
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
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
^src/rust/vendor$
^src/Makevars$
^tools/libprqlr\.a$

^src/rust/.cargo$
^src/rust/target$
22 changes: 21 additions & 1 deletion .github/workflows/release-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -90,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"

Expand Down Expand Up @@ -119,6 +136,9 @@ jobs:
r: devel
- os: macos-latest
r: oldrel-1
include:
- os: macos-12
r: release

permissions:
contents: read
Expand Down
8 changes: 4 additions & 4 deletions LICENSE.note
Original file line number Diff line number Diff line change
Expand Up @@ -516,31 +516,31 @@ 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

-------------------------------------------------------------

Name: savvy-bindgen
Version: 0.4.2
Version: 0.6.3
Repository: https://github.com/yutannihilation/savvy/
Authors: Hiroaki Yutani
License: MIT

-------------------------------------------------------------

Name: savvy-ffi
Version: 0.4.2
Version: 0.6.3
Repository: https://github.com/yutannihilation/savvy/
Authors: Hiroaki Yutani
License: MIT

-------------------------------------------------------------

Name: savvy-macro
Version: 0.4.2
Version: 0.6.3
Repository: https://github.com/yutannihilation/savvy/
Authors: Hiroaki Yutani
License: MIT
Expand Down
19 changes: 13 additions & 6 deletions R/wrappers.R → R/000-wrappers.R
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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)
}


2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ tasks:
deps:
- build-vendor-sources
generates:
- R/wrappers.R
- R/000-wrappers.R
cmds:
- savvy-cli update .

Expand Down
2 changes: 1 addition & 1 deletion man/prql_get_targets.Rd

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

45 changes: 25 additions & 20 deletions src/init.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#include <stdint.h>
#include <Rinternals.h>
#include <R_ext/Parse.h>

#include "rust/api.h"

static uintptr_t TAGGED_POINTER_MASK = (uintptr_t)1;
Expand Down Expand Up @@ -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.

}
16 changes: 8 additions & 8 deletions src/rust/Cargo.lock

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

2 changes: 1 addition & 1 deletion src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/rust/api.h
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 2 additions & 2 deletions tests/testthat/test-compile.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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_),
Expand Down
Loading