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 bool getAttempted(
void)
const;
107 void setAttempted(
bool attempted);
108 dispatch_group_t getLoadingGroup(
void)
const;
112 void initialize(Environment *environment,
const string &searchPath,
VuoFileUtilities::File *file,
bool isSourceFile,
bool isSubcomposition);
114 Environment *environment;
119 bool sourceCodeOverridden;
120 unsigned long lastModified;
121 set<string> containedNodeClasses;
123 dispatch_group_t loading;
126 #include "pro/VuoCompilerModuleInfo_Pro.hh"
134 string getDependency(
void);
135 Environment * getEnvironment(
void);
136 void setEnvironment(Environment *environment);
137 bool isCompatible(
void);
138 void setCompatible(
bool compatible);
143 Environment *environment;
150 class ModuleInfoIterator
153 ModuleInfoIterator(map<
string, map<string, ModuleInfo *> > *allModuleInfos);
154 ModuleInfoIterator(map<
string, map<string, ModuleInfo *> > *allModuleInfos,
const set<string> &searchModuleKeys);
155 ModuleInfo * next(
void);
158 void initialize(
void);
160 map<string, map<string, ModuleInfo *> > *allModuleInfos;
161 set<string> searchModuleKeys;
162 bool hasSearchModuleKeys;
163 map<string, map<string, ModuleInfo *> >::iterator currSearchPath;
164 map<string, ModuleInfo *>::iterator currModuleKey;
165 bool hasCurrModuleKey;
199 set<VuoCompiler *> compilersToNotify;
200 dispatch_queue_t compilersToNotifyQueue;
201 set<VuoFileWatcher *> moduleSearchPathWatchers;
202 map<string, VuoCompilerNodeClass *> nodeClasses;
203 map<string, VuoCompilerType *> types;
204 set<VuoCompilerGenericType *> genericTypes;
205 map<string, VuoNodeSet *> nodeSetForName;
206 map<string, VuoCompilerModule *> libraryModules;
207 map<string, dispatch_group_t> specializedModulesLoading;
208 map<string, map<string, ModuleInfo *> > moduleFilesAtSearchPath;
209 map<string, map<string, ModuleInfo *> > sourceFilesAtSearchPath;
210 vector<string> moduleSearchPaths;
211 vector<string> headerSearchPaths;
212 vector<string> librarySearchPaths;
213 vector<string> frameworkSearchPaths;
214 vector<string> expatriateSourceFiles;
215 string moduleCachePath;
216 string moduleCacheSuffix;
217 bool isModuleCacheableDataDirty;
218 bool isModuleCacheInitialized;
219 bool isModuleCacheAvailable;
220 set<string> moduleCacheContents;
221 set<string> moduleCacheDylibs;
222 set<string> moduleCacheFrameworks;
223 static map<string, VuoFileUtilities::File *> moduleCacheFileForLocking;
224 static dispatch_queue_t moduleCacheBuildingQueue;
229 void updateModulesAtSearchPath(
const string &path,
bool shouldCleanModuleCache=
true);
230 void updateSourceFilesAtSearchPath(
const string &path);
231 void startWatchingModuleSearchPath(
const string &moduleSearchPath);
237 dispatch_queue_t moduleSearchPathContentsChangedQueue;
238 static const string pidCacheDirPrefix;
241 virtual ~Environment(
void);
243 void removeCompilerToNotify(
VuoCompiler *compiler);
247 map<string, VuoCompilerType *>
getTypes(
void);
253 void addModuleSearchPath(
const string &path,
bool shouldWatch =
true);
254 vector<string> getModuleSearchPaths(
void);
256 vector<string> getHeaderSearchPaths(
void);
258 vector<string> getLibrarySearchPaths(
void);
260 void setModuleCachePath(
const string &path);
261 string getCompiledModuleCachePath(
void);
262 string getOverriddenCompiledModuleCachePath(
void);
263 vector<string> getFrameworkSearchPaths(
void);
266 void addExpatriateSourceFile(
const string &sourcePath);
267 void removeExpatriateSourceFile(
const string &sourcePath);
268 ModuleInfo * listModule(
const string &moduleKey);
269 ModuleInfoIterator listModules(
const set<string> &moduleKeys);
270 ModuleInfoIterator listAllModules(
void);
271 ModuleInfo * listSourceFile(
const string &moduleKey);
272 ModuleInfoIterator listSourceFiles(
const set<string> &moduleKeys);
273 ModuleInfoIterator listAllSourceFiles(
void);
274 static vector<string> getBuiltInModuleSearchPaths(
void);
275 static vector<string> getBuiltInHeaderSearchPaths(
void);
276 static vector<string> getBuiltInLibrarySearchPaths(
void);
277 static vector<string> getBuiltInFrameworkSearchPaths(
void);
278 void addSearchPathsToSharedEnvironment(
void);
279 void stopWatchingModuleSearchPaths(
void);
280 void fileChanged(
const string &moduleSearchPath);
281 void moduleSearchPathContentsChanged(
const string &moduleSearchPath,
const string &moduleAddedOrModifiedPath =
"",
const string &moduleAddedOrModifiedSourceCode =
"", std::function<
void(
void)> moduleLoadedCallback =
nullptr,
VuoCompiler *compiler =
nullptr,
VuoCompilerIssues *issues =
nullptr);
282 void notifyCompilers(
const set<VuoCompilerModule *> &modulesAdded,
const set<pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
const set<VuoCompilerModule *> &modulesRemoved,
VuoCompilerIssues *issues,
bool oldModulesInvalidated =
true);
283 set<VuoCompilerModule *> loadCompiledModules(
const set<string> &moduleKeys,
const map<string, string> &sourceCodeForModule);
284 set<dispatch_group_t> loadSpecializedModules(
const set<string> &moduleKeys,
VuoCompiler *compiler, dispatch_queue_t
llvmQueue);
285 set<dispatch_group_t> compileModulesFromSourceCode(
const set<string> &moduleKeys,
bool shouldRecompileIfUnchanged);
286 set<VuoCompilerModule *> unloadCompiledModules(
const set<string> &moduleKeys);
287 void deleteModulesCompiledFromSourceCode(
const set<string> &moduleKeys);
291 void reifyPortTypes(
const map<string, VuoCompilerType *> &inheritedTypes);
292 void getCacheableModulesAndDependencies(
bool isBuiltIn,
bool installed, set<string> &cacheableModulesAndDependencies, set<string> &dylibsNeededToLinkToThisCache, set<string> &frameworksNeededToLinkToThisCache);
293 void useModuleCache(
bool shouldUseExistingCache,
VuoCompiler *compiler, set<string> cacheableModulesAndDependencies, set<string> dylibsNeededToLinkToCaches, set<string> frameworksNeededToLinkToCaches);
294 static void waitForModuleCachesToBuild(
void);
295 bool findInModuleCache(
const string &moduleOrDependency,
string &cachePath);
296 void modulesChanged(
void);
302 #include "pro/VuoCompilerEnvironment_Pro.hh"
306 static dispatch_queue_t environmentQueue;
307 static vector< vector<Environment *> > sharedEnvironments;
308 static map<string, vector<Environment *> > environmentsForCompositionFamily;
309 vector< vector<Environment *> > environments;
310 string lastCompositionBaseDir;
311 bool lastCompositionIsSubcomposition;
312 bool shouldLoadAllModules;
313 bool hasLoadedAllModules;
314 dispatch_queue_t modulesToLoadQueue;
315 static dispatch_group_t moduleSourceCompilersExist;
316 dispatch_group_t moduleCacheBuilding;
319 static string vuoFrameworkInProgressPath;
320 llvm::sys::Path clangPath;
324 bool _shouldShowSplashWindow;
326 dispatch_queue_t delegateQueue;
328 void applyToInstalledEnvironments(
void (^doForEnvironment)(Environment *));
329 void applyToInstalledEnvironments(
void (^doForEnvironment)(Environment *,
bool *,
string),
bool *,
string);
330 void applyToAllEnvironments(
void (^doForEnvironment)(Environment *));
332 static void reset(
void);
334 void loadModulesIfNeeded(
const set<string> &moduleKeys = set<string>());
335 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);
336 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);
337 void loadedModules(map<string, VuoCompilerModule *> modulesAdded, map<
string, pair<VuoCompilerModule *, VuoCompilerModule *> > modulesModified, map<string, VuoCompilerModule *> modulesRemoved,
VuoCompilerIssues *issues,
void *delegateData, Environment *currentEnvironment);
340 void reifyGenericPortTypes(
VuoNode *node);
342 void compileSubcompositionString(
const string &compositionString,
const string &outputPath, std::function<
void(
void)> moduleLoadedCallback, Environment *environment,
VuoCompilerIssues *issues = NULL,
const string inputPathForIssues =
"");
343 void linkCompositionToCreateExecutableOrDynamicLibrary(
string compiledCompositionPath,
string linkedCompositionPath,
Optimization optimization,
bool isDylib,
string rPath=
"");
344 set<string> getDependenciesForComposition(
const string &compiledCompositionPath);
345 set<string> getDependenciesForComposition(
const set<string> &directDependencies,
bool checkCompatibility);
346 void getLinkerInputs(
const set<string> &dependencies,
Optimization optimization, set<Module *> &modules, set<string> &libraries, set<string> &frameworks);
347 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);
348 static string getLibraryPath(
const string &dependency, vector<string> librarySearchPaths);
349 void useModuleCache(
bool shouldUseExistingBuiltInCaches,
bool shouldUseExistingOtherCaches);
350 bool findInModuleCache(
const string &moduleOrDependency,
string &cachePath,
bool &isBuiltinCache)
VuoWarnUnusedResult;
351 void link(
string outputPath,
const set<Module *> &modules,
const set<string> &libraries,
const set<string> &frameworks,
bool isDylib,
string rPath=
"");
352 Module * readModuleFromC(
string inputPath,
const vector<string> &headerSearchPaths,
const vector<string> &extraArgs);
354 static Module * readModuleFromBitcodeData(
char *inputData,
size_t inputDataBytes,
string &error);
355 static bool writeModuleToBitcode(Module *module,
string outputPath);
356 VuoNode * createPublishedNode(
const string &nodeClassName,
const vector<VuoPublishedPort *> &publishedPorts);
357 static void setTargetForModule(Module *module,
string target =
"");
359 static vector<string> getCoreVuoDependencies(
void);
360 static string getRuntimeMainDependency(
void);
361 static string getRuntimeDependency(
void);
362 void addModuleSearchPath(
string path);
363 static string getVuoFrameworkPath(
void);
364 llvm::sys::Path getClangPath(
void);
365 void setClangPath(
const string &clangPath);
366 string getCompositionStubPath(
void);
367 static string getCachePathForComposition(
const string compositionDir);
371 friend class TestCompilerDelegate;
372 friend class TestVuoCompilerModule;
373 friend class TestVuoCompilerBitcodeGenerator;
385 static Module * readModuleFromBitcode(
string inputPath);
392 void compileModule(
string inputPath,
string outputPath,
const vector<string> &includeDirs);
413 map<string, VuoCompilerType *>
getTypes(
void);
439 #include "pro/VuoCompiler_Pro.hh"
482 virtual void loadedModules(
const map<string, VuoCompilerModule *> &modulesAdded,
483 const map<
string, pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
484 const map<string, VuoCompilerModule *> &modulesRemoved,
VuoCompilerIssues *issues) = 0;
498 class LoadedModulesData
501 LoadedModulesData(
const set< pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
503 ~LoadedModulesData(
void);
509 dispatch_queue_t referenceCountQueue;
510 set< pair<VuoCompilerModule *, VuoCompilerModule *> > modulesModified;
511 set<VuoCompilerModule *> modulesRemoved;
515 void enqueueData(LoadedModulesData *data);
516 LoadedModulesData * dequeueData(
void);
518 list<LoadedModulesData *> pendingData;
519 dispatch_queue_t pendingDataQueue;