-
Notifications
You must be signed in to change notification settings - Fork 5
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 #25 from peercoin/windows
Windows support
- Loading branch information
Showing
40 changed files
with
1,436 additions
and
61 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
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,57 @@ | ||
import 'dart:io'; | ||
|
||
import 'util.dart'; | ||
|
||
/// Follows bitcoin-core/secp256k1's "Building on Windows" instructions. | ||
/// | ||
/// Runnable in "Developer Command Prompt for VS 2022". | ||
void main() async { | ||
|
||
// Make temporary directory. | ||
final workDir = Directory.current.path; | ||
final tmpDir = createTmpDir(); | ||
|
||
// Clone bitcoin-core/secp256k1. | ||
await execWithStdio( | ||
"git", | ||
["clone", "https://github.com/bitcoin-core/secp256k1", "$tmpDir/secp256k1"], | ||
); | ||
Directory.current = Directory("$tmpDir/secp256k1"); | ||
await execWithStdio( | ||
"git", | ||
// Use version 0.4.1 | ||
["checkout", "1ad5185cd42c0636104129fcc9f6a4bf9c67cc40"], | ||
); | ||
|
||
// Build in tmpDir/secp256k1/build. | ||
Directory("build").createSync(); | ||
|
||
// Configure cmake. | ||
await execWithStdio("cmake", [ | ||
"-G", | ||
"Visual Studio 17 2022", | ||
"-A", | ||
"x64", | ||
"-S", | ||
".", | ||
"-B", | ||
"build", | ||
]); | ||
|
||
// Build. | ||
await execWithStdio("cmake", [ | ||
"--build", | ||
"build", | ||
"--config", | ||
"RelWithDebInfo", | ||
]); | ||
|
||
// Copy the DLL to build/windows/x64/secp256k1.dll. | ||
Directory("$workDir/build").createSync(); | ||
File("$tmpDir/secp256k1/build/src/RelWithDebInfo/secp256k1.dll") | ||
.copySync("$workDir/build/secp256k1.dll"); | ||
|
||
print("Output libsecp256k1.dll successfully"); | ||
|
||
} |
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,46 @@ | ||
import 'dart:io'; | ||
import 'docker_util.dart'; | ||
|
||
/// Build a Windows DLL for secp256k1 using a Dockerfile string. | ||
String dockerfile = r""" | ||
FROM debian:bullseye | ||
# Install dependenices. | ||
RUN apt-get update -y \ | ||
&& apt-get install -y autoconf libtool build-essential git cmake gcc-mingw-w64 | ||
# Clone libsecp256k1 0.4.1 release. | ||
RUN git clone https://github.com/bitcoin-core/secp256k1 \ | ||
&& cd secp256k1 \ | ||
&& git checkout 1ad5185cd42c0636104129fcc9f6a4bf9c67cc40 \ | ||
&& mkdir build | ||
WORKDIR /secp256k1/build | ||
# Build shared library for Windows. | ||
RUN cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-w64-mingw32.toolchain.cmake | ||
RUN make | ||
# Build DLL and copy into output. | ||
RUN make install | ||
RUN mkdir output | ||
RUN cp src/libsecp256k1-2.dll output/secp256k1.dll | ||
"""; | ||
|
||
void main() async { | ||
|
||
String cmd = await getDockerCmd(); | ||
print("Using $cmd to run dockerfile"); | ||
|
||
// Build secp256k1 and copy shared library to build directory | ||
if (!await dockerBuild( | ||
cmd, | ||
dockerfile, | ||
"coinlib_build_secp256k1_windows", | ||
"output/secp256k1.dll", | ||
)) { | ||
exit(1); | ||
} | ||
|
||
} |
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,48 @@ | ||
import 'dart:io'; | ||
|
||
import 'util.dart'; | ||
|
||
/// Follows bitcoin-core/secp256k1's "Cross compiling" instructions. | ||
/// | ||
/// Runnable in WSL. Install the dependencies listed in the README: | ||
/// ``` | ||
/// apt-get install -y autoconf libtool build-essential git cmake mingw-w64 | ||
/// ``` | ||
void main() async { | ||
// Make temporary directory. | ||
final workDir = Directory.current.path; | ||
final tmpDir = createTmpDir(); | ||
|
||
// Clone bitcoin-core/secp256k1. | ||
await execWithStdio( | ||
"git", | ||
["clone", "https://github.com/bitcoin-core/secp256k1", "$tmpDir/secp256k1"], | ||
); | ||
Directory.current = Directory("$tmpDir/secp256k1"); | ||
await execWithStdio( | ||
"git", | ||
// Use version 0.4.1 | ||
["checkout", "1ad5185cd42c0636104129fcc9f6a4bf9c67cc40"], | ||
); | ||
|
||
// Build in tmpDir/secp256k1/lib. | ||
Directory("lib").createSync(); | ||
Directory.current = Directory("lib"); | ||
|
||
// Run cmake with the provided toolchain file. | ||
await execWithStdio("cmake", [ | ||
"..", | ||
"-DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-w64-mingw32.toolchain.cmake", | ||
]); | ||
|
||
// Build the project using "make". | ||
await execWithStdio("make", []); | ||
|
||
// Copy the DLL to build/libsecp256k1.dll. | ||
Directory("$workDir/build").createSync(); | ||
File("src/libsecp256k1.dll").copySync("$workDir/build/secp256k1.dll"); | ||
|
||
print("Output libsecp256k1.dll successfully"); | ||
|
||
} |
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
Large diffs are not rendered by default.
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
Oops, something went wrong.