Vuo 2.4.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
VuoCompiler Class Reference

Description

This is the central class for compiling modules and compositions.

Its main responsibilities are:

A VuoCompiler instance encapsulates a set of VuoCompilerEnvironment instances that hold the node classes, types, and library modules that are available to the VuoCompiler. Some VuoCompilerEnvironments are shared among all VuoCompilers, while others are unique to one or a few VuoCompilers.

See also
Developing Applications that Use Vuo

Definition at line 49 of file VuoCompiler.hh.

Public Types

enum  Optimization { Optimization_ModuleCaches , Optimization_ExistingModuleCaches , Optimization_NoModuleCaches }
 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.
 
 ~VuoCompiler (void)
 Destructor.
 
void setDelegate (VuoCompilerDelegate *delegate)
 Sets the delegate that receives messages from the compiler when modules are loaded.
 
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.
 
void compileComposition (VuoCompilerComposition *composition, string outputPath, bool isTopLevelComposition, VuoCompilerIssues *issues)
 Compiles a composition to LLVM bitcode.
 
void compileComposition (string inputPath, string outputPath, bool isTopLevelComposition, VuoCompilerIssues *issues)
 Compiles a composition, read from file, to LLVM bitcode.
 
void compileCompositionString (const string &compositionString, string outputPath, bool isTopLevelComposition, VuoCompilerIssues *issues)
 Compiles the composition, read from a string, to LLVM bitcode.
 
VuoModuleCompilercreateModuleCompiler (const string &moduleKey, const string &inputPath, const map< string, string > &typeNameReplacements={})
 Returns a VuoModuleCompiler suitable for compiling the given module, or null if no such VuoModuleCompiler exists.
 
VuoModuleCompilerResults compileModuleInMemory (const string &inputPath, const string &overriddenSourceCode="", const map< string, string > &typeNameReplacements={})
 Compiles a node class, port type, or library module to LLVM bitcode.
 
void compileModule (const string &inputPath, const string &outputPath)
 Compiles a node class, port type, or library module to an LLVM bitcode file.
 
void generateHeaderForModule (const string &inputPath, const string &outputPath)
 Generates a header file for a specialization of a generic module.
 
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.
 
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.
 
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.
 
set< string > getDirectDependenciesForComposition (VuoCompilerComposition *composition)
 Returns the names of dependencies (node classes and types) directly referenced by the composition.
 
set< string > getDependenciesForComposition (VuoCompilerComposition *composition)
 Returns the names of dependencies (node classes, types, libraries, and frameworks) needed for linking the composition.
 
set< string > getDylibDependencyPathsForComposition (VuoCompilerComposition *composition)
 Returns the absolute paths of dylibs needed for linking the composition.
 
VuoCompilerCompatibility getCompatibilityOfDependencies (const set< string > &dependencies)
 Returns a description of the set of systems that all of dependencies are able to run on.
 
void prepareModuleCaches (void)
 Asynchronously makes the module caches available, rebuilding any non-built-in module caches that are out of date, to avoid a delay the first time a composition is linked with VuoCompiler::Optimization_ModuleCaches or VuoCompiler::Optimization_ExistingModuleCaches.
 
string getTarget (void)
 Returns this compiler instance's LLVM target triple.
 
string getArch (void)
 Returns this compiler instance's CPU architecture.
 
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.
 
VuoNodecreateNode (VuoCompilerNodeClass *nodeClass, string title="", double x=0, double y=0)
 Instantiates a node for the given node class.
 
VuoNodecreateNode (VuoCompilerNodeClass *nodeClass, VuoNode *nodeToCopyMetadataFrom)
 Instantiates a node for the given node class.
 
VuoNodecreatePublishedInputNode (vector< VuoPublishedPort * > publishedInputPorts)
 Instantiates a node used during code generation to represent published input ports.
 
VuoNodecreatePublishedOutputNode (vector< VuoPublishedPort * > publishedOutputPorts)
 Instantiates a node used during code generation to represent published output ports.
 
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.
 
void uninstallNodeClassAtCompositionLocalScope (const string &sourcePath)
 Causes the node class that was previously loaded from sourcePath by VuoCompiler::installNodeClassAtCompositionLocalScope(), if any, to be unloaded.
 
void overrideInstalledNodeClass (const string &sourcePath, const string &sourceCode)
 Temporarily replaces the subcomposition installed at sourcePath with a subcomposition compiled from sourceCode.
 
void revertOverriddenNodeClass (const string &sourcePath)
 Removes an override added by VuoCompiler::overrideInstalledNodeClass() (if any), reverting to the installed version of the node class.
 
VuoCompilerNodeClassgetNodeClass (const string &nodeClassName)
 Returns the node class specified by nodeClassName, or null if it can't be found or loaded.
 
map< string, VuoCompilerNodeClass * > getNodeClasses (void)
 Returns all node classes found and loaded, indexed by node class name.
 
VuoCompilerTypegetType (const string &typeName)
 Returns the type specified by typeName, or null if it can't be found or loaded.
 
map< string, VuoCompilerType * > getTypes (void)
 Returns all types found and loaded, indexed by type name.
 
VuoCompilerModulegetLibraryModule (const string &libraryModuleName)
 Returns the library specified by libraryName, or null if it can't be found or loaded.
 
map< string, VuoCompilerModule * > getLibraryModules ()
 Returns all libraries found and loaded, indexed by key.
 
map< string, VuoNodeSet * > getNodeSets ()
 Returns all node sets found and loaded, indexed by node set name.
 
VuoNodeSetgetNodeSetForName (const string &name)
 Returns the node set with the given name, or null if it can't be found.
 
void listNodeClasses (const string &format="")
 Prints a list of all loaded node classes to standard output.
 
bool isCompositionLocalModule (string moduleKey)
 Returns true if the module is installed in the composition-local Modules folder for this compiler's composition path.
 
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.
 
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.
 
void addHeaderSearchPath (const string &path)
 Adds a header search path to use when compiling a node class.
 
void addLibrarySearchPath (const string &path)
 Adds a library search path to use when linking a composition.
 
void addFrameworkSearchPath (const string &path)
 Adds a macOS framework search path to use when linking a composition.
 
void setVerbose (bool isVerbose)
 Sets the verbosity to use when compiling or linking.
 
void setShouldPotentiallyShowSplashWindow (bool potentiallyShow)
 Sets whether the compiled composition should show the Vuo Community Edition splash window, if generated by Vuo Community Edition.
 
void setDependencyOutput (const string &path)
 Specifies the path at which to create a GCC-style Makefile-depfile (used by CMake's DEPFILE) that lists the source/header files this module depends on.
 
bool shouldShowSplashWindow ()
 Returns whether the compiled composition should show the Vuo Community Edition splash window.
 
string getCompositionLoaderPath (void)
 Returns the path to the VuoCompositionLoader executable.
 
void print (void)
 Prints info about this compiler, for debugging.
 

Static Public Member Functions

static Module * readModuleFromBitcode (string inputPath, string arch)
 Returns the LLVM module in the arch slice of inputFile.
 
static void destroyModule (VuoCompilerModule *module)
 Deallocates module and associated data.
 
static void destroyLlvmModule (Module *module)
 Calls the destructor for module, using the LLVM global context thread-safely.
 
static void generateBuiltInModuleCache (string vuoFrameworkPath, string target, bool onlyGenerateModules)
 Generates the cache of built-in modules and places it inside of Vuo.framework.
 
static string getTargetArch (string target)
 Returns the CPU architecture part of the target triple.
 
static string getVuoFrameworkPath (void)
 Returns the absolute path of Vuo.framework.
 
static string getModuleKeyForPath (string path)
 Returns the name of the node class or other module that would be located at path.
 
static VuoRunnernewSeparateProcessRunnerFromCompositionFile (string compositionFilePath, VuoCompilerIssues *issues)
 Creates a runner object that can run the composition in file compositionFilePath in a new process.
 
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.
 
static VuoRunnernewCurrentProcessRunnerFromCompositionFile (string compositionFilePath, VuoCompilerIssues *issues)
 Creates a runner object that can run the composition in file compositionFilePath in this process.
 
static VuoRunnernewCurrentProcessRunnerFromCompositionString (string composition, string workingDirectory, VuoCompilerIssues *issues)
 Creates a runner object that can run the composition in string composition in this process.
 

Static Public Attributes

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

Friends

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

Member Enumeration Documentation

◆ Optimization

Options for optimizations when building a composition.

Enumerator
Optimization_ModuleCaches 

The composition binary will link to module cache dylibs on the user's system. These dylibs are created in advance of linking the composition; see VuoCompiler::prepareModuleCaches().

Optimization_ExistingModuleCaches 

Like Optimization_ModuleCaches, but skips ensuring that the module cache dylibs are up to date.

Optimization_NoModuleCaches 

The composition binary will not link to any module cache dylibs.

Definition at line 55 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 VuoCompiler::setCompositionPath() or VuoCompiler::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 214 of file VuoCompiler.cc.

◆ ~VuoCompiler()

VuoCompiler::~VuoCompiler ( void  )

Destructor.

Definition at line 313 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 4447 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 4427 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 4437 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 VuoCompiler::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 2310 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 2267 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 2354 of file VuoCompiler.cc.

◆ compileModule()

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

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

Parameters
inputPathThe file to compile, containing a text-code implementation of the node class, port type, or library module.
outputPathThe file in which to save the compiled LLVM bitcode.
Exceptions
VuoCompilerExceptionThe module source code is invalid.

Definition at line 2135 of file VuoCompiler.cc.

◆ compileModuleInMemory()

VuoModuleCompilerResults VuoCompiler::compileModuleInMemory ( const string &  inputPath,
const string &  overriddenSourceCode = "",
const map< string, string > &  typeNameReplacements = {} 
)

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

Parameters
inputPathThe file to compile, containing a text-code implementation of the node class, port type, or library module.
overriddenSourceCodeAn implementation overriding the contents of inputPath.
typeNameReplacementsFor each generic type name, the specialized type name that should be substituted in its place.
Exceptions
VuoCompilerExceptionThe module source code is invalid.

Definition at line 2095 of file VuoCompiler.cc.

◆ createModuleCompiler()

VuoModuleCompiler * VuoCompiler::createModuleCompiler ( const string &  moduleKey,
const string &  inputPath,
const map< string, string > &  typeNameReplacements = {} 
)

Returns a VuoModuleCompiler suitable for compiling the given module, or null if no such VuoModuleCompiler exists.

Definition at line 2042 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 3825 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 3840 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 3852 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 3861 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 3807 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 3764 of file VuoCompiler.cc.

◆ generateBuiltInModuleCache()

void VuoCompiler::generateBuiltInModuleCache ( string  vuoFrameworkPath,
string  target,
bool  onlyGenerateModules 
)
static

Generates the cache of built-in modules and places it 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.
onlyGenerateModulesIf true, this function only generates the modules for the module cache's compiled modules directory; it doesn't create the module cache dylib.
Changed in Vuo 2.0.0:
New.

Definition at line 3165 of file VuoCompiler.cc.

◆ generateHeaderForModule()

void VuoCompiler::generateHeaderForModule ( const string &  inputPath,
const string &  outputPath 
)

Generates a header file for a specialization of a generic module.

Parameters
inputPathThe path of the generic module's implementation file with the specialized type(s) appended to the file name, e.g. vuo/type/compound/VuoList_VuoInteger.cc.
outputPathThe path at which to save the header file.

Definition at line 2197 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 3202 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 3006 of file VuoCompiler.cc.

◆ getCompositionLoaderPath()

string VuoCompiler::getCompositionLoaderPath ( void  )

Returns the path to the VuoCompositionLoader executable.

Definition at line 4507 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 4393 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 4408 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 2777 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 2731 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 2788 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 4117 of file VuoCompiler.cc.

◆ getLibraryModules()

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

Returns all libraries found and loaded, indexed by key.

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

Definition at line 4127 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 4343 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.

If the node class has any ports with compound types, those types may still be loading in the background after this function returns. If you need to wait for them to load, either call getType() on each compound type, which will block until the type loads, or wait for a notification from the VuoCompilerDelegate that the node class has been added.

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

Definition at line 4039 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 4056 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 4165 of file VuoCompiler.cc.

◆ getNodeSets()

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

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 4146 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 3193 of file VuoCompiler.cc.

◆ getTargetArch()

string VuoCompiler::getTargetArch ( string  target)
static

Returns the CPU architecture part of the target triple.

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

Definition at line 3723 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 4075 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 4098 of file VuoCompiler.cc.

◆ getVuoFrameworkPath()

string VuoCompiler::getVuoFrameworkPath ( void  )
static

Returns the absolute path of Vuo.framework.

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

Definition at line 4324 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 3915 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 4375 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. This object should not be shared between different VuoRunner instances (or else the VuoModuleCacheRevision reference counts won't be incremented/decremented appropriately).
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 2466 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 VuoCompiler::Optimization_ModuleCaches or VuoCompiler::Optimization_ExistingModuleCaches. 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 2403 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 ld. If empty, defaults to all run-path search paths available to this compiler's environments.
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 2380 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 4207 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 4658 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 4697 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 4587 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 4626 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 VuoCompiler::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 3958 of file VuoCompiler.cc.

◆ prepareModuleCaches()

void VuoCompiler::prepareModuleCaches ( void  )

Asynchronously makes the module caches available, rebuilding any non-built-in module caches that are out of date, to avoid a delay the first time a composition is linked with VuoCompiler::Optimization_ModuleCaches or VuoCompiler::Optimization_ExistingModuleCaches.

Definition at line 3143 of file VuoCompiler.cc.

◆ print()

void VuoCompiler::print ( void  )

Prints info about this compiler, for debugging.

Definition at line 4529 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 3505 of file VuoCompiler.cc.

◆ revertOverriddenNodeClass()

void VuoCompiler::revertOverriddenNodeClass ( const string &  sourcePath)

Removes an override added by VuoCompiler::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 4017 of file VuoCompiler.cc.

◆ setCompositionPath()

void VuoCompiler::setCompositionPath ( const string &  compositionPathOrig)

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 404 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 388 of file VuoCompiler.cc.

◆ setDependencyOutput()

void VuoCompiler::setDependencyOutput ( const string &  path)

Specifies the path at which to create a GCC-style Makefile-depfile (used by CMake's DEPFILE) that lists the source/header files this module depends on.

Definition at line 4483 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 3211 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 4466 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 4457 of file VuoCompiler.cc.

◆ shouldShowSplashWindow()

bool VuoCompiler::shouldShowSplashWindow ( )

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

Definition at line 4491 of file VuoCompiler.cc.

◆ uninstallNodeClassAtCompositionLocalScope()

void VuoCompiler::uninstallNodeClassAtCompositionLocalScope ( const string &  sourcePath)

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

Definition at line 3927 of file VuoCompiler.cc.

Friends And Related Symbol Documentation

◆ TestCompilerDelegate

friend class TestCompilerDelegate
friend

Definition at line 136 of file VuoCompiler.hh.

◆ TestCompilingAndLinking

friend class TestCompilingAndLinking
friend

TestCompilingAndLinking calls reset().

Definition at line 137 of file VuoCompiler.hh.

◆ TestCompositionExecution

friend class TestCompositionExecution
friend

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

Definition at line 138 of file VuoCompiler.hh.

◆ TestEventDropping

friend class TestEventDropping
friend

TestEventDropping calls reset().

Definition at line 139 of file VuoCompiler.hh.

◆ TestModuleCaches

friend class TestModuleCaches
friend

TestModuleCaches calls getProcessTarget().

Definition at line 141 of file VuoCompiler.hh.

◆ TestModuleLoading

friend class TestModuleLoading
friend

TestModuleLoading calls reset().

Definition at line 140 of file VuoCompiler.hh.

◆ TestNodes

friend class TestNodes
friend

TestNodes calls getProcessTarget().

Definition at line 142 of file VuoCompiler.hh.

◆ TestSubcompositions

friend class TestSubcompositions
friend

TestSubcompositions calls reset().

Definition at line 143 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 144 of file VuoCompiler.hh.

◆ TestVuoCompilerBitcodeGenerator

friend class TestVuoCompilerBitcodeGenerator
friend

Definition at line 145 of file VuoCompiler.hh.

◆ TestVuoCompilerCompatibility

friend class TestVuoCompilerCompatibility
friend

TestVuoCompilerCompatibility calls getProcessTarget().

Definition at line 146 of file VuoCompiler.hh.

◆ TestVuoCompilerModule

friend class TestVuoCompilerModule
friend

Definition at line 147 of file VuoCompiler.hh.

◆ TestVuoIsfModuleCompiler

friend class TestVuoIsfModuleCompiler
friend

TestVuoIsfModuleCompiler calls writeModuleToBitcode().

Definition at line 148 of file VuoCompiler.hh.

◆ VuoCompilerEnvironment

friend class VuoCompilerEnvironment
friend

Definition at line 133 of file VuoCompiler.hh.

◆ VuoLinkerInputs

friend class VuoLinkerInputs
friend

Definition at line 134 of file VuoCompiler.hh.

◆ VuoModuleCache

friend class VuoModuleCache
friend

Definition at line 135 of file VuoCompiler.hh.

Member Data Documentation

◆ globalLLVMContext

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

LLVM's global context.

Definition at line 215 of file VuoCompiler.hh.


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