added shared starter tests and added to Makefile to add compile .h and .so files
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -26,3 +26,5 @@ logs/
|
|||||||
|
|
||||||
# ignore docker image files
|
# ignore docker image files
|
||||||
server/docker/containers/
|
server/docker/containers/
|
||||||
|
*.h
|
||||||
|
*.so
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package Bindings
|
package main
|
||||||
|
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
"github.com/Akilan1999/p2p-rendering-computation/abstractions"
|
||||||
|
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The Client package where data-types
|
// The Client package where data-types
|
||||||
@@ -13,32 +14,40 @@ import (
|
|||||||
|
|
||||||
//export StartContainer
|
//export StartContainer
|
||||||
func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (output string) {
|
func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (output string) {
|
||||||
container, err := client.StartContainer(IP, NumPorts, GPU, ContainerName, baseImage)
|
container, err := client.StartContainer(IP, NumPorts, GPU, ContainerName, baseImage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error()
|
return err.Error()
|
||||||
}
|
}
|
||||||
|
return ConvertStructToJSONString(container)
|
||||||
jsonBytes, err := json.Marshal(container)
|
|
||||||
if err != nil {
|
|
||||||
return err.Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert the JSON bytes to a string
|
|
||||||
return string(jsonBytes)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//export GetSpecs
|
//export GetSpecs
|
||||||
func GetSpecs(IP string) (output string) {
|
func GetSpecs(IP string) (output string) {
|
||||||
specs, err := client.GetSpecs(IP)
|
specs, err := client.GetSpecs(IP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err.Error()
|
return err.Error()
|
||||||
}
|
}
|
||||||
|
return ConvertStructToJSONString(specs)
|
||||||
jsonBytes, err := json.Marshal(specs)
|
|
||||||
if err != nil {
|
|
||||||
return err.Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert the JSON bytes to a string
|
|
||||||
return string(jsonBytes)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//export Init
|
||||||
|
func Init(customConfig string) (output string) {
|
||||||
|
init, err := abstractions.Init(customConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err.Error()
|
||||||
|
}
|
||||||
|
return ConvertStructToJSONString(init)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConvertStructToJSONString(Struct interface{}) string {
|
||||||
|
jsonBytes, err := json.Marshal(Struct)
|
||||||
|
if err != nil {
|
||||||
|
return err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert the JSON bytes to a string
|
||||||
|
return string(jsonBytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {}
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -9,3 +9,5 @@ testcases:
|
|||||||
run:
|
run:
|
||||||
go run main.go
|
go run main.go
|
||||||
|
|
||||||
|
sharedObjects:
|
||||||
|
sh build-bindings.sh
|
||||||
|
|||||||
1
build-bindings.sh
Normal file
1
build-bindings.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cd Bindings && go build -buildmode=c-shared -o p2prc.so
|
||||||
Reference in New Issue
Block a user