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

WIP: use_gitpod() and use_cmakelists() drafts #48

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
33f12f6
use_gitpod draft
benubah Oct 24, 2022
6e9c998
use_cmakelists draft
benubah Oct 24, 2022
70c8fc7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 24, 2022
fb9d217
no need to check
benubah Oct 26, 2022
c9f7608
Merge branch 'use-gitpod-cmakelists' of https://github.com/cynkra/cyn…
benubah Oct 26, 2022
745979d
add usethis templates for gitpod and CMakeLists
benubah Oct 26, 2022
3ddfc74
improve use_gitpod() to work with usethis templates
benubah Oct 26, 2022
2218c74
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 26, 2022
f9b7b6c
import fs
benubah Oct 26, 2022
77f8efc
improve use_cmakelists to use usethis templates
benubah Oct 26, 2022
6c177cc
Merge branch 'use-gitpod-cmakelists' of https://github.com/cynkra/cyn…
benubah Oct 26, 2022
30cc726
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 26, 2022
3d0ebe3
get list of files from R
benubah Oct 26, 2022
e5545bb
Merge branch 'use-gitpod-cmakelists' of https://github.com/cynkra/cyn…
benubah Oct 26, 2022
38fa54f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 26, 2022
679f1ab
basic documentation
benubah Oct 26, 2022
486e7a6
update NAMESPACE
benubah Oct 26, 2022
7eb3a12
Merge branch 'use-gitpod-cmakelists' of https://github.com/cynkra/cyn…
benubah Oct 26, 2022
e7516ab
update _pkgdown.yml
benubah Oct 26, 2022
8059079
Tweaks
krlmlr Oct 27, 2022
77fb2e3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 27, 2022
d3760e4
Dynamic R home and LinkingTo
krlmlr Dec 5, 2022
62bd3a2
Tweak
krlmlr Dec 6, 2022
c288ba0
Use new template
krlmlr Dec 6, 2022
4225863
Avoid creating Dockerfile by default
krlmlr Dec 6, 2022
dcabffa
Fix CMakeLists template
krlmlr Dec 6, 2022
b2ca34b
Tweak template
krlmlr Feb 20, 2023
8989c53
Install lazytest
krlmlr Feb 20, 2023
7cb5b0d
Merge branch 'main' into use-gitpod-cmakelists
krlmlr Mar 14, 2023
db7fed0
Merge branch 'main' into use-gitpod-cmakelists
krlmlr May 21, 2023
4f87d61
Package-agnostic
krlmlr May 21, 2023
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
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Imports:
callr,
checkmate,
cli,
fs,
gh,
glue,
jsonlite,
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ export(init_tic)
export(renv_downgrade)
export(renv_install_local)
export(renv_switch_r_version)
export(use_cmakelists)
export(use_gitpod)
importFrom(checkmate,assert_character)
importFrom(cli,cli_alert)
importFrom(fs,dir_create)
importFrom(gh,gh)
importFrom(jsonlite,read_json)
importFrom(lifecycle,deprecated)
Expand Down
34 changes: 34 additions & 0 deletions R/use_cmakelists.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#'
#' @importFrom fs dir_create
#' @export
use_cmakelists <- function(project = "NewProject") {
new_cmakelist <- usethis::use_template(
"CMakeLists.txt",
"CMakeLists.txt",
package = "cynkrathis",
data = list(project = project),
ignore = TRUE
)
if (!new_cmakelist) {
return(invisible(FALSE))
}

invisible(TRUE)

fs::dir_create("src")

ext_files <- list.files(path = ".", pattern = ".*\\.(c|h|cpp)$")

new_cmakelist_src <- usethis::use_template(
"CMakeLists-src.txt",
"src/CMakeLists.txt",
package = "cynkrathis",
data = list(project = project, ext_files = ext_files),
ignore = TRUE
)
if (!new_cmakelist_src) {
return(invisible(FALSE))
}

invisible(TRUE)
}
27 changes: 27 additions & 0 deletions R/use_gitpod.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#'
#' @export
use_gitpod <- function() {
new_gitpod_dockerfile <- usethis::use_template(
"gitpod.Dockerfile",
".gitpod.Dockerfile",
package = "cynkrathis",
ignore = TRUE
)
if (!new_gitpod_dockerfile) {
return(invisible(FALSE))
}

invisible(TRUE)

new_gitpod_yml <- usethis::use_template(
"gitpod.yml",
".gitpod.yml",
package = "cynkrathis",
ignore = TRUE
)
if (!new_gitpod_yml) {
return(invisible(FALSE))
}

invisible(TRUE)
}
18 changes: 18 additions & 0 deletions inst/templates/CMakeLists-src.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
add_library({{{project}}}
{{{ext_files}}}

)

target_include_directories({{{project}}} PUBLIC
"/usr/share/R/include"
"/home/gitpod/R/x86_64-pc-linux-gnu-library/3.6/Rcpp/include/"
"/home/gitpod/R/x86_64-pc-linux-gnu-library/3.6/plogr/include/"
"/usr/include/postgresql"
"vendor"
)

target_compile_definitions({{{project}}} PUBLIC
"RCPP_DEFAULT_INCLUDE_CALL=false"
"RCPP_USING_UTF8_ERROR_STRING"
"BOOST_NO_AUTO_PTR"
)
13 changes: 13 additions & 0 deletions inst/templates/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 3.0.0)
project({{{project}}} VERSION 0.1.0)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(CTest)
enable_testing()

add_subdirectory(src)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
11 changes: 11 additions & 0 deletions inst/templates/gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# You can find the new timestamped tags here: https://hub.docker.com/r/gitpod/workspace-base/tags
FROM gitpod/workspace-base:2022-05-08-14-31-53

# Install R and ccache
RUN sudo apt update
RUN sudo apt install -y \
r-base \
ccache \
cmake \
# Install dependencies for rlang packet
libharfbuzz-dev libfribidi-dev
28 changes: 28 additions & 0 deletions inst/templates/gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
image:
file: .gitpod.Dockerfile
tasks:
- name: dependencies
init: |
# Scriptlets, with custom Git config
mv ~/.gitconfig ~/.gitconfig.gitpod
curl -s https://raw.githubusercontent.com/krlmlr/scriptlets/master/bootstrap | sh
echo -e "[credential]\n\thelper = /usr/bin/gp credential-helper" >> ~/.gitconfig
# .editorconfig
ln -s ~/.editorconfig ..
# Set up ccache
ln -s /usr/lib/ccache/* ~/bin/
# Set up Makevars
mkdir -p ~/.R
echo -e "MAKEFLAGS = -j8\nCXXFLAGS = -O0 -g" > ~/.R/Makevars
# Install R packages
echo 'options(repos = "https://packagemanager.rstudio.com/all/__linux__/'$(cat /etc/lsb-release | sed -n '/DISTRIB_CODENAME=/ {s///;p}')'/latest")' > ~/.Rprofile
mkdir -p ~/R/x86_64-pc-linux-gnu-library/$(Rscript -e 'writeLines(gsub("[.][^.]+$", "", as.character(getRversion())))')
## Install pak in R
R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))'
## Install devtools and R dependencies
R -q -e 'pak::pak(c("devtools", "deps::."))'
vscode:
extensions:
- ms-vscode.cpptools-extension-pack
- go2sh.cmake-integration-vscode
- EditorConfig.EditorConfig