-
Notifications
You must be signed in to change notification settings - Fork 0
/
refresh_bindings.dart
80 lines (63 loc) · 2.01 KB
/
refresh_bindings.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/// This file is part of dart-qtbindings
///
/// SPDX-FileCopyrightText: 2022 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
/// SPDX-License-Identifier: MIT
/// This helper script generates the Qt bindings
import 'dart:io';
import 'utils.dart' as Utils;
import 'package:path/path.dart';
final String s_sourcePath = dirname(Platform.script.toFilePath());
Future<int> runCommand(String command, List<String> args,
{String? workingDirectory = null, Map<String, String>? env = null}) async {
print("Running: ${command} ${args.join(" ")}");
Process process = await Process.start(command, args,
workingDirectory: workingDirectory, environment: env)
.then((process) {
stderr.addStream(process.stderr);
stdout.addStream(process.stdout);
return process;
});
return await process.exitCode;
}
String generatedDir() {
return s_sourcePath + "/generated";
}
String testAppDir() {
return s_sourcePath + "/app";
}
String generatedFFICpp() {
return generatedDir() + "/" + "QtDartBindings/dart/ffi";
}
List<String> qtIncludes() {
return Utils.includeArguments();
}
void main(List<String> args_) async {
int res = await runCommand(
"dartagnan",
["--output-directory=${generatedDir()}", "--license-file=license-file-template"] +
qtIncludes() +
["bindings_global.h", "typesystem.xml"]);
if (res != 0) {
print("Error running dartagnan!");
exit(res);
}
/// If dartagnan already ran, then the tests don't need to
final bool runCodeFormat =
!Platform.environment.containsKey('DARTAGNAN_RUNS_CODE_FORMAT');
if (runCodeFormat) {
res = await Utils.runDartFormat(generatedDir());
if (res != 0) {
print("Error running dartfmt!");
exit(res);
}
res = await Utils.runClangFormat(generatedFFICpp());
if (res != 0) {
print("Error running clang-format!");
exit(res);
}
}
if (await Utils.getPackages(workingDirectory: testAppDir()) != 0) {
print("Error running dart pub get");
exit(res);
}
}