-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* flutter create --platforms=windows . I did not make any changes to these files, they were just generated using the command above. * generated plugin registrants autogenerated changes, no manual edits * add script to cross-compile secp256k1 for windows 77227a * include secp256k1 DLL in coinlib_flutter projects confirmed working with `flutter run -d windows` in `example` * ignore coinlib/src folder do not check secp256k1 submodule into git * document Windows builds * add tip about optionally skipping flutter installation in wsl2 instance * be more specific in docs re: building on windows without wsl2 * use dockerfile for native-ubuntu builds, use old approach only for wsl and update docs and docs formatting fix dockerfile * move depenedencies from script to docs * replace processSync with execWithStdio * move DLL to build/secp256k1.dll IAW lib/src/secp256k1/secp256k1_io.dart * remove unnecessary autogenerated files * use tmp dir to avoid polluting project dir * docs update and formatting * formatting remove double newlines and debugging print * remove unneeded gitignore line * correct relative path to secp256k1.dll * add ffiPlugin property to windows * correct relative path to secp256k1.dll * do not add unfruitful linux build of secp256k1 on windows TODO re-enable. TODO make CMake work on Windows natively * correct relative path to secp256k1.dll previous fixes fixed the example app but broke consumer apps. this version works for both the example app and consumers of this plugin the same way. the example just needs to get its secp256k1 built for it, too (but that makes sense) * bump version to rc 6 to denote windows support * bump example app pubspec bump version to rc 6 to denote windows support * place secp256k1.dll in build/windows * create build/windows folder if it doesn't exist * don't add extra windows folder in secp256k1 dll path it's included in the cmake var force pushing to fix typo * add a native windows build script and document its use * move dll output from build/windows to build in accordance with coinlib convention * minor docs update mention windows support and point to coinlib docs for lib-building guide * mention Visual Studio 17 2022 dependency * typofix: linux->windows in docs * clarify Windows library-building re: #24 (comment) * reduce example app version number to 1.0.0: partial reversion of 9573a05
- Loading branch information
Showing
31 changed files
with
1,344 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,5 +52,4 @@ void main() async { | |
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,51 @@ | ||
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", | ||
["checkout", "346a053d4c442e08191f075c3932d03140579d47"], | ||
); | ||
|
||
// 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"); | ||
} |
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,45 @@ | ||
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 | ||
# Clone libsecp256k1 0.3.1 release. | ||
RUN git clone https://github.com/bitcoin-core/secp256k1 \ | ||
&& cd secp256k1 \ | ||
&& git checkout 346a053d4c442e08191f075c3932d03140579d47 | ||
&& mkdir -p secp256k1/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 cp src/libsecp256k1-2.dll output/libsecp256k1.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", | ||
"/secp256k1/output/libsecp256k1.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,44 @@ | ||
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", | ||
["checkout", "346a053d4c442e08191f075c3932d03140579d47"], | ||
); | ||
|
||
// 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"); | ||
} |
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,17 @@ | ||
flutter/ephemeral/ | ||
|
||
# Visual Studio user-specific files. | ||
*.suo | ||
*.user | ||
*.userosscache | ||
*.sln.docstates | ||
|
||
# Visual Studio build-related files. | ||
x64/ | ||
x86/ | ||
|
||
# Visual Studio cache files | ||
# files ending in .cache can be ignored | ||
*.[Cc]ache | ||
# but keep track of directories ending in .cache | ||
!*.[Cc]ache/ |
Oops, something went wrong.