Skip to content

Commit

Permalink
Merge pull request #12 from andyquinterom/CRAN_FEEDBACK
Browse files Browse the repository at this point in the history
 Cran feedback
  • Loading branch information
andres-ixpantia authored Nov 24, 2023
2 parents 8c6e474 + 6bb9695 commit 40941c2
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 71 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
^src/rust/.cargo$
^src/rust/.vscode$
^src/rust/vendor$
^src/rust/target$

^_pkgdown\.yml$
^docs$
Expand Down
10 changes: 9 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ Authors@R:
person(given = "The authors of the dependency Rust crates",
role = c("ctb"),
comment = "see inst/AUTHORS file for details"))
Description: A set of optimized tools and abstractions for processing graph data structures.
Description: Empower your data analysis with 'orbweaver', an R package
designed for effortless construction and analysis of graph data
structures. With 'orbweaver', you can seamlessly build and manipulate
graph structures, leveraging its high-performance methods for
filtering, joining, and mutating data within the R environment.
Drawing inspiration from the efficiency of the 'data.table'
package, 'orbweaver' ensures that mutations and changes to
the graph are performed in place, streamlining your
workflow for optimal productivity.
URL: https://github.com/ixpantia/orbweaver
BugReports: https://github.com/ixpantia/orbweaver/issues
License: MIT + file LICENSE
Expand Down
11 changes: 6 additions & 5 deletions R/graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' Initializes a new graph with the given type.
#' @param type The type of graph to create. Currently only `acyclic` is
#' supported.
#' @return A new graph of the given type.
#' @export
new_graph <- function(type) {
switch(
Expand All @@ -21,7 +22,7 @@ new_graph <- function(type) {
#' @param type The type of graph to convert to. Currently only `acyclic` is
#' supported.
#' @param ... Additional arguments passed to the method.
#' @return A graph.
#' @return A graph of the given type.
#' @export
as_graph <- function(x, type, ...) {
UseMethod("as_graph")
Expand All @@ -35,7 +36,7 @@ as_graph <- function(x, type, ...) {
#' @param type The type of graph to convert to. Currently only `acyclic` is
#' supported.
#' @param ... Ignored.
#' @return A graph.
#' @return A graph of the given type.
#' @export
as_graph.data.frame <- function(x, type, ...) {
switch(
Expand All @@ -55,7 +56,7 @@ as_graph.data.frame <- function(x, type, ...) {
#' similar way to the `data.table` package.
#' @param graph The graph to add the node to.
#' @param node The ID of the node to add.
#' @return The graph.
#' @return A reference to the graph passed in.
#' @export
add_node <- function(graph, node) {
graph$add_node(node)
Expand All @@ -74,7 +75,7 @@ add_node <- function(graph, node) {
#' @param graph The graph to add the child to.
#' @param parent The ID of the parent node.
#' @param child The ID of the child node.
#' @return The graph.
#' @return A reference to the graph passed in.
#' @export
add_child <- function(graph, parent, child) {
graph$add_child(parent, child)
Expand Down Expand Up @@ -163,7 +164,7 @@ find_roots <- function(graph) {
#' @description
#' Creates a copy of the graph.
#' @param graph The graph to clone.
#' @return A new graph.
#' @return A new graph that is a copy of the original.
#' @export
clone_graph <- function(graph) {
graph$graph_clone()
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# orbweaver

<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/orbweaver)](https://cran.r-project.org/package=orbweaver)
[![R-CMD-check](https://github.com/ixpantia/orbweaver/actions/workflows/check-full.yaml/badge.svg)](https://github.com/ixpantia/orbweaver/actions/workflows/check-full.yaml)
<!-- badges: end -->

## Overview

A fast R library for working with Nodes in a graph. This library
modifies graphs in place, similar to how [data.table](https://github.com/Rdatatable/data.table)
modifies data.frames in place. This allows for fast and memory efficient
Expand Down
2 changes: 1 addition & 1 deletion man/add_child.Rd

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

2 changes: 1 addition & 1 deletion man/add_node.Rd

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

2 changes: 1 addition & 1 deletion man/as_graph.Rd

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

2 changes: 1 addition & 1 deletion man/as_graph.data.frame.Rd

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

2 changes: 1 addition & 1 deletion man/clone_graph.Rd

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

3 changes: 3 additions & 0 deletions man/new_graph.Rd

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

27 changes: 9 additions & 18 deletions src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,26 @@ TARGET_DIR = ./rust/target
LIBDIR = $(TARGET_DIR)/release
STATLIB = $(LIBDIR)/liborbweaver.a
PKG_LIBS = -L$(LIBDIR) -lorbweaver
CARGOTMP = ./rust/.cargo/tmp

all: C_clean

$(SHLIB): $(STATLIB)

$(STATLIB):
# vendoring (Note: to avoid NOTE of "Found the following hidden files and
# directories", .cargo needs to be created here)
if [ "$(VENDORING)" = "yes" ]; then \
$(TAR) --extract --xz -f ./rust/vendor.tar.xz -C ./rust && \
mkdir -p ./rust/.cargo && \
cp ./config/cargo_vendor_config.toml ./rust/.cargo/config.toml; \
fi

# In some environments, ~/.cargo/bin might not be included in PATH, so we need
# to set it here to ensure cargo can be invoked. It is appended to PATH and
# therefore is only used if cargo is absent from the user's PATH.
if [ "$(NOT_CRAN)" != "true" ]; then \
export CARGO_HOME=$(CARGOTMP); \
fi && \
export PATH="$(PATH):$(HOME)/.cargo/bin" && \
cd ./rust && \
cargo build --lib --release \
$(OFFLINE_OPTION) \
--jobs 1
if [ "$(NOT_CRAN)" != "true" ]; then \
rm -Rf $(CARGOTMP) && \
rm -Rf $(LIBDIR)/build; \
fi
export CARGO_HOME=$(CARGOTMP); \
export PATH="$(PATH):$(HOME)/.cargo/bin" && \
cd ./rust && \
cargo build --lib --release \
$(OFFLINE_OPTION) \
--jobs 1; \
rm -Rf $(CARGOTMP) && \
rm -Rf $(LIBDIR)/build; \

C_clean:
rm -Rf $(SHLIB) $(OBJECTS) ./rust/.cargo $(STATLIB)
Expand Down
62 changes: 20 additions & 42 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,61 +1,39 @@
TARGET = x86_64-pc-windows-gnu

# Rtools42 doesn't have the linker in the location that cargo expects, so we
# need to overwrite it via configuration.
CARGO_LINKER = x86_64-w64-mingw32.static.posix-gcc.exe

# TODO
VENDORING = yes
OFFLINE_OPTION = --offline
VENDORING = yes

TARGET = $(subst 64,x86_64,$(subst 32,i686,$(WIN)))-pc-windows-gnu

TARGET_DIR = ./rust/target
LIBDIR = $(TARGET_DIR)/$(TARGET)/release
STATLIB = $(LIBDIR)/liborbweaver.a
PKG_LIBS = -L$(LIBDIR) -lorbweaver -lws2_32 -ladvapi32 -luserenv -lbcrypt -lntdll
CARGOTMP = ./rust/.cargo/tmp
TAR=tar

all: C_clean

$(SHLIB): $(STATLIB)

$(STATLIB):
mkdir -p $(LIBDIR)/libgcc_mock && touch $(LIBDIR)/libgcc_mock/libgcc_eh.a
CARGOTMP = $(CURDIR)/.cargo

# vendoring (Note: to avoid NOTE of "Found the following hidden files and
# directories", .cargo needs to be created here)
$(STATLIB):
mkdir -p $(TARGET_DIR)/libgcc_mock && \
touch $(TARGET_DIR)/libgcc_mock/libgcc_eh.a && \
if [ "$(VENDORING)" = "yes" ]; then \
$(TAR) --extract --xz -f ./rust/vendor.tar.xz -C ./rust && \
mkdir -p ./rust/.cargo && \
cp ./config/cargo_vendor_config.toml ./rust/.cargo/config.toml; \
fi

mkdir -p $(TARGET_DIR)/libgcc_mock
# `rustc` adds `-lgcc_eh` flags to the compiler, but Rtools' GCC doesn't have
# `libgcc_eh` due to the compilation settings. So, in order to please the
# compiler, we need to add empty `libgcc_eh` to the library search paths.
#
# For more details, please refer to
# https://github.com/r-windows/rtools-packages/blob/2407b23f1e0925bbb20a4162c963600105236318/mingw-w64-gcc/PKGBUILD#L313-L316
touch $(TARGET_DIR)/libgcc_mock/libgcc_eh.a

# CARGO_LINKER is provided in Makevars.ucrt for R >= 4.2
if [ "$(NOT_CRAN)" != "true" ]; then \
export CARGO_HOME=$(CARGOTMP); \
mkdir -p ./rust/.cargo && \
cp ./config/cargo_vendor_config.toml ./rust/.cargo/config.toml; \
fi && \
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$(CARGO_LINKER)" && \
export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(TARGET_DIR)/libgcc_mock" && \
cd ./rust && \
cargo build --target=$(TARGET) --lib --release \
$(OFFLINE_OPTION) \
--jobs 1
if [ "$(NOT_CRAN)" != "true" ]; then \
rm -Rf $(CARGOTMP) && \
rm -Rf $(LIBDIR)/build; \
fi
export CARGO_HOME=$(CARGOTMP); \
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$(CARGO_LINKER)" && \
export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(TARGET_DIR)/libgcc_mock" && \
cd ./rust && \
cargo build --target=$(TARGET) --lib --release $(OFFLINE_OPTION) --jobs 1; \
rm -Rf $(CARGOTMP) && \
rm -Rf $(LIBDIR)/build; \

C_clean:
rm -Rf $(SHLIB) $(OBJECTS) ./rust/.cargo $(STATLIB)
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS)

clean:
rm -Rf $(SHLIB) $(OBJECTS) $(STATLIB) ./rust/.cargo ./rust/vendor ./rust/target

.PHONY: all C_clean clean
rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS) $(TARGET_DIR)

0 comments on commit 40941c2

Please sign in to comment.