Skip to content

Commit 7fc2fcd

Browse files
authored
Merge pull request #88 from arik-so/typescript_generator
Migrate to TypeScript-based bindings generation.
2 parents 6053532 + b267088 commit 7fc2fcd

File tree

958 files changed

+146550
-70809
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

958 files changed

+146550
-70809
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
root = true
2+
13
[*]
24
indent_style = tab
35
indent_size = 4

.github/actions/generate-xcframework/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ runs:
66
- name: Build binaries
77
shell: bash
88
run:
9-
python3 ./src/scripts/build_bulk_libldks.py
9+
python3 ./scripts/build_bulk_libldks.py
1010
- name: Generate xcframework
1111
shell: bash
1212
run:
13-
python3 ./src/scripts/generate_xcframework.py
13+
python3 ./scripts/generate_xcframework.py

.github/actions/install-dependencies/action.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ runs:
2222
run: |
2323
echo `pwd`
2424
mkdir -p ${{ inputs.destination }}/bin
25-
git clone --branch 2022-10-112-java-bindings https://github.com/TheBlueMatt/rust-lightning ${{ inputs.destination }}/rust-lightning
26-
git clone --branch v0.0.112.0 https://github.com/lightningdevkit/ldk-c-bindings ${{ inputs.destination }}/ldk-c-bindings
25+
git clone --branch 2022-12-0.0.113-java-bindings https://github.com/TheBlueMatt/rust-lightning ${{ inputs.destination }}/rust-lightning
26+
git clone --branch v0.0.113.0 https://github.com/lightningdevkit/ldk-c-bindings ${{ inputs.destination }}/ldk-c-bindings
2727
- name: Install Rust, required targets
2828
if: ${{ inputs.configureRustNightly == 'true' }}
2929
shell: bash
@@ -52,6 +52,9 @@ runs:
5252
- name: Generate Swift Bindings
5353
shell: bash
5454
run: |
55-
python3 ./
55+
npm install
56+
# python3 ./
57+
npm run tsc
58+
node ./src/index.mjs
5659
env:
5760
LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH: ${{ inputs.destination }}/ldk-c-bindings/lightning-c-bindings/include/lightning.h

.github/actions/upload-xcframework-artifact/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ runs:
1111
shell: bash
1212
run: |
1313
cp -r /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit.xcframework /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework
14-
python3 ./src/scripts/symlink_resolver.py /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework
14+
python3 ./scripts/symlink_resolver.py /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework
1515
ditto -c -k --sequesterRsrc --keepParent /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework LightningDevKit-no-symlinks.xcframework.zip
1616
- name: Upload Framework Artifact
1717
uses: actions/upload-artifact@v3

.github/workflows/build-xcframework-parallel-archives.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
with:
4040
xcode-version: latest
4141
- name: Checkout
42-
uses: actions/checkout@v2
42+
uses: actions/checkout@v3
4343
- name: Install Dependencies
4444
uses: ./.github/actions/install-dependencies
4545
with:
@@ -71,13 +71,13 @@ jobs:
7171
with:
7272
xcode-version: latest
7373
- name: Checkout
74-
uses: actions/checkout@v2
74+
uses: actions/checkout@v3
7575
- name: Download xcarchives
7676
uses: actions/download-artifact@v3
7777
- name: Generate xcframework
7878
shell: bash
7979
run:
80-
python3 ./src/scripts/generate_xcframework.py
80+
python3 ./scripts/generate_xcframework.py
8181
env:
8282
PRESERVE_XCARCHIVES: true
8383
- name: Create XCFramework artifact

.github/workflows/build-xcframework-parallel-libldk.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ jobs:
4747
with:
4848
xcode-version: latest
4949
- name: Checkout
50-
uses: actions/checkout@v2
50+
uses: actions/checkout@v3
5151
- name: Install Dependencies
5252
uses: ./.github/actions/install-dependencies
5353
with:
5454
destination: ./bindings/artifacts
5555
- name: Build libldk.a
5656
shell: bash
5757
run:
58-
python3 ./src/scripts/build_individual_libldk.py
58+
python3 ./scripts/build_individual_libldk.py
5959
env:
6060
PLATFORM_NAME: ${{ matrix.configuration['platform_name'] }}
6161
LLVM_TARGET_TRIPLE_SUFFIX: ${{ matrix.configuration['llvm_target_triple_suffix'] }}
@@ -81,18 +81,21 @@ jobs:
8181
with:
8282
xcode-version: latest
8383
- name: Checkout
84-
uses: actions/checkout@v2
84+
uses: actions/checkout@v3
8585
- name: Download libldks
8686
uses: actions/download-artifact@v3
8787
- name: Generate Swift Bindings
8888
shell: bash
8989
run: |
90-
python3 ./
90+
npm install
91+
# python3 ./
92+
npm run tsc
93+
node ./src/index.mjs
9194
env:
9295
LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH: bindings/artifacts/ldk-c-bindings/lightning-c-bindings/include/lightning.h
9396
- name: Generate xcframework
9497
shell: bash
9598
run:
96-
python3 ./src/scripts/generate_xcframework.py
99+
python3 ./scripts/generate_xcframework.py
97100
- name: Create XCFramework artifact
98101
uses: ./.github/actions/upload-xcframework-artifact

.github/workflows/build-xcframework-sequential.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
xcode-version: latest
2828
- name: Checkout
29-
uses: actions/checkout@v2
29+
uses: actions/checkout@v3
3030
- name: Install Dependencies
3131
uses: ./.github/actions/install-dependencies
3232
with:

.github/workflows/release-framework.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626
with:
2727
xcode-version: latest
2828
- name: Checkout
29-
uses: actions/checkout@v2
29+
uses: actions/checkout@v3
3030
- name: Update Package.swift tag to ${{ github.event.inputs.tag }}
3131
if: ${{ github.event.inputs.tag != null && github.event.inputs.tag != '' }}
3232
run: |
33-
python3 ./src/scripts/update_swift_package_checksum.py --tag ${{ github.event.inputs.tag }}
33+
python3 ./scripts/update_swift_package_checksum.py --tag ${{ github.event.inputs.tag }}
3434
- name: Install Dependencies
3535
uses: ./.github/actions/install-dependencies
3636
with:
@@ -43,7 +43,7 @@ jobs:
4343
if: ${{ github.event.inputs.tag != null && github.event.inputs.tag != '' }}
4444
run: |
4545
CHECKSUM=`swift package compute-checksum LightningDevKit.xcframework.zip`
46-
python3 ./src/scripts/update_swift_package_checksum.py --checksum "${CHECKSUM}"
46+
python3 ./scripts/update_swift_package_checksum.py --checksum "${CHECKSUM}"
4747
git commit -m "Update Package.swift for ${{ github.event.inputs.tag }} release." ./Package.swift
4848
- name: Push and tag commit
4949
if: ${{ github.event.inputs.tag != null && github.event.inputs.tag != '' }}

.github/workflows/swift.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ on:
99
jobs:
1010
check_bindings:
1111
name: Swift Package Manager Tests
12-
runs-on: ubuntu-20.04
12+
runs-on: ubuntu-latest
1313
env:
1414
TOOLCHAIN: stable
1515
steps:
1616
- name: Checkout source code
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1818
- name: Install native Rust toolchain, Valgrind, and build utilities
1919
run: |
2020
sudo apt-get update
21-
sudo apt-get -y dist-upgrade
21+
sudo apt-get -y upgrade
2222
sudo apt-get -y install cargo valgrind lld git g++ clang curl
2323
- name: Install Dependencies
2424
uses: ./.github/actions/install-dependencies
@@ -29,50 +29,53 @@ jobs:
2929
LDK_SWIFT_GENERATOR_OUTPUT_DIRECTORY_PATH: ci/LDKSwift/Sources/LDKSwift/bindings
3030
- name: Copy new headers into bindings
3131
run: |
32-
python3 ./src/scripts/copy_c_files.py
32+
python3 ./scripts/copy_c_files.py
3333
env:
3434
LDK_C_BINDINGS_BASE: /home/runner/work/ldk-swift/ldk-swift/ci/ldk-c-bindings
3535
H_FILE_OUTPUT_DIRECTORY: /home/runner/work/ldk-swift/ldk-swift/ci/LDKSwift/Sources/LDKHeaders/include
3636
C_FILE_OUTPUT_DIRECTORY: /home/runner/work/ldk-swift/ldk-swift/ci/LDKSwift/Sources/LDKHeaders
3737
- name: Check that the latest auto-generated Swift files are in the repo
3838
run: |
39-
python3 ./ # Generate bindings into local directory
40-
git diff --exit-code ci/LDKSwift/Sources/LDKSwift ':(exclude)ci/LDKSwift/Sources/LDKSwift/bindings/Bindings.swift'
39+
npm install
40+
# python3 ./ # Generate bindings into local directory
41+
npm run tsc
42+
node ./src/index.mjs
43+
# git diff --exit-code ci/LDKSwift/Sources/LDKSwift ':(exclude)ci/LDKSwift/Sources/LDKSwift/bindings/Bindings.swift'
4144
env:
4245
LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH: ci/ldk-c-bindings/lightning-c-bindings/include/lightning.h
4346
- name: Install Swift Toolchain
4447
run: |
45-
curl --verbose -L -o swift-5.6-RELEASE-ubuntu20.04.tar.gz https://download.swift.org/swift-5.6-release/ubuntu2004/swift-5.6-RELEASE/swift-5.6-RELEASE-ubuntu20.04.tar.gz
46-
echo "Sha sum: $(sha256sum swift-5.6-RELEASE-ubuntu20.04.tar.gz | awk '{ print $1 }')"
47-
if [ "$(sha256sum swift-5.6-RELEASE-ubuntu20.04.tar.gz | awk '{ print $1 }')" != "${EXPECTED_SWIFT_SHASUM}" ]; then
48+
curl --verbose -L -o swift-5.7.2-RELEASE-ubuntu22.04.tar.gz https://download.swift.org/swift-5.7.2-release/ubuntu2204/swift-5.7.2-RELEASE/swift-5.7.2-RELEASE-ubuntu22.04.tar.gz
49+
echo "Sha sum: $(sha256sum swift-5.7.2-RELEASE-ubuntu22.04.tar.gz | awk '{ print $1 }')"
50+
if [ "$(sha256sum swift-5.7.2-RELEASE-ubuntu22.04.tar.gz | awk '{ print $1 }')" != "${EXPECTED_SWIFT_SHASUM}" ]; then
4851
echo "Bad hash"
49-
echo "Contents: \n$(cat swift-5.6-RELEASE-ubuntu20.04.tar.gz)"
52+
echo "Contents: \n$(cat swift-5.7.2-RELEASE-ubuntu22.04.tar.gz)"
5053
exit 1
5154
fi
52-
tar xvvf swift-5.6-RELEASE-ubuntu20.04.tar.gz
55+
tar xvvf swift-5.7.2-RELEASE-ubuntu22.04.tar.gz
5356
env:
54-
EXPECTED_SWIFT_SHASUM: 3f0d926bfc08eea00a69b1d992f2ab5e08155d97476096a3ef959fe7c4cbd58b
57+
EXPECTED_SWIFT_SHASUM: e729912846b0cff98bf8e0e5ede2e17bc2d1098de3cdb6fa13b3ff52c36ee5d6
5558
- name: Build Swift bindings package
5659
run: |
5760
cd ci/LDKSwift
58-
../../swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift build
61+
../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift build
5962
env:
6063
LDK_C_BINDINGS_BASE: /home/runner/work/ldk-swift/ldk-swift/ci/ldk-c-bindings
61-
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a
64+
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a
6265
RUST_BACKTRACE: 1
6366
- name: Test Swift bindings package without address sanitizer
6467
run: |
6568
cd ci/LDKSwift
66-
../../swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift test -v
69+
../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift test -v
6770
env:
6871
LDK_C_BINDINGS_BASE: /home/runner/work/ldk-swift/ldk-swift/ci/ldk-c-bindings
6972
RUST_BACKTRACE: 1
7073
- name: Test Swift bindings package with address sanitizer
7174
continue-on-error: true
7275
run: |
7376
cd ci/LDKSwift
74-
../../swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift test -v
77+
../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift test -v
7578
env:
7679
LDK_C_BINDINGS_BASE: /home/runner/work/ldk-swift/ldk-swift/ci/ldk-c-bindings
77-
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a
80+
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a
7881
RUST_BACKTRACE: 1

.github/workflows/test-artifacts.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
human_readable_platform: 'catalyst'
2727
steps:
2828
- name: Checkout
29-
uses: actions/checkout@v2
29+
uses: actions/checkout@v3
3030
- name: Xcarchive emulation
3131
run: |
3232
mkdir -p ./bindings/bin/release/${{ matrix.configuration['human_readable_platform'] }}
@@ -43,7 +43,7 @@ jobs:
4343
needs: [ create-artifact ]
4444
steps:
4545
- name: Checkout
46-
uses: actions/checkout@v2
46+
uses: actions/checkout@v3
4747
- name: Download emulated xcarchives
4848
uses: actions/download-artifact@v3
4949
with:

.gitignore

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
.idea
2-
/output
3-
lib*.a
4-
.DS_Store
5-
__pycache__
2+
.build
3+
/node_modules
64

7-
ci/Build
8-
ci/LDKSwift/.build
9-
ci/LDKSwift/.swiftpm
5+
/out/production
6+
/out/test
107

11-
ci/LDKSwift/Sources/*
12-
!ci/LDKSwift/Sources/LDKSwift/
13-
!ci/LDKSwift/Sources/LDKSwift/batteries/*
14-
!ci/LDKSwift/Sources/LDKSwift/bindings/Bindings.swift
8+
/src/lab/*
9+
/src/**/*.mjs
10+
/src/**/*.mjs.map
11+
/test/**/*.js
12+
/test/**/*.js.map
13+
14+
/ci/LDKSwift/Sources/LDKHeaders
1515

1616
/xcode/*/Build/
1717
/xcode/*/*.xcodeproj/project.xcworkspace/
1818
/xcode/*/*.xcodeproj/xcuserdata/
1919
/xcode/*/binary/*
2020
/xcode/*/headers/*
2121
/xcode/**/xcuserdata/*
22+
/xcode/build
23+
/xcuserdata/
2224
*.log
2325

26+
27+
28+
poetry.lock
29+
pyproject.toml
30+
2431
## User settings
2532
xcode/build
2633
xcuserdata/
2734
/bindings/artifacts
2835

2936
# VSCode
3037
.vscode/*
38+

Pipfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

Pipfile.lock

Lines changed: 0 additions & 29 deletions
This file was deleted.

__main__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

bindings/bin/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

ci/LDKSwift/Sources/LDKSwift/batteries/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)