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 3 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
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ 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(gh,gh)
Expand Down
85 changes: 85 additions & 0 deletions R/use_cmakelists.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#'
#'
#' @export
use_cmakelists <- function(project = NULL) {
writeLines(
c(
"cmake_minimum_required(VERSION 3.0.0)",
paste0("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)",
"set(CMAKE_EXPORT_COMPILE_COMMANDS ON)"
), "CMakeLists.txt"
)
benubah marked this conversation as resolved.
Show resolved Hide resolved

if (!fs::dir_exists("src")) fs::dir_create("src")
benubah marked this conversation as resolved.
Show resolved Hide resolved

writeLines(
benubah marked this conversation as resolved.
Show resolved Hide resolved
c(
paste0("add_library(", project),
" connection.cpp",
" DbColumn.cpp",
" DbColumnDataSource.cpp",
" DbColumnDataSourceFactory.cpp",
" DbColumnStorage.cpp",
" DbConnection.cpp",
" DbDataFrame.cpp",
" DbResult.cpp",
" encode.cpp",
" encrypt.cpp",
" logging.cpp",
" PqColumnDataSource.cpp",
" PqColumnDataSourceFactory.cpp",
" PqDataFrame.cpp",
" PqResult.cpp",
" PqResultImpl.cpp",
" PqResultSource.cpp",
" PqUtils.cpp",
" RcppExports.cpp",
" result.cpp",
" DbColumnDataSourceFactory.h",
" DbColumnDataSource.h",
" DbColumnDataType.h",
" DbColumn.h",
" DbColumnStorage.h",
" DbConnection.h",
" DbDataFrame.h",
" DbResult.h",
" DbResultImplDecl.h",
" DbResultImpl.h",
" encode.h",
" integer64.h",
" pch.h",
" PqColumnDataSourceFactory.h",
" PqColumnDataSource.h",
" PqDataFrame.h",
" PqResult.h",
" PqResultImpl.h",
" PqResultSource.h",
" PqUtils.h",
" RPostgres-init.c",
" RPostgres_types.h",
benubah marked this conversation as resolved.
Show resolved Hide resolved
")",
"",
paste0("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"',
")",
"",
paste0("target_compile_definitions(", project, " PUBLIC"),
' "RCPP_DEFAULT_INCLUDE_CALL=false"',
' "RCPP_USING_UTF8_ERROR_STRING"',
' "BOOST_NO_AUTO_PTR"',
")"
), "src/CMakeLists.txt"
)
}
55 changes: 55 additions & 0 deletions R/use_gitpod.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#'
#' @export
use_gitpod <- function() {
writeLines(
c(
"# 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"
), "gitpod.Dockerfile"
)

writeLines(
"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
",
"gitpod.yml"
)
}