90 ModuleInfo(Environment *environment,
const string &searchPath,
const string &relativePath,
bool isSourceFile,
bool isSubcomposition);
91 ModuleInfo(Environment *environment,
const string &searchPath,
VuoFileUtilities::File *file,
bool isSourceFile,
bool isSubcomposition);
93 Environment * getEnvironment(
void)
const;
94 string getSearchPath(
void)
const;
95 string getModuleKey(
void)
const;
97 string getSourceCode(
void)
const;
98 void setSourceCode(
const string &sourceCode);
99 void revertSourceCode(
void);
100 bool isSourceCodeOverridden(
void)
const;
101 void setSourceCodeOverridden(
bool overridden);
102 bool isNewerThan(ModuleInfo *other)
const;
103 bool isNewerThan(
unsigned long seconds)
const;
104 bool isOlderThan(
unsigned long seconds)
const;
105 void setLastModifiedToNow(
void);
106 set<string> getContainedNodeClasses(
void)
const;
107 int getLongestDownstreamPath(
void)
const;
108 void setLongestDownstreamPath(
int pathLength);
109 bool getAttempted(
void)
const;
110 void setAttempted(
bool attempted);
111 dispatch_group_t getLoadingGroup(
void)
const;
115 void initialize(Environment *environment,
const string &searchPath,
VuoFileUtilities::File *file,
bool isSourceFile,
bool isSubcomposition);
117 Environment *environment;
122 bool sourceCodeOverridden;
123 unsigned long lastModified;
124 set<string> containedNodeClasses;
125 int longestDownstreamPath;
127 dispatch_group_t loading;
129 #pragma clang diagnostic push
130 #pragma clang diagnostic ignored "-Wunused-private-field"
132 #pragma clang diagnostic pop
134 #include "pro/VuoCompilerModuleInfo_Pro.hh"
142 string getDependency(
void);
143 Environment * getEnvironment(
void);
144 void setEnvironment(Environment *environment);
149 Environment *environment;
156 class ModuleInfoIterator
159 ModuleInfoIterator(map<
string, map<string, ModuleInfo *> > *allModuleInfos,
const string &overriddenCompiledModuleCachePath);
160 ModuleInfoIterator(map<
string, map<string, ModuleInfo *> > *allModuleInfos,
const string &overriddenCompiledModuleCachePath,
const set<string> &searchModuleKeys);
161 ModuleInfo * next(
void);
164 void initialize(
void);
166 map<string, map<string, ModuleInfo *> > *allModuleInfos;
167 set<string> searchModuleKeys;
168 bool hasSearchModuleKeys;
169 map<string, map<string, ModuleInfo *> >::iterator currSearchPath;
170 map<string, ModuleInfo *>::iterator currModuleKey;
171 bool hasCurrModuleKey;
172 string overriddenCompiledModuleCachePath;
173 set<string> overriddenModuleKeys;
210 set<VuoCompiler *> compilersToNotify;
211 dispatch_queue_t compilersToNotifyQueue;
212 set<VuoFileWatcher *> moduleSearchPathWatchers;
213 map<string, VuoCompilerNodeClass *> nodeClasses;
214 map<string, VuoCompilerType *> types;
215 set<VuoCompilerGenericType *> genericTypes;
216 map<string, VuoNodeSet *> nodeSetForName;
217 map<string, VuoCompilerModule *> libraryModules;
218 map<string, dispatch_group_t> specializedModulesLoading;
219 map<string, map<string, ModuleInfo *> > moduleFilesAtSearchPath;
220 map<string, map<string, ModuleInfo *> > sourceFilesAtSearchPath;
221 vector<string> moduleSearchPaths;
222 vector<string> headerSearchPaths;
223 vector<string> librarySearchPaths;
224 vector<string> frameworkSearchPaths;
225 vector<string> expatriateSourceFiles;
226 string moduleCachePath;
227 string currentModuleCacheDylib;
228 unsigned long lastModuleCacheRebuild;
229 bool isModuleCacheableDataDirty;
230 bool isModuleCacheInitialized;
231 bool isModuleCacheAvailable;
232 set<string> moduleCacheContents;
233 set<string> moduleCacheDylibs;
234 set<string> moduleCacheFrameworks;
235 static map<string, VuoFileUtilities::File *> moduleCacheFileForLocking;
236 static dispatch_queue_t moduleCacheBuildingQueue;
241 void updateModulesAtSearchPath(
const string &path);
242 void updateModuleAtSearchPath(
const string &moduleSearchPath,
const string &moduleRelativePath);
243 void updateSourceFilesAtSearchPath(
const string &path);
244 void startWatchingModuleSearchPath(
const string &moduleSearchPath);
250 dispatch_queue_t moduleSearchPathContentsChangedQueue;
251 static const string pidCacheDirPrefix;
253 explicit Environment(
string target,
bool builtIn,
bool generated);
254 virtual ~Environment(
void);
257 void removeCompilerToNotify(
VuoCompiler *compiler);
261 map<string, VuoCompilerType *>
getTypes(
void);
268 void addModuleSearchPath(
const string &path,
bool shouldWatch =
true);
269 vector<string> getModuleSearchPaths(
void);
271 vector<string> getHeaderSearchPaths(
void);
273 vector<string> getLibrarySearchPaths(
void);
275 void setModuleCachePath(
const string &path,
bool shouldAddModuleSearchPath);
276 string getCompiledModuleCachePath(
void);
277 string getOverriddenCompiledModuleCachePath(
void);
278 vector<string> getFrameworkSearchPaths(
void);
281 void addExpatriateSourceFile(
const string &sourcePath);
282 void removeExpatriateSourceFile(
const string &sourcePath);
283 ModuleInfo * listModule(
const string &moduleKey);
284 ModuleInfoIterator listModules(
const set<string> &moduleKeys);
285 ModuleInfoIterator listAllModules(
void);
286 ModuleInfo * listSourceFile(
const string &moduleKey);
287 ModuleInfoIterator listSourceFiles(
const set<string> &moduleKeys);
288 ModuleInfoIterator listAllSourceFiles(
void);
289 static vector<string> getBuiltInModuleSearchPaths(
void);
290 static vector<string> getBuiltInHeaderSearchPaths(
void);
291 static vector<string> getBuiltInLibrarySearchPaths(
void);
292 static vector<string> getBuiltInFrameworkSearchPaths(
void);
293 void addSearchPathsToSharedEnvironment(
void);
294 void stopWatchingModuleSearchPaths(
void);
295 void fileChanged(
const string &moduleSearchPath);
296 void moduleSearchPathContentsChanged(
const string &moduleSearchPath);
297 void moduleFileChanged(
const string &modulePath,
const string &moduleSourceCode, std::function<
void(
void)> moduleLoadedCallback,
VuoCompiler *compiler,
VuoCompilerIssues *issues =
nullptr);
298 void notifyCompilers(
const set<VuoCompilerModule *> &modulesAdded,
const set<pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
const set<VuoCompilerModule *> &modulesRemoved,
VuoCompilerIssues *issues,
bool oldModulesInvalidated =
true);
299 set<VuoCompilerModule *> loadCompiledModules(
const set<string> &moduleKeys,
const map<string, string> &sourceCodeForModule);
300 set<dispatch_group_t> loadSpecializedModules(
const set<string> &moduleKeys,
VuoCompiler *compiler, dispatch_queue_t
llvmQueue);
301 set<dispatch_group_t> compileModulesFromSourceCode(
const set<string> &moduleKeys,
bool shouldRecompileIfUnchanged);
302 set<VuoCompilerModule *> unloadCompiledModules(
const set<string> &moduleKeys);
303 void deleteModulesCompiledFromSourceCode(
const set<string> &moduleKeys);
307 void reifyPortTypes(
const map<string, VuoCompilerType *> &inheritedTypes);
308 void getCacheableModulesAndDependencies(set<string> &cacheableModulesAndDependencies, set<string> &dylibsNeededToLinkToThisCache, set<string> &frameworksNeededToLinkToThisCache);
309 void useModuleCache(
bool shouldUseExistingCache,
VuoCompiler *compiler, set<string> cacheableModulesAndDependencies, set<string> dylibsNeededToLinkToCaches, set<string> frameworksNeededToLinkToCaches,
unsigned long lastPrerequisiteModuleCacheRebuild);
310 static void waitForModuleCachesToBuild(
void);
311 bool findInModuleCache(
const string &moduleOrDependency,
string &cachePath);
312 string getCurrentModuleCacheDylib(
void);
313 unsigned long getLastModuleCacheRebuild(
void);
314 void modulesChanged(
void);
316 bool isBuiltInOriginal(
void);
317 bool isBuiltIn(
void);
318 bool isGenerated(
void);
322 #include "pro/VuoCompilerEnvironment_Pro.hh"
326 static set<VuoCompiler *> allCompilers;
327 static dispatch_queue_t environmentQueue;
328 static map<string, vector< vector<Environment *> > > sharedEnvironments;
329 static map<string, map<string, vector<Environment *> > > environmentsForCompositionFamily;
330 vector< vector<Environment *> > environments;
331 string lastCompositionBaseDir;
332 bool lastCompositionIsSubcomposition;
333 bool shouldLoadAllModules;
334 bool hasLoadedAllModules;
335 dispatch_queue_t modulesToLoadQueue;
336 dispatch_group_t moduleSourceCompilersExist;
337 static dispatch_group_t moduleSourceCompilersExistGlobally;
338 dispatch_group_t moduleCacheBuilding;
341 static string vuoFrameworkInProgressPath;
346 bool _shouldShowSplashWindow;
348 dispatch_queue_t delegateQueue;
350 void applyToInstalledEnvironments(
void (^doForEnvironment)(Environment *));
351 void applyToInstalledEnvironments(
void (^doForEnvironment)(Environment *,
bool *,
string),
bool *,
string);
352 void applyToAllEnvironments(
void (^doForEnvironment)(Environment *));
354 static void reset(
void);
356 void loadModulesIfNeeded(
const set<string> &moduleKeys = set<string>());
357 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);
358 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);
359 void loadedModules(map<string, VuoCompilerModule *> modulesAdded, map<
string, pair<VuoCompilerModule *, VuoCompilerModule *> > modulesModified, map<string, VuoCompilerModule *> modulesRemoved,
VuoCompilerIssues *issues,
void *delegateData, Environment *currentEnvironment);
362 void reifyGenericPortTypes(
VuoNode *node);
364 void linkCompositionToCreateExecutableOrDynamicLibrary(
string compiledCompositionPath,
string linkedCompositionPath,
Optimization optimization,
bool isDylib,
string rPath=
"",
bool shouldAdHocCodeSign =
true);
365 set<string> getDependenciesForComposition(
const string &compiledCompositionPath);
366 set<string> getDependenciesForComposition(
const set<string> &directDependencies,
bool checkCompatibility);
367 void getLinkerInputs(
const set<string> &dependencies,
Optimization optimization, set<Module *> &modules, set<string> &libraries, set<string> &frameworks);
368 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);
369 static string getLibraryPath(
const string &dependency, vector<string> librarySearchPaths);
370 void useModuleCache(
bool shouldUseExistingBuiltInCaches,
bool shouldUseExistingOtherCaches);
371 bool findInModuleCache(
const string &moduleOrDependency,
string &cachePath,
bool &isBuiltinCache)
VuoWarnUnusedResult;
372 void link(
string outputPath,
const set<Module *> &modules,
const set<string> &libraries,
const set<string> &frameworks,
bool isDylib,
string rPath=
"",
bool shouldAdHocCodeSign =
true,
VuoCompilerIssues *issues =
nullptr);
373 static void adHocCodeSign(
string path);
374 Module *readModuleFromC(
string inputPath,
const vector<string> &headerSearchPaths,
const vector<string> &extraArgs,
VuoCompilerIssues *issues);
376 static Module *readModuleFromBitcodeData(
char *inputData,
size_t inputDataBytes,
string arch, set<string> &availableArchs,
string &error);
377 static bool writeModuleToBitcode(Module *module,
string outputPath);
378 VuoNode * createPublishedNode(
const string &nodeClassName,
const vector<VuoPublishedPort *> &publishedPorts);
379 static void setTargetForModule(Module *module,
string target);
380 static string getTargetArch(
string target);
381 static string getProcessTarget(
void);
383 static vector<string> getCoreVuoDependencies(
void);
384 static string getRuntimeMainDependency(
void);
385 static string getRuntimeDependency(
void);
386 void addModuleSearchPath(
string path);
387 string getClangPath(
void);
388 void setClangPath(
const string &clangPath);
389 string getCompositionStubPath(
void);
390 static string getCachePathForComposition(
const string compositionDir);
394 friend class TestCompilerDelegate;
395 friend class TestVuoCompilerModule;
396 friend class TestVuoCompilerBitcodeGenerator;
406 VuoCompiler(
const string &compositionPath =
"",
string target =
"");
410 static Module *readModuleFromBitcode(
string inputPath,
string arch);
417 void compileModule(
string inputPath,
string outputPath,
const vector<string> &includeDirs);
442 map<string, VuoCompilerType *>
getTypes(
void);
473 #include "pro/VuoCompiler_Pro.hh"
516 virtual void loadedModules(
const map<string, VuoCompilerModule *> &modulesAdded,
517 const map<
string, pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
518 const map<string, VuoCompilerModule *> &modulesRemoved,
VuoCompilerIssues *issues) = 0;
532 class LoadedModulesData
535 LoadedModulesData(
const set< pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified,
537 ~LoadedModulesData(
void);
543 dispatch_queue_t referenceCountQueue;
544 set< pair<VuoCompilerModule *, VuoCompilerModule *> > modulesModified;
545 set<VuoCompilerModule *> modulesRemoved;
549 void enqueueData(LoadedModulesData *data);
550 LoadedModulesData * dequeueData(
void);
552 list<LoadedModulesData *> pendingData;
553 dispatch_queue_t pendingDataQueue;