Skip to content

Commit

Permalink
🐛 Fix windows artifact deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzybinary committed Oct 9, 2023
1 parent 4770d1f commit 172f0c2
Showing 1 changed file with 48 additions and 44 deletions.
92 changes: 48 additions & 44 deletions scripts/build_helpers/bin/assemble_artifacts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
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);
}
}

0 comments on commit 172f0c2

Please sign in to comment.