Expand description
Package C/C++ code compilation โ Makevars parser and compiler invocation.
Compiles package src/*.{c,cpp,cc,cxx} files into a shared library
(.so/.dylib). Uses the cc crate for compiler detection and flag
management (respects CC, CXX, CFLAGS, CXXFLAGS env vars, handles
cross-compilation). Only the final linking step uses std::process::Command.
Reads src/Makevars for package-specific flags.
Structsยง
- Makevars
- Parsed Makevars key-value pairs.
Enumsยง
- Assign
Op ๐
Functionsยง
- compile_
package - Compile C/C++ source files in a packageโs
src/directory into a shared library. - compile_
package_ with_ deps - Compile package native code with additional include paths from LinkingTo dependencies.
- current_
target_ ๐triple - Get the current platformโs target triple (e.g. โaarch64-apple-darwinโ).
- dylib_
ext ๐ - Shared library extension for the current platform.
- emulate_
configure ๐ - Emulate configure scripts for known packages that need platform-specific config.h or Makevars generation. Called before Makevars parsing.
- emulate_
configure_ ๐fs - Generate Makevars for
fspackage using system libuv instead of bundled. - emulate_
configure_ ๐ps - Generate config.h and Makevars for the
pspackage. - emulate_
configure_ ๐system_ lib - Generic configure emulation: replace a bundled static lib build with system library found via pkg-config. Writes a Makevars that uses system headers and libs instead of bundled source.
- expand_
make_ ๐vars - Expand Make variable references
$(VAR)with known R values. Unknown variables are stripped (removed from the string). - extract_
pkg_ ๐config_ name_ from_ configure - Parse a configure script to extract the pkg-config library name.
Looks for
PKG_CONFIG_NAME="..."pattern. - find_
sources ๐ - Find C and C++ source files to compile.
- is_
valid_ ๐makevars_ key - Check if a string is a valid Makevars variable name.
- parse_
assignment ๐ - Parse a line as
KEY = VALUEorKEY += VALUE. Returns (key, op, value_part) where value_part may have trailing\. - pkg_
config_ ๐name_ for_ package - Known mappings from CRAN package names to their pkg-config library names.
Derived from the
PKG_CONFIG_NAMEvariable in each packageโs configure script. - resolve_
anticonf ๐ - Resolve
@cflags@and@libs@placeholders in a Makevars.in file by querying pkg-config, replicating Rโs โanticonfโ configure pattern. - shell_
split ๐ - Simple shell-like splitting of a string into words. Handles basic quoting (double quotes) but not single quotes or escapes.
- strip_
continuation ๐ - Strip trailing backslash continuation. Returns (line_without_backslash, has_continuation).