Skip to main content

Module compile

Module compile 

Source
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ยง

AssignOp ๐Ÿ”’

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 fs package using system libuv instead of bundled.
emulate_configure_ps ๐Ÿ”’
Generate config.h and Makevars for the ps package.
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 = VALUE or KEY += 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_NAME variable 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).