dart: 2.18.4 -> 2.19.3, refactor, and add tests (#219875)

* dart: 2.18.4 -> 2.19.3

https://dart.dev/guides/whats-new#january-25-2023-219--30-alpha-releases

* dart: move interpreters -> compilers

Dart is not an interpreted language by default. It can JIT compile, but
ultimately runs on a VM.
Languages which are similar in this regard, like Java and Go also
are sorted into interpreters.

* dart: add primitive tests

* dart: remove version override in sources

* dart: make codesign available in tests

* dart: format

---------

Co-authored-by: Weijia Wang <9713184+wegank@users.noreply.github.com>
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
This commit is contained in:
gilice 2023-03-16 13:25:34 +01:00 committed by GitHub
parent 922eede26b
commit ae660ed77e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 9 deletions

View file

@ -2,16 +2,18 @@
, lib
, fetchurl
, unzip
, version ? "2.18.0"
, runCommand
, darwin
# we need a way to build other dart versions
# than the latest, because flutter might want
# another version
, version ? "2.19.3"
, sources ? let
base = "https://storage.googleapis.com/dart-archive/channels";
x86_64 = "x64";
i686 = "ia32";
aarch64 = "arm64";
# Make sure that if the user overrides version parameter they're
# also need to override sources, to avoid mistakes
version = "2.18.0";
in
in
{
"${version}-aarch64-darwin" = fetchurl {
url = "${base}/stable/release/${version}/sdk/dartsdk-macos-${aarch64}-release.zip";
@ -39,7 +41,7 @@
assert version != null && version != "";
assert sources != null && (builtins.isAttrs sources);
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "dart";
inherit version;
@ -56,9 +58,30 @@ stdenv.mkDerivation {
'';
libPath = lib.makeLibraryPath [ stdenv.cc.cc ];
dontStrip = true;
passthru.tests = {
testCreate = runCommand "dart-test-create" { nativeBuildInputs = [ finalAttrs.finalPackage ]; } ''
PROJECTNAME="dart_test_project"
dart create --no-pub $PROJECTNAME
[[ -d $PROJECTNAME ]]
[[ -f $PROJECTNAME/bin/$PROJECTNAME.dart ]]
touch $out
'';
testCompile = runCommand "dart-test-compile" {
nativeBuildInputs = [ finalAttrs.finalPackage ]
++ lib.optionals stdenv.isDarwin [ darwin.cctools darwin.sigtool ];
} ''
HELLO_MESSAGE="Hello, world!"
echo "void main() => print('$HELLO_MESSAGE');" > hello.dart
dart compile exe hello.dart
PROGRAM_OUT=$(./hello.exe)
[[ "$PROGRAM_OUT" == "$HELLO_MESSAGE" ]]
touch $out
'';
};
meta = with lib; {
homepage = "https://www.dartlang.org/";
maintainers = with maintainers; [ grburst ];
@ -72,4 +95,4 @@ stdenv.mkDerivation {
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.bsd3;
};
}
})

View file

@ -39153,7 +39153,7 @@ with pkgs;
spdlog = spdlog_1;
dart = callPackage ../development/interpreters/dart { };
dart = callPackage ../development/compilers/dart { };
httrack = callPackage ../tools/backup/httrack { };