-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Empty R package with Rust implementation
Using in R: ```R usethis::create_package(‘path/to/libkrigingtemplate’) setwd(‘/path/to/libkrigingtemplate/‘) cf https://extendr.github.io/rextendr/articles/package.html ```
- Loading branch information
Showing
11 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.idea | ||
/*.tar.gz | ||
/.Rproj.user | ||
/.Rhistory | ||
/.RData | ||
/.Ruserdata | ||
*.a | ||
*.o | ||
*.so | ||
/src/rust/vendor | ||
/src/rust/vendor.tar.xz | ||
/src/rust/**/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Package: libkrigingtemplate | ||
Title: What the Package Does (One Line, Title Case) | ||
Version: 0.0.0.9000 | ||
Authors@R: | ||
person("First", "Last", , "first.last@example.com", role = c("aut", "cre"), | ||
comment = c(ORCID = "YOUR-ORCID-ID")) | ||
Description: What the package does (one paragraph). | ||
License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a | ||
license | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#' @docType package | ||
#' @usage NULL | ||
#' @useDynLib libkrigingtemplate, .registration = TRUE | ||
NULL | ||
|
||
#' Return string `"Hello world!"` to R. | ||
#' @export | ||
hello_world <- function() .Call(wrap__hello_world) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.o | ||
*.so | ||
*.dll | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
LIBDIR = ./rust/target/release | ||
STATLIB = $(LIBDIR)/liblibkrigingtemplate.a | ||
PKG_LIBS = -L$(LIBDIR) -llibkrigingtemplate | ||
|
||
all: C_clean | ||
|
||
$(SHLIB): $(STATLIB) | ||
|
||
$(STATLIB): | ||
cargo build --lib --release --manifest-path=./rust/Cargo.toml | ||
|
||
C_clean: | ||
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) | ||
|
||
clean: | ||
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) rust/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
TARGET = $(subst 64,x86_64,$(subst 32,i686,$(WIN)))-pc-windows-gnu | ||
LIBDIR = ./rust/target/$(TARGET)/release | ||
STATLIB = $(LIBDIR)/liblibkrigingtemplate.a | ||
PKG_LIBS = -L$(LIBDIR) -llibkrigingtemplate -lws2_32 -ladvapi32 -luserenv | ||
|
||
all: C_clean | ||
|
||
$(SHLIB): $(STATLIB) | ||
|
||
$(STATLIB): | ||
cargo build --target=$(TARGET) --lib --release --manifest-path=./rust/Cargo.toml | ||
|
||
C_clean: | ||
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) | ||
|
||
clean: | ||
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) rust/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// We need to forward routine registration from C to Rust | ||
// to avoid the linker removing the static library. | ||
|
||
void R_init_libkrigingtemplate_extendr(void *dll); | ||
|
||
void R_init_libkrigingtemplate(void *dll) { | ||
R_init_libkrigingtemplate_extendr(dll); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = 'libkrigingtemplate' | ||
version = '0.1.0' | ||
edition = '2018' | ||
|
||
[lib] | ||
crate-type = [ 'staticlib' ] | ||
|
||
[dependencies] | ||
extendr-api = '*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use extendr_api::prelude::*; | ||
|
||
/// Return string `"Hello world!"` to R. | ||
/// @export | ||
#[extendr] | ||
fn hello_world() -> &'static str { | ||
"Hello world!" | ||
} | ||
|
||
// Macro to generate exports. | ||
// This ensures exported functions are registered with R. | ||
// See corresponding C code in `entrypoint.c`. | ||
extendr_module! { | ||
mod libkrigingtemplate; | ||
fn hello_world; | ||
} |