Skip to content

Commit

Permalink
Use native finalizer (#41)
Browse files Browse the repository at this point in the history
* Use NativeFinalizer

* Remove dart_dl_api based finalizer logic

* Remove Dart SDK vendoring

* Regenerate bindings with new ffigen

* Regenerate bindings for webcrypto library

* New script for updating bindings

* Fix lookup on MacOS
  • Loading branch information
jonasfj authored Oct 17, 2022
1 parent 5a6b16e commit 461987e
Show file tree
Hide file tree
Showing 48 changed files with 1,838 additions and 8,383 deletions.
13 changes: 0 additions & 13 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ cmake_minimum_required(VERSION 3.6.0)

enable_language(ASM)

# Set as required by ../third_party/dart-sdk/sources.cmake included below
set(DARTSDK_ROOT ../third_party/dart-sdk/)

# Import sources generated by tool/update-dart-sdk.py
# This provides variables, and requires DARTSDK_ROOT to be set.
# - dart_dl_sources
include(
../third_party/dart-sdk/sources.cmake
)

# Set as required by android-sources.cmake included below
set(BORINGSSL_ROOT ../third_party/boringssl/)

Expand Down Expand Up @@ -69,9 +59,7 @@ add_library(

# Source files
../src/webcrypto.c
../src/webcrypto_dart_dl.c
../src/symbols.generated.c
${dart_dl_sources}
${crypto_sources}
${crypto_sources_ARCH}
)
Expand All @@ -81,7 +69,6 @@ target_include_directories(

PRIVATE

../third_party/dart-sdk/src/runtime/
../third_party/boringssl/src/include/
)

Expand Down
69 changes: 31 additions & 38 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ packages:
name: _fe_analyzer_shared
url: "https://pub.dartlang.org"
source: hosted
version: "46.0.0"
version: "47.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "4.6.0"
version: "4.7.0"
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.11"
version: "3.3.0"
args:
dependency: transitive
description:
Expand All @@ -35,7 +35,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
Expand All @@ -49,21 +49,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
Expand All @@ -77,21 +70,21 @@ packages:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.5.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
version: "3.0.2"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -105,7 +98,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -172,7 +165,7 @@ packages:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1"
version: "4.0.2"
integration_test:
dependency: "direct dev"
description: flutter
Expand All @@ -198,28 +191,28 @@ packages:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "1.1.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -247,7 +240,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
platform:
dependency: transitive
description:
Expand Down Expand Up @@ -275,14 +268,14 @@ packages:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.2"
version: "1.4.0"
shelf_packages_handler:
dependency: transitive
description:
Expand Down Expand Up @@ -329,7 +322,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
Expand All @@ -350,49 +343,49 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
sync_http:
dependency: transitive
description:
name: sync_http
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
version: "0.3.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "1.21.1"
version: "1.21.4"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.12"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.13"
version: "0.4.16"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
vector_math:
dependency: transitive
description:
Expand All @@ -406,14 +399,14 @@ packages:
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "8.2.2"
version: "9.0.0"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.0.2"
web_socket_channel:
dependency: transitive
description:
Expand All @@ -427,7 +420,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.5.3-dev"
version: "0.5.3"
webdriver:
dependency: transitive
description:
Expand All @@ -441,7 +434,7 @@ packages:
name: webkit_inspection_protocol
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
yaml:
dependency: transitive
description:
Expand All @@ -450,5 +443,5 @@ packages:
source: hosted
version: "3.1.1"
sdks:
dart: ">=2.17.0 <3.0.0"
dart: ">=2.18.0 <3.0.0"
flutter: ">=3.0.0"
1 change: 0 additions & 1 deletion ios/Classes/include_webcrypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@

#include "../../src/symbols.generated.c"
#include "../../src/webcrypto.c"
#include "../../src/webcrypto_dart_dl.c"
2 changes: 0 additions & 2 deletions ios/webcrypto.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Pod::Spec.new do |s|
# Since we can't embed source from ../third_party/, we have created files
# in ios/third_party/... which simply use #include "../...". This is a hack!
'third_party/boringssl/**/*.{c,h}',
'third_party/dart-sdk/**/*.{c,h}',
]
s.compiler_flags = [
'-DOPENSSL_NO_ASM',
Expand All @@ -35,7 +34,6 @@ Pod::Spec.new do |s|
# Enable equivalent of '-Isrc/include' to make '#include <openssl/...>' work
'HEADER_SEARCH_PATHS' => [
'$(PODS_TARGET_SRCROOT)/../third_party/boringssl/src/include',
'$(PODS_TARGET_SRCROOT)/../third_party/dart-sdk/src/runtime',
],
'DEFINES_MODULE' => 'YES',
# Flutter.framework does not contain a i386 slice.
Expand Down
31 changes: 9 additions & 22 deletions lib/src/boringssl/bindings/ffigen.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
name: WebCryptoDartDL
description: 'Bindings to src/webcrypto_dart_dl.h.'
name: WebCrypto
description: 'Bindings to src/webcrypto.h.'
output: 'lib/src/boringssl/bindings/generated_bindings.dart'
headers:
entry-points:
- src/webcrypto_dart_dl.h
- src/webcrypto.c
compiler-opts: '-Ithird_party/dart-sdk/src/runtime/ -Ithird_party/boringssl/src/include'
- src/webcrypto.h
comments:
style: any
length: full
sort: true
typedef-map:
# TODO(dacoharkes): https://github.com/dart-lang/sdk/issues/42563 https://github.com/dart-lang/ffigen/issues/7
size_t: IntPtr
macros:
include:
- nothing
include: []
enums:
include:
- nothing
include: []
unnamed-enums:
include:
- nothing
include: []
globals:
include:
- nothing
include: []
structs:
include:
- nothing
include: []
dependency-only: opaque
functions:
include:
# Keep consistent with src/symbols.yaml.
- webcrypto_dart_dl_attach_finalizer
- webcrypto_dart_dl_initialize
- webcrypto_lookup_symbol
preamble: |
// Copyright 2021 Google LLC
Expand All @@ -51,4 +38,4 @@ preamble: |
// limitations under the License.
//
// ignore_for_file: unused_element
// ignore_for_file: non_constant_identifier_names
Loading

0 comments on commit 461987e

Please sign in to comment.