Vuo 2.4.4
Loading...
Searching...
No Matches
VuoCompilerEnvironment.hh
Go to the documentation of this file.
1
10#pragma once
11
12#include "VuoFileUtilities.hh"
13#include "VuoFileWatcher.hh"
15class VuoCompiler;
20class VuoCompilerType;
23class VuoModuleCache;
25class VuoModuleInfo;
27class VuoNodeSet;
28
63{
64private:
65 string target;
66 bool builtIn;
67 bool generated;
68 set<VuoCompiler *> compilersToNotify;
69 dispatch_queue_t compilersToNotifyQueue;
70 set<VuoFileWatcher *> moduleSearchPathWatchers;
71 map<string, VuoCompilerNodeClass *> nodeClasses;
72 map<string, VuoCompilerType *> types;
73 map<string, VuoNodeSet *> nodeSetForName;
74 map<string, VuoCompilerModule *> libraryModules;
75 VuoCompilerModule * inMemoryModuleAwaitingLoad;
76 map<string, dispatch_group_t> specializedModulesLoading;
77 map<string, map<string, VuoModuleInfo *> > moduleFilesAtSearchPath;
78 map<string, map<string, VuoModuleInfo *> > sourceFilesAtSearchPath;
79 vector<string> moduleSearchPaths;
80 vector<string> headerSearchPaths;
81 vector<string> librarySearchPaths;
82 vector<string> frameworkSearchPaths;
83 vector<string> expatriateSourceFiles;
84 shared_ptr<VuoModuleCache> moduleCache;
85 string compiledModuleCachePath;
86 string overriddenCompiledModuleCachePath;
87 bool isModuleCacheableDataDirty;
88 VuoModuleCacheManifest cacheableModulesAndDependencies;
89 set<string> dylibsNeededToLinkToThisCache;
90 set<string> frameworksNeededToLinkToThisCache;
91 VuoDirectedAcyclicGraph *dependencyGraph;
92 VuoDirectedAcyclicGraph *compositionDependencyGraph;
93 VuoModuleCompilationQueue *moduleCompilationQueue;
94
95 void updateModulesAtSearchPath(const string &path);
96 void updateModuleAtSearchPath(const string &moduleSearchPath, const string &moduleRelativePath);
97 void updateSourceFilesAtSearchPath(const string &path);
98 void unmangleModuleKeysAtSearchPath(const string &path, const set<string> &knownModuleKeys);
99 void startWatchingModuleSearchPath(const string &moduleSearchPath);
100 bool writeToCompiledModuleCache(Module *module, const string &compiledModulePath, shared_ptr<VuoMakeDependencies> makeDependencies, dispatch_queue_t llvmQueue, VuoCompilerIssues *issues);
101 void deleteFromCompiledModuleCache(const string &compiledModulePath);
102 VuoCompilerModule * readModuleFromFile(VuoModuleInfo *moduleInfo, dispatch_queue_t llvmQueue);
103 void loadInMemoryModule(const string &moduleKey, const string &moduleSourceCode, Module *module, std::function<void(void)> moduleLoadedCallback, VuoCompiler *compiler, dispatch_queue_t llvmQueue);
104 void loadInMemoryModule(VuoCompilerModule *module, const string &moduleSourceCode, std::function<void(void)> moduleLoadedCallback, VuoCompiler *compiler, dispatch_queue_t llvmQueue);
105
106 friend class TestCompilingAndLinking;
107
108public:
110
111 explicit VuoCompilerEnvironment(string target, bool builtIn, bool generated);
112 virtual ~VuoCompilerEnvironment(void);
113 string getTarget();
114 void addCompilerToNotify(VuoCompiler *compiler);
115 void removeCompilerToNotify(VuoCompiler *compiler);
116 map<string, VuoCompilerNodeClass *> getNodeClasses(void);
117 VuoCompilerNodeClass * getNodeClass(const string &moduleKey);
118 map<string, VuoCompilerType *> getTypes(void);
119 VuoCompilerType * getType(const string &moduleKey);
120 map<string, VuoNodeSet *> getNodeSets();
121 VuoCompilerModule *getLibraryModule(const string &libraryModuleName);
122 map<string, VuoCompilerModule *> getLibraryModules(void);
123 VuoCompilerModule * findModule(const string &moduleKey);
124 VuoNodeSet * findNodeSet(const string &name);
125 void addModuleSearchPath(const string &path, bool shouldWatch = true);
126 vector<string> getModuleSearchPaths(void);
127 void addHeaderSearchPath(const string &path);
128 vector<string> getHeaderSearchPaths(void);
129 void addLibrarySearchPath(const string &path);
130 vector<string> getLibrarySearchPaths(void);
131 void addFrameworkSearchPath(const string &path);
132 void setModuleCache(shared_ptr<VuoModuleCache> moduleCache);
133 shared_ptr<VuoModuleCache> getModuleCache(void);
134 string getCompiledModuleCachePath(void);
136 vector<string> getFrameworkSearchPaths(void);
139 void addExpatriateSourceFile(const string &sourcePath);
140 void removeExpatriateSourceFile(const string &sourcePath);
141 VuoModuleInfo * listModule(const string &moduleKey);
142 VuoModuleInfoIterator listModules(const set<string> &moduleKeys);
144 VuoModuleInfo * listSourceFile(const string &moduleKey);
145 VuoModuleInfoIterator listSourceFiles(const set<string> &moduleKeys);
147 static vector<string> getBuiltInModuleSearchPaths(void);
148 static vector<string> getBuiltInLibrarySearchPaths(void);
149 static vector<string> getBuiltInFrameworkSearchPaths(void);
151 void fileChanged(const string &moduleSearchPath);
152 void moduleSearchPathContentsChanged(const string &moduleSearchPath);
153 void moduleFileChanged(const string &moduleKey, const string &modulePath, const string &moduleSourceCode, std::function<void(void)> moduleLoadedCallback, VuoCompiler *compiler, VuoCompilerIssues *issues = nullptr);
154 void deleteOverriddenModuleFile(const string &moduleKey);
155 void notifyCompilers(const set<VuoCompilerModule *> &modulesAdded, const set<pair<VuoCompilerModule *, VuoCompilerModule *> > &modulesModified, const set<VuoCompilerModule *> &modulesRemoved, VuoCompilerIssues *issues, bool oldModulesInvalidated = true);
156 set<VuoCompilerModule *> loadCompiledModules(const set<string> &moduleKeys, const map<string, string> &sourceCodeForModule, dispatch_queue_t llvmQueue);
157 set<dispatch_group_t> generateSpecializedModules(const set<string> &moduleKeys, VuoCompiler *compiler, dispatch_group_t moduleSourceCompilersExist, dispatch_queue_t llvmQueue);
158 set<dispatch_group_t> compileModulesFromSourceCode(const set<string> &moduleKeys, bool shouldRecompileIfUnchanged, dispatch_group_t moduleSourceCompilersExist, dispatch_queue_t llvmQueue);
159 set<VuoCompilerModule *> unloadCompiledModules(const set<string> &moduleKeys);
160 void deleteFromCompiledModuleCache(const set<string> &moduleKeys);
163 VuoModuleCacheManifest getCacheableModulesAndDependencies(set<string> &dylibsNeededToLinkToThisCache, set<string> &frameworksNeededToLinkToThisCache);
164 void modulesChanged(void);
165
166 bool isBuiltInOriginal(void);
167 bool isBuiltIn(void);
168 bool isGenerated(void);
169 string getName();
170
171#ifdef VUO_PRO
172#include "../compiler/pro/VuoCompilerEnvironment_Pro.hh"
173#endif
174};