Skip to main content

compile_package

Function compile_package 

Source
pub fn compile_package(
    pkg_src_dir: &Path,
    pkg_name: &str,
    output_dir: &Path,
    include_dir: &Path,
) -> Result<PathBuf, String>
Expand description

Compile C/C++ source files in a package’s src/ directory into a shared library.

Uses the cc crate for compiler detection (respects CC, CXX, CFLAGS, CXXFLAGS env vars, handles cross-compilation). The cc crate compiles sources to .o files; we then link them into a .so/.dylib ourselves.

§Arguments

  • pkg_src_dir — the package’s src/ directory
  • pkg_name — package name (used for the output library name)
  • output_dir — directory to write the compiled shared library
  • include_dir — path to miniR’s include/ directory (for Rinternals.h)

§Returns

Path to the compiled shared library.