refactor(build): add c-shared buildmode to wasm plugin compilation
This commit is contained in:
2
Makefile
2
Makefile
@@ -15,7 +15,7 @@ deps:
|
||||
|
||||
build:
|
||||
@echo "Building WASM plugin..."
|
||||
@GOOS=wasip1 GOARCH=wasm go build -o $(BUILD_DIR)/$(BINARY) .
|
||||
@GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared -o $(BUILD_DIR)/$(BINARY) .
|
||||
@echo "Built $(BUILD_DIR)/$(BINARY)"
|
||||
|
||||
sdk:
|
||||
|
||||
28
main.go
28
main.go
@@ -205,25 +205,29 @@ func exec() int32 {
|
||||
pdk.Log(pdk.LogInfo, "exec: executing action")
|
||||
|
||||
if !enclave.initialized {
|
||||
pdk.SetError(errors.New("exec: database not initialized, call generate or load first"))
|
||||
return 1
|
||||
output := ExecOutput{Success: false, Error: "database not initialized, call generate or load first"}
|
||||
pdk.OutputJSON(output)
|
||||
return 0
|
||||
}
|
||||
|
||||
var input ExecInput
|
||||
if err := pdk.InputJSON(&input); err != nil {
|
||||
pdk.SetError(fmt.Errorf("exec: failed to parse input: %w", err))
|
||||
return 1
|
||||
output := ExecOutput{Success: false, Error: fmt.Sprintf("failed to parse input: %s", err)}
|
||||
pdk.OutputJSON(output)
|
||||
return 0
|
||||
}
|
||||
|
||||
if input.Filter == "" {
|
||||
pdk.SetError(errors.New("exec: filter is required"))
|
||||
return 1
|
||||
output := ExecOutput{Success: false, Error: "filter is required"}
|
||||
pdk.OutputJSON(output)
|
||||
return 0
|
||||
}
|
||||
|
||||
params, err := parseFilter(input.Filter)
|
||||
if err != nil {
|
||||
pdk.SetError(fmt.Errorf("exec: invalid filter: %w", err))
|
||||
return 1
|
||||
output := ExecOutput{Success: false, Error: fmt.Sprintf("invalid filter: %s", err)}
|
||||
pdk.OutputJSON(output)
|
||||
return 0
|
||||
}
|
||||
|
||||
if input.Token != "" {
|
||||
@@ -252,11 +256,7 @@ func exec() int32 {
|
||||
Result: result,
|
||||
}
|
||||
|
||||
if err := pdk.OutputJSON(output); err != nil {
|
||||
pdk.SetError(fmt.Errorf("exec: failed to output result: %w", err))
|
||||
return 1
|
||||
}
|
||||
|
||||
pdk.OutputJSON(output)
|
||||
pdk.Log(pdk.LogInfo, fmt.Sprintf("exec: completed %s on %s", params.Action, params.Resource))
|
||||
return 0
|
||||
}
|
||||
@@ -266,7 +266,7 @@ func query() int32 {
|
||||
pdk.Log(pdk.LogInfo, "query: resolving DID document")
|
||||
|
||||
if !enclave.initialized {
|
||||
pdk.SetError(errors.New("query: database not initialized, call generate or load first"))
|
||||
pdk.SetError(errors.New("database not initialized, call generate or load first"))
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user