@@ -174,14 +174,23 @@ codeql::TrapDomain invocationTrapDomain(codeql::SwiftExtractorState& state) {
174174 return std::move (maybeDomain.value ());
175175}
176176
177- codeql::SwiftExtractorConfiguration configure (int argc, char ** argv) {
177+ codeql::SwiftExtractorConfiguration configure (int argc,
178+ char ** argv,
179+ const std::string& resourceDir) {
178180 codeql::SwiftExtractorConfiguration configuration{};
179181 configuration.trapDir = getenv_or (" CODEQL_EXTRACTOR_SWIFT_TRAP_DIR" , " extractor-out/trap/swift" );
180182 configuration.sourceArchiveDir =
181183 getenv_or (" CODEQL_EXTRACTOR_SWIFT_SOURCE_ARCHIVE_DIR" , " extractor-out/src" );
182184 configuration.scratchDir =
183185 getenv_or (" CODEQL_EXTRACTOR_SWIFT_SCRATCH_DIR" , " extractor-out/working" );
184186 configuration.frontendOptions .assign (argv + 1 , argv + argc);
187+ // TODO: Should be moved to the tracer config
188+ for (int i = 0 ; i < argc - 1 ; i++) {
189+ if (std::string (" -resource-dir" ) == configuration.frontendOptions [i]) {
190+ configuration.frontendOptions [i + 1 ] = resourceDir.c_str ();
191+ break ;
192+ }
193+ }
185194 return configuration;
186195}
187196
@@ -214,7 +223,9 @@ int main(int argc, char** argv, char** envp) {
214223 INITIALIZE_LLVM ();
215224 initializeSwiftModules ();
216225
217- const auto configuration = configure (argc, argv);
226+ std::string resourceDir = getenv_or (" CODEQL_EXTRACTOR_SWIFT_ROOT" , " ." ) + " /resource-dir/" +
227+ getenv_or (" CODEQL_PLATFORM" , " ." );
228+ const auto configuration = configure (argc, argv, resourceDir);
218229 LOG_INFO (" calling extractor with arguments \" {}\" " , argDump (argc, argv));
219230 LOG_DEBUG (" environment:\n {}\n " , envDump (envp));
220231
0 commit comments