Unverified Commit ae660ed7 authored by gilice's avatar gilice Committed by GitHub
Browse files

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: default avatarWeijia Wang <9713184+wegank@users.noreply.github.com>
Co-authored-by: default avatarSandro <sandro.jaeckel@gmail.com>
parent 922eede2
Loading
Loading
Loading
Loading
+31 −8
Original line number Diff line number Diff line
@@ -2,15 +2,17 @@
, 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
  {
    "${version}-aarch64-darwin" = fetchurl {
@@ -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;
  };
}
})
+1 −1
Original line number Diff line number Diff line
@@ -39153,7 +39153,7 @@ with pkgs;
  spdlog = spdlog_1;
  dart = callPackage ../development/interpreters/dart { };
  dart = callPackage ../development/compilers/dart { };
  httrack = callPackage ../tools/backup/httrack { };