MCPcopy Create free account
hub / github.com/Autodesk/AutomaticComponentToolkit / BuildBindingCppImplicit

Function BuildBindingCppImplicit

Source/buildbindingccpp.go:118–172  ·  view source on GitHub ↗

BuildBindingCppImplicit builds dynamic C++-bindings of a library's API in form of implicitly linked functions handles.

(component ComponentDefinition, outputFolder string, outputFolderExample string, indentString string, ClassIdentifier string)

Source from the content-addressed store, hash-verified

116
117// BuildBindingCppImplicit builds dynamic C++-bindings of a library's API in form of implicitly linked functions handles.
118func BuildBindingCppImplicit(component ComponentDefinition, outputFolder string, outputFolderExample string, indentString string, ClassIdentifier string) error {
119 forceRecreation := false
120 ExplicitLinking := false
121
122 namespace := component.NameSpace
123 libraryname := component.LibraryName
124 baseName := component.BaseName
125
126 CppHeader := path.Join(outputFolder, baseName+"_implicit.hpp")
127 log.Printf("Creating \"%s\"", CppHeader)
128 hppfile, err := CreateLanguageFile(CppHeader, indentString)
129 if err != nil {
130 return err
131 }
132 hppfile.WriteCLicenseHeader(component,
133 fmt.Sprintf("This is an autogenerated C++-Header file in order to allow an easy\n use of %s", libraryname),
134 true)
135 err = buildCppHeader(component, hppfile, namespace, baseName, ClassIdentifier, ExplicitLinking)
136 if err != nil {
137 return err
138 }
139
140 if len(outputFolderExample) > 0 {
141 CPPExample := path.Join(outputFolderExample, namespace+"_example"+".cpp")
142 if forceRecreation || !FileExists(CPPExample) {
143 log.Printf("Creating \"%s\"", CPPExample)
144 cppexamplefile, err := CreateLanguageFile(CPPExample, indentString)
145 if err != nil {
146 return err
147 }
148 cppexamplefile.WriteCLicenseHeader(component,
149 fmt.Sprintf("This is an autogenerated C++ application that demonstrates the\n usage of the C++ bindings of %s", libraryname),
150 true)
151 buildDynamicCppExample(component, cppexamplefile, outputFolder, ClassIdentifier, ExplicitLinking)
152 } else {
153 log.Printf("Omitting recreation of C++-example file \"%s\"", CPPExample)
154 }
155
156 CPPCMake := path.Join(outputFolderExample, "CMakeLists.txt")
157 if forceRecreation || !FileExists(CPPCMake) {
158 log.Printf("Creating \"%s\"", CPPCMake)
159 cppcmake, err := CreateLanguageFile(CPPCMake, " ")
160 if err != nil {
161 return err
162 }
163 cppcmake.WriteCMakeLicenseHeader(component,
164 fmt.Sprintf("This is an autogenerated CMake Project that demonstrates the\n usage of the C++ bindings of %s", libraryname),
165 true)
166 buildCppDynamicExampleCMake(component, cppcmake, outputFolder, outputFolderExample, ExplicitLinking)
167 } else {
168 log.Printf("Omitting recreation of C++-example CMakeLists-file \"%s\"", CPPCMake)
169 }
170 }
171 return nil
172}
173
174func buildDynamicCCPPHeader(component ComponentDefinition, w LanguageWriter, NameSpace string, BaseName string,
175 headerOnly bool, useCPPTypes bool) error {

Callers 1

createComponentFunction · 0.85

Calls 8

CreateLanguageFileFunction · 0.85
buildCppHeaderFunction · 0.85
FileExistsFunction · 0.85
buildDynamicCppExampleFunction · 0.85
PrintfMethod · 0.80
WriteCLicenseHeaderMethod · 0.80

Tested by

no test coverage detected