Skip to content

Commit 44d34c7

Browse files
committed
Initial commit (craigwrong fork)
1 parent d8a2463 commit 44d34c7

File tree

11 files changed

+136
-0
lines changed

11 files changed

+136
-0
lines changed

.gitconfig/shared

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Shared git configuration
2+
#
3+
# Include the shared config file:
4+
#
5+
# git config include.path ../.gitconfig/shared
6+
#
7+
# Create a user-specific config file:
8+
#
9+
# cp .gitconfig/user.example .gitconfig/user
10+
#
11+
# Decrypt a user config file:
12+
#
13+
# gpg --output .gitconfig/user --decrypt .gitconfig/users/[USER].gpg
14+
#
15+
# To encrypt a user config file:
16+
#
17+
# gpg --output .gitconfig/users/[USER].gpg --encrypt --recipient [USER] .gitconfig/user
18+
#
19+
20+
[commit]
21+
gpgsign = true
22+
[include]
23+
path = user

.gitconfig/user.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Example user-specific git configuration
2+
3+
[user]
4+
signingkey = AB0C1D23E456FG7H
5+
name = Your Name
6+

.gitconfig/users/craigwrong.gpg

699 Bytes
Binary file not shown.

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,14 @@ build-aux/compile
5656
build-aux/test-driver
5757
src/stamp-h1
5858
libsecp256k1.pc
59+
60+
.DS_Store
61+
/.gitconfig/user
62+
xcuserdata/
63+
/dist.docker
64+
/dist.macos.x86_64
65+
/dist.macos.arm64
66+
/dist.macos
67+
/*.xcframework
68+
/*.xcframework.zip
69+
/Package.swift

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM alpine as config
4+
COPY . /opt/secp256k1
5+
WORKDIR /opt/secp256k1
6+
RUN apk --update upgrade && apk add autoconf automake libtool
7+
RUN ./autogen.sh
8+
9+
FROM alpine as build
10+
COPY --from=config /opt/secp256k1 /opt/secp256k1
11+
WORKDIR /opt/secp256k1
12+
RUN apk --update upgrade && apk add g++ make
13+
RUN ./configure --enable-experimental --enable-module-extrakeys --enable-module-schnorrsig --disable-module-recovery --disable-module-ecdh --enable-tests --disable-benchmark --disable-shared && make check && make install
14+
15+
# Fetch, configure
16+
17+
FROM alpine
18+
COPY --from=build /usr/local /usr/local

README.craigwrong.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `secp256k1` Library - Craig S. Wrong's Fork
2+
3+
I forked the original Bitcoin Core's library to add:
4+
5+
- A `Dockerfile` with build procedures for various configurations.
6+
- A shell script to target macOS and package as XCFramework.
7+
8+
This way the library can be used in Swift projects using Swift Package Manager (SPM) on both Mac and Linux platforms.
9+
10+
PRs welcome. If you need to contact me just DM me at `twitter.com/notcraigwright`.

docker-build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
set -e
3+
docker build -t secp256k1 .
4+
rm -rf dist.docker
5+
docker cp $(docker create --name=secp256k1 secp256k1):/usr/local ./dist.docker
6+
docker rm secp256k1

macos-xcframework-build.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/sh
2+
3+
# Dependencies: autoconf automake zip
4+
5+
set -e
6+
7+
./autogen.sh
8+
9+
# Optional MACOSX_DEPLOYMENT_TARGET=12.0
10+
11+
./configure --prefix=$PWD/dist.macos.x86_64 \
12+
--enable-experimental --enable-tests --disable-benchmark --disable-shared \
13+
--enable-module-extrakeys --enable-module-schnorrsig \
14+
--disable-module-recovery --disable-module-ecdh \
15+
--host=x86_64-apple-darwin \
16+
CFLAGS="-O3 -arch x86_64 -fembed-bitcode -mmacosx-version-min=12.0"
17+
make check
18+
make install
19+
20+
# Set the CPU architecture for ARM.
21+
22+
make clean
23+
./configure --prefix=$PWD/dist.macos.arm64 \
24+
--enable-experimental --enable-tests --disable-benchmark --disable-shared \
25+
--enable-module-extrakeys --enable-module-schnorrsig \
26+
--disable-module-recovery --disable-module-ecdh \
27+
--host=arm64-apple-darwin \
28+
CFLAGS="-O3 -arch arm64 -fembed-bitcode -mmacosx-version-min=12.0"
29+
make install
30+
31+
### Creating an XCFramework
32+
33+
make clean
34+
35+
rm -rf dist.macos
36+
mkdir dist.macos
37+
38+
lipo dist.macos.x86_64/lib/libsecp256k1.a dist.macos.arm64/lib/libsecp256k1.a -create -output dist.macos/libsecp256k1.a
39+
xcodebuild -create-xcframework -library dist.macos/libsecp256k1.a -headers dist.macos.x86_64/include -output secp256k1.xcframework
40+
41+
rm -rf dist.macos
42+
43+
zip -Xr secp256k1.xcframework.zip secp256k1.xcframework
44+
touch Package.swift
45+
swift package compute-checksum secp256k1.xcframework.zip > secp256k1.xcframework.zip.checksum
46+
rm -rf Package.swift

project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)