Title: | Exploring and Testing the Toolchain and System Libraries |
---|---|
Description: | Helper functions that interface with the system utilities to learn about the local build environment. Lets you explore 'make' rules to test the local configuration, or query 'pkg-config' to find compiler flags and libs needed for building packages with external dependencies. Also contains tools to analyze which libraries that a installed R package linked to by inspecting output from 'ldd' in combination with information from your distribution package manager, e.g. 'rpm' or 'dpkg'. |
Authors: | Jeroen Ooms [aut, cre, cph] |
Maintainer: | Jeroen Ooms <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.3.1 |
Built: | 2024-11-04 05:49:50 UTC |
Source: | https://github.com/jeroen/maketools |
Print some diagnostics about your compiler environment. These are also
shown when the maketools
package is attached.
maketools_diagnostics()
maketools_diagnostics()
Other maketools:
make()
,
pkgconfig
,
r_config
,
sysdeps
Get some extra info about packages.
find_logo(path = ".")
find_logo(path = ".")
path |
root directory of package |
Compile C / C++ / Fortran source files using the compiler configured
by your R Makeconf
file.
make(target = "all", makefile = r_makeconf_path()) make_call(cmd = "$(CC)", args = "--version") make_echo(cmd = "$(CC)") make_info()
make(target = "all", makefile = r_makeconf_path()) make_call(cmd = "$(CC)", args = "--version") make_echo(cmd = "$(CC)") make_info()
target |
name of output file that you want to make |
makefile |
path to the |
cmd |
command to invoke (may be a variable) |
args |
additional arguments for |
The make
function literally calls make yourfile.o -f /path/to/R/Makeconf
.
This is exactly what R does when building packages and hence the best
way to test if the compiler is working.
Other maketools:
diagnostics
,
pkgconfig
,
r_config
,
sysdeps
# Test the CXX compiler if(cxx_info()$available){ testprog <- '#include <iostream>\nint main() {std::cout << "Hello World!";}' writeLines(testprog, con = 'testprog.cc') make('testprog') # Test and cleanup system('./testprog') unlink('testprog*', recursive = TRUE) } # Run a program from a make variable make_call('$(CXX)', '--version') # Where your makeconf is stored: make_info()
# Test the CXX compiler if(cxx_info()$available){ testprog <- '#include <iostream>\nint main() {std::cout << "Hello World!";}' writeLines(testprog, con = 'testprog.cc') make('testprog') # Test and cleanup system('./testprog') unlink('testprog*', recursive = TRUE) } # Run a program from a make variable make_call('$(CXX)', '--version') # Where your makeconf is stored: make_info()
Wrappers for the pkg-config utility to query information on C/C++ libraries that are available on your system.
pc_info() pc_pkg_list() pc_pkg_exists(pkg = "libcurl") pc_pkg_version(pkg = "libcurl") pc_pkg_cflags(pkg = "libcurl") pc_pkg_libs(pkg = "libcurl", static = FALSE) pc_pkg_info(pkg = "libcurl")
pc_info() pc_pkg_list() pc_pkg_exists(pkg = "libcurl") pc_pkg_version(pkg = "libcurl") pc_pkg_cflags(pkg = "libcurl") pc_pkg_libs(pkg = "libcurl", static = FALSE) pc_pkg_info(pkg = "libcurl")
pkg |
names of the pkg-config libraries to query |
static |
get libs for static linking, i.e. include dependencies |
Other maketools:
diagnostics
,
make()
,
r_config
,
sysdeps
# Check if pkg-config is available (info <- pc_info()) if(info$available) pc_pkg_list()
# Check if pkg-config is available (info <- pc_info()) if(info$available) pc_pkg_list()
Cross-platform wrappers for R CMD config
to lookup the availability
of the compiler.
cc_info() cxx_info() cxx11_info() cxx14_info() cxx17_info() fc_info() r_cmd_config(VAR = "--all")
cc_info() cxx_info() cxx11_info() cxx14_info() cxx17_info() fc_info() r_cmd_config(VAR = "--all")
VAR |
value passed to |
Other maketools:
diagnostics
,
make()
,
pkgconfig
,
sysdeps
# This runs 'R CMD CONFIG CXX' r_cmd_config("CXX") # Show C++ config: cxx_info()
# This runs 'R CMD CONFIG CXX' r_cmd_config("CXX") # Show C++ config: cxx_info()
Shows the external shared libraries that an installed R package is linked to
by running ldd
on the package so
file. Then uses system package manager
(e.g. dpkg
or rpm
or brew
) to locate which system package that contains
the binaries, headers, and (if available) sources for this library.
package_sysdeps(pkg, lib.loc = NULL) package_sysdeps_string(pkg, lib.loc = NULL) package_links_to(pkg, lib.loc = NULL)
package_sysdeps(pkg, lib.loc = NULL) package_sysdeps_string(pkg, lib.loc = NULL) package_links_to(pkg, lib.loc = NULL)
pkg |
name of an installed R package |
lib.loc |
path to the R package directory for this package |
For common distributions, the output also includes a URL to the distro-homepage of the system package. Here we can typically find more information about the package, such as configuration options, dependencies, and custom patches applied by your distribution.
Because we use ldd
, this only shows run-time dependencies of an installed R
package. This is especially relevant if you distribute the compiled R package
in binary form, because the same external libraries need to be available on
the user/deployment machine. This tool does not show dependencies that are
only needed at build-time, such as static or header-only libraries, and other
utilities required to build the package.
Other maketools:
diagnostics
,
make()
,
pkgconfig
,
r_config