MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / addExtraDependency

Function addExtraDependency

src/ast/ast_parse.cpp:990–1057  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

988 }
989
990 bool addExtraDependency(
991 string modName,
992 string modFile,
993 vector<MissingRecord> & missing,
994 vector<RequireRecord> & circular,
995 vector<RequireRecord> & notAllowed,
996 vector<ModuleInfo> & req,
997 das_set<string> & dependencies,
998 das_hash_map<string, NamelessModuleReq> & namelessReq,
999 vector<NamelessMismatch> & namelessMismatches,
1000 const FileAccessPtr & access,
1001 ModuleGroup & libGroup,
1002 CodeOfPolicies policies,
1003 TextWriter * log = nullptr) {
1004 bool hasModule = false;
1005 for ( auto & mod : req ) {
1006 if ( mod.moduleName==modName) {
1007 hasModule = true;
1008 break;
1009 }
1010 }
1011 if ( !hasModule && !modFile.empty() ) {
1012 vector<FileInfo *> chain;
1013 TextWriter tw;
1014 // vector<ModuleInfo> new_reqs;
1015 const auto prev_mod = libGroup.getModules();
1016 auto prev_req = req;
1017 if ( !getPrerequisits(modFile, access, modName, req, missing, circular, notAllowed, chain,
1018 dependencies, namelessReq, namelessMismatches, libGroup, &tw, 1, !policies.ignore_shared_modules) ) {
1019 if ( log ) {
1020 *log << "failed to add extra dependency " << modName << " from " << modFile << "\n";
1021 *log << "module dependency graph:\n" << tw.str();
1022 }
1023 return false;
1024 }
1025 for (auto mod : libGroup.getModules()) {
1026 if (!count(prev_mod.begin(), prev_mod.end(), mod)) {
1027 mod->fromExtraDependency = true;
1028 }
1029 }
1030 for (auto &reqR : req) {
1031 if (!count_if(prev_req.begin(), prev_req.end(), [&reqR](const ModuleInfo &mod) {
1032 return mod.moduleName == reqR.moduleName;
1033 })) {
1034 reqR.extraDepModule = true;
1035 }
1036 }
1037 // If the module was already promoted to the global list
1038 // by a prior compilation reuse it directly instead of
1039 // recompilation. Without this, a second Module* with the
1040 // same nameHash ends up in the library and causes
1041 // a hash-collision crash in addModule.
1042 auto promotedMod = Module::requireEx(modName, true);
1043 if ( promotedMod && promotedMod->promoted ) {
1044 promotedMod->fromExtraDependency = true;
1045 libGroup.addModule(promotedMod);
1046 return true;
1047 }

Callers 1

compileDaScriptFunction · 0.85

Calls 9

getPrerequisitsFunction · 0.85
countFunction · 0.85
emptyMethod · 0.45
strMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
addModuleMethod · 0.45
getFileInfoMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected