Skip to content

Commit 5b8d25d

Browse files
committed
build_helpers commandline enable debug log
1 parent 5bedf77 commit 5b8d25d

File tree

6 files changed

+58
-22
lines changed

6 files changed

+58
-22
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- run: dart pub get
2828
working-directory: ./scripts/build_helpers
2929
- name: Build Dart
30-
run: dart ./scripts/build_helpers/bin/build_dart.dart
30+
run: dart ./scripts/build_helpers/bin/build_dart.dart -v
3131
- uses: threeal/[email protected]
3232
- name: Build Shared Library
3333
run: cmake --build build --config release

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ You need:
2828
* git
2929
* Dart 3+
3030
* C++ build tools for your platform (Visual Studio, XCode, gcc, etc)
31-
* For Windows VS 2019 16.61 with 10.0.20348.0 SDK don't forget install Debugger Tools
31+
* For Windows
32+
* 2019 16.61 with 10.0.20348.0 SDK don't forget install Debugger Tools
33+
* 2022 17 with ? SDK don't forget install Debugger Tools
34+
* 2017 15 with ? SDK don't forget install Debugger Tools
35+
* see dart-sdk\sdk\build\vs_toolchain.py
3236
* CMake
3337

3438
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
3943
> This will set up some environment variables that will be needed to build Dart properly.
4044
4145
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.
46+
build_dart commandline
47+
* -v -> Verbose Log
48+
* -t -> Build Type all, release, debug
4249

4350
```bash
4451
cd ./scripts/build_helpers

examples/simple_example/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@ add_custom_command(TARGET simple_example POST_BUILD
1515
COMMAND_EXPAND_LISTS
1616
)
1717

18-
target_link_libraries(simple_example PUBLIC dart_dll)
18+
add_dependencies(simple_example ALWAYS_DO_POST_BUILD)
19+
20+
target_link_libraries(simple_example PUBLIC dart_dll)
21+
22+
if (MSVC)
23+
set_property(TARGET simple_example PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<TARGET_FILE_DIR:simple_example>)
24+
endif()

scripts/build_helpers/bin/build_dart.dart

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,33 @@ import 'package:path/path.dart' as path;
88

99
void main(List<String> args) async {
1010
final parser = ArgParser();
11-
parser.addFlag('verbose', abbr: 'v');
11+
parser.addFlag('verbose', abbr: 'v', help: 'enable all debug');
12+
parser.addOption('buildType',
13+
abbr: 't',
14+
help: 'build typ release or debug. all for both',
15+
allowed: ['all', 'debug', 'release']);
16+
17+
ArgResults? argResults;
18+
try {
19+
argResults = parser.parse(args);
20+
} catch (error) {
21+
if (error is! FormatException) rethrow;
22+
print(parser.usage);
23+
exit(-1);
24+
}
1225

13-
final argResults = parser.parse(args);
1426
Level logLevel = Level.info;
1527
if (argResults['verbose'] == true) {
16-
logLevel = Level.debug;
28+
logLevel = Level.all;
1729
}
18-
BuildToolsLogger.initLogger(logLevel: logLevel);
30+
31+
BuildToolsLogger.initLogger(
32+
logLevel: logLevel,
33+
);
34+
35+
String buildType = argResults['buildType'] ?? "all";
36+
37+
BuildToolsLogger.shared.d('Build Typ $buildType');
1938

2039
if (!checkRightDirectory()) {
2140
// Not run from root. Exit.
@@ -47,11 +66,21 @@ void main(List<String> args) async {
4766
exit(-1);
4867
}
4968

50-
if (!await _buildDart('release')) {
51-
exit(-1);
52-
}
53-
if (!await _buildDart('debug')) {
54-
exit(-1);
69+
if (buildType == "all") {
70+
if (!await _buildDart('release')) {
71+
exit(-1);
72+
}
73+
if (!await _buildDart('debug')) {
74+
exit(-1);
75+
}
76+
} else if (buildType == "release") {
77+
if (!await _buildDart('release')) {
78+
exit(-1);
79+
}
80+
} else if (buildType == "debug") {
81+
if (!await _buildDart('debug')) {
82+
exit(-1);
83+
}
5584
}
5685
} catch (e) {
5786
BuildToolsLogger.shared.f('Caught an exception building the Dart SDK:');
@@ -128,7 +157,7 @@ Future<bool> _patchDartSdk() async {
128157
logger.i("Patching the Dart SDK to create libdart");
129158
var result = await Process.run('git', ['apply', '../../dart_sdk.patch'],
130159
runInShell: true);
131-
logger.d(result.stdout);
160+
logger.d('Patch result is ${result.exitCode}');
132161
return result.exitCode;
133162
});
134163
if (result != 0) {
@@ -140,6 +169,7 @@ Future<bool> _patchDartSdk() async {
140169

141170
Future<bool> _buildDart(String buildType) async {
142171
final logger = BuildToolsLogger.shared;
172+
logger.d('starting build for $buildType');
143173
final result = await inDir('dart-sdk/sdk', () async {
144174
logger.i("Building libdart");
145175
var script = './tools/build.py';

scripts/build_helpers/lib/build_helpers.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ class BuildToolsLogger {
1515
}
1616

1717
static Logger initLogger({Level logLevel = Level.info}) {
18-
return Logger(
18+
_shared = Logger(
1919
filter: ProductionFilter(),
2020
level: logLevel,
2121
printer: SimplePrinter(),
2222
);
23+
return shared;
2324
}
2425
}
2526

src/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ find_library(LIB_DART_RELEASE
3434
HINTS "${DART_DIR}/out/ReleaseX64/obj/runtime/bin" "${DART_DIR}/xcodebuild/ReleaseX64/obj/runtime/bin"
3535
)
3636

37-
add_custom_command(TARGET dart_dll
38-
# On Visual Studio Generators, run before any other rules are executed within the target. On other generators, run just before PRE_LINK commands
39-
PRE_BUILD
40-
COMMAND echo -e "\texecuting a PRE_BUILD command"
41-
COMMENT "Building Dart bevor Lib"
42-
VERBATIM # to support \t for example
43-
)
44-
4537
target_compile_definitions(dart_dll PRIVATE
4638
__STDC_LIMIT_MACROS
4739
__STDC_FORMAT_MACROS

0 commit comments

Comments
 (0)