-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from Peefy/go-static-lib-link
chore: remove cgo and zig cc compilation in the kcl go lib
- Loading branch information
Showing
22 changed files
with
240 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
github.com/ebitengine/purego v0.7.1 h1:6/55d26lG3o9VCZX8lping+bZcmShseiqlh2bnUDiPA= | ||
github.com/ebitengine/purego v0.7.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= | ||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= | ||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= | ||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= | ||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= | ||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# KCL Artifact Library for Go | ||
|
||
## Developing | ||
|
||
### Prerequisites | ||
|
||
+ Go 1.23+ | ||
|
||
### Build and Test | ||
|
||
```shell | ||
go test ./... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//go:build cgo | ||
// +build cgo | ||
|
||
package native | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"kcl-lang.io/lib/go/api" | ||
"kcl-lang.io/lib/go/plugin" | ||
) | ||
|
||
func init() { | ||
// Add a plugin named hello | ||
plugin.RegisterPlugin(plugin.Plugin{ | ||
Name: "hello", | ||
MethodMap: map[string]plugin.MethodSpec{ | ||
"add": { | ||
Body: func(args *plugin.MethodArgs) (*plugin.MethodResult, error) { | ||
v := args.IntArg(0) + args.IntArg(1) | ||
return &plugin.MethodResult{V: v}, nil | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestExecProgramWithPlugin(t *testing.T) { | ||
client := NewNativeServiceClient() | ||
result, err := client.ExecProgram(&api.ExecProgram_Args{ | ||
KFilenameList: []string{"main.k"}, | ||
KCodeList: []string{code}, | ||
Args: []*api.Argument{ | ||
{ | ||
Name: "a", | ||
Value: "1", | ||
}, | ||
{ | ||
Name: "b", | ||
Value: "2", | ||
}, | ||
}, | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if result.ErrMessage != "" { | ||
t.Fatal("error message must be empty") | ||
} | ||
} | ||
|
||
func TestExecProgramWithPluginError(t *testing.T) { | ||
client := NewNativeServiceClient() | ||
result, err := client.ExecProgram(&api.ExecProgram_Args{ | ||
KFilenameList: []string{"main.k"}, | ||
KCodeList: []string{code}, | ||
}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !strings.Contains(result.ErrMessage, "strconv.ParseInt: parsing \"<nil>\": invalid syntax") { | ||
t.Fatal(result.ErrMessage) | ||
} | ||
} |
Oops, something went wrong.