Compile the attributes within the specified package directory into RcppExports.cpp and RcppExports.R
| 3616 | // Compile the attributes within the specified package directory into |
| 3617 | // RcppExports.cpp and RcppExports.R |
| 3618 | RcppExport SEXP compileAttributes(SEXP sPackageDir, |
| 3619 | SEXP sPackageName, |
| 3620 | SEXP sDepends, |
| 3621 | SEXP sRegistration, |
| 3622 | SEXP sCppFiles, |
| 3623 | SEXP sCppFileBasenames, |
| 3624 | SEXP sIncludes, |
| 3625 | SEXP sVerbose, |
| 3626 | SEXP sPlatform) { |
| 3627 | BEGIN_RCPP |
| 3628 | // arguments |
| 3629 | std::string packageDir = Rcpp::as<std::string>(sPackageDir); |
| 3630 | std::string packageName = Rcpp::as<std::string>(sPackageName); |
| 3631 | |
| 3632 | Rcpp::CharacterVector vDepends = Rcpp::as<Rcpp::CharacterVector>(sDepends); |
| 3633 | std::set<std::string> depends; |
| 3634 | for (Rcpp::CharacterVector::iterator |
| 3635 | it = vDepends.begin(); it != vDepends.end(); ++it) { |
| 3636 | depends.insert(std::string(*it)); |
| 3637 | } |
| 3638 | |
| 3639 | bool registration = Rcpp::as<bool>(sRegistration); |
| 3640 | |
| 3641 | std::vector<std::string> cppFiles = |
| 3642 | Rcpp::as<std::vector<std::string> >(sCppFiles); |
| 3643 | std::vector<std::string> cppFileBasenames = |
| 3644 | Rcpp::as<std::vector<std::string> >(sCppFileBasenames); |
| 3645 | std::vector<std::string> includes = |
| 3646 | Rcpp::as<std::vector<std::string> >(sIncludes); |
| 3647 | bool verbose = Rcpp::as<bool>(sVerbose); |
| 3648 | Rcpp::List platform = Rcpp::as<Rcpp::List>(sPlatform); |
| 3649 | std::string fileSep = Rcpp::as<std::string>(platform["file.sep"]); |
| 3650 | |
| 3651 | // initialize generators |
| 3652 | ExportsGenerators generators; |
| 3653 | generators.add(new CppExportsGenerator(packageDir, packageName, fileSep)); |
| 3654 | generators.add(new RExportsGenerator(packageDir, packageName, registration, fileSep)); |
| 3655 | |
| 3656 | // catch file exists exception if the include file already exists |
| 3657 | // and we are unable to overwrite it |
| 3658 | try { |
| 3659 | generators.add(new CppExportsIncludeGenerator(packageDir, |
| 3660 | packageName, |
| 3661 | fileSep)); |
| 3662 | } |
| 3663 | catch(const Rcpp::file_exists& e) { |
| 3664 | std::string msg = |
| 3665 | "The header file '" + e.filePath() + "' already exists so " |
| 3666 | "cannot be overwritten by Rcpp::interfaces"; |
| 3667 | throw Rcpp::exception(msg.c_str(), __FILE__, __LINE__); |
| 3668 | } |
| 3669 | |
| 3670 | // catch file exists exception for package include (because if it |
| 3671 | // already exists we simply leave it alone) |
| 3672 | try { |
| 3673 | generators.add(new CppPackageIncludeGenerator(packageDir, |
| 3674 | packageName, |
| 3675 | fileSep)); |
nothing calls this directly
no test coverage detected