This commit is contained in:
Aleksandr 2026-01-28 23:00:48 +00:00 committed by GitHub
commit 8aeb07f546
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 69 additions and 8 deletions

15
buildlibs.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/sh
if [ -z "$v" ]; then
echo "Version number cannot be null. Run with v=[version] $0"
exit 1
fi
mkdir -p build-lib
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS="linux" GOARCH="arm64" go build -ldflags "-X main.version=${v}" -buildmode=c-shared -tags=external_main -o libck-client-arm64-linux.so ./cmd/ck-client
CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS="linux" GOARCH="arm" go build -ldflags "-X main.version=${v}" -buildmode=c-shared -tags=external_main -o libck-client-arm-linux.so ./cmd/ck-client
CC=x86_64-linux-gnu-gcc CGO_ENABLED=1 GOOS="linux" GOARCH="amd64" go build -ldflags "-X main.version=${v}" -buildmode=c-shared -tags=external_main -o libck-client-amd64-linux.so ./cmd/ck-client
CC=x86_64-linux-gnu-gcc CGO_ENABLED=1 GOOS="linux" GOARCH="386" go build -ldflags "-X main.version=${v}" -buildmode=c-shared -tags=external_main -o libck-client-386-linux.so ./cmd/ck-client
mv libck* build-lib

View File

@ -0,0 +1,23 @@
//go:build external_main
// +build external_main
package main
import (
"os"
"C"
"unsafe"
)
//export external_main
func external_main(argc C.int, argv **C.char) {
var offset = unsafe.Sizeof(uintptr(0))
var go_argv []string
for i := 0; i < int(argc); i++ {
go_argv = append(go_argv, C.GoString(*argv))
argv = (**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + offset))
}
os.Args = go_argv
main()
}

View File

@ -1,5 +1,5 @@
//go:build !android
// +build !android
//go:build !log_android
// +build !log_android
package main

View File

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build android
// +build android
//go:build log_android
// +build log_android
package main

View File

@ -1,5 +1,5 @@
//go:build !android
// +build !android
//go:build !protector_android
// +build !protector_android
package main

View File

@ -1,5 +1,5 @@
//go:build android
// +build android
//go:build protector_android
// +build protector_android
package main

View File

@ -0,0 +1,23 @@
//go:build external_main
// +build external_main
package main
import (
"os"
"C"
"unsafe"
)
//export external_main
func external_main(argc C.int, argv **C.char) {
var offset = unsafe.Sizeof(uintptr(0))
var go_argv []string
for i := 0; i < int(argc); i++ {
go_argv = append(go_argv, C.GoString(*argv))
argv = (**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + offset))
}
os.Args = go_argv
main()
}