Skip to content

Commit b24bdd9

Browse files
committed
feat: Update to Dart 3.5, fix build
Updated to Dart 3.5, fixed a lot of build mistakes in various CMakeLists.
1 parent ccef86b commit b24bdd9

File tree

12 files changed

+64
-26
lines changed

12 files changed

+64
-26
lines changed

.dart_version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# This file contains the current Dart version we build against
2-
3.3.0
2+
3.5.0

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.21)
22

33
project(DartSharedLibrary VERSION 0.1)
44

5-
option(BUILD_SMAPLES "Build the Sampels" ON)
5+
option(BUILD_SAMPLES "Build the Samples" ON)
66

77
set(CMAKE_CXX_STANDARD 11)
88
set(CMAKE_CXX_STANDARD_REQUIRED True)

examples/realtime_example/CMakeLists.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ cmake_minimum_required(VERSION 3.21)
33
project(realtime_example)
44
set(CMAKE_CXX_STANDARD 17)
55

6-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
7-
86
set(CUTE_FRAMEWORK_STATIC ON)
97
set(CF_FRAMEWORK_BUILD_TESTS OFF)
108
# Samples Build on Windows Falied
@@ -14,6 +12,7 @@ include(FetchContent)
1412
FetchContent_Declare(
1513
cute
1614
GIT_REPOSITORY https://github.com/RandyGaul/cute_framework
15+
GIT_TAG a2341c72f02e019e157cfc3997cd81d98c825004
1716
)
1817
FetchContent_MakeAvailable(cute)
1918

@@ -34,12 +33,11 @@ if(LINUX)
3433
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -export-dynamic")
3534
endif()
3635

37-
add_custom_target(ALWAYS_DO_POST_BUILD
38-
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:realtime_example> $<TARGET_RUNTIME_DLLS:simple_example_ffi>
39-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/dart $<TARGET_FILE_DIR:realtime_example>/dart
36+
add_custom_command(TARGET realtime_example POST_BUILD
37+
COMMAND ${CMAKE_COMMAND} -E copy -t $<TARGET_FILE_DIR:realtime_example> $<TARGET_RUNTIME_DLLS:realtime_example>
38+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/dart/ $<TARGET_FILE_DIR:realtime_example>/dart
4039
COMMAND_EXPAND_LISTS
4140
)
42-
add_dependencies(realtime_example ALWAYS_DO_POST_BUILD)
4341

4442
target_link_libraries(realtime_example PUBLIC dart_dll cute)
4543

examples/realtime_example/dart/main.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ class Wall {
2020
List<Wall> walls = [];
2121

2222
// Dot!
23+
final int speed = 80;
2324
int dotEntity = 0;
24-
int dotX = 0;
25-
int dotY = 0;
25+
double dotX = 0;
26+
double dotY = 0;
2627
bool movingLeft = true;
2728

2829
void main() {
@@ -42,25 +43,27 @@ void main() {
4243

4344
dotEntity = ffi.createEntity(0, 0, 10, 10);
4445
final drawable = ffi.getDrawable(dotEntity);
46+
drawable.ref.color.r = 0.0;
4547
drawable.ref.color.g = 1.0;
48+
drawable.ref.color.b = 0.0;
4649
}
4750

4851
void frame(double dt) {
4952
if (movingLeft) {
50-
dotX -= 3;
53+
dotX -= (speed * dt);
5154
if (dotX < -200) {
5255
dotX = -200;
5356
movingLeft = false;
5457
}
5558
} else {
56-
dotX += 3;
59+
dotX += (speed * dt);
5760
if (dotX > 200) {
5861
dotX = 200;
5962
movingLeft = true;
6063
}
6164
}
6265

6366
final dotDrawable = ffi.getDrawable(dotEntity);
64-
dotDrawable.ref.x = dotX;
65-
dotDrawable.ref.y = dotY;
67+
dotDrawable.ref.x = dotX.floor();
68+
dotDrawable.ref.y = dotY.floor();
6669
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: realtime_example
22
environment:
3-
sdk: ">=3.0.0 <=3.3.0"
3+
sdk: ">=3.0.0 <4.0.0"
44

55
dependencies:
66
ffi: ^2.1.0

examples/realtime_example/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <cute.h>
22
using namespace Cute;
33

4+
#include <iostream>
45
#include <dart_dll.h>
56

67
#include <dart_tools_api.h>
@@ -100,7 +101,7 @@ void render_drawables() {
100101
// These need to be exposed as "C" functions and be exported
101102
//
102103
#if defined(_WIN32)
103-
#define WORM_EXPORT exten "C" __declspec(dllexport)
104+
#define WORM_EXPORT extern "C" __declspec(dllexport)
104105
#else
105106
#define WORM_EXPORT extern "C" __attribute__((visibility("default"))) __attribute((used))
106107
#endif
@@ -137,10 +138,9 @@ WORM_EXPORT bool get_key_just_pressed(int key_code) {
137138

138139
int main(int argc, char* argv[]) {
139140
// Create a window with a resolution of 640 x 480.
140-
int options =
141-
APP_OPTIONS_DEFAULT_GFX_CONTEXT | APP_OPTIONS_WINDOW_POS_CENTERED;
141+
int options = APP_OPTIONS_WINDOW_POS_CENTERED;
142142
Result result =
143-
make_app("Fancy Window Title", 0, 0, 640, 480, options, argv[0]);
143+
make_app("Fancy Window Title", 0, 0, 0, 640, 480, options, argv[0]);
144144
if (is_error(result)) return -1;
145145

146146
if (!init_dart()) return -1;

examples/simple_example/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ add_custom_command(TARGET simple_example POST_BUILD
1818
target_link_libraries(simple_example PUBLIC dart_dll)
1919

2020
if (MSVC)
21-
set_property(TARGET realtime_example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:simple_example>)
21+
set_property(TARGET simple_example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:simple_example>)
2222
endif()
2323

2424
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/simple_example")

examples/simple_example_ffi/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ add_custom_command(TARGET simple_example_ffi POST_BUILD
1616
COMMAND_EXPAND_LISTS
1717
)
1818

19+
target_link_libraries(simple_example_ffi PUBLIC dart_dll)
20+
1921
if (MSVC)
20-
set_property(TARGET realtime_example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:simple_example_ffi>)
22+
set_property(TARGET simple_example_ffi PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:simple_example_ffi>)
2123
endif()
2224

23-
target_link_libraries(simple_example_ffi PUBLIC dart_dll)
25+
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/simple_example_ffi")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: simple_example_ffi
22
environment:
3-
sdk: ">=3.0.0 <=3.3.0"
3+
sdk: ">=3.0.0 <4.0.0"
44

55
dependencies:
66
ffi: ^2.1.0

scripts/build_helpers/bin/build_dart.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Future<bool> _buildDart(String buildType) async {
178178
final result = await inDir('dart-sdk/sdk', () async {
179179
logger.i("Building libdart");
180180
var script = './tools/build.py';
181-
var args = ['--no-goma', '-m', buildType, 'libdart'];
181+
var args = ['-m', buildType, 'libdart'];
182182
var command = script;
183183
if (Platform.isWindows) {
184184
command = 'python';

0 commit comments

Comments
 (0)