diff --git a/pkgs/ffigen/CHANGELOG.md b/pkgs/ffigen/CHANGELOG.md index 03d0ee82e..429e331ad 100644 --- a/pkgs/ffigen/CHANGELOG.md +++ b/pkgs/ffigen/CHANGELOG.md @@ -1,3 +1,9 @@ +## 20.1.0 + +- Add `xcodeUri`, `iosSdkUri`, and `macSdkUri`, to mirror `xcodePath`, + `iosSdkPath`, and `macSdkPath`. +- Export some missing elements from the config API. + ## 20.0.0 - __Breaking change__: Completely rewrite the public Dart API for FFIgen. diff --git a/pkgs/ffigen/lib/ffigen.dart b/pkgs/ffigen/lib/ffigen.dart index 737bd3321..efac9fc6a 100644 --- a/pkgs/ffigen/lib/ffigen.dart +++ b/pkgs/ffigen/lib/ffigen.dart @@ -18,10 +18,13 @@ export 'src/config_provider.dart' show BindingStyle, Categories, + CommentLength, + CommentStyle, CommentType, CompoundDependencies, Declaration, DynamicLibraryBindings, + EnumStyle, Enums, ExternalVersions, FfiGenerator, @@ -42,9 +45,13 @@ export 'src/config_provider.dart' Unions, UnnamedEnums, VarArgFunction, + Version, Versions, YamlConfig, defaultCompilerOpts, iosSdkPath, + iosSdkUri, macSdkPath, - xcodePath; + macSdkUri, + xcodePath, + xcodeUri; diff --git a/pkgs/ffigen/lib/src/config_provider.dart b/pkgs/ffigen/lib/src/config_provider.dart index 31f24a18c..82e82ce8a 100644 --- a/pkgs/ffigen/lib/src/config_provider.dart +++ b/pkgs/ffigen/lib/src/config_provider.dart @@ -8,5 +8,6 @@ library; export 'config_provider/config.dart'; export 'config_provider/config_types.dart'; export 'config_provider/path_finder.dart'; -export 'config_provider/utils.dart' show iosSdkPath, macSdkPath, xcodePath; +export 'config_provider/utils.dart' + show iosSdkPath, iosSdkUri, macSdkPath, macSdkUri, xcodePath, xcodeUri; export 'config_provider/yaml_config.dart'; diff --git a/pkgs/ffigen/lib/src/config_provider/config_types.dart b/pkgs/ffigen/lib/src/config_provider/config_types.dart index ac61da7f9..d8fbee7d7 100644 --- a/pkgs/ffigen/lib/src/config_provider/config_types.dart +++ b/pkgs/ffigen/lib/src/config_provider/config_types.dart @@ -15,6 +15,8 @@ import '../code_generator.dart'; import 'config.dart'; import 'path_finder.dart'; +export 'package:pub_semver/pub_semver.dart' show Version; + enum Language { c, objc } class CommentType { diff --git a/pkgs/ffigen/lib/src/config_provider/spec_utils.dart b/pkgs/ffigen/lib/src/config_provider/spec_utils.dart index d8ace53e8..10963e300 100644 --- a/pkgs/ffigen/lib/src/config_provider/spec_utils.dart +++ b/pkgs/ffigen/lib/src/config_provider/spec_utils.dart @@ -9,7 +9,6 @@ import 'package:glob/glob.dart'; import 'package:logging/logging.dart'; import 'package:package_config/package_config.dart'; import 'package:path/path.dart' as p; -import 'package:pub_semver/pub_semver.dart'; import 'package:quiver/pattern.dart' as quiver; import 'package:yaml/yaml.dart'; diff --git a/pkgs/ffigen/lib/src/config_provider/utils.dart b/pkgs/ffigen/lib/src/config_provider/utils.dart index 296a96557..5a8ce98e1 100644 --- a/pkgs/ffigen/lib/src/config_provider/utils.dart +++ b/pkgs/ffigen/lib/src/config_provider/utils.dart @@ -62,3 +62,18 @@ String get iosSdkPath => _iosSdk.value; /// /// This is the result of the command `xcrun --show-sdk-path --sdk macosx`. String get macSdkPath => _macSdk.value; + +/// The directory where Xcode's APIs are installed. +/// +/// This is the result of the command `xcode-select -p`. +Uri get xcodeUri => Uri.directory(xcodePath); + +/// The directory within [xcodePath] where the iOS SDK is installed. +/// +/// This is the result of the command `xcrun --show-sdk-path --sdk iphoneos`. +Uri get iosSdkUri => Uri.directory(iosSdkPath); + +/// The directory within [xcodePath] where the macOS SDK is installed. +/// +/// This is the result of the command `xcrun --show-sdk-path --sdk macosx`. +Uri get macSdkUri => Uri.directory(macSdkPath); diff --git a/pkgs/ffigen/lib/src/header_parser/sub_parsers/api_availability.dart b/pkgs/ffigen/lib/src/header_parser/sub_parsers/api_availability.dart index e6840ef65..eb5e3a2b5 100644 --- a/pkgs/ffigen/lib/src/header_parser/sub_parsers/api_availability.dart +++ b/pkgs/ffigen/lib/src/header_parser/sub_parsers/api_availability.dart @@ -6,7 +6,6 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; import 'package:meta/meta.dart'; -import 'package:pub_semver/pub_semver.dart'; import '../../config_provider/config_types.dart'; import '../../context.dart'; diff --git a/pkgs/ffigen/lib/src/header_parser/utils.dart b/pkgs/ffigen/lib/src/header_parser/utils.dart index eaa56c539..8b53b2b2d 100644 --- a/pkgs/ffigen/lib/src/header_parser/utils.dart +++ b/pkgs/ffigen/lib/src/header_parser/utils.dart @@ -6,7 +6,6 @@ import 'dart:ffi'; import 'package:ffi/ffi.dart'; import 'package:logging/logging.dart'; -import 'package:pub_semver/pub_semver.dart'; import '../code_generator.dart'; import '../config_provider/config_types.dart'; diff --git a/pkgs/ffigen/pubspec.yaml b/pkgs/ffigen/pubspec.yaml index b1e010c2c..c94a179a4 100644 --- a/pkgs/ffigen/pubspec.yaml +++ b/pkgs/ffigen/pubspec.yaml @@ -3,7 +3,7 @@ # BSD-style license that can be found in the LICENSE file. name: ffigen -version: 20.0.0 +version: 20.1.0-dev description: > Generator for FFI bindings, using LibClang to parse C, Objective-C, and Swift files. diff --git a/pkgs/ffigen/test/large_integration_tests/large_objc_test.dart b/pkgs/ffigen/test/large_integration_tests/large_objc_test.dart index 7c66c0da4..ac54a853f 100644 --- a/pkgs/ffigen/test/large_integration_tests/large_objc_test.dart +++ b/pkgs/ffigen/test/large_integration_tests/large_objc_test.dart @@ -16,7 +16,6 @@ import 'package:ffigen/ffigen.dart'; import 'package:ffigen/src/code_generator/utils.dart'; import 'package:logging/logging.dart'; import 'package:path/path.dart' as path; -import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; import '../test_utils.dart'; diff --git a/pkgs/ffigen/test/unit_tests/api_availability_test.dart b/pkgs/ffigen/test/unit_tests/api_availability_test.dart index 84e7d6fea..79a383228 100644 --- a/pkgs/ffigen/test/unit_tests/api_availability_test.dart +++ b/pkgs/ffigen/test/unit_tests/api_availability_test.dart @@ -4,7 +4,6 @@ import 'package:ffigen/src/config_provider/config_types.dart'; import 'package:ffigen/src/header_parser/sub_parsers/api_availability.dart'; -import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; void main() { diff --git a/pkgs/ffigen/test/unit_tests/sdk_variables_test.dart b/pkgs/ffigen/test/unit_tests/sdk_variables_test.dart new file mode 100644 index 000000000..0e1e678fc --- /dev/null +++ b/pkgs/ffigen/test/unit_tests/sdk_variables_test.dart @@ -0,0 +1,28 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Objective C support is only available on mac. +@TestOn('mac-os') +library; + +import 'dart:io'; + +import 'package:ffigen/ffigen.dart'; +import 'package:test/test.dart'; + +void main() { + group('SDK variables', () { + test('directories exist', () { + expect(Directory(xcodePath).existsSync(), isTrue); + expect(Directory(iosSdkPath).existsSync(), isTrue); + expect(Directory(macSdkPath).existsSync(), isTrue); + }); + + test('URIs', () { + expect(xcodeUri.path, '$xcodePath/'); + expect(iosSdkUri.path, '$iosSdkPath/'); + expect(macSdkUri.path, '$macSdkPath/'); + }); + }); +} diff --git a/pkgs/objective_c/CHANGELOG.md b/pkgs/objective_c/CHANGELOG.md index aaa25df99..172831979 100644 --- a/pkgs/objective_c/CHANGELOG.md +++ b/pkgs/objective_c/CHANGELOG.md @@ -1,3 +1,7 @@ +## 9.1.0 + +- Use FFIgen 20.1.0 + ## 9.0.0 - Use FFIgen 20.0.0 diff --git a/pkgs/objective_c/lib/src/internal.dart b/pkgs/objective_c/lib/src/internal.dart index 58c63a16a..cff36a77b 100644 --- a/pkgs/objective_c/lib/src/internal.dart +++ b/pkgs/objective_c/lib/src/internal.dart @@ -323,7 +323,7 @@ final class ObjCObjectRef extends _ObjCReference { bool _isValid(ObjectPtr ptr) => _isValidObject(ptr); } -/// Only for use by FFIgen bindings. +/// Base class for all Objective-C objects. class ObjCObject extends _ObjCRefHolder { ObjCObject(ObjectPtr ptr, {required bool retain, required bool release}) : super(ObjCObjectRef(ptr, retain: retain, release: release)); @@ -360,7 +360,7 @@ bool _isValidClass(ObjectPtr clazz, {bool forceReloadClasses = false}) { return _allClasses.contains(clazz); } -/// Only for use by FFIgen bindings. +/// Base class for all Objective-C protocols. // This exists so that interface_lists_test.dart can tell the difference between // a protocol and an interface. typedef ObjCProtocol = ObjCObject; diff --git a/pkgs/objective_c/pubspec.yaml b/pkgs/objective_c/pubspec.yaml index 2a17bfbf0..a32d06c69 100644 --- a/pkgs/objective_c/pubspec.yaml +++ b/pkgs/objective_c/pubspec.yaml @@ -4,7 +4,7 @@ name: objective_c description: 'A library to access Objective C from Flutter that acts as a support library for package:ffigen.' -version: 9.0.0+1 +version: 9.1.0-dev repository: https://github.com/dart-lang/native/tree/main/pkgs/objective_c issue_tracker: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aobjective_c @@ -28,7 +28,7 @@ dependencies: dev_dependencies: args: ^2.6.0 dart_flutter_team_lints: ^3.5.2 - ffigen: ^20.0.0 + ffigen: ^20.1.0 flutter_test: sdk: flutter native_test_helpers: