BuildBindingNode builds NodeJS-bindings of a library's API
(component ComponentDefinition, outputFolder string, indentString string)
| 44 | |
| 45 | // BuildBindingNode builds NodeJS-bindings of a library's API |
| 46 | func 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 | |
| 97 | func buildNodeAddOnImplementation(component ComponentDefinition, w io.Writer, NameSpace string, BaseName string) error { |
| 98 |
no test coverage detected