Skip to content

[swiftgen] Initial version of swiftgen #2372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ffigen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
- name: Upload coverage
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b
with:
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc"
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc,swiftgen"
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jnigen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,6 @@ jobs:
- name: Coveralls finished
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b
with:
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc"
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc,swiftgen"
github-token: ${{ secrets.github_token }}
parallel-finished: true
2 changes: 1 addition & 1 deletion .github/workflows/native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ jobs:
- name: Upload coverage
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b
with:
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc"
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc,swiftgen"
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
2 changes: 1 addition & 1 deletion .github/workflows/objective_c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
- name: Upload coverage
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b
with:
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc"
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc,swiftgen"
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/swift2objc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ jobs:
- name: Upload coverage
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b
with:
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc"
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc,swiftgen"
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
84 changes: 84 additions & 0 deletions .github/workflows/swiftgen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: swiftgen

on:
# Run on PRs and pushes to the default branch.
push:
branches: [main, stable]
paths:
- '.github/workflows/swiftgen.yaml'
- 'pkgs/swiftgen/**'
pull_request:
branches: [main, stable]
paths:
- '.github/workflows/swiftgen.yaml'
- 'pkgs/ffigen/**'
- 'pkgs/objective_c/**'
- 'pkgs/swift2objc/**'
- 'pkgs/swiftgen/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github

jobs:
# Check code formatting and static analysis.
analyze:
runs-on: macos-latest
defaults:
run:
working-directory: pkgs/swiftgen/
strategy:
fail-fast: false
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
with:
channel: 'stable'
- id: install
name: Install dependencies
run: flutter pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

test-mac:
needs: analyze
runs-on: 'macos-latest'
defaults:
run:
working-directory: pkgs/swiftgen/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
with:
channel: 'stable'
- name: Install dependencies
run: flutter pub get
- name: Install ObjC dependencies
working-directory: pkgs/objective_c/
run: flutter pub get
- name: Build ObjC test dylib
working-directory: pkgs/objective_c/
# TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
run: dart test/setup.dart
- name: Install coverage
run: dart pub global activate coverage
- name: Run VM tests and collect coverage
run: dart pub global run coverage:test_with_coverage --scope-output=swiftgen
- name: Upload coverage
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b
with:
flag-name: swiftgen
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
path-to-lcov: pkgs/swiftgen/coverage/lcov.info
- name: Upload coverage
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b
with:
carryforward: "ffigen,jni,jnigen,native_pkgs_macos,native_pkgs_ubuntu,native_pkgs_windows,objective_c,swift2objc,swiftgen"
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
11 changes: 10 additions & 1 deletion pkgs/ffigen/lib/ffigen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
/// https://pub.dev/packages/ffigen for details.
library ffigen;

export 'src/code_generator/imports.dart' show ImportedType, LibraryImport;
export 'src/config_provider.dart'
show
CommentType,
CompoundDependencies,
Config,
Declaration,
DeclarationFilters,
ExternalVersions,
FfiNativeConfig,
Language,
PackingValue,
SymbolFile,
VarArgFunction,
Versions,
YamlConfig;
YamlConfig,
defaultCompilerOpts;
export 'src/ffigen.dart' show FfiGen;
1 change: 1 addition & 0 deletions pkgs/ffigen/lib/src/config_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ library config_provider;

export 'config_provider/config.dart';
export 'config_provider/config_types.dart';
export 'config_provider/path_finder.dart';
export 'config_provider/yaml_config.dart';
2 changes: 1 addition & 1 deletion pkgs/ffigen/lib/src/config_provider/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ abstract interface class Config {
Uri? outputObjC,
SymbolFile? symbolFile,
Language language = Language.c,
required List<Uri> entryPoints,
List<Uri> entryPoints = const <Uri>[],
bool Function(Uri header)? shouldIncludeHeaderFunc,
List<String>? compilerOpts,
Map<String, List<VarArgFunction>> varArgFunctions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'dart:io';

import 'package:ffigen/ffigen.dart';
import 'package:ffigen/src/code_generator/utils.dart';
import 'package:ffigen/src/config_provider/config_types.dart';
import 'package:logging/logging.dart';
import 'package:path/path.dart' as path;
import 'package:pub_semver/pub_semver.dart';
Expand Down
1 change: 1 addition & 0 deletions pkgs/swiftgen/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
temp/
15 changes: 15 additions & 0 deletions pkgs/swiftgen/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# swiftgen example

Demonstrates how to use swiftgen to generate Dart bindings for a Swift API.

Regenerating the bindings:

```shell
dart generate_code.dart
```

Running the example:

```shell
dart play_audio.dart <audio_file>
```
Loading
Loading