log to file for build.dart, check for SUCCESS token
This commit is contained in:
@@ -6,9 +6,19 @@ import 'package:native_toolchain_c/native_toolchain_c.dart';
|
||||
|
||||
void main(List<String> args) async {
|
||||
await build(args, (config, output) async {
|
||||
var logDir = Directory(
|
||||
"${config.packageRoot.toFilePath()}/.dart_tool/thermion_dart/log/");
|
||||
if (!logDir.existsSync()) {
|
||||
logDir.createSync();
|
||||
}
|
||||
var logFile = File(logDir.path + "/build.log");
|
||||
|
||||
final logger = Logger("")..level = Level.ALL
|
||||
..onRecord.listen((record) => print(record.message));
|
||||
final logger = Logger("")
|
||||
..level = Level.ALL
|
||||
..onRecord.listen((record) => logFile.writeAsStringSync(
|
||||
record.message + "\n",
|
||||
mode: FileMode.append,
|
||||
flush: true));
|
||||
|
||||
var platform = config.targetOS.toString().toLowerCase();
|
||||
|
||||
@@ -71,7 +81,7 @@ void main(List<String> args) async {
|
||||
} else {
|
||||
libs.add("stdc++");
|
||||
}
|
||||
final flags = [];
|
||||
final flags = []; //"-fsanitize=address"];
|
||||
final defines = <String, String?>{};
|
||||
var frameworks = [];
|
||||
|
||||
@@ -85,7 +95,15 @@ void main(List<String> args) async {
|
||||
}
|
||||
|
||||
if (platform == "ios") {
|
||||
frameworks.addAll(['Foundation', 'CoreGraphics', 'QuartzCore', 'GLKit', "Metal", 'CoreVideo', 'OpenGLES']);
|
||||
frameworks.addAll([
|
||||
'Foundation',
|
||||
'CoreGraphics',
|
||||
'QuartzCore',
|
||||
'GLKit',
|
||||
"Metal",
|
||||
'CoreVideo',
|
||||
'OpenGLES'
|
||||
]);
|
||||
} else if (platform == "macos") {
|
||||
frameworks.addAll([
|
||||
'Foundation',
|
||||
@@ -162,7 +180,7 @@ void main(List<String> args) async {
|
||||
});
|
||||
}
|
||||
|
||||
String _FILAMENT_VERSION ="v1.51.2";
|
||||
String _FILAMENT_VERSION = "v1.51.2";
|
||||
String _getLibraryUrl(String platform, String mode) {
|
||||
return "https://pub-c8b6266320924116aaddce03b5313c0a.r2.dev/filament-${_FILAMENT_VERSION}-${platform}-${mode}.zip";
|
||||
}
|
||||
@@ -171,7 +189,6 @@ String _getLibraryUrl(String platform, String mode) {
|
||||
// Download precompiled Filament libraries for the target platform from Cloudflare.
|
||||
//
|
||||
Future<Directory> getLibDir(BuildConfig config, Logger logger) async {
|
||||
|
||||
var platform = config.targetOS.toString().toLowerCase();
|
||||
|
||||
// Except on Windows, most users will only need release builds of Filament.
|
||||
@@ -183,11 +200,12 @@ Future<Directory> getLibDir(BuildConfig config, Logger logger) async {
|
||||
// However, if you know what you're doing, you can change "release" to "debug" below.
|
||||
// TODO - check if we can pass this as a CLI compiler flag
|
||||
var mode = "release";
|
||||
if(platform == "windows") {
|
||||
if (platform == "windows") {
|
||||
mode = config.buildMode == BuildMode.debug ? "debug" : "release";
|
||||
}
|
||||
|
||||
var libDir = Directory("${config.packageRoot.toFilePath()}/.dart_tool/thermion_dart/lib/${_FILAMENT_VERSION}/$platform/$mode/");
|
||||
var libDir = Directory(
|
||||
"${config.packageRoot.toFilePath()}/.dart_tool/thermion_dart/lib/${_FILAMENT_VERSION}/$platform/$mode/");
|
||||
|
||||
if (platform == "android") {
|
||||
final archExtension = switch (config.targetArchitecture) {
|
||||
@@ -198,9 +216,10 @@ Future<Directory> getLibDir(BuildConfig config, Logger logger) async {
|
||||
_ => throw FormatException('Invalid')
|
||||
};
|
||||
libDir = Directory("${libDir.path}/$archExtension/");
|
||||
} else if(platform == "windows") {
|
||||
if(config.targetArchitecture != Architecture.x64) {
|
||||
throw Exception("Unsupported architecture : ${config.targetArchitecture}");
|
||||
} else if (platform == "windows") {
|
||||
if (config.targetArchitecture != Architecture.x64) {
|
||||
throw Exception(
|
||||
"Unsupported architecture : ${config.targetArchitecture}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,22 +227,23 @@ Future<Directory> getLibDir(BuildConfig config, Logger logger) async {
|
||||
|
||||
final filename = url.split("/").last;
|
||||
|
||||
// Assume that the libraries exist if the directory containing them exists.
|
||||
if (!libDir.existsSync()) {
|
||||
|
||||
// We will write an empty file called success to the unzip directory after successfully downloading/extracting the prebuilt libraries.
|
||||
// If this file already exists, we assume everything has been successfully extracted and skip
|
||||
final unzipDir = platform == "android" ? libDir.parent.path : libDir.path;
|
||||
|
||||
final successToken = File("$unzipDir/success");
|
||||
final libraryZip = File("$unzipDir/$filename");
|
||||
|
||||
if(libraryZip.existsSync()) {
|
||||
if (!successToken.existsSync()) {
|
||||
if (libraryZip.existsSync()) {
|
||||
libraryZip.deleteSync();
|
||||
}
|
||||
|
||||
if(!libraryZip.parent.existsSync()) {
|
||||
if (!libraryZip.parent.existsSync()) {
|
||||
libraryZip.parent.createSync(recursive: true);
|
||||
}
|
||||
|
||||
logger.info("Downloading prebuilt libraries for $platform/$mode from $url to ${libraryZip}, files will be unzipped to ${unzipDir}");
|
||||
logger.info(
|
||||
"Downloading prebuilt libraries for $platform/$mode from $url to ${libraryZip}, files will be unzipped to ${unzipDir}");
|
||||
final request = await HttpClient().getUrl(Uri.parse(url));
|
||||
final response = await request.close();
|
||||
|
||||
@@ -243,6 +263,7 @@ Future<Directory> getLibDir(BuildConfig config, Logger logger) async {
|
||||
await d.create(recursive: true);
|
||||
}
|
||||
}
|
||||
successToken.writeAsStringSync("SUCCESS");
|
||||
}
|
||||
return libDir;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user