mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[flutter]: build flowy sdk as static lib
This commit is contained in:
parent
d2a8f89668
commit
706f64c9dd
@ -40,6 +40,7 @@ TARGET_OS = "macos"
|
||||
RUST_COMPILE_TARGET = "x86_64-apple-darwin"
|
||||
FLUTTER_OUTPUT_DIR = "Release"
|
||||
PRODUCT_EXT = "app"
|
||||
CRATE_TYPE = "staticlib"
|
||||
|
||||
[env.production-desktop-windows-x86]
|
||||
BUILD_FLAG = "release"
|
||||
@ -51,6 +52,7 @@ PRODUCT_EXT = "exe"
|
||||
[tasks.echo_env]
|
||||
script = [
|
||||
'''
|
||||
echo CRATE_TYPE: ${CRATE_TYPE}
|
||||
echo BUILD_FLAG: ${BUILD_FLAG}
|
||||
echo TARGET_OS: ${TARGET_OS}
|
||||
echo RUST_COMPILE_TARGET: ${RUST_COMPILE_TARGET}
|
||||
@ -74,7 +76,7 @@ private = true
|
||||
script = [
|
||||
"""
|
||||
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
|
||||
val = replace ${toml} "rlib" ${CRATE_TYPE}
|
||||
val = replace ${toml} "dylib" ${CRATE_TYPE}
|
||||
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
|
||||
assert ${result}
|
||||
""",
|
||||
@ -86,7 +88,7 @@ private = true
|
||||
script = [
|
||||
"""
|
||||
toml = readfile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml
|
||||
val = replace ${toml} ${CRATE_TYPE} "rlib"
|
||||
val = replace ${toml} ${CRATE_TYPE} "dylib"
|
||||
result = writefile ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/Cargo.toml ${val}
|
||||
assert ${result}
|
||||
""",
|
||||
|
@ -46,7 +46,7 @@ EXTERNAL SOURCES:
|
||||
SPEC CHECKSUMS:
|
||||
flowy_editor: 26060a984848e6afac1f6a4455511f4114119d8d
|
||||
flowy_infra_ui: 9d5021b1610fe0476eb1191bf7cd41c4a4138d8f
|
||||
flowy_sdk: c302ac0a22dea596db0df8073b9637b2bf2ff6fd
|
||||
flowy_sdk: b7efddcc3af4ea87dc2f842c22dc37283bb9e169
|
||||
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
|
||||
package_info_plus_macos: f010621b07802a241d96d01876d6705f15e77c1c
|
||||
path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f
|
||||
|
3
app_flowy/packages/flowy_sdk/.gitignore
vendored
3
app_flowy/packages/flowy_sdk/.gitignore
vendored
@ -73,4 +73,5 @@ build/
|
||||
!**/ios/**/default.pbxuser
|
||||
!**/ios/**/default.perspectivev3
|
||||
|
||||
**/*.dylib
|
||||
**/*.dylib
|
||||
**/*.a
|
@ -20,5 +20,6 @@ A new flutter plugin project.
|
||||
# Flutter.framework does not contain a i386 slice.
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
|
||||
s.swift_version = '5.0'
|
||||
s.vendored_libraries = "libdart_ffi.dylib"
|
||||
s.static_framework = true
|
||||
s.vendored_libraries = "libdart_ffi.a"
|
||||
end
|
||||
|
@ -12,15 +12,10 @@ final DynamicLibrary _dl = _open();
|
||||
/// Reference to the Dynamic Library, it should be only used for low-level access
|
||||
final DynamicLibrary dl = _dl;
|
||||
DynamicLibrary _open() {
|
||||
if (is_tester()) {
|
||||
return DynamicLibrary.open(
|
||||
'${Directory.systemTemp.path}/app_flowy/libdart_ffi.dylib');
|
||||
} else {
|
||||
if (Platform.isAndroid) return DynamicLibrary.open('libdart_ffi.so');
|
||||
if (Platform.isMacOS) return DynamicLibrary.executable();
|
||||
if (Platform.isIOS) return DynamicLibrary.executable();
|
||||
throw UnsupportedError('This platform is not supported.');
|
||||
}
|
||||
if (Platform.isAndroid) return DynamicLibrary.open('libdart_ffi.so');
|
||||
if (Platform.isMacOS) return DynamicLibrary.executable();
|
||||
if (Platform.isIOS) return DynamicLibrary.executable();
|
||||
throw UnsupportedError('This platform is not supported.');
|
||||
}
|
||||
|
||||
/// C function `async_command`.
|
||||
@ -32,8 +27,7 @@ void async_command(
|
||||
_invoke_async(port, input, len);
|
||||
}
|
||||
|
||||
final _invoke_async_Dart _invoke_async =
|
||||
_dl.lookupFunction<_invoke_async_C, _invoke_async_Dart>('async_command');
|
||||
final _invoke_async_Dart _invoke_async = _dl.lookupFunction<_invoke_async_C, _invoke_async_Dart>('async_command');
|
||||
typedef _invoke_async_C = Void Function(
|
||||
Int64 port,
|
||||
Pointer<Uint8> input,
|
||||
@ -53,8 +47,7 @@ Pointer<Uint8> sync_command(
|
||||
return _invoke_sync(input, len);
|
||||
}
|
||||
|
||||
final _invoke_sync_Dart _invoke_sync =
|
||||
_dl.lookupFunction<_invoke_sync_C, _invoke_sync_Dart>('sync_command');
|
||||
final _invoke_sync_Dart _invoke_sync = _dl.lookupFunction<_invoke_sync_C, _invoke_sync_Dart>('sync_command');
|
||||
typedef _invoke_sync_C = Pointer<Uint8> Function(
|
||||
Pointer<Uint8> input,
|
||||
Uint64 len,
|
||||
@ -71,8 +64,7 @@ int init_sdk(
|
||||
return _init_sdk(path);
|
||||
}
|
||||
|
||||
final _init_sdk_Dart _init_sdk =
|
||||
_dl.lookupFunction<_init_sdk_C, _init_sdk_Dart>('init_sdk');
|
||||
final _init_sdk_Dart _init_sdk = _dl.lookupFunction<_init_sdk_C, _init_sdk_Dart>('init_sdk');
|
||||
typedef _init_sdk_C = Int64 Function(
|
||||
Pointer<ffi.Utf8> path,
|
||||
);
|
||||
@ -80,29 +72,28 @@ typedef _init_sdk_Dart = int Function(
|
||||
Pointer<ffi.Utf8> path,
|
||||
);
|
||||
|
||||
|
||||
/// C function `init_stream`.
|
||||
int set_stream_port(int port) {
|
||||
return _set_stream_port(port);
|
||||
}
|
||||
|
||||
final _set_stream_port_Dart _set_stream_port =
|
||||
_dl.lookupFunction<_set_stream_port_C, _set_stream_port_Dart>('set_stream_port');
|
||||
_dl.lookupFunction<_set_stream_port_C, _set_stream_port_Dart>('set_stream_port');
|
||||
|
||||
typedef _set_stream_port_C = Int32 Function(
|
||||
Int64 port,
|
||||
);
|
||||
Int64 port,
|
||||
);
|
||||
typedef _set_stream_port_Dart = int Function(
|
||||
int port,
|
||||
);
|
||||
int port,
|
||||
);
|
||||
|
||||
/// C function `link_me_please`.
|
||||
void link_me_please() {
|
||||
_link_me_please();
|
||||
}
|
||||
|
||||
final _link_me_please_Dart _link_me_please = _dl
|
||||
.lookupFunction<_link_me_please_C, _link_me_please_Dart>('link_me_please');
|
||||
final _link_me_please_Dart _link_me_please =
|
||||
_dl.lookupFunction<_link_me_please_C, _link_me_please_Dart>('link_me_please');
|
||||
typedef _link_me_please_C = Void Function();
|
||||
typedef _link_me_please_Dart = void Function();
|
||||
|
||||
@ -113,26 +104,11 @@ void store_dart_post_cobject(
|
||||
_store_dart_post_cobject(ptr);
|
||||
}
|
||||
|
||||
final _store_dart_post_cobject_Dart _store_dart_post_cobject = _dl
|
||||
.lookupFunction<_store_dart_post_cobject_C, _store_dart_post_cobject_Dart>(
|
||||
'store_dart_post_cobject');
|
||||
final _store_dart_post_cobject_Dart _store_dart_post_cobject =
|
||||
_dl.lookupFunction<_store_dart_post_cobject_C, _store_dart_post_cobject_Dart>('store_dart_post_cobject');
|
||||
typedef _store_dart_post_cobject_C = Void Function(
|
||||
Pointer<NativeFunction<Int8 Function(Int64, Pointer<Dart_CObject>)>> ptr,
|
||||
);
|
||||
typedef _store_dart_post_cobject_Dart = void Function(
|
||||
Pointer<NativeFunction<Int8 Function(Int64, Pointer<Dart_CObject>)>> ptr,
|
||||
);
|
||||
|
||||
bool is_tester() {
|
||||
if (Foundation.kDebugMode) {
|
||||
// ignore: unnecessary_null_comparison
|
||||
// if (Platform.executable.isEmpty) {
|
||||
// return false;
|
||||
// } else {
|
||||
// return Platform.executable.contains("tester");
|
||||
// }
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,12 @@ A new flutter plugin project.
|
||||
s.author = { 'Your Company' => 'email@example.com' }
|
||||
s.source = { :path => '.' }
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.public_header_files = 'Classes/**/*.h'
|
||||
s.dependency 'FlutterMacOS'
|
||||
|
||||
s.platform = :osx, '10.11'
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
||||
s.swift_version = '5.0'
|
||||
# s.static_framework = true
|
||||
s.vendored_libraries = "libdart_ffi.dylib"
|
||||
s.static_framework = true
|
||||
s.vendored_libraries = "libdart_ffi.a"
|
||||
end
|
||||
|
@ -7,6 +7,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
r2d2 = "0.8.9"
|
||||
libsqlite3-sys = {version = "0.9.1", features = ["bundled"]}
|
||||
diesel = {version = "1.4.7", features = ["sqlite"]}
|
||||
diesel_derives = {version = "1.4.1", features = ["sqlite"]}
|
||||
diesel_migrations = {version = "1.4.0", features = ["sqlite"]}
|
||||
|
@ -3,10 +3,11 @@
|
||||
[tasks.flowy-sdk]
|
||||
category = "Build"
|
||||
condition = { channels = ["nightly"] }
|
||||
dependencies = ["echo_env", "flowy-sdk-build"]
|
||||
dependencies = ["flowy-sdk-build"]
|
||||
run_task = { name = ["copy-to-sys-tmpdir"] }
|
||||
|
||||
[tasks.flowy-sdk-build]
|
||||
dependencies = ["echo_env"]
|
||||
condition = { env_set = [ "BUILD_FLAG", "RUST_COMPILE_TARGET", "CRATE_TYPE", "TARGET_OS"] }
|
||||
run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type"] }
|
||||
|
||||
@ -29,12 +30,11 @@ script_runner = "@shell"
|
||||
|
||||
[tasks.post-desktop]
|
||||
private = true
|
||||
condition = { platforms = ["mac"] }
|
||||
script = [
|
||||
"""
|
||||
echo "🚀 🚀 🚀 Flowy-SDK build success"
|
||||
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib \
|
||||
${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages/flowy_sdk/macos/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib
|
||||
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/lib${CARGO_MAKE_CRATE_FS_NAME}.a \
|
||||
${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages/flowy_sdk/macos/lib${CARGO_MAKE_CRATE_FS_NAME}.a
|
||||
""",
|
||||
"""
|
||||
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h \
|
||||
|
Loading…
Reference in New Issue
Block a user