Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Sep 20, 2023
1 parent 7013922 commit 2344bae
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ runs:
shell: bash

- name: Build version
run: dart pub global run grinder:grind build-version
run: dart pub global run grinder:grinder build-version
shell: bash

- name: Analyze
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ runs:
shell: bash

- name: Run tests
run: dart pub global run grinder:grind test
run: dart pub global run grinder:grinder test
shell: bash
58 changes: 58 additions & 0 deletions bin/compile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import 'dart:io';

Future<void> main() async {
const package = 'fvm'; // Your package name
const destination =
'/usr/local/bin'; // system location for user installed binaries

// Identify the operating system
var os = Platform.operatingSystem;

if (os != 'macos' && os != 'linux') {
print('Unsupported OS. Only MacOS and Linux are supported.');
return;
}

// Get temporary directory
var tempDir = await Directory.systemTemp.createTemp('fvm-compile');

var tempFile = File('${tempDir.path}/$package-$os');

// Compile the package to native executable
print('Compiling package...');
final compileResult = await Process.run(
'dart',
['compile', 'exe', 'bin/fvm.dart', '-o', tempFile.path],
);

// Error checking for compile process
if (compileResult.exitCode != 0) {
print('Error occurred in compilation:\n ${compileResult.stderr}');
return;
}

print('Compilation successful.');
print('Moving compiled package to destination...');

// Move the compiled executable to desired directory

// Make sure your Dart application has the necessary permissions for this operation
if (await tempFile.exists()) {
await tempFile.rename('$destination/$package');
print('Executable moved successfully');
} else {
print('Failed moving the binary. File does not exist.');
}

// Clean up the temp directory
await tempDir.delete();

// Deactivate current globally activated version of FVM
final deactivateResult =
await Process.run('dart', ['pub', 'global', 'deactivate', 'fvm']);
if (deactivateResult.exitCode == 0) {
print('Deactivated current global version of FVM successfully');
} else {
print('Error during the deactivation of the global FVM version');
}
}
20 changes: 0 additions & 20 deletions bin/flutter_select.dart

This file was deleted.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:

executables:
fvm: fvm
flutter-select: flutter_select
fvm-compile: compile

dependencies:
args: ^2.4.2
Expand Down

0 comments on commit 2344bae

Please sign in to comment.