Skip to content

Commit

Permalink
Add chmod for datagen
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Aug 23, 2024
1 parent 48e8fcd commit bf4cf65
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 30 deletions.
29 changes: 0 additions & 29 deletions pkgs/intl4x/hook/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -413,32 +413,3 @@ Future<void> copyFile(String from, Uri to) async {
}
await file.copy(to.toFilePath(windows: Platform.isWindows));
}

Future<void> runProcess(
String executable,
List<String> arguments, {
required String workingDirectory,
bool dryRun = false,
}) async {
print('----------');
print('Running `$executable $arguments` in $workingDirectory');
if (!dryRun) {
final processResult = await Process.run(
executable,
arguments,
workingDirectory: workingDirectory,
);
print('stdout:');
print(processResult.stdout);
if ((processResult.stderr as String).isNotEmpty) {
print('stderr:');
print(processResult.stderr);
}
if (processResult.exitCode != 0) {
throw ProcessException(executable, arguments, '', processResult.exitCode);
}
} else {
print('Not running, as --dry-run is set.');
}
print('==========');
}
7 changes: 6 additions & 1 deletion pkgs/intl4x/hook/link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ void main(List<String> arguments) {
config.assets.firstWhere((asset) => asset.id.endsWith('datagen'));
final dylib = output.assets.first;

await Process.run(datagenTool.file!.toFilePath(), [
final datagen = datagenTool.file!.toFilePath();
if (OS.current == OS.linux) {
await runProcess('chmod', ['+x', datagen]);
}

await Process.run(datagen, [
'--locales',
(await _customLocales ?? locales).join(','),
'--input',
Expand Down
31 changes: 31 additions & 0 deletions pkgs/intl4x/lib/src/hook_helpers/shared.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,36 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io';

const package = 'intl4x';
const assetId = 'src/bindings/lib.g.dart';

Future<void> runProcess(
String executable,
List<String> arguments, {
String? workingDirectory,
bool dryRun = false,
}) async {
print('----------');
print('Running `$executable $arguments` in $workingDirectory');
if (!dryRun) {
final processResult = await Process.run(
executable,
arguments,
workingDirectory: workingDirectory,
);
print('stdout:');
print(processResult.stdout);
if ((processResult.stderr as String).isNotEmpty) {
print('stderr:');
print(processResult.stderr);
}
if (processResult.exitCode != 0) {
throw ProcessException(executable, arguments, '', processResult.exitCode);
}
} else {
print('Not running, as --dry-run is set.');
}
print('==========');
}

0 comments on commit bf4cf65

Please sign in to comment.