Skip to content

Commit

Permalink
Rename toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
csnewman committed May 30, 2024
1 parent 15c5316 commit f997e87
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 29 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:io';
import 'dart:math';

import 'package:go_native_toolchain/run_process.dart';
import './run_process.dart';
import 'package:logging/logging.dart';
import 'package:native_assets_cli/native_assets_cli.dart';

Expand Down Expand Up @@ -79,7 +79,7 @@ class GoBuilder {
};

String buildArch;
switch(buildConfig.targetArchitecture) {
switch (buildConfig.targetArchitecture) {
case Architecture.arm:
buildArch = "arm";
case Architecture.arm64:
Expand All @@ -93,7 +93,7 @@ class GoBuilder {
}

String buildOs;
switch(buildConfig.targetOS) {
switch (buildConfig.targetOS) {
case OS.windows:
buildOs = "windows";

Expand All @@ -106,10 +106,13 @@ class GoBuilder {
// The Android Gradle plugin does not honor API level 19 and 20 when
// invoking clang. Mimic that behavior here.
// See https://github.com/dart-lang/native/issues/171.
final minimumApi = buildConfig.targetArchitecture == Architecture.riscv64 ? 35 : 21;
final targetAndroidNdkApi = max(buildConfig.targetAndroidNdkApi!, minimumApi);
final minimumApi =
buildConfig.targetArchitecture == Architecture.riscv64 ? 35 : 21;
final targetAndroidNdkApi =
max(buildConfig.targetAndroidNdkApi!, minimumApi);

final cc = compiler.uri.resolve('./${androidNdkClangTargetFlags[buildConfig.targetArchitecture]!}$targetAndroidNdkApi-clang');
final cc = compiler.uri.resolve(
'./${androidNdkClangTargetFlags[buildConfig.targetArchitecture]!}$targetAndroidNdkApi-clang');
env["CC"] = cc.toFilePath();

case OS.iOS:
Expand Down Expand Up @@ -173,7 +176,8 @@ class GoBuilder {
file: libUri,
linkMode: linkMode,
os: buildConfig.targetOS,
architecture: buildConfig.dryRun ? null : buildConfig.targetArchitecture,
architecture:
buildConfig.dryRun ? null : buildConfig.targetArchitecture,
)
]);
}
Expand All @@ -191,10 +195,11 @@ class GoBuilder {
final sourceFiles = await Stream.fromIterable(sources)
.asyncExpand(
(path) => Directory(path.toFilePath())
.list(recursive: true)
.where((entry) => entry is File)
.map((file) => file.uri),
).toList();
.list(recursive: true)
.where((entry) => entry is File)
.map((file) => file.uri),
)
.toList();

buildOutput.addDependencies({
...sourceFiles,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,25 @@ Future<RunProcessResult> runProcess({
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen(captureOutput
? (s) {
logger?.fine(s);
stdoutBuffer.writeln(s);
}
: logger?.fine);
? (s) {
logger?.fine(s);
stdoutBuffer.writeln(s);
}
: logger?.fine);
final stderrSub = process.stderr
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen(captureOutput
? (s) {
logger?.severe(s);
stderrBuffer.writeln(s);
}
: logger?.severe);
? (s) {
logger?.severe(s);
stderrBuffer.writeln(s);
}
: logger?.severe);

final (exitCode, _, _) = await (
process.exitCode,
stdoutSub.asFuture<void>(),
stderrSub.asFuture<void>()
process.exitCode,
stdoutSub.asFuture<void>(),
stderrSub.asFuture<void>()
).wait;
final result = RunProcessResult(
pid: process.pid,
Expand All @@ -95,8 +95,8 @@ Future<RunProcessResult> runProcess({
executable.toFilePath(),
arguments,
"Full command string: '$commandString'.\n"
"Exit code: '$exitCode'.\n"
'For the output of the process check the logger output.',
"Exit code: '$exitCode'.\n"
'For the output of the process check the logger output.',
);
}
return result;
Expand Down Expand Up @@ -127,4 +127,4 @@ class RunProcessResult {
exitCode: $exitCode
stdout: $stdout
stderr: $stderr''';
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: go_native_toolchain
name: native_toolchain_go
description: A library to invoke the native Go compiler installed on the host machine.
version: 0.2.0
version: 0.3.0
repository: https://github.com/csnewman/flutter-go-bridge

environment:
Expand Down

0 comments on commit f997e87

Please sign in to comment.