update build.dart to support windows
This commit is contained in:
@@ -20,9 +20,11 @@ void main(List<String> args) async {
|
|||||||
// However, if for some reason you need to debug a Filament-specific issue,
|
// However, if for some reason you need to debug a Filament-specific issue,
|
||||||
// you can build your own debug libraries, copy to the native/lib/android/debug folder, then change the following to "debug".
|
// you can build your own debug libraries, copy to the native/lib/android/debug folder, then change the following to "debug".
|
||||||
libDir += "release";
|
libDir += "release";
|
||||||
|
} else if (platform == "windows") {
|
||||||
|
libDir += "x86_64/mdd";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platform == "android" || platform == "windows") {
|
if (platform == "android") {
|
||||||
if (!config.dryRun) {
|
if (!config.dryRun) {
|
||||||
final archExtension = switch (config.targetArchitecture) {
|
final archExtension = switch (config.targetArchitecture) {
|
||||||
Architecture.arm => "armeabi-v7a",
|
Architecture.arm => "armeabi-v7a",
|
||||||
@@ -48,37 +50,63 @@ void main(List<String> args) async {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
final libs = [
|
final libs = [
|
||||||
"-lfilament",
|
"filament",
|
||||||
"-lbackend",
|
"backend",
|
||||||
"-lfilameshio",
|
"filameshio",
|
||||||
"-lviewer",
|
"viewer",
|
||||||
"-lfilamat",
|
"filamat",
|
||||||
"-lgeometry",
|
"geometry",
|
||||||
"-lutils",
|
"utils",
|
||||||
"-lfilabridge",
|
"filabridge",
|
||||||
"-lgltfio_core",
|
"gltfio_core",
|
||||||
"-lfilament-iblprefilter",
|
"filament-iblprefilter",
|
||||||
"-limage",
|
"image",
|
||||||
"-limageio",
|
"imageio",
|
||||||
"-ltinyexr",
|
"tinyexr",
|
||||||
"-lgltfio_core",
|
"gltfio_core",
|
||||||
"-lfilaflat",
|
"filaflat",
|
||||||
"-ldracodec",
|
"dracodec",
|
||||||
"-libl",
|
"ibl",
|
||||||
"-lktxreader",
|
"ktxreader",
|
||||||
"-lpng",
|
"png",
|
||||||
"-lz",
|
"z",
|
||||||
"-lstb",
|
"stb",
|
||||||
"-luberzlib",
|
"uberzlib",
|
||||||
"-lsmol-v",
|
"smol-v",
|
||||||
"-luberarchive",
|
"uberarchive",
|
||||||
"-lzstd",
|
"zstd",
|
||||||
"-lstdc++",
|
"basis_transcoder"
|
||||||
"-lbasis_transcoder"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
final linkWith = <String>[];
|
||||||
|
|
||||||
|
if (platform == "windows") {
|
||||||
|
linkWith.addAll(libs.map((lib) => "$libDir/$lib.lib"));
|
||||||
|
linkWith.addAll(["$libDir/bluevk.lib", "$libDir/bluegl.lib"]);
|
||||||
|
linkWith.addAll([
|
||||||
|
"gdi32.lib",
|
||||||
|
"user32.lib",
|
||||||
|
"shell32.lib",
|
||||||
|
"opengl32.lib",
|
||||||
|
"dwmapi.lib",
|
||||||
|
"comctl32.lib"
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
libs.add("stdc++");
|
||||||
|
}
|
||||||
|
final flags = [];
|
||||||
|
final defines = <String, String?>{};
|
||||||
var frameworks = [];
|
var frameworks = [];
|
||||||
|
|
||||||
|
if (platform != "windows") {
|
||||||
|
flags.addAll(['-std=c++17']);
|
||||||
|
} else {
|
||||||
|
defines["WIN32"] = "1";
|
||||||
|
defines["_DEBUG"] = "1";
|
||||||
|
defines["_DLL"] = "1";
|
||||||
|
flags.addAll(["/std:c++20", "/MDd"]);
|
||||||
|
}
|
||||||
|
|
||||||
if (platform == "ios") {
|
if (platform == "ios") {
|
||||||
frameworks.addAll([
|
frameworks.addAll([
|
||||||
'Foundation',
|
'Foundation',
|
||||||
@@ -96,9 +124,9 @@ void main(List<String> args) async {
|
|||||||
'Cocoa',
|
'Cocoa',
|
||||||
"Metal",
|
"Metal",
|
||||||
]);
|
]);
|
||||||
libs.addAll(["-lbluegl", "-lbluevk"]);
|
libs.addAll(["bluegl", "bluevk"]);
|
||||||
} else if (platform == "android") {
|
} else if (platform == "android") {
|
||||||
libs.addAll(["-lGLESv3", "-lEGL", "-lbluevk", "-ldl", "-landroid"]);
|
libs.addAll(["GLESv3", "EGL", "bluevk", "dl", "android"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
frameworks = frameworks.expand((f) => ["-framework", f]).toList();
|
frameworks = frameworks.expand((f) => ["-framework", f]).toList();
|
||||||
@@ -109,41 +137,72 @@ void main(List<String> args) async {
|
|||||||
assetName: 'dart_filament.dart',
|
assetName: 'dart_filament.dart',
|
||||||
sources: sources,
|
sources: sources,
|
||||||
includes: ['native/include', 'native/include/filament'],
|
includes: ['native/include', 'native/include/filament'],
|
||||||
|
defines: defines,
|
||||||
|
linkWith: linkWith,
|
||||||
flags: [
|
flags: [
|
||||||
'-std=c++17',
|
|
||||||
if (platform == "macos") '-mmacosx-version-min=13.0',
|
if (platform == "macos") '-mmacosx-version-min=13.0',
|
||||||
if (platform == "ios") '-mios-version-min=13.0',
|
if (platform == "ios") '-mios-version-min=13.0',
|
||||||
|
...flags,
|
||||||
...frameworks,
|
...frameworks,
|
||||||
...libs,
|
if (platform != "windows") ...libs.map((lib) => "-l$lib"),
|
||||||
"-L$libDir",
|
"-L$libDir",
|
||||||
],
|
],
|
||||||
dartBuildFiles: ['hook/build.dart'],
|
dartBuildFiles: ['hook/build.dart'],
|
||||||
);
|
);
|
||||||
|
|
||||||
await cbuilder.run(
|
await cbuilder.run(
|
||||||
buildConfig: config,
|
config: config,
|
||||||
buildOutput: output,
|
output: output,
|
||||||
logger: Logger('')
|
logger: Logger('')
|
||||||
..level = Level.ALL
|
..level = Level.ALL
|
||||||
..onRecord.listen((record) => print(record.message)),
|
..onRecord.listen((record) => print(record.message)),
|
||||||
);
|
);
|
||||||
if (!config.dryRun && config.targetOS == OS.android) {
|
if (config.targetOS == OS.android) {
|
||||||
final archExtension = switch (config.targetArchitecture) {
|
if (!config.dryRun) {
|
||||||
Architecture.arm => "arm-linux-androideabi",
|
final archExtension = switch (config.targetArchitecture) {
|
||||||
Architecture.arm64 => "aarch64-linux-android",
|
Architecture.arm => "arm-linux-androideabi",
|
||||||
Architecture.x64 => "x86_64-linux-android",
|
Architecture.arm64 => "aarch64-linux-android",
|
||||||
Architecture.ia32 => "i686-linux-android",
|
Architecture.x64 => "x86_64-linux-android",
|
||||||
_ => throw FormatException('Invalid')
|
Architecture.ia32 => "i686-linux-android",
|
||||||
};
|
_ => throw FormatException('Invalid')
|
||||||
var ndkRoot = File(config.cCompiler.compiler!.path).parent.parent.path;
|
};
|
||||||
var stlPath =
|
var ndkRoot = File(config.cCompiler.compiler!.path).parent.parent.path;
|
||||||
File("$ndkRoot/sysroot/usr/lib/${archExtension}/libc++_shared.so");
|
var stlPath =
|
||||||
output.addAsset(NativeCodeAsset(
|
File("$ndkRoot/sysroot/usr/lib/${archExtension}/libc++_shared.so");
|
||||||
package: "dart_filament",
|
output.addAsset(NativeCodeAsset(
|
||||||
name: "libc++_shared.so",
|
package: "dart_filament",
|
||||||
linkMode: DynamicLoadingBundled(),
|
name: "libc++_shared.so",
|
||||||
os: config.targetOS,
|
linkMode: DynamicLoadingBundled(),
|
||||||
file: stlPath.uri,
|
os: config.targetOS,
|
||||||
architecture: config.targetArchitecture));
|
file: stlPath.uri,
|
||||||
|
architecture: config.targetArchitecture));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (config.targetOS == "windows") {
|
||||||
|
final packageName = config.packageName;
|
||||||
|
final allAssets = [
|
||||||
|
DataAsset(
|
||||||
|
package: packageName,
|
||||||
|
name: 'unused_asset',
|
||||||
|
file: config.packageRoot.resolve('assets/unused_asset.json'),
|
||||||
|
),
|
||||||
|
DataAsset(
|
||||||
|
package: packageName,
|
||||||
|
name: 'used_asset',
|
||||||
|
file: config.packageRoot.resolve('assets/used_asset.json'),
|
||||||
|
)
|
||||||
|
];
|
||||||
|
output.addAssets(allAssets, linkInPackage: packageName);
|
||||||
|
output.addAsset(
|
||||||
|
NativeCodeAsset(
|
||||||
|
package: "dart_filament",
|
||||||
|
name: "dart_filament.dll",
|
||||||
|
linkMode: DynamicLoadingBundled(),
|
||||||
|
os: config.targetOS,
|
||||||
|
file: Uri.file(
|
||||||
|
config.outputDirectory.toFilePath() + "/dart_filament.dll"),
|
||||||
|
architecture: config.targetArchitecture),
|
||||||
|
linkInPackage: config.packageName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user