-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
168 lines (143 loc) · 6.45 KB
/
Copy pathjustfile
File metadata and controls
168 lines (143 loc) · 6.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# misskappa repo-root recipes.
#
# C++ library lives at the repo root (include/, src/, tests/).
# R bindings live under r-package/.
# Manuscripts live under papers/<slug>/, each with its own justfile.
set shell := ["bash", "-euo", "pipefail", "-c"]
default:
@just --list
# C++ build + tests (dev preset: debug, no sanitizers).
build:
@cmake --preset dev
@cmake --build --preset dev --parallel $(nproc)
test: build
@ctest --preset dev
fmt-cpp:
@formatter="$(command -v clang-format || command -v clang-format-18 || command -v clang-format-17 || true)"; \
if [[ -z "$formatter" ]]; then \
echo "clang-format not found; install clang-format or clang-format-18."; \
exit 127; \
fi; \
rg --files include src tests/unit r-package/src \
| rg '\.(c|cc|cpp|cxx|h|hpp)$' \
| xargs "$formatter" -i
# Release build (no sanitizers). Used by the C++ unit tests (ctest).
opt:
@cmake --preset opt
@cmake --build --preset opt --parallel $(nproc)
test-opt: opt
@ctest --preset opt
# C++ test coverage (clang source-based instrumentation + llvm-cov).
# Prints a per-file summary; full HTML lands in build-cov/coverage-html/.
cpp-cov:
@dev/cpp-coverage.sh
# R package test coverage (covr over the testthat suite). Vendors first so the
# package's C++ is fresh; covr also reports that C++ as hit through Rcpp.
r-cov: vendor
@Rscript dev/r-coverage.R
# Both coverage suites.
cov: cpp-cov r-cov
# Vendor the canonical C++ (src/ + include/) into r-package/src/ so the package
# is self-contained. Run after any C++ change — the R recipes below depend on it,
# so `just r-install` / `r-check` always build against fresh-vendored sources.
vendor:
@dev/vendor-cpp.sh
# Fail if the vendored copies are stale (canonical changed without re-vendoring,
# a vendored copy was hand-edited, or a new canonical source wasn't vendored).
# For CI / pre-commit.
vendor-check: vendor
@if [ -n "$(git status --porcelain -- r-package/src)" ]; then \
echo "r-package/src is out of sync — run \`just vendor\` and commit:"; \
git status --porcelain -- r-package/src; \
exit 1; \
fi
# Reinstall the R package against fresh-vendored sources.
r-docs:
@cd r-package && Rscript -e 'roxygen2::roxygenise()'
r-install: vendor r-docs
@MAKEFLAGS="-j$(nproc)" R CMD INSTALL --preclean r-package
# Fast DEV install — for day-to-day C++/logic iteration, NOT release. Compiles
# only the R glue (RcppExports.cpp + rcpp_glue.cpp) and links it against the
# opt-preset libmisskappa.a, so an install does a lib-only cmake build + a 2-file
# compile instead of recompiling the whole vendored library. Builds from a
# throwaway mirror (build-rdev/) with the dev-only dev/r-makevars-dev swapped in
# for src/Makevars, so the committed, CRAN-self-contained r-package/src/Makevars
# is never touched.
#
# Deliberately does NOT run r-docs: roxygenise() calls pkgbuild::compile_dll(),
# which recompiles all 14 files in r-package/ (the very thing we're avoiding).
# When you change the R-facing interface — add/remove a [[Rcpp::export]],
# edit roxygen/@export, touch NAMESPACE — run `just r-install` (or `just r-docs`)
# to regenerate RcppExports/NAMESPACE/man. r-dev only re-links existing exports
# against your new C++.
r-dev:
@cmake --preset opt
@cmake --build --preset opt --target misskappa --parallel $(nproc) # lib only — skip the unit-test exe
@root="$(pwd)"; \
rsync -a --delete \
--exclude='*.o' --exclude='*.so' --exclude='*.dll' --exclude='symbols.rds' \
r-package/ build-rdev/; \
cp dev/r-makevars-dev build-rdev/src/Makevars; \
MISSKAPPA_ROOT="$root" MAKEFLAGS="-j$(nproc)" R CMD INSTALL build-rdev
# Skips the Quarto vignettes (the dominant cost; exercised by the Docs workflow and
# `r-check-release`), downgrades absent Suggests to a NOTE, and keeps ccache warm
# across R CMD check's temp build dir (CCACHE_NOHASHDIR/BASEDIR — harmless no-ops
# when the compiler isn't ccache). Run `r-check-release` before a release/tag.
# Fast R CMD check for the dev loop — no vignettes (full check: r-check-release).
r-check: vendor r-docs
@cleanup() { rm -f misskappa_*.tar.gz; }; \
cleanup; \
trap cleanup EXIT; \
export _R_CHECK_FORCE_SUGGESTS_=false \
MAKEFLAGS="-j$(nproc)" \
CCACHE_NOHASHDIR=1 \
CCACHE_BASEDIR="$(pwd)" \
CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,time_macros; \
R CMD build r-package --no-build-vignettes; \
R CMD check --no-manual --no-build-vignettes misskappa_*.tar.gz
# Builds the Quarto vignettes (needs quarto/lavaan/psych) and checks the full
# tarball, as `remotes::install_github` / CRAN would. The fast `r-check` is the
# day-to-day dev check.
# Full R CMD check with vignettes — run before a release/tag, not in the dev loop.
r-check-release: vendor r-docs
@cleanup() { rm -f misskappa_*.tar.gz; }; \
cleanup; \
trap cleanup EXIT; \
R CMD build r-package; \
R CMD check --no-manual misskappa_*.tar.gz
# Regenerate irrCAC oracle fixtures (requires R + irrCAC installed).
regen-oracle:
@Rscript tests/tools/regen_oracle.R
# Build pkgdown site. Requires the R packages pkgdown and quarto; vendors first
# because pkgdown installs/loads the R package. If Pandoc is only available via
# Quarto, expose Quarto's bundled copy to rmarkdown/pkgdown.
docs-r: vendor
@cd r-package && \
if [[ -z "${RSTUDIO_PANDOC:-}" ]] && ! command -v pandoc >/dev/null 2>&1 && command -v quarto >/dev/null 2>&1; then \
quarto_bin="$(readlink -f "$(command -v quarto)")"; \
quarto_root="$(dirname "$(dirname "$quarto_bin")")"; \
quarto_pandoc="$quarto_root/bin/tools/x86_64"; \
if [[ -x "$quarto_pandoc/pandoc" ]]; then \
export RSTUDIO_PANDOC="$quarto_pandoc"; \
fi; \
fi; \
Rscript -e 'roxygen2::roxygenise(); pkgdown::build_site()'
# Build C++ API reference into the pkgdown output tree. Requires doxygen.
docs-cpp:
@doxygen docs/Doxyfile
# Build the combined local documentation site under docs/site/.
docs: docs-r docs-cpp
docs-clean:
@rm -rf docs/site docs/doxygen
# Render README.qmd -> README.md against the freshly built package.
readme: r-install
@quarto render README.qmd
# Delegate to a paper-local justfile. Slug is one of: combined, ipw, fiml, quadratic.
# Example: just paper ipw pdf
paper slug *args:
@cd papers/{{slug}} && just {{args}}
clean:
@rm -rf build-dev build-opt build-rdev
@rm -rf *.Rcheck
@rm -f misskappa_*.tar.gz
@rm -f r-package/src/*.o r-package/src/*.so r-package/src/*.dll r-package/src/symbols.rds