Skip to content
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

Update to Dart 3.3.0 and little changes for Building on Windows #12

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 .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.1.3
3.2.6
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dart-sdk/*
.build/*
build/*
artifacts/*
15 changes: 11 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think any version of Visual Studio 2019+ should work. I'm using 2022 I think....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is difficlut, I you have more than one IDE / Compiler on Machine

see dart_shared_libray\dart-sdk\sdk\build\vs_toolchain.py

That was my Build Problem at first time i get always an fiele not found from windows SDK.
wenn it found an 2019 it build with this and that it muss be 10.0.20348.0 as SDK
I don't know witch SDK version is used with 2022.
I want to say with 2019 it work only with this SDK

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment on the PR. The officially supported toolchains and what actually works are sometimes different :) I don't have 2019, I only have 2022, but if you look at setupEnv.ps1 I tell the script it's Visual studio 2019.

The key I think is just VS2019 and the SDK version you mentioned.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use setupEnv.ps1 only the DEPOT_TOOLS_WIN_TOOLCHAIN=0 is an must.
I have 2019 and 2022 Prof on my Machine
Don't think it is good Idea say there ist an 2019 and Complie with 2022.
I think we need an better description in readme vor that.

* 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.
Expand All @@ -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
```

Expand Down
3 changes: 3 additions & 0 deletions examples/realtime_example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions examples/realtime_example/dart/drawable.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:ffi';

class CF_Color extends Struct {
final class CF_Color extends Struct {
@Float()
external double r;

Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion examples/realtime_example/dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions examples/realtime_example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions scripts/build_helpers/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
pubspec.lock
9 changes: 6 additions & 3 deletions scripts/build_helpers/bin/build_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ void main(List<String> args) async {
exit(-1);
}

if (!await _buildDart()) {
if (!await _buildDart('release')) {
exit(-1);
}
if (!await _buildDart('debug')) {
fuzzybinary marked this conversation as resolved.
Show resolved Hide resolved
exit(-1);
}
} catch (e) {
Expand Down Expand Up @@ -135,12 +138,12 @@ Future<bool> _patchDartSdk() async {
return result == 0;
}

Future<bool> _buildDart() async {
Future<bool> _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';
Expand Down
Loading