89 ModuleInfo(Environment *environment,
const string &searchPath,
const string &relativePath,
bool isSourceFile,
bool isSubcomposition);
90 ModuleInfo(Environment *environment,
const string &searchPath,
VuoFileUtilities::File *file,
bool isSourceFile,
bool isSubcomposition);
92 Environment * getEnvironment(
void)
const;
93 string getSearchPath(
void)
const;
94 string getModuleKey(
void)
const;
96 string getSourceCode(
void)
const;
97 void setSourceCode(
const string &sourceCode);
98 void revertSourceCode(
void);
99 bool isSourceCodeOverridden(
void)
const;
100 void setSourceCodeOverridden(
bool overridden);
101 bool isNewerThan(ModuleInfo *other)
const;
102 bool isNewerThan(
unsigned long seconds)
const;
103 bool isOlderThan(
unsigned long seconds)
const;
104 void setLastModifiedToNow(
void);
105 set<string> getContainedNodeClasses(
void)
const;
106 int getLongestDownstreamPath(
void)
const;
107 void setLongestDownstreamPath(
int pathLength);
108 bool getAttempted(
void)
const;
109 void setAttempted(
bool attempted);
110 dispatch_group_t getLoadingGroup(
void)
const;
114 void initialize(Environment *environment,
const string &searchPath,
VuoFileUtilities::File *file,
bool isSourceFile,
bool isSubcomposition);
116 Environment *environment;
121 bool sourceCodeOverridden;
122 unsigned long lastModified;
123 set<string> containedNodeClasses;
124 int longestDownstreamPath;
126 dispatch_group_t loading;
128 #pragma clang diagnostic push
129 #pragma clang diagnostic ignored "-Wunused-private-field"
131 #pragma clang diagnostic pop
133 #include "pro/VuoCompilerModuleInfo_Pro.hh"
141 string getDependency(
void);
142 Environment * getEnvironment(
void);
143 void setEnvironment(Environment *environment);
144 bool isCompatible(
void);
145 void setCompatible(
bool compatible);
150 Environment *environment;
157 class ModuleInfoIterator
160 ModuleInfoIterator(map<
string, map<string, ModuleInfo *> > *allModuleInfos);
161 ModuleInfoIterator(map<
string, map<string, ModuleInfo *> > *allModuleInfos,
const set<string> &searchModuleKeys);
162 ModuleInfo * next(
void);
165 void initialize(
void);
167 map<string, map<string, ModuleInfo *> > *allModuleInfos;
168 set<string> searchModuleKeys;
169 bool hasSearchModuleKeys;
170 map<string, map<string, ModuleInfo *> >::iterator currSearchPath;
171 map<string, ModuleInfo *>::iterator currModuleKey;
172 bool hasCurrModuleKey;
206 set<VuoCompiler *> compilersToNotify;
207 dispatch_queue_t compilersToNotifyQueue;
208 set<VuoFileWatcher *> moduleSearchPathWatchers;
209 map<string, VuoCompilerNodeClass *> nodeClasses;
210 map<string, VuoCompilerType *> types;
211 set<VuoCompilerGenericType *> genericTypes;
212 map<string, VuoNodeSet *> nodeSetForName;
213 map<string, VuoCompilerModule *> libraryModules;
214 map<string, dispatch_group_t> specializedModulesLoading;
215 map<string, map<string, ModuleInfo *> > moduleFilesAtSearchPath;
216 map<string, map<string, ModuleInfo *> > sourceFilesAtSearchPath;
217 vector<string> moduleSearchPaths;
218 vector<string> headerSearchPaths;
219 vector<string> librarySearchPaths;
220 vector<string> frameworkSearchPaths;
221 vector<string> expatriateSourceFiles;
222 string moduleCachePath;
223 string moduleCacheSuffix;
224 bool isModuleCacheableDataDirty;
225 bool isModuleCacheInitialized;
226 bool isModuleCacheAvailable;
227 set<string> moduleCacheContents;
228 set<string> moduleCacheDylibs;
229 set<string> moduleCacheFrameworks;
230 static map<string, VuoFileUtilities::File *> moduleCacheFileForLocking;
231 static dispatch_queue_t moduleCacheBuildingQueue;
236 void updateModulesAtSearchPath(
const string &path,
bool shouldCleanModuleCache=
true);
237 void updateSourceFilesAtSearchPath(
const string &path);
238 void startWatchingModuleSearchPath(
const string &moduleSearchPath);
244 dispatch_queue_t moduleSearchPathContentsChangedQueue;
245 static const string pidCacheDirPrefix;
248 virtual ~Environment(
void);
250 void removeCompilerToNotify(
VuoCompiler *compiler);
254 map<string, VuoCompilerType *>
getTypes(
void);
260 void addModuleSearchPath(
const string &path,
bool shouldWatch =
true);
261 vector<string> getModuleSearchPaths(
void);
263 vector<string> getHeaderSearchPaths(
void);
265 vector<string> getLibrarySearchPaths(
void);
267 void setModuleCachePath(
const string &path);
268 string getCompiledModuleCachePath(
void);
269 string getOverriddenCompiledModuleCachePath(
void);
270 vector<string> getFrameworkSearchPaths(
void);
273 void addExpatriateSourceFile(
const string &sourcePath);
274 void removeExpatriateSourceFile(
const string &sourcePath);
275 ModuleInfo * listModule(
const string &moduleKey);
276 ModuleInfoIterator listModules(
const set<string> &moduleKeys);
277 ModuleInfoIterator listAllModules(
void);
278 ModuleInfo * listSourceFile(
const string &moduleKey);
279 ModuleInfoIterator listSourceFiles(
const set<string> &moduleKeys);
280 ModuleInfoIterator listAllSourceFiles(
void);
281 static vector<string> getBuiltInModuleSearchPaths(
void);
282 static vector<string> getBuiltInHeaderSearchPaths(
void);
283 static vector<string> getBuiltInLibrarySearchPaths(
void);
284 static vector<string> getBuiltInFrameworkSearchPaths(
void);
285 void addSearchPathsToSharedEnvironment(
void);
286 void stopWatchingModuleSearchPaths(
void);
287 void fileChanged(
const string &moduleSearchPath);
288 void moduleSearchPathContentsChanged(
const string &moduleSearchPath,
const string &moduleAddedOrModifiedPath =
"",
const string &moduleAddedOrModifiedSourceCode =
"", std::function<
void(
void)> moduleLoadedCallback =
nullptr,
VuoCompiler *compiler =
nullptr,
VuoCompilerIssues *issues =
nullptr);
289 void notifyCompilers(
const set<VuoCompilerModule *> &modulesAdded,
const set<pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
const set<VuoCompilerModule *> &modulesRemoved,
VuoCompilerIssues *issues,
bool oldModulesInvalidated =
true);
290 set<VuoCompilerModule *> loadCompiledModules(
const set<string> &moduleKeys,
const map<string, string> &sourceCodeForModule);
291 set<dispatch_group_t> loadSpecializedModules(
const set<string> &moduleKeys,
VuoCompiler *compiler, dispatch_queue_t
llvmQueue);
292 set<dispatch_group_t> compileModulesFromSourceCode(
const set<string> &moduleKeys,
bool shouldRecompileIfUnchanged);
293 set<VuoCompilerModule *> unloadCompiledModules(
const set<string> &moduleKeys);
294 void deleteModulesCompiledFromSourceCode(
const set<string> &moduleKeys);
298 void reifyPortTypes(
const map<string, VuoCompilerType *> &inheritedTypes);
299 void getCacheableModulesAndDependencies(
bool isBuiltIn,
bool installed, set<string> &cacheableModulesAndDependencies, set<string> &dylibsNeededToLinkToThisCache, set<string> &frameworksNeededToLinkToThisCache);
300 void useModuleCache(
bool shouldUseExistingCache,
VuoCompiler *compiler, set<string> cacheableModulesAndDependencies, set<string> dylibsNeededToLinkToCaches, set<string> frameworksNeededToLinkToCaches);
301 static void waitForModuleCachesToBuild(
void);
302 bool findInModuleCache(
const string &moduleOrDependency,
string &cachePath);
303 void modulesChanged(
void);
309 #include "pro/VuoCompilerEnvironment_Pro.hh"
313 static set<VuoCompiler *> allCompilers;
314 static dispatch_queue_t environmentQueue;
315 static vector< vector<Environment *> > sharedEnvironments;
316 static map<string, vector<Environment *> > environmentsForCompositionFamily;
317 vector< vector<Environment *> > environments;
318 string lastCompositionBaseDir;
319 bool lastCompositionIsSubcomposition;
320 bool shouldLoadAllModules;
321 bool hasLoadedAllModules;
322 dispatch_queue_t modulesToLoadQueue;
323 static dispatch_group_t moduleSourceCompilersExist;
324 dispatch_group_t moduleCacheBuilding;
327 static string vuoFrameworkInProgressPath;
328 llvm::sys::Path clangPath;
332 bool _shouldShowSplashWindow;
334 dispatch_queue_t delegateQueue;
336 void applyToInstalledEnvironments(
void (^doForEnvironment)(Environment *));
337 void applyToInstalledEnvironments(
void (^doForEnvironment)(Environment *,
bool *,
string),
bool *,
string);
338 void applyToAllEnvironments(
void (^doForEnvironment)(Environment *));
340 static void reset(
void);
342 void loadModulesIfNeeded(
const set<string> &moduleKeys = set<string>());
343 set<dispatch_group_t> loadModulesAndSources(
const set<string> &modulesAddedKeys,
const set<string> &modulesModifiedKeys,
const set<string> &modulesRemovedKeys,
const set<string> &sourcesAddedKeys,
const set<string> &sourcesModifiedKeys,
const set<string> &sourcesRemovedKeys,
bool willLoadAllModules,
bool shouldRecompileSourcesIfUnchanged, Environment *currentEnvironment,
VuoCompilerIssues *issuesForCurrentEnvironment, std::function<
void(
void)> moduleLoadedCallback,
const string &moduleAddedOrModifiedSourceCode);
344 void findDependentModulesAndSources(map<Environment *, set<string> > &changedModules,
const vector<VuoDirectedAcyclicNetwork *> &searchDependencyGraphs,
VuoDirectedAcyclicGraph *currentEnvironmentDependencyGraph, map<Environment *, set<string> > &modulesDepOnChangedModules_this, map<Environment *, set<string> > &modulesDepOnChangedModules_other, map<Environment *, set<string> > &sourcesDepOnChangedModules_this, map<Environment *, set<string> > &sourcesDepOnChangedModules_other);
345 void loadedModules(map<string, VuoCompilerModule *> modulesAdded, map<
string, pair<VuoCompilerModule *, VuoCompilerModule *> > modulesModified, map<string, VuoCompilerModule *> modulesRemoved,
VuoCompilerIssues *issues,
void *delegateData, Environment *currentEnvironment);
348 void reifyGenericPortTypes(
VuoNode *node);
350 void compileSubcompositionString(
const string &compositionString,
const string &outputPath, std::function<
void(
void)> moduleLoadedCallback, Environment *environment,
VuoCompilerIssues *issues = NULL,
const string inputPathForIssues =
"");
351 void linkCompositionToCreateExecutableOrDynamicLibrary(
string compiledCompositionPath,
string linkedCompositionPath,
Optimization optimization,
bool isDylib,
string rPath=
"");
352 set<string> getDependenciesForComposition(
const string &compiledCompositionPath);
353 set<string> getDependenciesForComposition(
const set<string> &directDependencies,
bool checkCompatibility);
354 void getLinkerInputs(
const set<string> &dependencies,
Optimization optimization, set<Module *> &modules, set<string> &libraries, set<string> &frameworks);
355 void getLinkerInputs(
const set<string> &dependencies,
Optimization optimization, set<string> &builtInModuleAndLibraryDependencies, set<string> &userModuleAndLibraryDependencies, map<
string, set<string> > &builtInCacheDependencies, map<
string, set<string> > &userCacheDependencies, set<Module *> &builtInModules, set<Module *> &userModules, set<string> &builtInLibraries, set<string> &userLibraries, set<string> &externalLibraries, set<string> &externalFrameworks);
356 static string getLibraryPath(
const string &dependency, vector<string> librarySearchPaths);
357 void useModuleCache(
bool shouldUseExistingBuiltInCaches,
bool shouldUseExistingOtherCaches);
358 bool findInModuleCache(
const string &moduleOrDependency,
string &cachePath,
bool &isBuiltinCache)
VuoWarnUnusedResult;
359 void link(
string outputPath,
const set<Module *> &modules,
const set<string> &libraries,
const set<string> &frameworks,
bool isDylib,
string rPath=
"");
360 Module * readModuleFromC(
string inputPath,
const vector<string> &headerSearchPaths,
const vector<string> &extraArgs);
362 static Module * readModuleFromBitcodeData(
char *inputData,
size_t inputDataBytes,
string &error);
363 static bool writeModuleToBitcode(Module *module,
string outputPath);
364 VuoNode * createPublishedNode(
const string &nodeClassName,
const vector<VuoPublishedPort *> &publishedPorts);
365 static void setTargetForModule(Module *module,
string target =
"");
367 static vector<string> getCoreVuoDependencies(
void);
368 static string getRuntimeMainDependency(
void);
369 static string getRuntimeDependency(
void);
370 void addModuleSearchPath(
string path);
371 static string getVuoFrameworkPath(
void);
372 llvm::sys::Path getClangPath(
void);
373 void setClangPath(
const string &clangPath);
374 string getCompositionStubPath(
void);
375 static string getCachePathForComposition(
const string compositionDir);
379 friend class TestCompilerDelegate;
380 friend class TestVuoCompilerModule;
381 friend class TestVuoCompilerBitcodeGenerator;
393 static Module * readModuleFromBitcode(
string inputPath);
400 void compileModule(
string inputPath,
string outputPath,
const vector<string> &includeDirs);
422 map<string, VuoCompilerType *>
getTypes(
void);
450 #include "pro/VuoCompiler_Pro.hh"
493 virtual void loadedModules(
const map<string, VuoCompilerModule *> &modulesAdded,
494 const map<
string, pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
495 const map<string, VuoCompilerModule *> &modulesRemoved,
VuoCompilerIssues *issues) = 0;
509 class LoadedModulesData
512 LoadedModulesData(
const set< pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
514 ~LoadedModulesData(
void);
520 dispatch_queue_t referenceCountQueue;
521 set< pair<VuoCompilerModule *, VuoCompilerModule *> > modulesModified;
522 set<VuoCompilerModule *> modulesRemoved;
526 void enqueueData(LoadedModulesData *data);
527 LoadedModulesData * dequeueData(
void);
529 list<LoadedModulesData *> pendingData;
530 dispatch_queue_t pendingDataQueue;