Vuo  2.3.2
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
VuoCompiler Class Reference

Description

This class compiles node classes, types, and library modules.

It compiles and links compositions.

Node classes, types, library modules, and compositions are all compiled to LLVM bitcode. LLVM bitcode is one of the file formats used by the Clang compiler.

When a composition is linked, the compiled composition and all of its node classes, types, library modules, and other dependencies are combined to create one of the following: an executable, a dynamic library, or or separate dynamic libraries for the composition and its resources.

All VuoCompiler instances share a basic set of node classes, types, library modules, and other dependencies. Each VuoCompiler instance can add its own dependencies on top of that basic set.

The easiest way to compile, link, and run a composition is to use the VuoCompiler factory methods to create a VuoRunner that's ready to run the composition:

When building a composition, this class optimizes the build in different ways depending on the functions, and in some cases the arguments, that you use. Some functions for linking a composition accept an Optimization argument. The rest default to the "faster build" optimization (Optimization_FastBuild). The "faster build" optimization works by caching a library on the user's filesystem and reusing it each time a composition is linked. The caching takes a while, and may delay the building of the first composition. However, if you call prepareForFastBuild(), the caching can be done in advance.

If you plan to distribute an executable or dynamic library built from a composition, use either linkCompositionToCreateExecutable() or linkCompositionToCreateDynamicLibrary(), and choose the "smaller binary" optimization. If building an executable, pass an rpath (such as "@loader_path/../Frameworks") to enable the executable to find Vuo.framework. Since the executable or dynamic library links to Vuo.framework, you need to distribute it along with the build composition.

See also
Developing Applications that Use Vuo

Definition at line 68 of file VuoCompiler.hh.

Public Types

enum  Optimization { Optimization_FastBuild , Optimization_FastBuildExistingCache , Optimization_SmallBinary }
 Options for optimizations when building a composition. More...
 

Public Member Functions

 VuoCompiler (const string &compositionPath="", string target="")
 Creates a compiler instance that can be used for compiling and linking. More...
 
 ~VuoCompiler (void)
 Destructor. More...
 
void setDelegate (VuoCompilerDelegate *delegate)
 Sets the delegate that receives messages from the compiler when modules are loaded. More...
 
void setCompositionPath (const string &compositionPath)
 If this compiler will be compiling a composition, pass its path here (if not already passed to VuoCompiler::VuoCompiler) so the compiler can locate composition-local modules. More...
 
void compileComposition (VuoCompilerComposition *composition, string outputPath, bool isTopLevelComposition, VuoCompilerIssues *issues)
 Compiles a composition to LLVM bitcode. More...
 
void compileComposition (string inputPath, string outputPath, bool isTopLevelComposition, VuoCompilerIssues *issues)
 Compiles a composition, read from file, to LLVM bitcode. More...
 
void compileCompositionString (const string &compositionString, string outputPath, bool isTopLevelComposition, VuoCompilerIssues *issues)
 Compiles the composition, read from a string, to LLVM bitcode. More...
 
void compileModule (string inputPath, string outputPath)
 Compiles a node class, port type, or library module to LLVM bitcode. More...
 
void compileModule (string inputPath, string outputPath, const vector< string > &includeDirs)
 Compiles a node class, port type, or library module to LLVM bitcode. More...
 
void linkCompositionToCreateExecutable (string inputPath, string outputPath, Optimization optimization, string rPath="", bool shouldAdHocCodeSign=true)
 Turns a compiled composition into an executable by linking in all of its dependencies and adding a main function. More...
 
void linkCompositionToCreateDynamicLibrary (string inputPath, string outputPath, Optimization optimization, bool shouldAdHocCodeSign=true)
 Turns a compiled composition into a dynamic library by linking in all of its dependencies. More...
 
void linkCompositionToCreateDynamicLibraries (string compiledCompositionPath, string linkedCompositionPath, VuoRunningCompositionLibraries *runningCompositionLibraries)
 Creates one dynamic library for the composition by itself and, if needed, additional dynamic libraries for the node classes and other resources that are dependencies of the composition. More...
 
set< string > getDirectDependenciesForComposition (VuoCompilerComposition *composition)
 Returns the names of dependencies (node classes and types) directly referenced by the composition. More...
 
set< string > getDependenciesForComposition (VuoCompilerComposition *composition)
 Returns the names of dependencies (node classes, types, libraries, and frameworks) needed for linking the composition. More...
 
set< string > getDylibDependencyPathsForComposition (VuoCompilerComposition *composition)
 Returns the absolute paths of dylibs needed for linking the composition. More...
 
VuoCompilerCompatibility getCompatibilityOfDependencies (const set< string > &dependencies)
 Returns a description of the set of systems that all of dependencies are able to run on. More...
 
void prepareForFastBuild (void)
 Asynchronously prepares the cache that enables compositions to build faster. More...
 
string getTarget (void)
 Returns this compiler instance's LLVM target triple. More...
 
string getArch (void)
 Returns this compiler instance's CPU architecture. More...
 
void setLoadAllModules (bool shouldLoadAllModules)
 Controls whether the VuoCompiler should load all node classes, types, and library modules from the module search paths the first time a module is needed. More...
 
VuoNodecreateNode (VuoCompilerNodeClass *nodeClass, string title="", double x=0, double y=0)
 Instantiates a node for the given node class. More...
 
VuoNodecreateNode (VuoCompilerNodeClass *nodeClass, VuoNode *nodeToCopyMetadataFrom)
 Instantiates a node for the given node class. More...
 
VuoNodecreatePublishedInputNode (vector< VuoPublishedPort * > publishedInputPorts)
 Instantiates a node used during code generation to represent published input ports. More...
 
VuoNodecreatePublishedOutputNode (vector< VuoPublishedPort * > publishedOutputPorts)
 Instantiates a node used during code generation to represent published output ports. More...
 
void installNodeClassAtCompositionLocalScope (const string &sourcePath)
 Causes the node class source code located at sourcePath to be loaded at composition-family scope — unless this compiler's composition path is within the user, system, or built-in scope, in which case does nothing. More...
 
void uninstallNodeClassAtCompositionLocalScope (const string &sourcePath)
 Causes the node class that was previously loaded from sourcePath by installNodeClassAtCompositionLocalScope, if any, to be unloaded. More...
 
void overrideInstalledNodeClass (const string &sourcePath, const string &sourceCode)
 Temporarily replaces the subcomposition installed at sourcePath with a subcomposition compiled from sourceCode. More...
 
void revertOverriddenNodeClass (const string &sourcePath)
 Removes an override added by overrideInstalledNodeClass (if any), reverting to the installed version of the node class. More...
 
VuoCompilerNodeClassgetNodeClass (const string &nodeClassName)
 Returns the node class specified by nodeClassName, or null if it can't be found or loaded. More...
 
map< string, VuoCompilerNodeClass * > getNodeClasses (void)
 Returns all node classes found and loaded, indexed by node class name. More...
 
VuoCompilerTypegetType (const string &typeName)
 Returns the type specified by typeName, or null if it can't be found or loaded. More...
 
map< string, VuoCompilerType * > getTypes (void)
 Returns all types found and loaded, indexed by type name. More...
 
VuoCompilerModulegetLibraryModule (const string &libraryModuleName)
 Returns the library specified by libraryName, or null if it can't be found or loaded. More...
 
map< string, VuoCompilerModule * > getLibraryModules ()
 Returns all libraries found and loaded, indexed by key. More...
 
map< string, VuoNodeSet * > getNodeSets ()
 Returns all node sets found and loaded, indexed by node set name. More...
 
VuoNodeSetgetNodeSetForName (const string &name)
 Returns the node set with the given name, or null if it can't be found. More...
 
void listNodeClasses (const string &format="")
 Prints a list of all loaded node classes to standard output. More...
 
bool isCompositionLocalModule (string moduleKey)
 Returns true if the module is installed in the composition-local Modules folder for this compiler's composition path. More...
 
string getCompositionLocalModulesPath (void)
 Returns the path of the composition-local Modules folder for this compiler's composition path, or an empty string if the composition path hasn't been set. More...
 
string getCompositionLocalPath (void)
 Returns the path of the top-level composition folder for this compiler's composition path, or an empty string if the composition path hasn't been set. More...
 
void addHeaderSearchPath (const string &path)
 Adds a header search path to use when compiling a node class. More...
 
void addLibrarySearchPath (const string &path)
 Adds a library search path to use when linking a composition. More...
 
void addFrameworkSearchPath (const string &path)
 Adds a macOS framework search path to use when linking a composition. More...
 
void setTelemetry (const string &telemetry)
 Sets the telemetry option to use when compiling a composition. More...
 
void setVerbose (bool isVerbose)
 Sets the verbosity to use when compiling or linking. More...
 
void setShouldPotentiallyShowSplashWindow (bool potentiallyShow)
 Sets whether the compiled composition should show the Vuo Community Edition splash window, if generated by Vuo Community Edition. More...
 
bool shouldShowSplashWindow ()
 Returns whether the compiled composition should show the Vuo Community Edition splash window. More...
 
string getCompositionLoaderPath (void)
 Returns the path to the VuoCompositionLoader executable. More...
 
void print (void)
 Prints info about this compiler, for debugging. More...
 

Static Public Member Functions

static Module * readModuleFromBitcode (string inputPath, string arch)
 Returns the LLVM module in the arch slice of inputFile. More...
 
static void destroyModule (VuoCompilerModule *module)
 Deallocates module and associated data. More...
 
static void destroyLlvmModule (Module *module)
 Calls the destructor for module, using the LLVM global context thread-safely. More...
 
static void generateBuiltInModuleCaches (string vuoFrameworkPath, string target)
 Generates the caches of built-in modules and places them inside of Vuo.framework. More...
 
static void deleteOldModuleCaches (void)
 Deletes: More...
 
static string getVuoFrameworkPath (void)
 Returns the absolute path of Vuo.framework. More...
 
static string getModuleKeyForPath (string path)
 Returns the name of the node class or other module that would be located at path. More...
 
static VuoRunnernewSeparateProcessRunnerFromCompositionFile (string compositionFilePath, VuoCompilerIssues *issues)
 Creates a runner object that can run the composition in file compositionFilePath in a new process. More...
 
static VuoRunnernewSeparateProcessRunnerFromCompositionString (string composition, string processName, string workingDirectory, VuoCompilerIssues *issues)
 Creates a runner object that can run the composition in string composition in a new process. More...
 
static VuoRunnernewCurrentProcessRunnerFromCompositionFile (string compositionFilePath, VuoCompilerIssues *issues)
 Creates a runner object that can run the composition in file compositionFilePath in this process. More...
 
static VuoRunnernewCurrentProcessRunnerFromCompositionString (string composition, string workingDirectory, VuoCompilerIssues *issues)
 Creates a runner object that can run the composition in string composition in this process. More...
 

Static Public Attributes

static llvm::LLVMContext * globalLLVMContext = nullptr
 LLVM's global context. More...
 

Friends

class TestVuoCompiler
 TestVuoCompiler needs to add a search path for its own private nodes/types. More...
 
class TestCompositionExecution
 TestCompositionExecution needs to add a search path for its own private nodes. More...
 
class TestCompilerDelegate
 
class TestVuoCompilerModule
 
class TestVuoCompilerBitcodeGenerator
 
class TestCompilingAndLinking
 TestCompilingAndLinking calls reset(). More...
 
class TestSubcompositions
 TestSubcompositions calls reset(). More...
 
class TestModuleLoading
 TestModuleLoading calls reset(). More...
 
class TestEventDropping
 TestEventDropping calls reset(). More...
 
class TestVuoIsfModuleCompiler
 TestVuoIsfModuleCompiler calls writeModuleToBitcode(). More...
 
class TestVuoCompilerCompatibility
 TestVuoCompilerCompatibility calls getProcessTarget(). More...
 
class TestNodes
 TestNodes calls getProcessTarget(). More...
 

Member Enumeration Documentation

◆ Optimization

Options for optimizations when building a composition.

Enumerator
Optimization_FastBuild 

Speed up the build by having the composition binary link to cache libraries on the user's system. See prepareForFastBuild.

Optimization_FastBuildExistingCache 

Like Optimization_FastBuild, but skips ensuring that the cache libraries are up to date.

Optimization_SmallBinary 

Don't link to any cache libraries.

Definition at line 74 of file VuoCompiler.hh.

Constructor & Destructor Documentation

◆ VuoCompiler()

VuoCompiler::VuoCompiler ( const string &  compositionPath = "",
string  target = "" 
)

Creates a compiler instance that can be used for compiling and linking.

Parameters
compositionPathIf this compiler will be compiling a composition and its path is already known, pass the path so the compiler can locate composition-local modules. If the path is not yet known, it can be set later with setCompositionPath or compileComposition. If not compiling a composition, pass an empty string.
targetThe LLVM Target Triple to use for this compiler instance. Affects which slice of multi-archtecture binaries is loaded, and affects the bitcode that's generated. If no target is specified, the current process's architecture is used.
Changed in Vuo 2.0.0:
Added compositionPath argument.

Definition at line 2718 of file VuoCompiler.cc.

◆ ~VuoCompiler()

VuoCompiler::~VuoCompiler ( void  )

Destructor.

Definition at line 2815 of file VuoCompiler.cc.

Member Function Documentation

◆ addFrameworkSearchPath()

void VuoCompiler::addFrameworkSearchPath ( const string &  path)

Adds a macOS framework search path to use when linking a composition.

Definition at line 6566 of file VuoCompiler.cc.

◆ addHeaderSearchPath()

void VuoCompiler::addHeaderSearchPath ( const string &  path)

Adds a header search path to use when compiling a node class.

Definition at line 6546 of file VuoCompiler.cc.

◆ addLibrarySearchPath()

void VuoCompiler::addLibrarySearchPath ( const string &  path)

Adds a library search path to use when linking a composition.

Definition at line 6556 of file VuoCompiler.cc.

◆ compileComposition() [1/2]

void VuoCompiler::compileComposition ( string  inputPath,
string  outputPath,
bool  isTopLevelComposition,
VuoCompilerIssues issues 
)

Compiles a composition, read from file, to LLVM bitcode.

Parameters
inputPathThe .vuo file containing the composition. If you haven't already specified the composition path in the constructor or setCompositionPath, then inputPath will be used to locate composition-local modules.
outputPathThe file in which to save the compiled LLVM bitcode.
isTopLevelCompositionTrue if the composition is top-level, false if it's a subcomposition.
issuesIssues encountered while compiling the composition are appended to this.
Exceptions
VuoCompilerExceptionThe composition is invalid.
Changed in Vuo 2.0.0:
New.

Definition at line 4257 of file VuoCompiler.cc.

◆ compileComposition() [2/2]

void VuoCompiler::compileComposition ( VuoCompilerComposition composition,
string  outputPath,
bool  isTopLevelComposition,
VuoCompilerIssues issues 
)

Compiles a composition to LLVM bitcode.

Parameters
compositionThe composition to compile.
outputPathThe file in which to save the compiled LLVM bitcode.
isTopLevelCompositionTrue if the composition is top-level, false if it's a subcomposition.
issuesIssues encountered while compiling the composition are appended to this.
Exceptions
VuoCompilerExceptionThe composition is invalid.
Changed in Vuo 2.0.0:
New.

Definition at line 4232 of file VuoCompiler.cc.

◆ compileCompositionString()

void VuoCompiler::compileCompositionString ( const string &  compositionString,
string  outputPath,
bool  isTopLevelComposition,
VuoCompilerIssues issues 
)

Compiles the composition, read from a string, to LLVM bitcode.

Parameters
compositionStringA string containing the composition.
outputPathThe file in which to save the compiled LLVM bitcode.
isTopLevelCompositionTrue if the composition is top-level, false if it's a subcomposition.
issuesIssues encountered while compiling the composition are appended to this.
Exceptions
VuoCompilerExceptionThe composition is invalid.
Changed in Vuo 2.0.0:
New.

Definition at line 4301 of file VuoCompiler.cc.

◆ compileModule() [1/2]

void VuoCompiler::compileModule ( string  inputPath,
string  outputPath 
)

Compiles a node class, port type, or library module to LLVM bitcode.

Parameters
inputPathThe file to compile, containing a C implementation of the node class, port type, or library module.
outputPathThe file in which to save the compiled LLVM bitcode.

Definition at line 4070 of file VuoCompiler.cc.

◆ compileModule() [2/2]

void VuoCompiler::compileModule ( string  inputPath,
string  outputPath,
const vector< string > &  includePaths 
)

Compiles a node class, port type, or library module to LLVM bitcode.

Parameters
inputPathThe file to compile, containing a C implementation of the node class, port type, or library module.
outputPathThe file in which to save the compiled LLVM bitcode.
includePathsDirectories with header files to be included when compiling.

Definition at line 4082 of file VuoCompiler.cc.

◆ createNode() [1/2]

VuoNode * VuoCompiler::createNode ( VuoCompilerNodeClass nodeClass,
string  title = "",
double  x = 0,
double  y = 0 
)

Instantiates a node for the given node class.

If the node class is a generic template (e.g. vuo.data.hold), then the node is instantiated with the specialized version of the node class (e.g. vuo.data.hold.VuoGenericType1).

Parameters
nodeClassThe node class from which to create the node.
titleThe node's title.
xThe node's x-coordinate within the composition.
yThe node's y-coordinate within the composition.

Definition at line 5960 of file VuoCompiler.cc.

◆ createNode() [2/2]

VuoNode * VuoCompiler::createNode ( VuoCompilerNodeClass nodeClass,
VuoNode nodeToCopyMetadataFrom 
)

Instantiates a node for the given node class.

If the node class is a generic template (e.g. vuo.data.hold), then the node is instantiated with the specialized version of the node class (e.g. vuo.data.hold.VuoGenericType1).

Definition at line 5975 of file VuoCompiler.cc.

◆ createPublishedInputNode()

VuoNode * VuoCompiler::createPublishedInputNode ( vector< VuoPublishedPort * >  publishedInputPorts)

Instantiates a node used during code generation to represent published input ports.

Definition at line 5987 of file VuoCompiler.cc.

◆ createPublishedOutputNode()

VuoNode * VuoCompiler::createPublishedOutputNode ( vector< VuoPublishedPort * >  publishedOutputPorts)

Instantiates a node used during code generation to represent published output ports.

Definition at line 5996 of file VuoCompiler.cc.

◆ deleteOldModuleCaches()

void VuoCompiler::deleteOldModuleCaches ( void  )
static

Deletes:

  • any composition-local module cache directories that have not been accessed for more than 30 days.
  • any pid-specific module cache directories for pids that are not currently running.
Changed in Vuo 2.0.0:
New.

Definition at line 5261 of file VuoCompiler.cc.

◆ destroyLlvmModule()

void VuoCompiler::destroyLlvmModule ( Module *  module)
static

Calls the destructor for module, using the LLVM global context thread-safely.

This function may be called on any dispatch queue except llvmQueue.

Changed in Vuo 2.0.0:
New.

Definition at line 5942 of file VuoCompiler.cc.

◆ destroyModule()

void VuoCompiler::destroyModule ( VuoCompilerModule module)
static

Deallocates module and associated data.

This function may be called on any dispatch queue except llvmQueue.

Changed in Vuo 2.0.0:
New.

Definition at line 5899 of file VuoCompiler.cc.

◆ generateBuiltInModuleCaches()

void VuoCompiler::generateBuiltInModuleCaches ( string  vuoFrameworkPath,
string  target 
)
static

Generates the caches of built-in modules and places them inside of Vuo.framework.

This function is intended for running Vuo in a special mode just to generate the caches and then exit. It's called while building Vuo itself, toward the end of the process of creating Vuo.framework.

Assumes that no VuoCompiler instances have been constructed before this call.

Parameters
vuoFrameworkPathThe absolute path of Vuo.framework, as would be returned by VuoFileUtilities::getVuoFrameworkPath if the Vuo.framework dynamic library were loaded.
targetThe LLVM target-triple to build.
Changed in Vuo 2.0.0:
New.

Definition at line 5246 of file VuoCompiler.cc.

◆ getArch()

string VuoCompiler::getArch ( void  )

Returns this compiler instance's CPU architecture.

E.g., x86_64 or arm64.

Definition at line 5228 of file VuoCompiler.cc.

◆ getCompatibilityOfDependencies()

VuoCompilerCompatibility VuoCompiler::getCompatibilityOfDependencies ( const set< string > &  dependencies)

Returns a description of the set of systems that all of dependencies are able to run on.

Definition at line 4906 of file VuoCompiler.cc.

◆ getCompositionLoaderPath()

string VuoCompiler::getCompositionLoaderPath ( void  )

Returns the path to the VuoCompositionLoader executable.

Definition at line 6625 of file VuoCompiler.cc.

◆ getCompositionLocalModulesPath()

string VuoCompiler::getCompositionLocalModulesPath ( void  )

Returns the path of the composition-local Modules folder for this compiler's composition path, or an empty string if the composition path hasn't been set.

Changed in Vuo 2.0.0:
New.

Definition at line 6512 of file VuoCompiler.cc.

◆ getCompositionLocalPath()

string VuoCompiler::getCompositionLocalPath ( void  )

Returns the path of the top-level composition folder for this compiler's composition path, or an empty string if the composition path hasn't been set.

If the composition is a composition-local subcomposition (it's located in a folder called Modules other than the Built-in, User, and System Modules folders), returns the folder containing the Modules folder. Otherwise, returns the folder containing the composition.

Changed in Vuo 2.0.0:
New.

Definition at line 6527 of file VuoCompiler.cc.

◆ getDependenciesForComposition()

set< string > VuoCompiler::getDependenciesForComposition ( VuoCompilerComposition composition)

Returns the names of dependencies (node classes, types, libraries, and frameworks) needed for linking the composition.

Changed in Vuo 2.0.0:
New.

Definition at line 4725 of file VuoCompiler.cc.

◆ getDirectDependenciesForComposition()

set< string > VuoCompiler::getDirectDependenciesForComposition ( VuoCompilerComposition composition)

Returns the names of dependencies (node classes and types) directly referenced by the composition.

Does not include dependencies of dependencies.

Changed in Vuo 2.0.0:
New.

Definition at line 4679 of file VuoCompiler.cc.

◆ getDylibDependencyPathsForComposition()

set< string > VuoCompiler::getDylibDependencyPathsForComposition ( VuoCompilerComposition composition)

Returns the absolute paths of dylibs needed for linking the composition.

Changed in Vuo 2.0.0:
New.

Definition at line 4736 of file VuoCompiler.cc.

◆ getLibraryModule()

VuoCompilerModule * VuoCompiler::getLibraryModule ( const string &  libraryModuleName)

Returns the library specified by libraryName, or null if it can't be found or loaded.

The library is loaded if it haven't been already.

Definition at line 6268 of file VuoCompiler.cc.

◆ getLibraryModules()

map< string, VuoCompilerModule * > VuoCompiler::getLibraryModules ( void  )

Returns all libraries found and loaded, indexed by key.

The libraries are loaded if they haven't been already.

Definition at line 6290 of file VuoCompiler.cc.

◆ getModuleKeyForPath()

string VuoCompiler::getModuleKeyForPath ( string  path)
static

Returns the name of the node class or other module that would be located at path.

Definition at line 6462 of file VuoCompiler.cc.

◆ getNodeClass()

VuoCompilerNodeClass * VuoCompiler::getNodeClass ( const string &  nodeClassName)

Returns the node class specified by nodeClassName, or null if it can't be found or loaded.

The node class module is loaded or generated if it hasn't been already.

Example:
VuoCompiler *compiler = new VuoCompiler();
VuoCompilerNodeClass *nc = compiler->getNodeClass("vuo.math.add.VuoInteger");
[...]
delete compiler;

Definition at line 6170 of file VuoCompiler.cc.

◆ getNodeClasses()

map< string, VuoCompilerNodeClass * > VuoCompiler::getNodeClasses ( void  )

Returns all node classes found and loaded, indexed by node class name.

The node class modules are loaded if they haven't been already.

Definition at line 6200 of file VuoCompiler.cc.

◆ getNodeSetForName()

VuoNodeSet * VuoCompiler::getNodeSetForName ( const string &  name)

Returns the node set with the given name, or null if it can't be found.

The node class modules are loaded if they haven't been already.

Definition at line 6326 of file VuoCompiler.cc.

◆ getNodeSets()

map< string, VuoNodeSet * > VuoCompiler::getNodeSets ( void  )

Returns all node sets found and loaded, indexed by node set name.

The node class modules are loaded if they haven't been already.

Definition at line 6308 of file VuoCompiler.cc.

◆ getTarget()

string VuoCompiler::getTarget ( void  )

Returns this compiler instance's LLVM target triple.

E.g., x86_64-apple-macosx10.10.0.

Definition at line 5219 of file VuoCompiler.cc.

◆ getType()

VuoCompilerType * VuoCompiler::getType ( const string &  typeName)

Returns the type specified by typeName, or null if it can't be found or loaded.

The type module is loaded or generated if it haven't been already.

Definition at line 6218 of file VuoCompiler.cc.

◆ getTypes()

map< string, VuoCompilerType * > VuoCompiler::getTypes ( void  )

Returns all types found and loaded, indexed by type name.

The type modules are loaded if they haven't been already.

Definition at line 6250 of file VuoCompiler.cc.

◆ getVuoFrameworkPath()

string VuoCompiler::getVuoFrameworkPath ( void  )
static

Returns the absolute path of Vuo.framework.

This returns the same thing VuoFileUtilities::getVuoFrameworkPath except during a call to VuoCompiler::generateBuiltInModuleCaches.

Definition at line 6443 of file VuoCompiler.cc.

◆ installNodeClassAtCompositionLocalScope()

void VuoCompiler::installNodeClassAtCompositionLocalScope ( const string &  sourcePath)

Causes the node class source code located at sourcePath to be loaded at composition-family scope — unless this compiler's composition path is within the user, system, or built-in scope, in which case does nothing.

Definition at line 6050 of file VuoCompiler.cc.

◆ isCompositionLocalModule()

bool VuoCompiler::isCompositionLocalModule ( string  moduleKey)

Returns true if the module is installed in the composition-local Modules folder for this compiler's composition path.

Definition at line 6494 of file VuoCompiler.cc.

◆ linkCompositionToCreateDynamicLibraries()

void VuoCompiler::linkCompositionToCreateDynamicLibraries ( string  compiledCompositionPath,
string  linkedCompositionPath,
VuoRunningCompositionLibraries runningCompositionLibraries 
)

Creates one dynamic library for the composition by itself and, if needed, additional dynamic libraries for the node classes and other resources that are dependencies of the composition.

Parameters
compiledCompositionPathPath to the compiled composition (an LLVM bitcode file).
linkedCompositionPathPath where the resulting dynamic library for the composition should be placed. Pass a different path each time this function is called (to ensure that the OS will agree to swap out the library during live coding).
runningCompositionLibrariesInformation about libraries referenced by the composition. On the first call to this function, pass in a newly constructed object. On subsequent calls, pass in the same object. It gets updated with each call.
Exceptions
VuoCompilerExceptionAt least one of the dependencies is incompatible with the targets for building the composition, or the linker encountered errors and failed. runningCompositionLibraries is unchanged.
Changed in Vuo 2.0.0:
Replaced newLinkedResourcePath, alreadyLinkedResourcePaths, alreadyLinkedResources arguments with runningCompositionLibraries.

Definition at line 4405 of file VuoCompiler.cc.

◆ linkCompositionToCreateDynamicLibrary()

void VuoCompiler::linkCompositionToCreateDynamicLibrary ( string  inputPath,
string  outputPath,
Optimization  optimization,
bool  shouldAdHocCodeSign = true 
)

Turns a compiled composition into a dynamic library by linking in all of its dependencies.

If you plan to run multiple compositions, or multiple instances of the same composition, in the same process (VuoRunner::newCurrentProcessRunnerFromDynamicLibrary), optimization should be Optimization_FastBuild or Optimization_FastBuildExistingCache. This prevents conflicts between Objective-C classes (from nodes) being defined in multiple loaded dynamic libraries.

Parameters
inputPathPath to the compiled composition (an LLVM bitcode file).
outputPathPath where the resulting dynamic library should be placed.
optimizationControls the time it takes to link the composition and the size and dependencies of the resulting dynamic library.
shouldAdHocCodeSignWhether to ad-hoc code-sign the generated dylib. Disable to improve performance (e.g., for systems that don't require code-signing, or if you will later be code-signing the whole bundle).
Exceptions
VuoCompilerExceptionAt least one of the dependencies is incompatible with the targets for building the composition, or the linker encountered errors and failed.

Definition at line 4348 of file VuoCompiler.cc.

◆ linkCompositionToCreateExecutable()

void VuoCompiler::linkCompositionToCreateExecutable ( string  inputPath,
string  outputPath,
Optimization  optimization,
string  rPath = "",
bool  shouldAdHocCodeSign = true 
)

Turns a compiled composition into an executable by linking in all of its dependencies and adding a main function.

Parameters
inputPathPath to the compiled composition (an LLVM bitcode file).
outputPathPath where the resulting executable should be placed.
optimizationControls the time it takes to link the composition and the size and dependencies of the resulting executable.
rPathAn optional -rpath argument to be passed to clang.
shouldAdHocCodeSignWhether to ad-hoc code-sign the generated executable. Disable to improve performance (e.g., for systems that don't require code-signing, or if you will later be code-signing the whole bundle).
Exceptions
VuoCompilerExceptionAt least one of the dependencies is incompatible with the targets for building the composition, or the linker encountered errors and failed.
Changed in Vuo 2.0.0:
Removed isApp argument.

Definition at line 4326 of file VuoCompiler.cc.

◆ listNodeClasses()

void VuoCompiler::listNodeClasses ( const string &  format = "")

Prints a list of all loaded node classes to standard output.

The node class modules are loaded if they haven't been already.

Parameters
formatThe format for printing the node classes.
  • If "", prints each class name (e.g. vuo.math.count.VuoInteger), one per line.
  • If "dot", prints the declaration of a node as it would appear in a .vuo (DOT format) file, with a constant value set for each data+event input port and a comment listing metadata and port types for the node class.

Definition at line 6366 of file VuoCompiler.cc.

◆ newCurrentProcessRunnerFromCompositionFile()

VuoRunner * VuoCompiler::newCurrentProcessRunnerFromCompositionFile ( string  compositionFilePath,
VuoCompilerIssues issues 
)
static

Creates a runner object that can run the composition in file compositionFilePath in this process.

If there's an error compiling or linking the composition, the error is added to issues and this function returns null. Any warnings are also added to issues.

Changed in Vuo 2.0.0:
Added issues argument.

Definition at line 6781 of file VuoCompiler.cc.

◆ newCurrentProcessRunnerFromCompositionString()

VuoRunner * VuoCompiler::newCurrentProcessRunnerFromCompositionString ( string  composition,
string  workingDirectory,
VuoCompilerIssues issues 
)
static

Creates a runner object that can run the composition in string composition in this process.

If there's an error compiling or linking the composition, the error is added to issues and this function returns null. Any warnings are also added to issues.

Parameters
compositionA serialized composition.
workingDirectoryThe compiling and linking steps and the running composition behave as if the composition is in this directory. The directory is used by when compiling and linking to search for composition-local nodes, and it's used by nodes in the running composition to resolve relative paths.
issuesProblems encountered while compiling and linking.
Changed in Vuo 2.0.0:
Added issues argument.

Definition at line 6817 of file VuoCompiler.cc.

◆ newSeparateProcessRunnerFromCompositionFile()

VuoRunner * VuoCompiler::newSeparateProcessRunnerFromCompositionFile ( string  compositionFilePath,
VuoCompilerIssues issues 
)
static

Creates a runner object that can run the composition in file compositionFilePath in a new process.

If there's an error compiling or linking the composition, the error is added to issues and this function returns null. Any warnings are also added to issues.

Changed in Vuo 2.0.0:
Added issues argument.

Definition at line 6716 of file VuoCompiler.cc.

◆ newSeparateProcessRunnerFromCompositionString()

VuoRunner * VuoCompiler::newSeparateProcessRunnerFromCompositionString ( string  composition,
string  processName,
string  workingDirectory,
VuoCompilerIssues issues 
)
static

Creates a runner object that can run the composition in string composition in a new process.

If there's an error compiling or linking the composition, the error is added to issues and this function returns null. Any warnings are also added to issues.

Parameters
compositionA serialized composition.
processNameThe executable filename that the running composition should use.
workingDirectoryThe compiling and linking steps and the running composition behave as if the composition is in this directory. The directory is used by when compiling and linking to search for composition-local nodes, and it's used by nodes in the running composition to resolve relative paths.
issuesProblems encountered while compiling and linking.
Changed in Vuo 2.0.0:
Added processName, issues arguments.

Definition at line 6752 of file VuoCompiler.cc.

◆ overrideInstalledNodeClass()

void VuoCompiler::overrideInstalledNodeClass ( const string &  sourcePath,
const string &  sourceCode 
)

Temporarily replaces the subcomposition installed at sourcePath with a subcomposition compiled from sourceCode.

The newly compiled subcomposition becomes the active version, overriding the installed subcomposition.

This function can be called multiple times in succession, replacing one override with another.

The most recent override remains active until the installed subcomposition is saved or revertOverriddenNodeClass is called.

A call to this function may or may not result in a call to VuoCompilerDelegate::loadedModules. The node class won't be reloaded if sourceCode is the same as source code from which the module was most recently loaded.

Changed in Vuo 2.0.0:
New.

Definition at line 6093 of file VuoCompiler.cc.

◆ prepareForFastBuild()

void VuoCompiler::prepareForFastBuild ( void  )

Asynchronously prepares the cache that enables compositions to build faster.

The first time a composition is built with the "faster build" optimization, it waits until the cache is prepared. Preparing the cache may take several seconds. By calling this function, the cache can be prepared in advance, so that there's no delay when building the first composition.

Definition at line 5208 of file VuoCompiler.cc.

◆ print()

void VuoCompiler::print ( void  )

Prints info about this compiler, for debugging.

Definition at line 6658 of file VuoCompiler.cc.

◆ readModuleFromBitcode()

Module * VuoCompiler::readModuleFromBitcode ( string  inputPath,
string  arch 
)
static

Returns the LLVM module in the arch slice of inputFile.

This function may be called on any dispatch queue except llvmQueue.

Definition at line 5653 of file VuoCompiler.cc.

◆ revertOverriddenNodeClass()

void VuoCompiler::revertOverriddenNodeClass ( const string &  sourcePath)

Removes an override added by overrideInstalledNodeClass (if any), reverting to the installed version of the node class.

A call to this function always results in a call to VuoCompilerDelegate::loadedModules, even if the node class's source code was not overridden.

Changed in Vuo 2.0.0:
New.

Definition at line 6153 of file VuoCompiler.cc.

◆ setCompositionPath()

void VuoCompiler::setCompositionPath ( const string &  compositionPath)

If this compiler will be compiling a composition, pass its path here (if not already passed to VuoCompiler::VuoCompiler) so the compiler can locate composition-local modules.

If you compile a composition and haven't told the compiler its path, the composition will be able to use modules at the shared scopes (built-in, system, user) but not at the composition-local scope.

Changed in Vuo 2.0.0:
New.

Definition at line 2901 of file VuoCompiler.cc.

◆ setDelegate()

void VuoCompiler::setDelegate ( VuoCompilerDelegate delegate)

Sets the delegate that receives messages from the compiler when modules are loaded.

May be null.

Changed in Vuo 2.0.0:
New.

Definition at line 2885 of file VuoCompiler.cc.

◆ setLoadAllModules()

void VuoCompiler::setLoadAllModules ( bool  shouldLoadAllModules)

Controls whether the VuoCompiler should load all node classes, types, and library modules from the module search paths the first time a module is needed.

Definition at line 5294 of file VuoCompiler.cc.

◆ setShouldPotentiallyShowSplashWindow()

void VuoCompiler::setShouldPotentiallyShowSplashWindow ( bool  potentiallyShow)

Sets whether the compiled composition should show the Vuo Community Edition splash window, if generated by Vuo Community Edition.

Definition at line 6593 of file VuoCompiler.cc.

◆ setTelemetry()

void VuoCompiler::setTelemetry ( const string &  telemetry)

Sets the telemetry option to use when compiling a composition.

Valid values are "on" and "console".

Definition at line 6576 of file VuoCompiler.cc.

◆ setVerbose()

void VuoCompiler::setVerbose ( bool  isVerbose)

Sets the verbosity to use when compiling or linking.

If true, prints some debug info and passes the -v option to Clang.

Definition at line 6584 of file VuoCompiler.cc.

◆ shouldShowSplashWindow()

bool VuoCompiler::shouldShowSplashWindow ( )

Returns whether the compiled composition should show the Vuo Community Edition splash window.

Definition at line 6609 of file VuoCompiler.cc.

◆ uninstallNodeClassAtCompositionLocalScope()

void VuoCompiler::uninstallNodeClassAtCompositionLocalScope ( const string &  sourcePath)

Causes the node class that was previously loaded from sourcePath by installNodeClassAtCompositionLocalScope, if any, to be unloaded.

Definition at line 6062 of file VuoCompiler.cc.

Friends And Related Function Documentation

◆ TestCompilingAndLinking

friend class TestCompilingAndLinking
friend

TestCompilingAndLinking calls reset().

Definition at line 397 of file VuoCompiler.hh.

◆ TestCompositionExecution

friend class TestCompositionExecution
friend

TestCompositionExecution needs to add a search path for its own private nodes.

Definition at line 393 of file VuoCompiler.hh.

◆ TestEventDropping

friend class TestEventDropping
friend

TestEventDropping calls reset().

Definition at line 400 of file VuoCompiler.hh.

◆ TestModuleLoading

friend class TestModuleLoading
friend

TestModuleLoading calls reset().

Definition at line 399 of file VuoCompiler.hh.

◆ TestNodes

friend class TestNodes
friend

TestNodes calls getProcessTarget().

Definition at line 403 of file VuoCompiler.hh.

◆ TestSubcompositions

friend class TestSubcompositions
friend

TestSubcompositions calls reset().

Definition at line 398 of file VuoCompiler.hh.

◆ TestVuoCompiler

friend class TestVuoCompiler
friend

TestVuoCompiler needs to add a search path for its own private nodes/types.

Definition at line 392 of file VuoCompiler.hh.

◆ TestVuoCompilerCompatibility

friend class TestVuoCompilerCompatibility
friend

TestVuoCompilerCompatibility calls getProcessTarget().

Definition at line 402 of file VuoCompiler.hh.

◆ TestVuoIsfModuleCompiler

friend class TestVuoIsfModuleCompiler
friend

TestVuoIsfModuleCompiler calls writeModuleToBitcode().

Definition at line 401 of file VuoCompiler.hh.

Member Data Documentation

◆ globalLLVMContext

llvm::LLVMContext * VuoCompiler::globalLLVMContext = nullptr
static

LLVM's global context.

Definition at line 468 of file VuoCompiler.hh.


The documentation for this class was generated from the following files: