Skip to content

Commit dfbed10

Browse files
committed
Guess changes required for Windows
Requires actual testing on Windows
1 parent 5df5e86 commit dfbed10

File tree

4 files changed

+70
-59
lines changed

4 files changed

+70
-59
lines changed

coinlib/bin/build_windows.dart

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
import 'dart:io';
22
import 'util.dart';
33

4-
/// Follows bitcoin-core/secp256k1's "Building on Windows" instructions.
4+
/// Follows peercoin/secp256k1-coinlib's "Building on Windows" instructions.
55
///
66
/// Runnable in "Developer Command Prompt for VS 2022".
7-
87
void main() async {
98

10-
// Make temporary directory.
119
final workDir = Directory.current.path;
12-
final tmpDir = createTmpDir();
13-
14-
// Clone bitcoin-core/secp256k1.
15-
await execWithStdioWin("git", [
16-
"clone",
17-
"https://github.com/bitcoin-core/secp256k1",
18-
"$tmpDir/secp256k1",
19-
]);
20-
Directory.current = Directory("$tmpDir/secp256k1");
21-
await execWithStdioWin(
22-
"git",
23-
// Use version 0.5.0
24-
["checkout", "e3a885d42a7800c1ccebad94ad1e2b82c4df5c65"],
25-
);
2610

27-
// Build in tmpDir/secp256k1/build.
28-
Directory("build").createSync();
11+
// Clone into tmp directory
12+
final tmpDir = await cloneForWindowsInTmpDir();
2913

3014
// Configure cmake.
3115
await execWithStdioWin("cmake", [
@@ -38,6 +22,13 @@ void main() async {
3822
"-B",
3923
"build",
4024
"--debug-output",
25+
"-DSECP256K1_ENABLE_MODULE_RECOVERY=ON",
26+
"-DSECP256K1_BUILD_TESTS=OFF",
27+
"-DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF",
28+
"-DSECP256K1_BUILD_BENCHMARK=OFF",
29+
"-DSECP256K1_BUILD_EXAMPLES=OFF",
30+
"-DSECP256K1_BUILD_CTIME_TESTS=OFF",
31+
"-DCMAKE_BUILD_TYPE=Release",
4132
]);
4233

4334
// Build.
@@ -53,11 +44,11 @@ void main() async {
5344
Directory("$workDir${Platform.pathSeparator}build").createSync();
5445
final dll = File(
5546
"$tmpDir"
56-
"${Platform.pathSeparator}secp256k1"
47+
"${Platform.pathSeparator}secp256k1-coinlib"
5748
"${Platform.pathSeparator}build"
5849
"${Platform.pathSeparator}src"
5950
"${Platform.pathSeparator}RelWithDebInfo"
60-
"${Platform.pathSeparator}libsecp256k1-2.dll",
51+
"${Platform.pathSeparator}libsecp256k1-6.dll",
6152
);
6253

6354
print("File exists: ${dll.existsSync()}");

coinlib/bin/build_windows_crosscompile.dart

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,34 @@ import 'docker_util.dart';
44
/// Build a Windows DLL for secp256k1 using a Dockerfile string.
55
66
String dockerfile = r"""
7-
FROM debian:bullseye
7+
FROM debian:bookworm
88
99
# Install dependenices.
10-
RUN apt-get update -y \
11-
&& apt-get install -y autoconf libtool build-essential git cmake gcc-mingw-w64
10+
RUN apt-get update -y && apt-get install -y git cmake gcc-mingw-w64
1211
13-
# Clone libsecp256k1 0.5.0 release.
14-
RUN git clone https://github.com/bitcoin-core/secp256k1 \
15-
&& cd secp256k1 \
16-
&& git checkout e3a885d42a7800c1ccebad94ad1e2b82c4df5c65 \
17-
&& mkdir build
12+
# Clone libsecp256k1-coinlib v0.7.0
13+
RUN git clone https://github.com/peercoin/secp256k1-coinlib \
14+
&& cd secp256k1-coinlib \
15+
&& git checkout 69018e5b939d8d540ca6b237945100f4ecb5681e
1816
19-
WORKDIR /secp256k1/build
17+
WORKDIR /secp256k1-coinlib
2018
2119
# Build shared library for Windows.
22-
RUN cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-w64-mingw32.toolchain.cmake
23-
RUN make
20+
RUN cmake -B build \
21+
-DCMAKE_TOOLCHAIN_FILE=cmake/x86_64-w64-mingw32.toolchain.cmake \
22+
-DSECP256K1_ENABLE_MODULE_RECOVERY=ON \
23+
-DSECP256K1_BUILD_TESTS=OFF \
24+
-DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF \
25+
-DSECP256K1_BUILD_BENCHMARK=OFF \
26+
-DSECP256K1_BUILD_EXAMPLES=OFF \
27+
-DSECP256K1_BUILD_CTIME_TESTS=OFF \
28+
-DCMAKE_BUILD_TYPE=Release
29+
RUN cmake --build build
2430
2531
# Build DLL and copy into output.
26-
RUN make install
32+
RUN cmake --install build
2733
RUN mkdir output
28-
RUN cp src/libsecp256k1-2.dll output/secp256k1.dll
34+
RUN cp build/bin/libsecp256k1-6.dll output/secp256k1.dll
2935
""";
3036

3137
void main() async {

coinlib/bin/build_wsl.dart

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,37 @@
11
import 'dart:io';
2-
32
import 'util.dart';
43

5-
/// Follows bitcoin-core/secp256k1's "Cross compiling" instructions.
4+
/// Follows peercoin/secp256k1-coinlib's "Cross compiling" instructions.
65
///
76
/// Runnable in WSL. Install the dependencies listed in the README:
87
/// ```
98
/// apt-get install -y autoconf libtool build-essential git cmake mingw-w64
109
/// ```
11-
1210
void main() async {
13-
// Make temporary directory.
11+
1412
final workDir = Directory.current.path;
15-
final tmpDir = createTmpDir();
16-
17-
// Clone bitcoin-core/secp256k1.
18-
await execWithStdio(
19-
"git",
20-
["clone", "https://github.com/bitcoin-core/secp256k1", "$tmpDir/secp256k1"],
21-
);
22-
Directory.current = Directory("$tmpDir/secp256k1");
23-
await execWithStdio(
24-
"git",
25-
// Use version 0.5.0
26-
["checkout", "e3a885d42a7800c1ccebad94ad1e2b82c4df5c65"],
27-
);
28-
29-
// Build in tmpDir/secp256k1/lib.
30-
Directory("lib").createSync();
31-
Directory.current = Directory("lib");
13+
14+
// Clone into tmp directory
15+
await cloneForWindowsInTmpDir();
3216

3317
// Run cmake with the provided toolchain file.
3418
await execWithStdio("cmake", [
35-
"..",
19+
"-B", "build",
3620
"-DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-w64-mingw32.toolchain.cmake",
21+
"-DSECP256K1_ENABLE_MODULE_RECOVERY=ON",
22+
"-DSECP256K1_BUILD_TESTS=OFF",
23+
"-DSECP256K1_BUILD_EXHAUSTIVE_TESTS=OFF",
24+
"-DSECP256K1_BUILD_BENCHMARK=OFF",
25+
"-DSECP256K1_BUILD_EXAMPLES=OFF",
26+
"-DSECP256K1_BUILD_CTIME_TESTS=OFF",
27+
"-DCMAKE_BUILD_TYPE=Release",
3728
]);
3829

39-
// Build the project using "make".
40-
await execWithStdio("make", []);
30+
await execWithStdio("cmake", ["--build", "build"]);
4131

4232
// Copy the DLL to build/libsecp256k1.dll.
4333
Directory("$workDir/build").createSync();
44-
File("src/libsecp256k1.dll").copySync("$workDir/build/secp256k1.dll");
34+
File("build/bin/libsecp256k1-6.dll").copySync("$workDir/build/secp256k1.dll");
4535

4636
print("Output libsecp256k1.dll successfully");
4737

coinlib/bin/util.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,27 @@ void exitOnCode(int exitCode, String exitMsg) {
6161

6262
String createTmpDir() =>
6363
Directory.systemTemp.createTempSync("coinlibBuild").path;
64+
65+
Future<String> cloneForWindowsInTmpDir() async {
66+
67+
final tmpDir = createTmpDir();
68+
69+
// Clone bitcoin-core/secp256k1.
70+
await execWithStdioWin("git", [
71+
"clone",
72+
"https://github.com/peercoin/secp256k1-coinlib",
73+
"$tmpDir/secp256k1-coinlib",
74+
]);
75+
Directory.current = Directory("$tmpDir/secp256k1-coinlib");
76+
await execWithStdioWin(
77+
"git",
78+
// Use version 0.7.0
79+
["checkout", "69018e5b939d8d540ca6b237945100f4ecb5681e"],
80+
);
81+
82+
// Build in tmpDir/secp256k1-coinlib/build.
83+
Directory("build").createSync();
84+
85+
return tmpDir;
86+
87+
}

0 commit comments

Comments
 (0)