Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
28 changes: 11 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,24 @@ jobs:
run: |
curl -sfL https://direnv.net/install.sh | bash
echo "$HOME/.local/bin" >> $GITHUB_PATH
# - name: Load environment variables
# run: |
# direnv allow .
# direnv export gha > "$GITHUB_ENV"

# # Codegen
# - name: Run codegen
# run: melos run codegen
# - name: Ensure there are no diffs from codegen
# run: git diff --exit-code
- name: Load environment variables
run: |
direnv allow .
direnv export gha > "$GITHUB_ENV"

# # Rust
# - name: Rust format
# run: cargo fmt --all --check
# - name: Rust lint
# run: cargo clippy -- -D warnings
# - name: Rust format
# run: cargo fmt --all --check
# - name: Rust tests
# run: cargo test

# # Dart/Flutter
# - name: Dart format
# run: dart format --set-exit-if-changed .
# - name: Dart lint
# run: flutter analyze --fatal-infos --fatal-warnings
# Dart/Flutter
- name: Dart lint
run: flutter analyze --fatal-infos --fatal-warnings
- name: Dart format
run: dart format --set-exit-if-changed .
# - name: Dart tests
# run: melos run test

Expand Down
61 changes: 61 additions & 0 deletions flake.lock

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

85 changes: 85 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
description = "native_toolchain_rs";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
};

outputs =
{
self,
nixpkgs,
utils,
}:
utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in
{
formatter = pkgs.nixfmt-tree;

devShells = {
default = pkgs.mkShell {
packages = with pkgs; [
# TODO flutter335 but at version where native assets works
rustup
llvmPackages_20.clangUseLLVM
];

env = {
RUST_BACKTRACE = "1";
};

shellHook = ''
export PATH=$HOME/.pub-cache/bin:$PATH
dart pub global activate melos
'';
};

android =
let
arch = builtins.head (builtins.split "-" system);
androidEnv = pkgs.androidenv.override { licenseAccepted = true; };
androidComposition = androidEnv.composeAndroidPackages {
platformVersions = [
"35"
"36"
];
buildToolsVersions = [ "35.0.0" ];
cmakeVersions = [ "3.22.1" ];
includeNDK = true;
ndkVersions = [ "27.0.12077973" ];

# For the emulator:
includeEmulator = true;
includeSystemImages = true;
systemImageTypes = [ "default" ];
abiVersions = [
{
"x86_64" = "x86_64";
"aarch64" = "arm64-v8a";
}
.${arch} or (throw "Unsupported architecture: ${arch}")
];
};
in
pkgs.mkShell {
packages = with pkgs; [
androidComposition.androidsdk
jdk17
];

env = rec {
ANDROID_HOME = "${androidComposition.androidsdk}/libexec/android-sdk";
ANDROID_NDK_ROOT = "${ANDROID_HOME}/ndk-bundle";
};
};
};
}
);
}
6 changes: 1 addition & 5 deletions lib/native_toolchain_rs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ final class RustBuilder {
tomlDocumentWrapperFactory: tomlDocumentWrapperFactory,
cargoManifestParser: cargoManifestParser,
toolchainTomlParser: toolchainTomlParser,
).run(
input: input,
output: output,
assetRouting: assetRouting,
);
).run(input: input, output: output, assetRouting: assetRouting);
}
}
5 changes: 1 addition & 4 deletions lib/src/build_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ final class RustBuildRunner {
'--target-dir',
outputDir,
if (!enableDefaultFeatures) '--no-default-features',
if (features.isNotEmpty) ...[
'--features',
features.join(','),
],
if (features.isNotEmpty) ...['--features', features.join(',')],
...extraCargoBuildArgs,
],
environment: {
Expand Down
10 changes: 2 additions & 8 deletions lib/src/toml_parsing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ final class CargoManifestParser {
() => manifest.walk<List<dynamic>>('lib.crate-type').cast<String>(),
]);

return (
crateName: crateName,
libCrateTypes: libCrateTypes,
);
return (crateName: crateName, libCrateTypes: libCrateTypes);
}
}

Expand Down Expand Up @@ -114,9 +111,6 @@ final class ToolchainTomlParser {
.toSet(),
]);

return (
channel: channel,
targets: targets,
);
return (channel: channel, targets: targets);
}
}