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

Function BuildBindingNode

Source/buildbindingnode.go:46–95  ·  view source on GitHub ↗

BuildBindingNode builds NodeJS-bindings of a library's API

(component ComponentDefinition, outputFolder string, indentString string)

Source from the content-addressed store, hash-verified

44
45// BuildBindingNode builds NodeJS-bindings of a library's API
46func BuildBindingNode(component ComponentDefinition, outputFolder string, indentString string) error {
47 namespace := component.NameSpace
48 libraryname := component.LibraryName
49 baseName := component.BaseName;
50
51 NodeAddOnImplName := path.Join(outputFolder, baseName + "_nodeaddon.cc");
52 log.Printf("Creating \"%s\"", NodeAddOnImplName)
53 nodeaddonfile, err := os.Create(NodeAddOnImplName)
54 if err != nil {
55 log.Fatal(err)
56 }
57 WriteLicenseHeader(nodeaddonfile, component,
58 fmt.Sprintf("This is an autogenerated C++ Implementation file for the Node addon class \n of %s", libraryname),
59 true)
60
61 NodeWrapperHeaderName := path.Join(outputFolder, baseName + "_nodewrapper.h")
62 log.Printf("Creating \"%s\"", NodeWrapperHeaderName)
63 nodewrapperhfile, err := os.Create(NodeWrapperHeaderName)
64 if err != nil {
65 log.Fatal(err)
66 }
67 WriteLicenseHeader(nodewrapperhfile, component,
68 fmt.Sprintf("This is an autogenerated C++ Header file for the Node wrapper class \n of %s", libraryname),
69 true)
70
71 NodeWrapperImplName := path.Join(outputFolder, baseName + "_nodewrapper.cc")
72 log.Printf("Creating \"%s\"", NodeWrapperImplName)
73 nodewrapperccfile, err := os.Create(NodeWrapperImplName)
74 if err != nil {
75 log.Fatal(err)
76 }
77 WriteLicenseHeader(nodewrapperccfile, component,
78 fmt.Sprintf("This is an autogenerated C++ Implementation file for the Node wrapper class \n of %s", libraryname),
79 true)
80
81 err = buildNodeAddOnImplementation(component, nodeaddonfile, namespace, baseName)
82 if err != nil {
83 log.Fatal(err)
84 }
85
86 NodeBindingGypName := path.Join(outputFolder, "binding.gyp")
87 log.Printf("Creating \"%s\"", NodeBindingGypName)
88 bindinggypfile, err := os.Create(NodeBindingGypName)
89 if err != nil {
90 log.Fatal(err)
91 }
92 buildNodeBindingGyp (component, bindinggypfile, indentString);
93
94 return buildNodeWrapperClass(component, nodewrapperhfile, nodewrapperccfile, namespace, baseName)
95}
96
97func buildNodeAddOnImplementation(component ComponentDefinition, w io.Writer, NameSpace string, BaseName string) error {
98

Callers 1

createComponentFunction · 0.85

Calls 5

WriteLicenseHeaderFunction · 0.85
buildNodeBindingGypFunction · 0.85
buildNodeWrapperClassFunction · 0.85
PrintfMethod · 0.80

Tested by

no test coverage detected