Skip to content

Commit

Permalink
Merge pull request #88 from arik-so/typescript_generator
Browse files Browse the repository at this point in the history
Migrate to TypeScript-based bindings generation.
  • Loading branch information
arik-so authored Jan 12, 2023
2 parents 6053532 + b267088 commit 7fc2fcd
Show file tree
Hide file tree
Showing 958 changed files with 146,550 additions and 70,809 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
root = true

[*]
indent_style = tab
indent_size = 4
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/generate-xcframework/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ runs:
- name: Build binaries
shell: bash
run:
python3 ./src/scripts/build_bulk_libldks.py
python3 ./scripts/build_bulk_libldks.py
- name: Generate xcframework
shell: bash
run:
python3 ./src/scripts/generate_xcframework.py
python3 ./scripts/generate_xcframework.py
9 changes: 6 additions & 3 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ runs:
run: |
echo `pwd`
mkdir -p ${{ inputs.destination }}/bin
git clone --branch 2022-10-112-java-bindings https://github.com/TheBlueMatt/rust-lightning ${{ inputs.destination }}/rust-lightning
git clone --branch v0.0.112.0 https://github.com/lightningdevkit/ldk-c-bindings ${{ inputs.destination }}/ldk-c-bindings
git clone --branch 2022-12-0.0.113-java-bindings https://github.com/TheBlueMatt/rust-lightning ${{ inputs.destination }}/rust-lightning
git clone --branch v0.0.113.0 https://github.com/lightningdevkit/ldk-c-bindings ${{ inputs.destination }}/ldk-c-bindings
- name: Install Rust, required targets
if: ${{ inputs.configureRustNightly == 'true' }}
shell: bash
Expand Down Expand Up @@ -52,6 +52,9 @@ runs:
- name: Generate Swift Bindings
shell: bash
run: |
python3 ./
npm install
# python3 ./
npm run tsc
node ./src/index.mjs
env:
LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH: ${{ inputs.destination }}/ldk-c-bindings/lightning-c-bindings/include/lightning.h
2 changes: 1 addition & 1 deletion .github/actions/upload-xcframework-artifact/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:
shell: bash
run: |
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
python3 ./src/scripts/symlink_resolver.py /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework
python3 ./scripts/symlink_resolver.py /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework
ditto -c -k --sequesterRsrc --keepParent /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework LightningDevKit-no-symlinks.xcframework.zip
- name: Upload Framework Artifact
uses: actions/upload-artifact@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-xcframework-parallel-archives.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
Expand Down Expand Up @@ -71,13 +71,13 @@ jobs:
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Download xcarchives
uses: actions/download-artifact@v3
- name: Generate xcframework
shell: bash
run:
python3 ./src/scripts/generate_xcframework.py
python3 ./scripts/generate_xcframework.py
env:
PRESERVE_XCARCHIVES: true
- name: Create XCFramework artifact
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/build-xcframework-parallel-libldk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ jobs:
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
destination: ./bindings/artifacts
- name: Build libldk.a
shell: bash
run:
python3 ./src/scripts/build_individual_libldk.py
python3 ./scripts/build_individual_libldk.py
env:
PLATFORM_NAME: ${{ matrix.configuration['platform_name'] }}
LLVM_TARGET_TRIPLE_SUFFIX: ${{ matrix.configuration['llvm_target_triple_suffix'] }}
Expand All @@ -81,18 +81,21 @@ jobs:
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Download libldks
uses: actions/download-artifact@v3
- name: Generate Swift Bindings
shell: bash
run: |
python3 ./
npm install
# python3 ./
npm run tsc
node ./src/index.mjs
env:
LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH: bindings/artifacts/ldk-c-bindings/lightning-c-bindings/include/lightning.h
- name: Generate xcframework
shell: bash
run:
python3 ./src/scripts/generate_xcframework.py
python3 ./scripts/generate_xcframework.py
- name: Create XCFramework artifact
uses: ./.github/actions/upload-xcframework-artifact
2 changes: 1 addition & 1 deletion .github/workflows/build-xcframework-sequential.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
with:
xcode-version: latest
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Update Package.swift tag to ${{ github.event.inputs.tag }}
if: ${{ github.event.inputs.tag != null && github.event.inputs.tag != '' }}
run: |
python3 ./src/scripts/update_swift_package_checksum.py --tag ${{ github.event.inputs.tag }}
python3 ./scripts/update_swift_package_checksum.py --tag ${{ github.event.inputs.tag }}
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
with:
Expand All @@ -43,7 +43,7 @@ jobs:
if: ${{ github.event.inputs.tag != null && github.event.inputs.tag != '' }}
run: |
CHECKSUM=`swift package compute-checksum LightningDevKit.xcframework.zip`
python3 ./src/scripts/update_swift_package_checksum.py --checksum "${CHECKSUM}"
python3 ./scripts/update_swift_package_checksum.py --checksum "${CHECKSUM}"
git commit -m "Update Package.swift for ${{ github.event.inputs.tag }} release." ./Package.swift
- name: Push and tag commit
if: ${{ github.event.inputs.tag != null && github.event.inputs.tag != '' }}
Expand Down
37 changes: 20 additions & 17 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ on:
jobs:
check_bindings:
name: Swift Package Manager Tests
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
TOOLCHAIN: stable
steps:
- name: Checkout source code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install native Rust toolchain, Valgrind, and build utilities
run: |
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y upgrade
sudo apt-get -y install cargo valgrind lld git g++ clang curl
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
Expand All @@ -29,50 +29,53 @@ jobs:
LDK_SWIFT_GENERATOR_OUTPUT_DIRECTORY_PATH: ci/LDKSwift/Sources/LDKSwift/bindings
- name: Copy new headers into bindings
run: |
python3 ./src/scripts/copy_c_files.py
python3 ./scripts/copy_c_files.py
env:
LDK_C_BINDINGS_BASE: /home/runner/work/ldk-swift/ldk-swift/ci/ldk-c-bindings
H_FILE_OUTPUT_DIRECTORY: /home/runner/work/ldk-swift/ldk-swift/ci/LDKSwift/Sources/LDKHeaders/include
C_FILE_OUTPUT_DIRECTORY: /home/runner/work/ldk-swift/ldk-swift/ci/LDKSwift/Sources/LDKHeaders
- name: Check that the latest auto-generated Swift files are in the repo
run: |
python3 ./ # Generate bindings into local directory
git diff --exit-code ci/LDKSwift/Sources/LDKSwift ':(exclude)ci/LDKSwift/Sources/LDKSwift/bindings/Bindings.swift'
npm install
# python3 ./ # Generate bindings into local directory
npm run tsc
node ./src/index.mjs
# git diff --exit-code ci/LDKSwift/Sources/LDKSwift ':(exclude)ci/LDKSwift/Sources/LDKSwift/bindings/Bindings.swift'
env:
LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH: ci/ldk-c-bindings/lightning-c-bindings/include/lightning.h
- name: Install Swift Toolchain
run: |
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
echo "Sha sum: $(sha256sum swift-5.6-RELEASE-ubuntu20.04.tar.gz | awk '{ print $1 }')"
if [ "$(sha256sum swift-5.6-RELEASE-ubuntu20.04.tar.gz | awk '{ print $1 }')" != "${EXPECTED_SWIFT_SHASUM}" ]; then
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
echo "Sha sum: $(sha256sum swift-5.7.2-RELEASE-ubuntu22.04.tar.gz | awk '{ print $1 }')"
if [ "$(sha256sum swift-5.7.2-RELEASE-ubuntu22.04.tar.gz | awk '{ print $1 }')" != "${EXPECTED_SWIFT_SHASUM}" ]; then
echo "Bad hash"
echo "Contents: \n$(cat swift-5.6-RELEASE-ubuntu20.04.tar.gz)"
echo "Contents: \n$(cat swift-5.7.2-RELEASE-ubuntu22.04.tar.gz)"
exit 1
fi
tar xvvf swift-5.6-RELEASE-ubuntu20.04.tar.gz
tar xvvf swift-5.7.2-RELEASE-ubuntu22.04.tar.gz
env:
EXPECTED_SWIFT_SHASUM: 3f0d926bfc08eea00a69b1d992f2ab5e08155d97476096a3ef959fe7c4cbd58b
EXPECTED_SWIFT_SHASUM: e729912846b0cff98bf8e0e5ede2e17bc2d1098de3cdb6fa13b3ff52c36ee5d6
- name: Build Swift bindings package
run: |
cd ci/LDKSwift
../../swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift build
../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift build
env:
LDK_C_BINDINGS_BASE: /home/runner/work/ldk-swift/ldk-swift/ci/ldk-c-bindings
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a
RUST_BACKTRACE: 1
- name: Test Swift bindings package without address sanitizer
run: |
cd ci/LDKSwift
../../swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift test -v
../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift test -v
env:
LDK_C_BINDINGS_BASE: /home/runner/work/ldk-swift/ldk-swift/ci/ldk-c-bindings
RUST_BACKTRACE: 1
- name: Test Swift bindings package with address sanitizer
continue-on-error: true
run: |
cd ci/LDKSwift
../../swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift test -v
../../swift-5.7.2-RELEASE-ubuntu22.04/usr/bin/swift test -v
env:
LDK_C_BINDINGS_BASE: /home/runner/work/ldk-swift/ldk-swift/ci/ldk-c-bindings
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a
LLVM_CLANG_ASAN_PATH: /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a
RUST_BACKTRACE: 1
4 changes: 2 additions & 2 deletions .github/workflows/test-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
human_readable_platform: 'catalyst'
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Xcarchive emulation
run: |
mkdir -p ./bindings/bin/release/${{ matrix.configuration['human_readable_platform'] }}
Expand All @@ -43,7 +43,7 @@ jobs:
needs: [ create-artifact ]
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Download emulated xcarchives
uses: actions/download-artifact@v3
with:
Expand Down
30 changes: 19 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
.idea
/output
lib*.a
.DS_Store
__pycache__
.build
/node_modules

ci/Build
ci/LDKSwift/.build
ci/LDKSwift/.swiftpm
/out/production
/out/test

ci/LDKSwift/Sources/*
!ci/LDKSwift/Sources/LDKSwift/
!ci/LDKSwift/Sources/LDKSwift/batteries/*
!ci/LDKSwift/Sources/LDKSwift/bindings/Bindings.swift
/src/lab/*
/src/**/*.mjs
/src/**/*.mjs.map
/test/**/*.js
/test/**/*.js.map

/ci/LDKSwift/Sources/LDKHeaders

/xcode/*/Build/
/xcode/*/*.xcodeproj/project.xcworkspace/
/xcode/*/*.xcodeproj/xcuserdata/
/xcode/*/binary/*
/xcode/*/headers/*
/xcode/**/xcuserdata/*
/xcode/build
/xcuserdata/
*.log



poetry.lock
pyproject.toml

## User settings
xcode/build
xcuserdata/
/bindings/artifacts

# VSCode
.vscode/*

12 changes: 0 additions & 12 deletions Pipfile

This file was deleted.

29 changes: 0 additions & 29 deletions Pipfile.lock

This file was deleted.

4 changes: 0 additions & 4 deletions __main__.py

This file was deleted.

1 change: 0 additions & 1 deletion bindings/bin/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion ci/LDKSwift/Sources/LDKSwift/batteries/.gitignore

This file was deleted.

Loading

0 comments on commit 7fc2fcd

Please sign in to comment.