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
12 changes: 4 additions & 8 deletions .github/workflows/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: "master"
channel: "stable"
- name: run dart-cli example
run: |
cd ${{github.workspace}}\example\dart_cli
dart run
- name: run flutter example
run: |
cd ${{github.workspace}}\example\flutter
flutter config --enable-native-assets
flutter build windows --release
linux:
name: linux
Expand All @@ -44,15 +43,14 @@ jobs:
libstdc++-12-dev
- uses: subosito/flutter-action@v2
with:
channel: "master"
channel: "stable"
- name: run dart-cli example
run: |
cd "${{github.workspace}}/example/dart_cli"
dart run
- name: run flutter example
run: |
cd "${{github.workspace}}/example/flutter"
flutter config --enable-native-assets
flutter build linux --release
macos:
name: macos
Expand All @@ -61,15 +59,14 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: "master"
channel: "stable"
- name: run dart-cli example
run: |
cd "${{github.workspace}}/example/dart_cli"
dart run
- name: run flutter example
run: |
cd "${{github.workspace}}/example/flutter"
flutter config --enable-native-assets
flutter build macos --release
ios:
name: ios
Expand Down Expand Up @@ -97,7 +94,7 @@ jobs:
gcc-riscv64-linux-gnu ninja-build
- uses: subosito/flutter-action@v2
with:
channel: "master"
channel: "stable"
- uses: actions/setup-java@v4
with:
distribution: "temurin"
Expand All @@ -110,5 +107,4 @@ jobs:
- name: flutter example
run: |
cd "${{github.workspace}}/example/flutter"
flutter config --enable-native-assets
flutter build apk --release
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# native_toolchain_cmake

## 0.2.7

- new: add `CMakeBuilder.runStandalone` to allow running builder without `BuildInput input` and `BuildOutputBuilder output`

## 0.2.6

- bump hooks to 2.0
Expand Down
1 change: 1 addition & 0 deletions example/add/bin/add.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:add/add.dart';

void main() {
// ignore: avoid_print
print(calculate(7, 7, times: 3));
}
5 changes: 1 addition & 4 deletions example/add/lib/src/g/add.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,4 @@ library;
import 'dart:ffi' as ffi;

@ffi.Native<ffi.Int32 Function(ffi.Int32, ffi.Int32)>()
external int math_add(
int a,
int b,
);
external int math_add(int a, int b);
24 changes: 5 additions & 19 deletions example/add/lib/src/hook_helpers/hook_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import 'package:native_toolchain_cmake/native_toolchain_cmake.dart';

const name = 'add';

Future<void> runBuild(
BuildInput input,
BuildOutputBuilder output,
Uri sourceDir,
) async {
Future<void> runBuild(BuildInput input, BuildOutputBuilder output, Uri sourceDir) async {
final _logger = Logger('')
..level = Level.ALL
// temp fwd to stderr until process logs pass to stdout
Expand All @@ -23,9 +19,7 @@ Future<void> runBuild(
'CMAKE_BUILD_TYPE': 'Release',
'CMAKE_INSTALL_PREFIX': '${input.outputDirectory.toFilePath()}/install',
},
targets: [
'install',
],
targets: ['install'],
buildLocal: true,
logger: _logger,
);
Expand All @@ -48,11 +42,7 @@ Future<void> runBuild(
_logger.info('Found libs: $outLibs');
}

Future<void> runBuildGit(
BuildInput input,
BuildOutputBuilder output,
Uri sourceDir,
) async {
Future<void> runBuildGit(BuildInput input, BuildOutputBuilder output, Uri sourceDir) async {
final logger = Logger('')
..level = Level.ALL
// temp fwd to stderr until process logs pass to stdout
Expand All @@ -72,11 +62,7 @@ Future<void> runBuildGit(
logger: logger,
);

await builder.run(
input: input,
output: output,
logger: logger,
);
await builder.run(input: input, output: output, logger: logger);

// manually add assets
final libPath = switch (input.config.code.targetOS) {
Expand All @@ -85,7 +71,7 @@ Future<void> runBuildGit(
OS.windows => "install/lib/add.dll",
OS.android => "install/lib/libadd.so",
OS.iOS => "install/lib/libadd.dylib",
_ => throw UnsupportedError("Unsupported OS")
_ => throw UnsupportedError("Unsupported OS"),
};
output.assets.code.add(
CodeAsset(
Expand Down
24 changes: 5 additions & 19 deletions example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ void main(List<String> args) async {

const name = 'add';

Future<void> runBuild(
BuildInput input,
BuildOutputBuilder output,
Uri sourceDir,
) async {
Future<void> runBuild(BuildInput input, BuildOutputBuilder output, Uri sourceDir) async {
final _logger = Logger('')
..level = Level.ALL
// temp fwd to stderr until process logs pass to stdout
Expand All @@ -36,9 +32,7 @@ Future<void> runBuild(
'CMAKE_BUILD_TYPE': 'Release',
'CMAKE_INSTALL_PREFIX': '${input.outputDirectory.toFilePath()}/install',
},
targets: [
'install',
],
targets: ['install'],
buildLocal: true,
logger: _logger,
);
Expand All @@ -61,11 +55,7 @@ Future<void> runBuild(
_logger.info('Found libs: $outLibs');
}

Future<void> runBuildGit(
BuildInput input,
BuildOutputBuilder output,
Uri sourceDir,
) async {
Future<void> runBuildGit(BuildInput input, BuildOutputBuilder output, Uri sourceDir) async {
final logger = Logger('')
..level = Level.ALL
// temp fwd to stderr until process logs pass to stdout
Expand All @@ -85,11 +75,7 @@ Future<void> runBuildGit(
logger: logger,
);

await builder.run(
input: input,
output: output,
logger: logger,
);
await builder.run(input: input, output: output, logger: logger);

// manually add assets
final libPath = switch (input.config.code.targetOS) {
Expand All @@ -98,7 +84,7 @@ Future<void> runBuildGit(
OS.windows => "install/lib/add.dll",
OS.android => "install/lib/libadd.so",
OS.iOS => "install/lib/libadd.dylib",
_ => throw UnsupportedError("Unsupported OS")
_ => throw UnsupportedError("Unsupported OS"),
};
output.assets.code.add(
CodeAsset(
Expand Down
10 changes: 10 additions & 0 deletions example/flutter/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
analyzer:
exclude:
- build/**
- android/**
- ios/**
- web/**
- windows/**
- macos/**
- linux/**

include: package:flutter_lints/flutter.yaml

linter:
Expand Down
4 changes: 4 additions & 0 deletions example/flutter/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
# This builtInKotlin flag was added automatically by Flutter migrator
android.builtInKotlin=false
# This newDsl flag was added automatically by Flutter migrator
android.newDsl=false
5 changes: 1 addition & 4 deletions lib/src/builder/build_mode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ final class BuildMode {
static const release = BuildMode._('release');

/// All known build modes.
static const values = [
debug,
release,
];
static const values = [debug, release];

/// The name of this [BuildMode].
///
Expand Down
Loading
Loading