From 39b79274c78039393a371287524ddffbdeb19566 Mon Sep 17 00:00:00 2001 From: Jeff Ward Date: Mon, 9 Oct 2023 09:25:41 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20windows=20artifact=20deplo?= =?UTF-8?q?yment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../build_helpers/bin/assemble_artifacts.dart | 92 ++++++++++--------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/scripts/build_helpers/bin/assemble_artifacts.dart b/scripts/build_helpers/bin/assemble_artifacts.dart index 8becb27..bdcd7e3 100644 --- a/scripts/build_helpers/bin/assemble_artifacts.dart +++ b/scripts/build_helpers/bin/assemble_artifacts.dart @@ -8,58 +8,62 @@ import 'package:logger/logger.dart'; import 'package:path/path.dart' as path; void main() { - if (!checkRightDirectory()) { - // Not run from root. Exit. - exit(-1); - } - // Always verbose - BuildToolsLogger.initLogger(logLevel: Level.debug); - - final dest = Directory('artifacts'); - dest.createSync(); - _copyIncludeFiles(dest); - _copyLibs(dest); + if (!checkRightDirectory()) { + // Not run from root. Exit. + exit(-1); + } + // Always verbose + BuildToolsLogger.initLogger(logLevel: Level.debug); + + final dest = Directory('artifacts'); + dest.createSync(); + _copyIncludeFiles(dest); + _copyLibs(dest); } void _copyIncludeFiles(Directory dest) { - final logger = BuildToolsLogger.shared; + final logger = BuildToolsLogger.shared; - final includePath = Directory('dart-sdk/sdk/runtime/include'); - if (!includePath.existsSync()) { - logger.f("Couldn't find Dart SDK include dir."); - exit(-1); - } + final includePath = Directory('dart-sdk/sdk/runtime/include'); + if (!includePath.existsSync()) { + logger.f("Couldn't find Dart SDK include dir."); + exit(-1); + } - const dartIncludeFiles = ['dart_api.h', 'dart_tools_api.h']; - Directory(path.join(dest.path, 'include')).createSync(recursive: true); - for (var dartIncludeFile in dartIncludeFiles) { - final file = File(path.join(includePath.path, dartIncludeFile)); - file.copySync(path.join(dest.path, 'include', dartIncludeFile)); - } + const dartIncludeFiles = ['dart_api.h', 'dart_tools_api.h']; + Directory(path.join(dest.path, 'include')).createSync(recursive: true); + for (var dartIncludeFile in dartIncludeFiles) { + final file = File(path.join(includePath.path, dartIncludeFile)); + final destPath = path.join(dest.path, 'include', dartIncludeFile); + logger.i(' ${file.path} => $destPath'); + file.copySync(destPath); + } - final dartDllHeader = File('src/dart_dll.h'); - dartDllHeader.copySync(path.join(dest.path, 'include', 'dart_dll.h')); + final dartDllHeader = File('src/dart_dll.h'); + dartDllHeader.copySync(path.join(dest.path, 'include', 'dart_dll.h')); } void _copyLibs(Directory dest) { - final logger = BuildToolsLogger.shared; + final logger = BuildToolsLogger.shared; + + final builtLibPath = Directory(path.join('.build', 'src')); + if (!builtLibPath.existsSync()) { + logger.f('Could not find built artifact path'); + } - final builtLibPath = Directory('build/src'); - if (!builtLibPath.existsSync()) { - logger.f('Could not find built artifact path'); - } - - final binDestPath = Directory(path.join(dest.path, 'bin')); - binDestPath.createSync(recursive: true); + final binDestPath = Directory(path.join(dest.path, 'bin')); + binDestPath.createSync(recursive: true); - var copyGlob = Glob('*.so'); - if (Platform.isWindows) { - copyGlob = Glob(path.join('Release', '*.*')); - } else if (Platform.isMacOS) { - copyGlob = Glob('*.dylib'); - } - final files = copyGlob.listSync(root: builtLibPath.path); - for (var file in files) { - (file as File).copySync(path.join(binDestPath.path, file.basename)); - } -} \ No newline at end of file + var copyGlob = Glob('*.so'); + if (Platform.isWindows) { + copyGlob = Glob(r'Release/*.*', caseSensitive: false); + } else if (Platform.isMacOS) { + copyGlob = Glob('*.dylib'); + } + final files = copyGlob.listSync(root: builtLibPath.path); + for (var file in files) { + final destPath = path.join(binDestPath.path, file.basename); + logger.i(' ${file.path} => $destPath'); + (file as File).copySync(destPath); + } +}