@@ -58,6 +58,8 @@ nCompile_nFunction <- function(NF,
5858 if (is.null(compileInfo )) compileInfo <- NFinternals(NF )$ compileInfo
5959
6060 is_predefined <- ! isFALSE(NFinternals(NF )$ predefined )
61+ gather_needed_units <- isTRUE(controlFull $ always_include_units )
62+ needed_units <- list ()
6163 if (is_predefined ) {
6264 predefined_dir <- NFinternals(NF )$ predefined
6365 # predefined can be character, quoted expression, or function.
@@ -75,6 +77,7 @@ nCompile_nFunction <- function(NF,
7577 " It should give the directory path of the predefined nFunction. " ,
7678 " The name argument to nFunction gives the base for filenames in that directory." )
7779 regular_filename <- NFinternals(NF )$ cpp_code_name
80+ if (gather_needed_units ) needed_units <- NFinternals(NF )$ compileInfo $ needed_units
7881 }
7982 if (is_predefined && isFALSE(controlFull $ generate_predefined )) {
8083 RcppPacket <- loadRcppPacket(predefined_dir , regular_filename )
@@ -98,6 +101,8 @@ nCompile_nFunction <- function(NF,
98101 predefined_gen_dir <- predefined_dir
99102 RcppPacket <- cppDefs_2_RcppPacket(NF_Compiler $ cppDef )
100103 saveRcppPacket(RcppPacket , predefined_dir , regular_filename )
104+ } else {
105+ if (gather_needed_units ) needed_units <- NF_Compiler $ gather_needed_units()
101106 }
102107 stageName <- ' makeRcppPacket'
103108 if (logging ) logBeforeStage(stageName )
@@ -106,8 +111,10 @@ nCompile_nFunction <- function(NF,
106111
107112 cppDef <- NF_Compiler $ cppDef
108113 }
109- if (stopAfterCppDef ) return (cppDef )
110-
114+ if (stopAfterCppDef ) {
115+ if (gather_needed_units ) return (list (needed_units = needed_units , cppDef = cppDef ))
116+ else return (cppDef )
117+ }
111118 # We might deprecate from here down and make all usages start from nCompile.
112119
113120 stop(" Entering deprecated portion of nCompile_nFunction. Check what is going on." )
0 commit comments