Skip to content

Commit c3423da

Browse files
committed
Add generate xcframework job that runs Python scripts.
1 parent c0e9537 commit c3423da

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed

.github/actions/build-for-testing/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ runs:
1818
run: |
1919
cd xcode
2020
21+
LDK_C_BINDINGS_BINARY_DIRECTORY="" \
2122
xcodebuild clean build-for-testing \
2223
-allowProvisioningUpdates \
2324
-allowProvisioningDeviceRegistration \
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Generate XCFramework Workflow
2+
permissions:
3+
contents: read
4+
statuses: read
5+
pull-requests: read
6+
actions: read
7+
checks: write
8+
on:
9+
push:
10+
branches:
11+
- main
12+
pull_request:
13+
branches:
14+
- "*"
15+
16+
jobs:
17+
build:
18+
name: Generate XCFramework job
19+
runs-on: macos-12
20+
env:
21+
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer
22+
LDK_C_BINDINGS_BASE: /Users/runner/work/ldk-swift/ldk-swift/bindings/artifacts/ldk-c-bindings
23+
steps:
24+
- name: Configure Xcode
25+
uses: maxim-lobanov/setup-xcode@v1
26+
with:
27+
xcode-version: latest
28+
- name: Checkout
29+
uses: actions/checkout@v2
30+
- name: Install Dependencies
31+
uses: ./.github/actions/install-dependencies
32+
- name: Build binaries
33+
run:
34+
python3 ./src/scripts/build_bulk_libldks.py
35+
- name: Generate xcframework
36+
run:
37+
python3 ./src/scripts/generate_xcframework.py

src/scripts/build_individual_libldk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def run(config: ScriptConfig):
9191
os.makedirs(current_architecture_binary_directory, exist_ok=True)
9292

9393
# stop the complaints about directories not being empty
94-
shutil.rmtree(cargo_target_directory)
94+
if os.path.isdir(cargo_target_directory):
95+
shutil.rmtree(cargo_target_directory)
9596
subprocess.check_call([CARGO_PATH, 'clean'], cwd=config.LDK_C_BINDINGS_DIRECTORY)
9697

9798
# cargo build -Z build-std=panic_abort,std --features "std" --target "${RUST_ARCH}-apple-${RUST_TARGET_OS}" $RUST_CONFIGURATION_FLAG

src/scripts/generate_xcframework.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def run(config: ScriptConfig):
7979
'EXCLUDED_ARCHS="i386 armv7"',
8080
'SKIP_INSTALL=NO',
8181
'BUILD_LIBRARY_FOR_DISTRIBUTION=YES',
82-
f'LDK_C_BINDINGS_BASE="{config.LDK_C_BINDINGS_BASE}"',
83-
f'LDK_C_BINDINGS_BINARY_DIRECTORY="{lipo_binary_directory}"',
82+
f'LDK_C_BINDINGS_BASE={config.LDK_C_BINDINGS_BASE}',
83+
f'LDK_C_BINDINGS_BINARY_DIRECTORY={lipo_binary_directory}',
8484
f'LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY=""',
8585
], env=child_environment
8686
)

src/scripts/script_config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ def parse(cls, allow_ldk_argument=True, parse_configuration=False, parse_lipo_ou
4444
print('Missing LDK C-bindings base directory. Either call the value or set the environment variable.')
4545
sys.exit(1)
4646

47+
4748
ldk_directory = os.path.realpath(ldk_directory_string)
4849
c_bindings_directory = os.path.join(ldk_directory, 'lightning-c-bindings')
50+
51+
print('ldk_directory_string (LDK_C_BINDINGS_BASE):', ldk_directory_string)
52+
print('ldk_directory:', ldk_directory)
53+
print('c_bindings_directory (LDK_C_BINDINGS_DIRECTORY):', c_bindings_directory)
54+
4955
if not os.path.exists(c_bindings_directory):
50-
print('LDK C-bindings directory does not contain lightning-c-bindings')
56+
print('LDK C-bindings directory does not contain lightning-c-bindings:', c_bindings_directory)
5157
sys.exit(1)
5258

5359
if not os.path.isdir(c_bindings_directory):

xcode/LDKFramework/LDKFramework.xcodeproj/project.pbxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,11 @@
13491349
outputFileListPaths = (
13501350
);
13511351
outputPaths = (
1352+
"$(PROJECT_DIR)/headers/ldk_net.c",
1353+
"$(PROJECT_DIR)/headers/ldk_net.h",
1354+
"$(PROJECT_DIR)/headers/ldk_rust_types.h",
1355+
"$(PROJECT_DIR)/headers/ldk_ver.h",
1356+
"$(PROJECT_DIR)/headers/lightning.h",
13521357
);
13531358
runOnlyForDeploymentPostprocessing = 0;
13541359
shellPath = /bin/sh;

0 commit comments

Comments
 (0)