Skip to content

Commit

Permalink
chore(mason): v0.1.0-dev.56 (#1336)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored May 29, 2024
1 parent 7a45b6e commit 7a0d79f
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 36 deletions.
5 changes: 5 additions & 0 deletions packages/mason/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.1.0-dev.56

- revert: fix: compile hooks to AOT when using AOT runtime ([#1331](https://github.com/felangel/mason/issues/1331))
- fix was incomplete and resulted in hook execution to break in JIT mode in some situations

# 0.1.0-dev.55

- fix: nested hooks execution ([#1334](https://github.com/felangel/mason/issues/1334))
Expand Down
11 changes: 1 addition & 10 deletions packages/mason/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ import 'package:pool/pool.dart';

part 'hooks.dart';

const bool _isProductMode = bool.fromEnvironment('dart.vm.product');
const _hookIsolateName = '__mason_hook__';
bool get _isHookIsolate => Isolate.current.debugName == _hookIsolateName;
bool get _useAot {
if (_isHookIsolate) return false;
return _isProductMode;
}

final _descriptorPool = Pool(32);
final _partialRegExp = RegExp(r'\{\{~\s(.+)\s\}\}');
final _fileRegExp = RegExp(r'{{%\s?([a-zA-Z]+)\s?%}}');
Expand Down Expand Up @@ -647,11 +639,10 @@ extension on HookFile {
}

File module(String checksum) {
final extension = _useAot ? 'aot' : 'dill';
return File(
p.join(
buildDirectory.path,
'${p.basenameWithoutExtension(path)}_$checksum.$extension',
'${p.basenameWithoutExtension(path)}_$checksum.dill',
),
);
}
Expand Down
4 changes: 1 addition & 3 deletions packages/mason/lib/src/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,10 @@ class GeneratorHooks {
final uri = await _getHookUri(hook, checksum);

if (uri == null) throw HookMissingRunException(hook.path);
final mode = _useAot ? 'aot-snapshot' : 'kernel';
final progress = logger?.progress('Compiling ${p.basename(hook.path)}');
final result = await Process.run(
'dart',
['compile', mode, uri.toFilePath()],
['compile', 'kernel', uri.toFilePath()],
runInShell: true,
);

Expand Down Expand Up @@ -314,7 +313,6 @@ class GeneratorHooks {
[json.encode(vars)],
messagePort.sendPort,
paused: true,
debugName: _hookIsolateName,
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/mason/lib/src/version.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/mason/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: mason
description: >
A Dart template generator which helps teams generate files quickly and consistently.
version: 0.1.0-dev.55
version: 0.1.0-dev.56
homepage: https://github.com/felangel/mason
repository: https://github.com/felangel/mason
issue_tracker: https://github.com/felangel/mason/issues
Expand Down
39 changes: 22 additions & 17 deletions packages/mason/test/src/hooks_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,28 @@ void main() {
expect(generator.hooks.preGen(), completes);
});

test('supports aot runtime', () async {
final tempDir = Directory.systemTemp.createTempSync();
final aotEntryPoint = path.join(tempDir.path, 'main-aot');
final compileResult = await Process.run(
'dart',
[
'compile',
'exe',
'-o',
aotEntryPoint,
path.join('test', 'fixtures', 'programmatic_usage', 'main.dart'),
],
);
expect(compileResult.exitCode, equals(ExitCode.success.code));
final runResult = await Process.run(aotEntryPoint, []);
expect(runResult.exitCode, equals(ExitCode.success.code));
});
test(
'supports aot runtime',
() async {
final tempDir = Directory.systemTemp.createTempSync();
final aotEntryPoint = path.join(tempDir.path, 'main-aot');
final compileResult = await Process.run(
'dart',
[
'compile',
'exe',
'-o',
aotEntryPoint,
path.join('test', 'fixtures', 'programmatic_usage', 'main.dart'),
],
);
expect(compileResult.exitCode, equals(ExitCode.success.code));
final runResult = await Process.run(aotEntryPoint, []);
expect(runResult.exitCode, equals(ExitCode.success.code));
},
// https://github.com/felangel/mason/issues/1329
skip: true,
);

test('supports jit runtime', () async {
final result = await Process.run(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ version: 0.1.0+1
# The following defines the environment for the current brick.
# It includes the version of mason that the brick requires.
environment:
mason: ">=0.1.0-dev.55 <0.1.0"
mason: ">=0.1.0-dev.56 <0.1.0"

# Variables specify dynamic values that your brick depends on.
# Zero or more variables can be specified for a given brick.
Expand Down
2 changes: 1 addition & 1 deletion packages/mason_cli/test/fixtures/new/hooks/brick.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ version: 0.1.0+1
# The following defines the environment for the current brick.
# It includes the version of mason that the brick requires.
environment:
mason: ">=0.1.0-dev.55 <0.1.0"
mason: ">=0.1.0-dev.56 <0.1.0"

# Variables specify dynamic values that your brick depends on.
# Zero or more variables can be specified for a given brick.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
mason: ">=0.1.0-dev.55 <0.1.0"
mason: ">=0.1.0-dev.56 <0.1.0"
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ version: 0.1.0+1
# The following defines the environment for the current brick.
# It includes the version of mason that the brick requires.
environment:
mason: ">=0.1.0-dev.55 <0.1.0"
mason: ">=0.1.0-dev.56 <0.1.0"

# Variables specify dynamic values that your brick depends on.
# Zero or more variables can be specified for a given brick.
Expand Down

0 comments on commit 7a0d79f

Please sign in to comment.