Skip to content

Commit

Permalink
Update To 3.3.0 and get FFI sample running
Browse files Browse the repository at this point in the history
  • Loading branch information
DerKleinePunk committed Feb 22, 2024
1 parent 5b8d25d commit 37f1e07
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .dart_version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# This file contains the current Dart version we build against
3.2.6
3.3.0
6 changes: 3 additions & 3 deletions examples/realtime_example/dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: worm_example
name: realtime_example
environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ">=3.0.0 <=3.3.0"

dependencies:
ffi: ^2.0.1
ffi: ^2.1.0
2 changes: 2 additions & 0 deletions examples/simple_example_ffi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ target_include_directories(simple_example_ffi PRIVATE

add_custom_command(TARGET simple_example_ffi POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:simple_example_ffi> $<TARGET_RUNTIME_DLLS:simple_example_ffi>
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:simple_example_ffi> ${PROJECT_SOURCE_DIR}/hello_world_ffi.dart
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/.dart_tool $<TARGET_FILE_DIR:simple_example_ffi>/.dart_tool
COMMAND_EXPAND_LISTS
)

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_example_ffi/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int main() {

// Load your main isolate file, also providing the path to a package config if one exists.
// The build makes sure these are coppied to the output directory for running the example
Dart_Isolate isolate = DartDll_LoadScript("hello_world.dart", ".dart_tool/package_config.json");
Dart_Isolate isolate = DartDll_LoadScript("hello_world_ffi.dart", ".dart_tool/package_config.json");
if (isolate == nullptr) {
return -1;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/simple_example_ffi/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: simple_example_ffi
environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=3.0.0 <=3.3.0"

dependencies:
ffi: ^2.0.1
ffi: ^2.1.0
43 changes: 24 additions & 19 deletions scripts/build_helpers/bin/build_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ import 'package:path/path.dart' as path;
void main(List<String> args) async {
final parser = ArgParser();
parser.addFlag('verbose', abbr: 'v', help: 'enable all debug');
parser.addOption('buildType',
abbr: 't',
help: 'build typ release or debug. all for both',
allowed: ['all', 'debug', 'release']);
parser.addMultiOption(
'target',
abbr: 't',
help: 'Target to build (release or debug)',
allowed: ['debug', 'release', 'all'],
defaultsTo: ['release'],
);
parser.addFlag('help', abbr: 'h');

ArgResults? argResults;
try {
Expand All @@ -23,6 +27,11 @@ void main(List<String> args) async {
exit(-1);
}

if (argResults['help'] == true) {
print(parser.usage);
return;
}

Level logLevel = Level.info;
if (argResults['verbose'] == true) {
logLevel = Level.all;
Expand All @@ -32,9 +41,12 @@ void main(List<String> args) async {
logLevel: logLevel,
);

String buildType = argResults['buildType'] ?? "all";
var buildTargets = argResults['target'] as List<String>;
if (buildTargets.contains('all')) {
buildTargets = ['debug', 'release'];
}

BuildToolsLogger.shared.d('Build Typ $buildType');
BuildToolsLogger.shared.d('Build Targets $buildTargets');

if (!checkRightDirectory()) {
// Not run from root. Exit.
Expand All @@ -48,6 +60,10 @@ void main(List<String> args) async {
'DEPOT_TOOLS_WIN_TOOOLCHAIN not set! Run ./setup_env.ps1 before running this script!');
exit(-1);
}
final gypMsysVersion = Platform.environment['GYP_MSVS_VERSION'];
final gypMsysOverridePath = Platform.environment['GYP_MSVS_OVERRIDE_PATH'];
BuildToolsLogger.shared.d('GYP_MSVS_VERSION $gypMsysVersion');
BuildToolsLogger.shared.d('GYP_MSVS_OVERRIDE_PATH $gypMsysOverridePath');
}

if (!await checkForDepotTools()) {
Expand All @@ -66,19 +82,8 @@ void main(List<String> args) async {
exit(-1);
}

if (buildType == "all") {
if (!await _buildDart('release')) {
exit(-1);
}
if (!await _buildDart('debug')) {
exit(-1);
}
} else if (buildType == "release") {
if (!await _buildDart('release')) {
exit(-1);
}
} else if (buildType == "debug") {
if (!await _buildDart('debug')) {
for (var target in buildTargets) {
if (!await _buildDart(target)) {
exit(-1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_helpers/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 1.0.0
publish_to: none

environment:
sdk: ^3.0.6
sdk: ^3.3.0

dependencies:
args: ^2.4.2
Expand Down

0 comments on commit 37f1e07

Please sign in to comment.