From f010d0cd191df8708de84e95813a5da20b11dae6 Mon Sep 17 00:00:00 2001 From: DerKleinePunk Date: Tue, 13 Feb 2024 08:40:56 +0100 Subject: [PATCH 1/5] update to dart version 3.2.6 and debug build --- .dart_version | 2 +- .gitignore | 1 + README.md | 6 ++- scripts/build_helpers/bin/build_dart.dart | 9 ++-- scripts/build_helpers/pubspec.lock | 66 +++++++++++++---------- scripts/build_helpers/pubspec.yaml | 2 +- 6 files changed, 51 insertions(+), 35 deletions(-) diff --git a/.dart_version b/.dart_version index 49ca62e..53ae4c0 100644 --- a/.dart_version +++ b/.dart_version @@ -1,2 +1,2 @@ # This file contains the current Dart version we build against -3.1.3 \ No newline at end of file +3.2.6 \ No newline at end of file diff --git a/.gitignore b/.gitignore index aebcdfc..d22a5b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dart-sdk/* .build/* +build/* artifacts/* \ No newline at end of file diff --git a/README.md b/README.md index 6220c31..5ac519e 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,8 @@ Github Actions currently builds a Windows x64 `.dll`, A Linux x64 `.so`, and a m You need: * git * Dart 3+ -* C++ build tools for your platform (Visual Studio, XCode, gcc, etc) +* C++ build tools for your platform (Visual Studio, XCode, gcc, etc) +* For Windows VS 2019 16.61 with 10.0.20348.0 SDK don't forget install Debugger Tools * CMake Optionally, I recommend installing [`depot_tools`](https://www.chromium.org/developers/how-tos/depottools/) and making sure it is on your path before running setup scripts. Without depot_tools, the scripts will download them anyway, but having them already set up will save you some time with subsequent builds. @@ -40,6 +41,9 @@ Optionally, I recommend installing [`depot_tools`](https://www.chromium.org/deve The first step is to build a statically linkable verison of Dart. This requires that we download Dart, patch some of the Dart build files, and then run the actual build. Thankfully there is a Dart script to do this. ```bash +cd ./scripts/build_helpers +dart pub get +cd ../.. dart ./scripts/build_helpers/bin/build_dart.dart ``` diff --git a/scripts/build_helpers/bin/build_dart.dart b/scripts/build_helpers/bin/build_dart.dart index 10ec6d4..de59f61 100644 --- a/scripts/build_helpers/bin/build_dart.dart +++ b/scripts/build_helpers/bin/build_dart.dart @@ -47,7 +47,10 @@ void main(List args) async { exit(-1); } - if (!await _buildDart()) { + if (!await _buildDart('release')) { + exit(-1); + } + if (!await _buildDart('debug')) { exit(-1); } } catch (e) { @@ -135,12 +138,12 @@ Future _patchDartSdk() async { return result == 0; } -Future _buildDart() async { +Future _buildDart(String buildType) async { final logger = BuildToolsLogger.shared; final result = await inDir('dart-sdk/sdk', () async { logger.i("Building libdart"); var script = './tools/build.py'; - var args = ['--no-goma', '-m', 'release', 'libdart']; + var args = ['--no-goma', '-m', buildType, 'libdart']; var command = script; if (Platform.isWindows) { command = 'python'; diff --git a/scripts/build_helpers/pubspec.lock b/scripts/build_helpers/pubspec.lock index 7ff7192..518ab4f 100644 --- a/scripts/build_helpers/pubspec.lock +++ b/scripts/build_helpers/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" url: "https://pub.dev" source: hosted - version: "64.0.0" + version: "67.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" url: "https://pub.dev" source: hosted - version: "6.2.0" + version: "6.4.1" args: dependency: "direct main" description: @@ -61,10 +61,10 @@ packages: dependency: transitive description: name: coverage - sha256: "595a29b55ce82d53398e1bcc2cba525d7bd7c59faeb2d2540e9d42c390cfeeeb" + sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" url: "https://pub.dev" source: hosted - version: "1.6.4" + version: "1.7.2" crypto: dependency: transitive description: @@ -125,18 +125,18 @@ packages: dependency: transitive description: name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + sha256: "4186c61b32f99e60f011f7160e32c89a758ae9b1d0c6d28e2c02ef0382300e2b" url: "https://pub.dev" source: hosted - version: "0.6.7" + version: "0.7.0" lints: dependency: "direct dev" description: name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "3.0.0" logger: dependency: "direct main" description: @@ -157,26 +157,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.12.0" mime: dependency: transitive description: name: mime - sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.0.5" node_preamble: dependency: transitive description: @@ -197,10 +197,10 @@ packages: dependency: "direct main" description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" pool: dependency: transitive description: @@ -309,26 +309,26 @@ packages: dependency: "direct dev" description: name: test - sha256: a20ddc0723556dc6dd56094e58ec1529196d5d7774156604cb14e8445a5a82ff + sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073" url: "https://pub.dev" source: hosted - version: "1.24.7" + version: "1.25.2" test_api: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" test_core: dependency: transitive description: name: test_core - sha256: "96382d0bc826e260b077bb496259e58bc82e90b603ab16cd5ae95dfe1dfcba8b" + sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4" url: "https://pub.dev" source: hosted - version: "0.5.7" + version: "0.6.0" typed_data: dependency: transitive description: @@ -341,10 +341,10 @@ packages: dependency: transitive description: name: vm_service - sha256: a13d5503b4facefc515c8c587ce3cf69577a7b064a9f1220e005449cf1f64aad + sha256: a2662fb1f114f4296cf3f5a50786a2d888268d7776cf681aa17d660ffa23b246 url: "https://pub.dev" source: hosted - version: "12.0.0" + version: "14.0.0" watcher: dependency: transitive description: @@ -353,14 +353,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05" + url: "https://pub.dev" + source: hosted + version: "0.4.2" web_socket_channel: dependency: transitive description: name: web_socket_channel - sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + sha256: "939ab60734a4f8fa95feacb55804fa278de28bdeef38e616dc08e44a84adea23" url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.4.3" webkit_inspection_protocol: dependency: transitive description: @@ -378,4 +386,4 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.0.6 <4.0.0" + dart: ">=3.2.0 <4.0.0" diff --git a/scripts/build_helpers/pubspec.yaml b/scripts/build_helpers/pubspec.yaml index 5106a96..70b16f9 100644 --- a/scripts/build_helpers/pubspec.yaml +++ b/scripts/build_helpers/pubspec.yaml @@ -13,5 +13,5 @@ dependencies: glob: ^2.1.2 dev_dependencies: - lints: ^2.0.0 + lints: ^3.0.0 test: ^1.21.0 From af305ac3f9c887299db5385979e82cd09cdd45fa Mon Sep 17 00:00:00 2001 From: DerKleinePunk Date: Tue, 20 Feb 2024 07:49:32 +0100 Subject: [PATCH 2/5] Now Build and run Sample with 3.2.6 --- .vscode/launch.json | 15 +++++++++++---- examples/realtime_example/CMakeLists.txt | 3 +++ examples/realtime_example/dart/drawable.dart | 4 ++-- examples/realtime_example/dart/pubspec.yaml | 2 +- examples/realtime_example/main.cpp | 1 + src/isolate_setup.cpp | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 3e8e95b..3eac41c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,10 +5,17 @@ "version": "0.2.0", "configurations": [ { - "name": "Dart: Attach to Simple", - "type": "dart", - "request": "attach", - "vmServiceUri": "http://127.0.0.1:5858/" + + "name": "(WIN)RealTime Sample", + "type": "cppvsdbg", + "request": "launch", + //"preLaunchTask": "buildSimpelTest", + "program": "${workspaceFolder}/build/Debug/realtime_example.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "console": "externalTerminal" } ] } \ No newline at end of file diff --git a/examples/realtime_example/CMakeLists.txt b/examples/realtime_example/CMakeLists.txt index db8340c..dd72ddf 100644 --- a/examples/realtime_example/CMakeLists.txt +++ b/examples/realtime_example/CMakeLists.txt @@ -6,6 +6,9 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CUTE_FRAMEWORK_STATIC ON) +set(CF_FRAMEWORK_BUILD_TESTS OFF) +# Samples Build on Windows Falied +set(CF_FRAMEWORK_BUILD_SAMPLES OFF) include(FetchContent) FetchContent_Declare( diff --git a/examples/realtime_example/dart/drawable.dart b/examples/realtime_example/dart/drawable.dart index 7d59f5f..1b050cb 100644 --- a/examples/realtime_example/dart/drawable.dart +++ b/examples/realtime_example/dart/drawable.dart @@ -1,6 +1,6 @@ import 'dart:ffi'; -class CF_Color extends Struct { +final class CF_Color extends Struct { @Float() external double r; @@ -14,7 +14,7 @@ class CF_Color extends Struct { external double a; } -class Drawable extends Struct { +final class Drawable extends Struct { @Int32() external int x; diff --git a/examples/realtime_example/dart/pubspec.yaml b/examples/realtime_example/dart/pubspec.yaml index 98cc45d..7ab96d1 100644 --- a/examples/realtime_example/dart/pubspec.yaml +++ b/examples/realtime_example/dart/pubspec.yaml @@ -1,6 +1,6 @@ name: worm_example environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: ffi: ^2.0.1 \ No newline at end of file diff --git a/examples/realtime_example/main.cpp b/examples/realtime_example/main.cpp index eb22d01..c55f46c 100644 --- a/examples/realtime_example/main.cpp +++ b/examples/realtime_example/main.cpp @@ -20,6 +20,7 @@ bool init_dart() { DartDllConfig config; DartDll_Initialize(config); + //if package_config.json not exits run pub get _dart_isolate = DartDll_LoadScript("dart/main.dart", "dart/.dart_tool/package_config.json"); if (_dart_isolate == nullptr) { diff --git a/src/isolate_setup.cpp b/src/isolate_setup.cpp index 8230f46..dc00911 100644 --- a/src/isolate_setup.cpp +++ b/src/isolate_setup.cpp @@ -221,7 +221,7 @@ Dart_Isolate CreateIsolate(bool is_main_isolate, int exit_code = 0; dfe.CompileAndReadScript(script_uri, &application_kernel_buffer, &application_kernel_buffer_size, error, &exit_code, - resolved_packages_config, true); + resolved_packages_config, true, false); if (application_kernel_buffer == nullptr) { std::cerr << "Error reading Dart script " << script_uri << ": " << *error << std::endl; From 5bedf7749467b56c753399e3c0380c0d6efec783 Mon Sep 17 00:00:00 2001 From: DerKleinePunk Date: Tue, 20 Feb 2024 09:08:41 +0100 Subject: [PATCH 3/5] Only an Test --- scripts/build_helpers/.gitignore | 1 + scripts/build_helpers/pubspec.lock | 389 ----------------------------- src/CMakeLists.txt | 12 +- 3 files changed, 12 insertions(+), 390 deletions(-) delete mode 100644 scripts/build_helpers/pubspec.lock diff --git a/scripts/build_helpers/.gitignore b/scripts/build_helpers/.gitignore index 3a85790..af0687c 100644 --- a/scripts/build_helpers/.gitignore +++ b/scripts/build_helpers/.gitignore @@ -1,3 +1,4 @@ # https://dart.dev/guides/libraries/private-files # Created by `dart pub` .dart_tool/ +pubspec.lock \ No newline at end of file diff --git a/scripts/build_helpers/pubspec.lock b/scripts/build_helpers/pubspec.lock deleted file mode 100644 index 518ab4f..0000000 --- a/scripts/build_helpers/pubspec.lock +++ /dev/null @@ -1,389 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - _fe_analyzer_shared: - dependency: transitive - description: - name: _fe_analyzer_shared - sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" - url: "https://pub.dev" - source: hosted - version: "67.0.0" - analyzer: - dependency: transitive - description: - name: analyzer - sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" - url: "https://pub.dev" - source: hosted - version: "6.4.1" - args: - dependency: "direct main" - description: - name: args - sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 - url: "https://pub.dev" - source: hosted - version: "2.4.2" - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - collection: - dependency: transitive - description: - name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.dev" - source: hosted - version: "1.18.0" - convert: - dependency: transitive - description: - name: convert - sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" - url: "https://pub.dev" - source: hosted - version: "3.1.1" - coverage: - dependency: transitive - description: - name: coverage - sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" - url: "https://pub.dev" - source: hosted - version: "1.7.2" - crypto: - dependency: transitive - description: - name: crypto - sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab - url: "https://pub.dev" - source: hosted - version: "3.0.3" - file: - dependency: transitive - description: - name: file - sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" - url: "https://pub.dev" - source: hosted - version: "7.0.0" - frontend_server_client: - dependency: transitive - description: - name: frontend_server_client - sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" - url: "https://pub.dev" - source: hosted - version: "3.2.0" - glob: - dependency: "direct main" - description: - name: glob - sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" - url: "https://pub.dev" - source: hosted - version: "2.1.2" - http_multi_server: - dependency: transitive - description: - name: http_multi_server - sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" - url: "https://pub.dev" - source: hosted - version: "3.2.1" - http_parser: - dependency: transitive - description: - name: http_parser - sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" - url: "https://pub.dev" - source: hosted - version: "4.0.2" - io: - dependency: transitive - description: - name: io - sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" - url: "https://pub.dev" - source: hosted - version: "1.0.4" - js: - dependency: transitive - description: - name: js - sha256: "4186c61b32f99e60f011f7160e32c89a758ae9b1d0c6d28e2c02ef0382300e2b" - url: "https://pub.dev" - source: hosted - version: "0.7.0" - lints: - dependency: "direct dev" - description: - name: lints - sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 - url: "https://pub.dev" - source: hosted - version: "3.0.0" - logger: - dependency: "direct main" - description: - name: logger - sha256: "6bbb9d6f7056729537a4309bda2e74e18e5d9f14302489cc1e93f33b3fe32cac" - url: "https://pub.dev" - source: hosted - version: "2.0.2+1" - logging: - dependency: transitive - description: - name: logging - sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - matcher: - dependency: transitive - description: - name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb - url: "https://pub.dev" - source: hosted - version: "0.12.16+1" - meta: - dependency: transitive - description: - name: meta - sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" - url: "https://pub.dev" - source: hosted - version: "1.12.0" - mime: - dependency: transitive - description: - name: mime - sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" - url: "https://pub.dev" - source: hosted - version: "1.0.5" - node_preamble: - dependency: transitive - description: - name: node_preamble - sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" - url: "https://pub.dev" - source: hosted - version: "2.0.2" - package_config: - dependency: transitive - description: - name: package_config - sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" - url: "https://pub.dev" - source: hosted - version: "2.1.0" - path: - dependency: "direct main" - description: - name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" - url: "https://pub.dev" - source: hosted - version: "1.9.0" - pool: - dependency: transitive - description: - name: pool - sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" - url: "https://pub.dev" - source: hosted - version: "1.5.1" - pub_semver: - dependency: transitive - description: - name: pub_semver - sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - shelf: - dependency: transitive - description: - name: shelf - sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 - url: "https://pub.dev" - source: hosted - version: "1.4.1" - shelf_packages_handler: - dependency: transitive - description: - name: shelf_packages_handler - sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" - url: "https://pub.dev" - source: hosted - version: "3.0.2" - shelf_static: - dependency: transitive - description: - name: shelf_static - sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e - url: "https://pub.dev" - source: hosted - version: "1.1.2" - shelf_web_socket: - dependency: transitive - description: - name: shelf_web_socket - sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" - url: "https://pub.dev" - source: hosted - version: "1.0.4" - source_map_stack_trace: - dependency: transitive - description: - name: source_map_stack_trace - sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - source_maps: - dependency: transitive - description: - name: source_maps - sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" - url: "https://pub.dev" - source: hosted - version: "0.10.12" - source_span: - dependency: transitive - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.dev" - source: hosted - version: "2.1.2" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test: - dependency: "direct dev" - description: - name: test - sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073" - url: "https://pub.dev" - source: hosted - version: "1.25.2" - test_api: - dependency: transitive - description: - name: test_api - sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" - url: "https://pub.dev" - source: hosted - version: "0.7.0" - test_core: - dependency: transitive - description: - name: test_core - sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4" - url: "https://pub.dev" - source: hosted - version: "0.6.0" - typed_data: - dependency: transitive - description: - name: typed_data - sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c - url: "https://pub.dev" - source: hosted - version: "1.3.2" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: a2662fb1f114f4296cf3f5a50786a2d888268d7776cf681aa17d660ffa23b246 - url: "https://pub.dev" - source: hosted - version: "14.0.0" - watcher: - dependency: transitive - description: - name: watcher - sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - web: - dependency: transitive - description: - name: web - sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05" - url: "https://pub.dev" - source: hosted - version: "0.4.2" - web_socket_channel: - dependency: transitive - description: - name: web_socket_channel - sha256: "939ab60734a4f8fa95feacb55804fa278de28bdeef38e616dc08e44a84adea23" - url: "https://pub.dev" - source: hosted - version: "2.4.3" - webkit_inspection_protocol: - dependency: transitive - description: - name: webkit_inspection_protocol - sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" - url: "https://pub.dev" - source: hosted - version: "1.2.1" - yaml: - dependency: transitive - description: - name: yaml - sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" - url: "https://pub.dev" - source: hosted - version: "3.1.2" -sdks: - dart: ">=3.2.0 <4.0.0" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 393cc7e..e59135a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15) -project(dart_dll VERSION 0.1) +project(dart_dll VERSION 0.1.2) set(DARTSDK_ROOTDIR "${PROJECT_SOURCE_DIR}/../dart-sdk" CACHE FILEPATH "Directory that dart-sdk is cloned too") set(DART_DIR "${DARTSDK_ROOTDIR}/sdk") @@ -22,6 +22,8 @@ if(WIN32) set(LIB_PREFIX "lib") endif() +MESSAGE(STATUS "Dart SDK ${DART_DIR}") + find_library(LIB_DART_DEBUG NAMES "${LIB_PREFIX}dart" HINTS "${DART_DIR}/out/DebugX64/obj/runtime/bin" "${DART_DIR}/xcodebuild/ReleaseX64/obj/runtime/bin" @@ -32,6 +34,14 @@ find_library(LIB_DART_RELEASE HINTS "${DART_DIR}/out/ReleaseX64/obj/runtime/bin" "${DART_DIR}/xcodebuild/ReleaseX64/obj/runtime/bin" ) +add_custom_command(TARGET dart_dll + # On Visual Studio Generators, run before any other rules are executed within the target. On other generators, run just before PRE_LINK commands + PRE_BUILD + COMMAND echo -e "\texecuting a PRE_BUILD command" + COMMENT "Building Dart bevor Lib" + VERBATIM # to support \t for example +) + target_compile_definitions(dart_dll PRIVATE __STDC_LIMIT_MACROS __STDC_FORMAT_MACROS From 5b8d25d49490257612192f6a967cdf448f49d77f Mon Sep 17 00:00:00 2001 From: DerKleinePunk Date: Wed, 21 Feb 2024 07:42:54 +0100 Subject: [PATCH 4/5] build_helpers commandline enable debug log --- .github/workflows/build.yaml | 2 +- README.md | 9 +++- examples/simple_example/CMakeLists.txt | 8 +++- scripts/build_helpers/bin/build_dart.dart | 50 ++++++++++++++++---- scripts/build_helpers/lib/build_helpers.dart | 3 +- src/CMakeLists.txt | 8 ---- 6 files changed, 58 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 67efe9e..66a0110 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -27,7 +27,7 @@ jobs: - run: dart pub get working-directory: ./scripts/build_helpers - name: Build Dart - run: dart ./scripts/build_helpers/bin/build_dart.dart + run: dart ./scripts/build_helpers/bin/build_dart.dart -v - uses: threeal/cmake-action@v1.3.0 - name: Build Shared Library run: cmake --build build --config release diff --git a/README.md b/README.md index 5ac519e..eb782ad 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,11 @@ You need: * git * Dart 3+ * C++ build tools for your platform (Visual Studio, XCode, gcc, etc) -* For Windows VS 2019 16.61 with 10.0.20348.0 SDK don't forget install Debugger Tools +* For Windows + * 2019 16.61 with 10.0.20348.0 SDK don't forget install Debugger Tools + * 2022 17 with ? SDK don't forget install Debugger Tools + * 2017 15 with ? SDK don't forget install Debugger Tools + * see dart-sdk\sdk\build\vs_toolchain.py * CMake Optionally, I recommend installing [`depot_tools`](https://www.chromium.org/developers/how-tos/depottools/) and making sure it is on your path before running setup scripts. Without depot_tools, the scripts will download them anyway, but having them already set up will save you some time with subsequent builds. @@ -39,6 +43,9 @@ Optionally, I recommend installing [`depot_tools`](https://www.chromium.org/deve > This will set up some environment variables that will be needed to build Dart properly. The first step is to build a statically linkable verison of Dart. This requires that we download Dart, patch some of the Dart build files, and then run the actual build. Thankfully there is a Dart script to do this. +build_dart commandline + * -v -> Verbose Log + * -t -> Build Type all, release, debug ```bash cd ./scripts/build_helpers diff --git a/examples/simple_example/CMakeLists.txt b/examples/simple_example/CMakeLists.txt index f6d4584..38991cd 100644 --- a/examples/simple_example/CMakeLists.txt +++ b/examples/simple_example/CMakeLists.txt @@ -15,4 +15,10 @@ add_custom_command(TARGET simple_example POST_BUILD COMMAND_EXPAND_LISTS ) -target_link_libraries(simple_example PUBLIC dart_dll) \ No newline at end of file +add_dependencies(simple_example ALWAYS_DO_POST_BUILD) + +target_link_libraries(simple_example PUBLIC dart_dll) + +if (MSVC) + set_property(TARGET simple_example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $) +endif() \ No newline at end of file diff --git a/scripts/build_helpers/bin/build_dart.dart b/scripts/build_helpers/bin/build_dart.dart index de59f61..2b9af93 100644 --- a/scripts/build_helpers/bin/build_dart.dart +++ b/scripts/build_helpers/bin/build_dart.dart @@ -8,14 +8,33 @@ import 'package:path/path.dart' as path; void main(List args) async { final parser = ArgParser(); - parser.addFlag('verbose', abbr: 'v'); + 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']); + + ArgResults? argResults; + try { + argResults = parser.parse(args); + } catch (error) { + if (error is! FormatException) rethrow; + print(parser.usage); + exit(-1); + } - final argResults = parser.parse(args); Level logLevel = Level.info; if (argResults['verbose'] == true) { - logLevel = Level.debug; + logLevel = Level.all; } - BuildToolsLogger.initLogger(logLevel: logLevel); + + BuildToolsLogger.initLogger( + logLevel: logLevel, + ); + + String buildType = argResults['buildType'] ?? "all"; + + BuildToolsLogger.shared.d('Build Typ $buildType'); if (!checkRightDirectory()) { // Not run from root. Exit. @@ -47,11 +66,21 @@ void main(List args) async { exit(-1); } - if (!await _buildDart('release')) { - exit(-1); - } - if (!await _buildDart('debug')) { - 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')) { + exit(-1); + } } } catch (e) { BuildToolsLogger.shared.f('Caught an exception building the Dart SDK:'); @@ -128,7 +157,7 @@ Future _patchDartSdk() async { logger.i("Patching the Dart SDK to create libdart"); var result = await Process.run('git', ['apply', '../../dart_sdk.patch'], runInShell: true); - logger.d(result.stdout); + logger.d('Patch result is ${result.exitCode}'); return result.exitCode; }); if (result != 0) { @@ -140,6 +169,7 @@ Future _patchDartSdk() async { Future _buildDart(String buildType) async { final logger = BuildToolsLogger.shared; + logger.d('starting build for $buildType'); final result = await inDir('dart-sdk/sdk', () async { logger.i("Building libdart"); var script = './tools/build.py'; diff --git a/scripts/build_helpers/lib/build_helpers.dart b/scripts/build_helpers/lib/build_helpers.dart index 5e6a2e4..283eff5 100644 --- a/scripts/build_helpers/lib/build_helpers.dart +++ b/scripts/build_helpers/lib/build_helpers.dart @@ -15,11 +15,12 @@ class BuildToolsLogger { } static Logger initLogger({Level logLevel = Level.info}) { - return Logger( + _shared = Logger( filter: ProductionFilter(), level: logLevel, printer: SimplePrinter(), ); + return shared; } } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e59135a..78f1c25 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,14 +34,6 @@ find_library(LIB_DART_RELEASE HINTS "${DART_DIR}/out/ReleaseX64/obj/runtime/bin" "${DART_DIR}/xcodebuild/ReleaseX64/obj/runtime/bin" ) -add_custom_command(TARGET dart_dll - # On Visual Studio Generators, run before any other rules are executed within the target. On other generators, run just before PRE_LINK commands - PRE_BUILD - COMMAND echo -e "\texecuting a PRE_BUILD command" - COMMENT "Building Dart bevor Lib" - VERBATIM # to support \t for example -) - target_compile_definitions(dart_dll PRIVATE __STDC_LIMIT_MACROS __STDC_FORMAT_MACROS From 37f1e074f31fe0aa00f15e7098166b8dcb25c8ca Mon Sep 17 00:00:00 2001 From: DerKleinePunk Date: Thu, 22 Feb 2024 09:21:28 +0100 Subject: [PATCH 5/5] Update To 3.3.0 and get FFI sample running --- .dart_version | 2 +- examples/realtime_example/dart/pubspec.yaml | 6 +-- examples/simple_example_ffi/CMakeLists.txt | 2 + ...{hello_world.dart => hello_world_ffi.dart} | 0 examples/simple_example_ffi/main.cpp | 2 +- examples/simple_example_ffi/pubspec.yaml | 4 +- scripts/build_helpers/bin/build_dart.dart | 43 +++++++++++-------- scripts/build_helpers/pubspec.yaml | 2 +- 8 files changed, 34 insertions(+), 27 deletions(-) rename examples/simple_example_ffi/{hello_world.dart => hello_world_ffi.dart} (100%) diff --git a/.dart_version b/.dart_version index 53ae4c0..a2ec1a2 100644 --- a/.dart_version +++ b/.dart_version @@ -1,2 +1,2 @@ # This file contains the current Dart version we build against -3.2.6 \ No newline at end of file +3.3.0 \ No newline at end of file diff --git a/examples/realtime_example/dart/pubspec.yaml b/examples/realtime_example/dart/pubspec.yaml index 7ab96d1..44a39ab 100644 --- a/examples/realtime_example/dart/pubspec.yaml +++ b/examples/realtime_example/dart/pubspec.yaml @@ -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 \ No newline at end of file + ffi: ^2.1.0 \ No newline at end of file diff --git a/examples/simple_example_ffi/CMakeLists.txt b/examples/simple_example_ffi/CMakeLists.txt index 96b96a0..866b3d1 100644 --- a/examples/simple_example_ffi/CMakeLists.txt +++ b/examples/simple_example_ffi/CMakeLists.txt @@ -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 $ $ + COMMAND ${CMAKE_COMMAND} -E copy -t $ ${PROJECT_SOURCE_DIR}/hello_world_ffi.dart + COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/.dart_tool $/.dart_tool COMMAND_EXPAND_LISTS ) diff --git a/examples/simple_example_ffi/hello_world.dart b/examples/simple_example_ffi/hello_world_ffi.dart similarity index 100% rename from examples/simple_example_ffi/hello_world.dart rename to examples/simple_example_ffi/hello_world_ffi.dart diff --git a/examples/simple_example_ffi/main.cpp b/examples/simple_example_ffi/main.cpp index f4562f0..8385a1d 100644 --- a/examples/simple_example_ffi/main.cpp +++ b/examples/simple_example_ffi/main.cpp @@ -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; } diff --git a/examples/simple_example_ffi/pubspec.yaml b/examples/simple_example_ffi/pubspec.yaml index dd622a6..cab9123 100644 --- a/examples/simple_example_ffi/pubspec.yaml +++ b/examples/simple_example_ffi/pubspec.yaml @@ -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 \ No newline at end of file + ffi: ^2.1.0 \ No newline at end of file diff --git a/scripts/build_helpers/bin/build_dart.dart b/scripts/build_helpers/bin/build_dart.dart index 2b9af93..7e34742 100644 --- a/scripts/build_helpers/bin/build_dart.dart +++ b/scripts/build_helpers/bin/build_dart.dart @@ -9,10 +9,14 @@ import 'package:path/path.dart' as path; void main(List 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 { @@ -23,6 +27,11 @@ void main(List args) async { exit(-1); } + if (argResults['help'] == true) { + print(parser.usage); + return; + } + Level logLevel = Level.info; if (argResults['verbose'] == true) { logLevel = Level.all; @@ -32,9 +41,12 @@ void main(List args) async { logLevel: logLevel, ); - String buildType = argResults['buildType'] ?? "all"; + var buildTargets = argResults['target'] as List; + 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. @@ -48,6 +60,10 @@ void main(List 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()) { @@ -66,19 +82,8 @@ void main(List 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); } } diff --git a/scripts/build_helpers/pubspec.yaml b/scripts/build_helpers/pubspec.yaml index 70b16f9..9b3a00c 100644 --- a/scripts/build_helpers/pubspec.yaml +++ b/scripts/build_helpers/pubspec.yaml @@ -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