-
Notifications
You must be signed in to change notification settings - Fork 12
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
Changes from 4 commits
f010d0c
af305ac
5bedf77
5b8d25d
37f1e07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/[email protected] | ||
- name: Build Shared Library | ||
run: cmake --build build --config release | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dart-sdk/* | ||
.build/* | ||
build/* | ||
artifacts/* |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,10 @@ add_custom_command(TARGET simple_example POST_BUILD | |
COMMAND_EXPAND_LISTS | ||
) | ||
|
||
target_link_libraries(simple_example PUBLIC dart_dll) | ||
add_dependencies(simple_example ALWAYS_DO_POST_BUILD) | ||
|
||
target_link_libraries(simple_example PUBLIC dart_dll) | ||
|
||
if (MSVC) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have to wrap this in MSVC? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No i build with VSCode but you have it on other samples why not in simple ? my practice is put the output too an bin folder i no that makes small count of developer it is easier to wirte launch.json for debugging There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, to be honest I'm not as good with CMake as I'd like, so I'm not surprised there are weird issues. I'll leave this in if it's working for you and take another pass at the CMake files at some point. |
||
set_property(TARGET simple_example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:simple_example>) | ||
endif() |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,33 @@ import 'package:path/path.dart' as path; | |
|
||
void main(List<String> 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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the default should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default working without ?? all i think. it looks on my tests now |
||
|
||
BuildToolsLogger.shared.d('Build Typ $buildType'); | ||
|
||
if (!checkRightDirectory()) { | ||
// Not run from root. Exit. | ||
|
@@ -47,8 +66,21 @@ void main(List<String> args) async { | |
exit(-1); | ||
} | ||
|
||
if (!await _buildDart()) { | ||
exit(-1); | ||
if (buildType == "all") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there's a simpler way to do this. I'll take a stab at it and modify the PR this evening. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's my stab at supporting multiple targets: https://github.com/fuzzybinary/dart_shared_libray/blob/987261ef05376b1d1dea0dbd4bbcab23ae5c9f86/scripts/build_helpers/bin/build_dart.dart#L12 |
||
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:'); | ||
|
@@ -125,7 +157,7 @@ Future<bool> _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) { | ||
|
@@ -135,12 +167,13 @@ Future<bool> _patchDartSdk() async { | |
return result == 0; | ||
} | ||
|
||
Future<bool> _buildDart() async { | ||
Future<bool> _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'; | ||
var args = ['--no-goma', '-m', 'release', 'libdart']; | ||
var args = ['--no-goma', '-m', buildType, 'libdart']; | ||
var command = script; | ||
if (Platform.isWindows) { | ||
command = 'python'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,12 @@ class BuildToolsLogger { | |
} | ||
|
||
static Logger initLogger({Level logLevel = Level.info}) { | ||
return Logger( | ||
_shared = Logger( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please Debug your Code. Without this the shared Logger hast always the Level Info so the Init do not work final logger = BuildToolsLogger.shared; static Logger get shared { Add First Call shared ist null and creates new one with default level. so i Init in Init... |
||
filter: ProductionFilter(), | ||
level: logLevel, | ||
printer: SimplePrinter(), | ||
); | ||
return shared; | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the windows SDK is always going to be the same, so I think the answer is VS 2019+ with Windows SDK 10.0.20348.0