-
Notifications
You must be signed in to change notification settings - Fork 1
/
create-streamr-xcframework.pl
executable file
·68 lines (56 loc) · 3 KB
/
create-streamr-xcframework.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use File::Path qw(make_path);
use File::Copy::Recursive qw(dircopy);
use Cwd;
my $abs_path = getcwd;
my $root_build = "build/ios";
my $build_include = "$abs_path/$root_build/include";
my $build_lib = "$abs_path/$root_build/lib";
my $dist_path = "$abs_path/dist/ios";
print "Please wait, building xcframework.\n";
`rm -rf $build_include`;
`rm -rf $build_lib`;
`rm -rf $dist_path`;
make_path($build_include);
make_path($build_lib);
# Copy streamr headers
dircopy("$abs_path/packages/streamr-proto-rpc/include", $build_include);
dircopy("$abs_path/packages/streamr-logger/include", $build_include);
dircopy("$abs_path/packages/streamr-json/include", $build_include);
dircopy("$abs_path/packages/streamr-dht/include", $build_include);
dircopy("$abs_path/packages/streamr-eventemitter/include", $build_include);
dircopy("$abs_path/packages/streamr-trackerless-network/include", $build_include);
dircopy("$abs_path/packages/streamr-utils/include", $build_include);
dircopy("$abs_path/packages/streamr-proto-rpc/src/proto", $build_include);
dircopy("$abs_path/packages/streamr-dht/src/proto", $build_include);
dircopy("$abs_path/packages/streamr-trackerless-network/src/proto", $build_include);
`cp packages/streamr-libstreamrproxyclient/include/streamrproxyclient.h $build_include`;
`cp packages/streamr-libstreamrproxyclient/include/StreamrProxyClient.hpp $build_include`;
`cp packages/streamr-libstreamrproxyclient/src/LibProxyClientApi.hpp $build_include`;
my $filename = "$build_include/module.modulemap";
open(my $fh, '>', $filename) or die "Could not open file '$filename' $!";
print $fh <<'END_MODULE';
module streamr {
header "streamrproxyclient.h" // Replace with your main header file name
export *
}
END_MODULE
close $fh;
# Find all include and lib directories and process them
find(\&process_dir, "./build/vcpkg_installed/arm64-ios");
dircopy("$abs_path/build/vcpkg_installed/arm64-ios/lib", $build_lib);
`libtool -static -o $build_lib/libstreamr.a $build_lib/*.a packages/streamr-trackerless-network/build/CMakeFiles/streamr-trackerless-network.dir/src/proto/packages/network/protos/NetworkRpc.pb.cc.o packages/streamr-dht/build/CMakeFiles/streamr-dht.dir/src/proto/packages/dht/protos/DhtRpc.pb.cc.o packages/streamr-libstreamrproxyclient/build/CMakeFiles/streamrproxyclient.dir/src/streamrproxyclient.cpp.o packages/streamr-proto-rpc/build/CMakeFiles/streamr-proto-rpc.dir/src/proto/packages/proto-rpc/protos/ProtoRpc.pb.cc.o`;
`xcodebuild -create-xcframework -library $build_lib/libstreamr.a -headers $build_include -output $dist_path/streamr.xcframework`;
print "\nstreamr.xcframework was created in the directory: dist/ios.\n";
# Subroutine to process each directory
sub process_dir {
my $dir = $File::Find::name;
if ($dir =~ m|^\./build/vcpkg_installed/arm64-ios/include$|) {
# Copy includes from vcpkg-packages (vcpkg/packages/<Package>/include)
dircopy("$abs_path/$dir", $build_include);
print "cp $abs_path/$dir $build_include\n";
}
}