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
|
||||
server/docker/containers/
|
||||
*.h
|
||||
*.so
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package Bindings
|
||||
package main
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||
"encoding/json"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/abstractions"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||
)
|
||||
|
||||
// The Client package where data-types
|
||||
@@ -13,32 +14,40 @@ import (
|
||||
|
||||
//export StartContainer
|
||||
func StartContainer(IP string, NumPorts int, GPU bool, ContainerName string, baseImage string) (output string) {
|
||||
container, err := client.StartContainer(IP, NumPorts, GPU, ContainerName, baseImage)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
jsonBytes, err := json.Marshal(container)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
// Convert the JSON bytes to a string
|
||||
return string(jsonBytes)
|
||||
container, err := client.StartContainer(IP, NumPorts, GPU, ContainerName, baseImage)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
return ConvertStructToJSONString(container)
|
||||
}
|
||||
|
||||
//export GetSpecs
|
||||
func GetSpecs(IP string) (output string) {
|
||||
specs, err := client.GetSpecs(IP)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
jsonBytes, err := json.Marshal(specs)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
// Convert the JSON bytes to a string
|
||||
return string(jsonBytes)
|
||||
specs, err := client.GetSpecs(IP)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
return ConvertStructToJSONString(specs)
|
||||
}
|
||||
|
||||
//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:
|
||||
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