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;
127 #include "pro/VuoCompilerModuleInfo_Pro.hh"
135 string getDependency(
void);
136 Environment * getEnvironment(
void);
137 void setEnvironment(Environment *environment);
138 bool isCompatible(
void);
139 void setCompatible(
bool compatible);
144 Environment *environment;
151 class ModuleInfoIterator
154 ModuleInfoIterator(map<
string, map<string, ModuleInfo *> > *allModuleInfos);
155 ModuleInfoIterator(map<
string, map<string, ModuleInfo *> > *allModuleInfos,
const set<string> &searchModuleKeys);
156 ModuleInfo * next(
void);
159 void initialize(
void);
161 map<string, map<string, ModuleInfo *> > *allModuleInfos;
162 set<string> searchModuleKeys;
163 bool hasSearchModuleKeys;
164 map<string, map<string, ModuleInfo *> >::iterator currSearchPath;
165 map<string, ModuleInfo *>::iterator currModuleKey;
166 bool hasCurrModuleKey;
200 set<VuoCompiler *> compilersToNotify;
201 dispatch_queue_t compilersToNotifyQueue;
202 set<VuoFileWatcher *> moduleSearchPathWatchers;
203 map<string, VuoCompilerNodeClass *> nodeClasses;
204 map<string, VuoCompilerType *> types;
205 set<VuoCompilerGenericType *> genericTypes;
206 map<string, VuoNodeSet *> nodeSetForName;
207 map<string, VuoCompilerModule *> libraryModules;
208 map<string, dispatch_group_t> specializedModulesLoading;
209 map<string, map<string, ModuleInfo *> > moduleFilesAtSearchPath;
210 map<string, map<string, ModuleInfo *> > sourceFilesAtSearchPath;
211 vector<string> moduleSearchPaths;
212 vector<string> headerSearchPaths;
213 vector<string> librarySearchPaths;
214 vector<string> frameworkSearchPaths;
215 vector<string> expatriateSourceFiles;
216 string moduleCachePath;
217 string moduleCacheSuffix;
218 bool isModuleCacheableDataDirty;
219 bool isModuleCacheInitialized;
220 bool isModuleCacheAvailable;
221 set<string> moduleCacheContents;
222 set<string> moduleCacheDylibs;
223 set<string> moduleCacheFrameworks;
224 static map<string, VuoFileUtilities::File *> moduleCacheFileForLocking;
225 static dispatch_queue_t moduleCacheBuildingQueue;
230 void updateModulesAtSearchPath(
const string &path,
bool shouldCleanModuleCache=
true);
231 void updateSourceFilesAtSearchPath(
const string &path);
232 void startWatchingModuleSearchPath(
const string &moduleSearchPath);
238 dispatch_queue_t moduleSearchPathContentsChangedQueue;
239 static const string pidCacheDirPrefix;
242 virtual ~Environment(
void);
244 void removeCompilerToNotify(
VuoCompiler *compiler);
248 map<string, VuoCompilerType *>
getTypes(
void);
254 void addModuleSearchPath(
const string &path,
bool shouldWatch =
true);
255 vector<string> getModuleSearchPaths(
void);
257 vector<string> getHeaderSearchPaths(
void);
259 vector<string> getLibrarySearchPaths(
void);
261 void setModuleCachePath(
const string &path);
262 string getCompiledModuleCachePath(
void);
263 string getOverriddenCompiledModuleCachePath(
void);
264 vector<string> getFrameworkSearchPaths(
void);
267 void addExpatriateSourceFile(
const string &sourcePath);
268 void removeExpatriateSourceFile(
const string &sourcePath);
269 ModuleInfo * listModule(
const string &moduleKey);
270 ModuleInfoIterator listModules(
const set<string> &moduleKeys);
271 ModuleInfoIterator listAllModules(
void);
272 ModuleInfo * listSourceFile(
const string &moduleKey);
273 ModuleInfoIterator listSourceFiles(
const set<string> &moduleKeys);
274 ModuleInfoIterator listAllSourceFiles(
void);
275 static vector<string> getBuiltInModuleSearchPaths(
void);
276 static vector<string> getBuiltInHeaderSearchPaths(
void);
277 static vector<string> getBuiltInLibrarySearchPaths(
void);
278 static vector<string> getBuiltInFrameworkSearchPaths(
void);
279 void addSearchPathsToSharedEnvironment(
void);
280 void stopWatchingModuleSearchPaths(
void);
281 void fileChanged(
const string &moduleSearchPath);
282 void moduleSearchPathContentsChanged(
const string &moduleSearchPath,
const string &moduleAddedOrModifiedPath =
"",
const string &moduleAddedOrModifiedSourceCode =
"", std::function<
void(
void)> moduleLoadedCallback =
nullptr,
VuoCompiler *compiler =
nullptr,
VuoCompilerIssues *issues =
nullptr);
283 void notifyCompilers(
const set<VuoCompilerModule *> &modulesAdded,
const set<pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
const set<VuoCompilerModule *> &modulesRemoved,
VuoCompilerIssues *issues,
bool oldModulesInvalidated =
true);
284 set<VuoCompilerModule *> loadCompiledModules(
const set<string> &moduleKeys,
const map<string, string> &sourceCodeForModule);
285 set<dispatch_group_t> loadSpecializedModules(
const set<string> &moduleKeys,
VuoCompiler *compiler, dispatch_queue_t
llvmQueue);
286 set<dispatch_group_t> compileModulesFromSourceCode(
const set<string> &moduleKeys,
bool shouldRecompileIfUnchanged);
287 set<VuoCompilerModule *> unloadCompiledModules(
const set<string> &moduleKeys);
288 void deleteModulesCompiledFromSourceCode(
const set<string> &moduleKeys);
292 void reifyPortTypes(
const map<string, VuoCompilerType *> &inheritedTypes);
293 void getCacheableModulesAndDependencies(
bool isBuiltIn,
bool installed, set<string> &cacheableModulesAndDependencies, set<string> &dylibsNeededToLinkToThisCache, set<string> &frameworksNeededToLinkToThisCache);
294 void useModuleCache(
bool shouldUseExistingCache,
VuoCompiler *compiler, set<string> cacheableModulesAndDependencies, set<string> dylibsNeededToLinkToCaches, set<string> frameworksNeededToLinkToCaches);
295 static void waitForModuleCachesToBuild(
void);
296 bool findInModuleCache(
const string &moduleOrDependency,
string &cachePath);
297 void modulesChanged(
void);
303 #include "pro/VuoCompilerEnvironment_Pro.hh"
307 static dispatch_queue_t environmentQueue;
308 static vector< vector<Environment *> > sharedEnvironments;
309 static map<string, vector<Environment *> > environmentsForCompositionFamily;
310 vector< vector<Environment *> > environments;
311 string lastCompositionBaseDir;
312 bool lastCompositionIsSubcomposition;
313 bool shouldLoadAllModules;
314 bool hasLoadedAllModules;
315 dispatch_queue_t modulesToLoadQueue;
316 static dispatch_group_t moduleSourceCompilersExist;
317 dispatch_group_t moduleCacheBuilding;
320 static string vuoFrameworkInProgressPath;
321 llvm::sys::Path clangPath;
325 bool _shouldShowSplashWindow;
327 dispatch_queue_t delegateQueue;
329 void applyToInstalledEnvironments(
void (^doForEnvironment)(Environment *));
330 void applyToInstalledEnvironments(
void (^doForEnvironment)(Environment *,
bool *,
string),
bool *,
string);
331 void applyToAllEnvironments(
void (^doForEnvironment)(Environment *));
333 static void reset(
void);
335 void loadModulesIfNeeded(
const set<string> &moduleKeys = set<string>());
336 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);
337 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);
338 void loadedModules(map<string, VuoCompilerModule *> modulesAdded, map<
string, pair<VuoCompilerModule *, VuoCompilerModule *> > modulesModified, map<string, VuoCompilerModule *> modulesRemoved,
VuoCompilerIssues *issues,
void *delegateData, Environment *currentEnvironment);
341 void reifyGenericPortTypes(
VuoNode *node);
343 void compileSubcompositionString(
const string &compositionString,
const string &outputPath, std::function<
void(
void)> moduleLoadedCallback, Environment *environment,
VuoCompilerIssues *issues = NULL,
const string inputPathForIssues =
"");
344 void linkCompositionToCreateExecutableOrDynamicLibrary(
string compiledCompositionPath,
string linkedCompositionPath,
Optimization optimization,
bool isDylib,
string rPath=
"");
345 set<string> getDependenciesForComposition(
const string &compiledCompositionPath);
346 set<string> getDependenciesForComposition(
const set<string> &directDependencies,
bool checkCompatibility);
347 void getLinkerInputs(
const set<string> &dependencies,
Optimization optimization, set<Module *> &modules, set<string> &libraries, set<string> &frameworks);
348 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);
349 static string getLibraryPath(
const string &dependency, vector<string> librarySearchPaths);
350 void useModuleCache(
bool shouldUseExistingBuiltInCaches,
bool shouldUseExistingOtherCaches);
351 bool findInModuleCache(
const string &moduleOrDependency,
string &cachePath,
bool &isBuiltinCache)
VuoWarnUnusedResult;
352 void link(
string outputPath,
const set<Module *> &modules,
const set<string> &libraries,
const set<string> &frameworks,
bool isDylib,
string rPath=
"");
353 Module * readModuleFromC(
string inputPath,
const vector<string> &headerSearchPaths,
const vector<string> &extraArgs);
355 static Module * readModuleFromBitcodeData(
char *inputData,
size_t inputDataBytes,
string &error);
356 static bool writeModuleToBitcode(Module *module,
string outputPath);
357 VuoNode * createPublishedNode(
const string &nodeClassName,
const vector<VuoPublishedPort *> &publishedPorts);
358 static void setTargetForModule(Module *module,
string target =
"");
360 static vector<string> getCoreVuoDependencies(
void);
361 static string getRuntimeMainDependency(
void);
362 static string getRuntimeDependency(
void);
363 void addModuleSearchPath(
string path);
364 static string getVuoFrameworkPath(
void);
365 llvm::sys::Path getClangPath(
void);
366 void setClangPath(
const string &clangPath);
367 string getCompositionStubPath(
void);
368 static string getCachePathForComposition(
const string compositionDir);
372 friend class TestCompilerDelegate;
373 friend class TestVuoCompilerModule;
374 friend class TestVuoCompilerBitcodeGenerator;
386 static Module * readModuleFromBitcode(
string inputPath);
393 void compileModule(
string inputPath,
string outputPath,
const vector<string> &includeDirs);
414 map<string, VuoCompilerType *>
getTypes(
void);
442 #include "pro/VuoCompiler_Pro.hh"
485 virtual void loadedModules(
const map<string, VuoCompilerModule *> &modulesAdded,
486 const map<
string, pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
487 const map<string, VuoCompilerModule *> &modulesRemoved,
VuoCompilerIssues *issues) = 0;
501 class LoadedModulesData
504 LoadedModulesData(
const set< pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
506 ~LoadedModulesData(
void);
512 dispatch_queue_t referenceCountQueue;
513 set< pair<VuoCompilerModule *, VuoCompilerModule *> > modulesModified;
514 set<VuoCompilerModule *> modulesRemoved;
518 void enqueueData(LoadedModulesData *data);
519 LoadedModulesData * dequeueData(
void);
521 list<LoadedModulesData *> pendingData;
522 dispatch_queue_t pendingDataQueue;