Skip to content

Commit 190918d

Browse files
committed
fix
1 parent 84204bf commit 190918d

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

binding/dart/bin/pack.dart

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ import '../lib/storage/lookup.dart';
66

77
import 'compile.dart';
88

9-
Future<void> main(List<String> args) async {
10-
if (args.isEmpty) {
9+
Future<void> main(List<String> arguments) async {
10+
if (arguments.isEmpty) {
1111
print(Messages.specifyDartEntryPoint);
1212
exit(1);
1313
}
1414
final root = Directory.current.uri;
15-
final entryPoint = File(args[0]);
15+
final entryPoint = File(arguments[0]);
1616
if (!entryPoint.existsSync()) {
1717
print(Messages.specifyDartEntryPoint);
1818
exit(1);
1919
}
20+
bool native = (arguments.length > 1 && arguments[1] == Arguments.native) || (arguments.length > 2 && arguments[2] == Arguments.native);
21+
bool lua = (arguments.length > 1 && arguments[1] == Arguments.lua) || (arguments.length > 2 && arguments[2] == Arguments.lua);
2022
final dotDartTool = findDotDartTool();
2123
if (dotDartTool == null) {
2224
print(Messages.runPubGet);
@@ -29,17 +31,21 @@ Future<void> main(List<String> args) async {
2931
}
3032
final projectName = basename(projectRoot);
3133
final packageRoot = findPackageRoot(dotDartTool);
32-
final packageNativeRoot = Directory(packageRoot.toFilePath() + Directories.native);
3334
final resultPackageRoot = Directory(root.toFilePath() + Directories.package);
3435
if (resultPackageRoot.existsSync()) resultPackageRoot.deleteSync(recursive: true);
35-
final nativeRoot = Directory(root.toFilePath() + Directories.native);
36-
final luaRoot = Directory(root.toFilePath() + Directories.lua);
37-
if (!resultPackageRoot.existsSync()) resultPackageRoot.createSync();
38-
if (luaRoot.existsSync()) copyLua(luaRoot, resultPackageRoot);
36+
if (native) {
37+
final packageNativeRoot = Directory(packageRoot.toFilePath() + Directories.native);
38+
final nativeRoot = Directory(root.toFilePath() + Directories.native);
39+
if (!resultPackageRoot.existsSync()) resultPackageRoot.createSync();
40+
copyLibrary(packageNativeRoot, resultPackageRoot);
41+
compileNative(nativeRoot, packageNativeRoot, projectName);
42+
if (nativeRoot.existsSync()) copyNative(nativeRoot, projectName, resultPackageRoot);
43+
}
44+
if (lua) {
45+
final luaRoot = Directory(root.toFilePath() + Directories.lua);
46+
if (luaRoot.existsSync()) copyLua(luaRoot, resultPackageRoot);
47+
}
3948
compileDart(resultPackageRoot, entryPoint);
40-
copyLibrary(packageNativeRoot, resultPackageRoot);
41-
compileNative(nativeRoot, packageNativeRoot, projectName);
42-
if (nativeRoot.existsSync()) copyNative(nativeRoot, projectName, resultPackageRoot);
4349
archive(resultPackageRoot, projectName);
4450
resultPackageRoot.deleteSync(recursive: true);
4551
}

binding/dart/bin/setup.dart

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,28 @@ import 'package:path/path.dart';
44
import '../lib/storage/constants.dart';
55
import '../lib/storage/lookup.dart';
66

7-
void main() {
7+
void main(List<String> arguments) {
8+
bool native = (arguments.length > 0 && arguments[0] == Arguments.native) || (arguments.length > 1 && arguments[1] == Arguments.native);
9+
bool lua = (arguments.length > 0 && arguments[0] == Arguments.lua) || (arguments.length > 1 && arguments[1] == Arguments.lua);
810
final root = Directory.current.uri;
911
final dotDartTool = findDotDartTool();
1012
if (dotDartTool == null) {
1113
print(Messages.runPubGet);
1214
exit(1);
1315
}
1416
final packageRoot = findPackageRoot(dotDartTool);
15-
final packageNativeRoot = Directory(packageRoot.toFilePath() + Directories.native);
16-
final nativeRoot = Directory(root.toFilePath() + Directories.native);
17-
if (!nativeRoot.existsSync()) nativeRoot.createSync();
18-
final packageLuaRoot = Directory(packageRoot.toFilePath() + Directories.lua);
19-
final luaRoot = Directory(root.toFilePath() + Directories.lua);
20-
if (!luaRoot.existsSync()) luaRoot.createSync();
21-
copyHeaders(packageNativeRoot, nativeRoot);
22-
copyLuaScrits(packageLuaRoot, luaRoot);
17+
if (native) {
18+
final packageNativeRoot = Directory(packageRoot.toFilePath() + Directories.native);
19+
final nativeRoot = Directory(root.toFilePath() + Directories.native);
20+
if (!nativeRoot.existsSync()) nativeRoot.createSync();
21+
copyHeaders(packageNativeRoot, nativeRoot);
22+
}
23+
if (lua) {
24+
final packageLuaRoot = Directory(packageRoot.toFilePath() + Directories.lua);
25+
final luaRoot = Directory(root.toFilePath() + Directories.lua);
26+
if (!luaRoot.existsSync()) luaRoot.createSync();
27+
copyLuaScrits(packageLuaRoot, luaRoot);
28+
}
2329
}
2430

2531
void copyHeaders(Directory packageNativeRoot, Directory nativeRoot) {

binding/dart/lib/storage/constants.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ class Directories {
114114
static const dotDartTool = ".dart_tool";
115115
}
116116

117+
class Arguments {
118+
const Arguments._();
119+
120+
static const native = "--native";
121+
static const lua = "--lua";
122+
}
123+
117124
class Messages {
118125
const Messages._();
119126

0 commit comments

Comments
 (0)