Skip to content

Commit 1e7808b

Browse files
committed
Build script for windows
1 parent c84b428 commit 1e7808b

File tree

7 files changed

+284
-6
lines changed

7 files changed

+284
-6
lines changed

library/go/build-darwin.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
# should export JAVA_HOME if not set
88
export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home
99

10-
GOMOBILE=gomobile
11-
12-
$GOMOBILE bind -target=darwin/amd64 -x -v -o build -tags=openssl mixin/kernel
10+
gomobile bind -target=darwin/amd64 -x -v -o build -tags=openssl mixin/kernel

library/go/build-linux.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99
# export CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++
1010
# export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home
1111

12-
GOMOBILE=gomobile
13-
$GOMOBILE bind -target=linux/amd64 -x -v -o build -tags=openssl mixin/kernel
12+
gomobile bind -target=linux/amd64 -x -v -o build -tags=openssl mixin/kernel

library/go/build-windows.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# should install this version
4+
#go install github.com/tougee/jvm/cmd/gomobile
5+
#go install github.com/tougee/jvm/cmd/gobind
6+
7+
# build on MacOS
8+
# brew install mingw-w64
9+
# export CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++
10+
# export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home
11+
12+
gomobile bind -target=windows/amd64 -x -v -o build -tags=openssl mixin/kernel
6.22 MB
Binary file not shown.
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
/* Code generated by cmd/cgo; DO NOT EDIT. */
2+
3+
/* package gobind/gobind */
4+
5+
6+
#line 1 "cgo-builtin-export-prolog"
7+
8+
#include <stddef.h>
9+
10+
#ifndef GO_CGO_EXPORT_PROLOGUE_H
11+
#define GO_CGO_EXPORT_PROLOGUE_H
12+
13+
#ifndef GO_CGO_GOSTRING_TYPEDEF
14+
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
15+
#endif
16+
17+
#endif
18+
19+
/* Start of preamble from import "C" comments. */
20+
21+
22+
#line 8 "go_kernelmain.go"
23+
24+
#include <stdlib.h>
25+
#include <stdint.h>
26+
#include "seq.h"
27+
#include "kernel.h"
28+
29+
30+
#line 1 "cgo-generated-wrapper"
31+
32+
#line 8 "go_main.go"
33+
34+
#include <stdlib.h>
35+
#include <stdint.h>
36+
#include "seq.h"
37+
#include "universe.h"
38+
39+
40+
#line 1 "cgo-generated-wrapper"
41+
42+
#line 11 "seq.go"
43+
44+
45+
46+
47+
#include <stdlib.h>
48+
#include "seq.h"
49+
50+
#line 1 "cgo-generated-wrapper"
51+
52+
#line 15 "seq_support.go"
53+
54+
55+
#include <jni.h>
56+
#include <stdint.h>
57+
#include <stdlib.h>
58+
#include "seq_support.h"
59+
60+
#line 1 "cgo-generated-wrapper"
61+
62+
63+
/* End of preamble from import "C" comments. */
64+
65+
66+
/* Start of boilerplate cgo prologue. */
67+
#line 1 "cgo-gcc-export-header-prolog"
68+
69+
#ifndef GO_CGO_PROLOGUE_H
70+
#define GO_CGO_PROLOGUE_H
71+
72+
typedef signed char GoInt8;
73+
typedef unsigned char GoUint8;
74+
typedef short GoInt16;
75+
typedef unsigned short GoUint16;
76+
typedef int GoInt32;
77+
typedef unsigned int GoUint32;
78+
typedef long long GoInt64;
79+
typedef unsigned long long GoUint64;
80+
typedef GoInt64 GoInt;
81+
typedef GoUint64 GoUint;
82+
typedef size_t GoUintptr;
83+
typedef float GoFloat32;
84+
typedef double GoFloat64;
85+
#ifdef _MSC_VER
86+
#include <complex.h>
87+
typedef _Fcomplex GoComplex64;
88+
typedef _Dcomplex GoComplex128;
89+
#else
90+
typedef float _Complex GoComplex64;
91+
typedef double _Complex GoComplex128;
92+
#endif
93+
94+
/*
95+
static assertion to make sure the file is being used on architecture
96+
at least with matching size of GoInt.
97+
*/
98+
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
99+
100+
#ifndef GO_CGO_GOSTRING_TYPEDEF
101+
typedef _GoString_ GoString;
102+
#endif
103+
typedef void *GoMap;
104+
typedef void *GoChan;
105+
typedef struct { void *t; void *v; } GoInterface;
106+
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
107+
108+
#endif
109+
110+
/* End of boilerplate cgo prologue. */
111+
112+
#ifdef __cplusplus
113+
extern "C" {
114+
#endif
115+
116+
extern __declspec(dllexport) nbyteslice proxykernel_Address_PublicSpendKey(int32_t refnum);
117+
extern __declspec(dllexport) nbyteslice proxykernel_Address_PublicViewkey(int32_t refnum);
118+
extern __declspec(dllexport) void proxykernel_Address_SetPublicSpendKey(int32_t refnum, nbyteslice param_k);
119+
extern __declspec(dllexport) void proxykernel_Address_SetPublicViewKey(int32_t refnum, nbyteslice param_k);
120+
extern __declspec(dllexport) nstring proxykernel_Address_String(int32_t refnum);
121+
extern __declspec(dllexport) int32_t new_kernel_Address();
122+
extern __declspec(dllexport) void proxykernel_Tx_Hash_Set(int32_t refnum, nstring v);
123+
extern __declspec(dllexport) nstring proxykernel_Tx_Hash_Get(int32_t refnum);
124+
extern __declspec(dllexport) void proxykernel_Tx_Raw_Set(int32_t refnum, nstring v);
125+
extern __declspec(dllexport) nstring proxykernel_Tx_Raw_Get(int32_t refnum);
126+
extern __declspec(dllexport) void proxykernel_Tx_Change_Set(int32_t refnum, int32_t v);
127+
extern __declspec(dllexport) int32_t proxykernel_Tx_Change_Get(int32_t refnum);
128+
extern __declspec(dllexport) int32_t new_kernel_Tx();
129+
extern __declspec(dllexport) void proxykernel_Utxo_Hash_Set(int32_t refnum, nstring v);
130+
extern __declspec(dllexport) nstring proxykernel_Utxo_Hash_Get(int32_t refnum);
131+
extern __declspec(dllexport) void proxykernel_Utxo_Index_Set(int32_t refnum, nint v);
132+
extern __declspec(dllexport) nint proxykernel_Utxo_Index_Get(int32_t refnum);
133+
extern __declspec(dllexport) void proxykernel_Utxo_Amount_Set(int32_t refnum, nstring v);
134+
extern __declspec(dllexport) nstring proxykernel_Utxo_Amount_Get(int32_t refnum);
135+
extern __declspec(dllexport) int32_t new_kernel_Utxo();
136+
137+
/* Return type for proxykernel__BuildTx */
138+
struct proxykernel__BuildTx_return {
139+
nstring r0;
140+
int32_t r1;
141+
};
142+
extern __declspec(dllexport) struct proxykernel__BuildTx_return proxykernel__BuildTx(nstring param_asset, nstring param_amount, int32_t param_threshold, nstring param_receiverKeys, nstring param_receiverMask, nbyteslice param_inputs, nstring param_changeKeys, nstring param_changeMask, nstring param_extra, nstring param_reference);
143+
144+
/* Return type for proxykernel__BuildTxToKernelAddress */
145+
struct proxykernel__BuildTxToKernelAddress_return {
146+
nstring r0;
147+
int32_t r1;
148+
};
149+
extern __declspec(dllexport) struct proxykernel__BuildTxToKernelAddress_return proxykernel__BuildTxToKernelAddress(nstring param_asset, nstring param_amount, nstring param_kenelAddress, nbyteslice param_inputs, nstring param_changeKeys, nstring param_changeMask, nstring param_extra);
150+
151+
/* Return type for proxykernel__BuildWithdrawalTx */
152+
struct proxykernel__BuildWithdrawalTx_return {
153+
int32_t r0;
154+
int32_t r1;
155+
};
156+
extern __declspec(dllexport) struct proxykernel__BuildWithdrawalTx_return proxykernel__BuildWithdrawalTx(nstring param_asset, nstring param_amount, nstring param_address, nstring param_tag, nstring param_feeAmount, nstring param_feeKeys, nstring param_feeMask, nbyteslice param_inputs, nstring param_changeKeys, nstring param_changeMask, nstring param_extra);
157+
158+
/* Return type for proxykernel__DecodeRawTx */
159+
struct proxykernel__DecodeRawTx_return {
160+
nstring r0;
161+
int32_t r1;
162+
};
163+
extern __declspec(dllexport) struct proxykernel__DecodeRawTx_return proxykernel__DecodeRawTx(nstring param_raw, nint param_p1);
164+
165+
/* Return type for proxykernel__NewMainAddressFromString */
166+
struct proxykernel__NewMainAddressFromString_return {
167+
int32_t r0;
168+
int32_t r1;
169+
};
170+
extern __declspec(dllexport) struct proxykernel__NewMainAddressFromString_return proxykernel__NewMainAddressFromString(nstring param_s);
171+
172+
/* Return type for proxykernel__SignTx */
173+
struct proxykernel__SignTx_return {
174+
int32_t r0;
175+
int32_t r1;
176+
};
177+
178+
// skipped function SignTransaction with unsupported parameter or result types
179+
//
180+
extern __declspec(dllexport) struct proxykernel__SignTx_return proxykernel__SignTx(nstring param_raw, nstring param_inputKeys, nstring param_viewKeys, nstring param_spendKey, char param_withoutFee);
181+
extern __declspec(dllexport) nstring proxy_error_Error(int32_t refnum);
182+
183+
// IncGoRef is called by foreign code to pin a Go object while its refnum is crossing
184+
// the language barrier
185+
extern __declspec(dllexport) void IncGoRef(int32_t refnum);
186+
187+
// DestroyRef is called by Java to inform Go it is done with a reference.
188+
extern __declspec(dllexport) void DestroyRef(int32_t refnum);
189+
190+
#ifdef __cplusplus
191+
}
192+
#endif
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package one.mixin.bot;
2+
3+
/**
4+
* Provides methods related to the runtime environment.
5+
*/
6+
public class OS {
7+
8+
private static final boolean osIsMacOsX;
9+
private static final boolean osIsWindows;
10+
private static final boolean osIsWindowsXP;
11+
private static final boolean osIsWindows2003;
12+
private static final boolean osIsWindowsVista;
13+
private static final boolean osIsLinux;
14+
15+
static {
16+
String os = System.getProperty("os.name");
17+
if (os != null)
18+
os = os.toLowerCase();
19+
20+
osIsMacOsX = "mac os x".equals(os);
21+
osIsWindows = os != null && os.contains("windows");
22+
osIsWindowsXP = "windows xp".equals(os);
23+
osIsWindows2003 = "windows 2003".equals(os);
24+
osIsWindowsVista = "windows vista".equals(os);
25+
osIsLinux = os != null && os.contains("linux");
26+
}
27+
28+
/**
29+
* @return true if this VM is running on Mac OS X
30+
*/
31+
public static boolean isMacOSX() {
32+
return osIsMacOsX;
33+
}
34+
35+
/**
36+
* @return true if this VM is running on Windows
37+
*/
38+
public static boolean isWindows() {
39+
return osIsWindows;
40+
}
41+
42+
/**
43+
* @return true if this VM is running on Windows XP
44+
*/
45+
public static boolean isWindowsXP() {
46+
return osIsWindowsXP;
47+
}
48+
49+
/**
50+
* @return true if this VM is running on Windows 2003
51+
*/
52+
public static boolean isWindows2003() {
53+
return osIsWindows2003;
54+
}
55+
56+
/**
57+
* @return true if this VM is running on Windows Vista
58+
*/
59+
public static boolean isWindowsVista() {
60+
return osIsWindowsVista;
61+
}
62+
63+
/**
64+
* @return true if this VM is running on a Linux distribution
65+
*/
66+
public static boolean isLinux() {
67+
return osIsLinux;
68+
}
69+
}

library/src/test/kotlin/one/mixin/bot/JNITest.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ class JNITest {
1717
val arch = System.getProperty("os.arch")
1818
println("os: $os, arch: $arch")
1919

20-
System.load("$s/libs/darwin/amd64/libgojni.so")
20+
val platform =
21+
when {
22+
OS.isLinux() -> "linux"
23+
OS.isMacOSX() -> "darwin"
24+
OS.isWindows() -> "windows"
25+
else -> throw IllegalArgumentException("not supported os $os")
26+
}
27+
28+
System.load("$s/libs/$platform/amd64/libgojni.so")
2129

2230
val assetId = "5b9d576914e71e2362f89bb867eb69084931eb958f9a3622d776b861602275f4"
2331
val amount = "1"

0 commit comments

Comments
 (0)