Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkgs/ffigen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
9 changes: 8 additions & 1 deletion pkgs/ffigen/lib/ffigen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ export 'src/config_provider.dart'
show
BindingStyle,
Categories,
CommentLength,
CommentStyle,
CommentType,
CompoundDependencies,
Declaration,
DynamicLibraryBindings,
EnumStyle,
Enums,
ExternalVersions,
FfiGenerator,
Expand All @@ -42,9 +45,13 @@ export 'src/config_provider.dart'
Unions,
UnnamedEnums,
VarArgFunction,
Version,
Versions,
YamlConfig,
defaultCompilerOpts,
iosSdkPath,
iosSdkUri,
macSdkPath,
xcodePath;
macSdkUri,
xcodePath,
xcodeUri;
3 changes: 2 additions & 1 deletion pkgs/ffigen/lib/src/config_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
2 changes: 2 additions & 0 deletions pkgs/ffigen/lib/src/config_provider/config_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion pkgs/ffigen/lib/src/config_provider/spec_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
15 changes: 15 additions & 0 deletions pkgs/ffigen/lib/src/config_provider/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 0 additions & 1 deletion pkgs/ffigen/lib/src/header_parser/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion pkgs/ffigen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 0 additions & 1 deletion pkgs/ffigen/test/unit_tests/api_availability_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
28 changes: 28 additions & 0 deletions pkgs/ffigen/test/unit_tests/sdk_variables_test.dart
Original file line number Diff line number Diff line change
@@ -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/');
});
});
}
4 changes: 4 additions & 0 deletions pkgs/objective_c/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 9.1.0

- Use FFIgen 20.1.0

## 9.0.0

- Use FFIgen 20.0.0
Expand Down
4 changes: 2 additions & 2 deletions pkgs/objective_c/lib/src/internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ final class ObjCObjectRef extends _ObjCReference<c.ObjCObjectImpl> {
bool _isValid(ObjectPtr ptr) => _isValidObject(ptr);
}

/// Only for use by FFIgen bindings.
/// Base class for all Objective-C objects.
class ObjCObject extends _ObjCRefHolder<c.ObjCObjectImpl, ObjCObjectRef> {
ObjCObject(ObjectPtr ptr, {required bool retain, required bool release})
: super(ObjCObjectRef(ptr, retain: retain, release: release));
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions pkgs/objective_c/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down