Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dart: support x86_64-darwin platform #105109

Merged
merged 1 commit into from Nov 28, 2020
Merged

Conversation

jtacoma
Copy link
Contributor

@jtacoma jtacoma commented Nov 27, 2020

Motivation for this change

Nix works on MacOS, Dart works on MacOS, so let's make Dart available through Nix on MacOS too. Later, we can do the same for Flutter.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS (n/a: only adding support for Darwin.)
    • macOS
      $ cat /etc/nix/nix.conf
      build-users-group = nixbld
      sandbox = true
      $ for v in 1.24.3 2.7.2 2.10.0 2.9.0-4.0.dev 2.11.0-161.0.dev ; do
        nix-build -E "with import <nixpkgs> {}; callPackage ./default.nix {version=\"$v\";}"
        r="$r $v:$?"
      done ; echo "$r"
      /nix/store/mw3v7784iz85gp2rw8j1gld6qsjnwcji-dart-1.24.3
      /nix/store/pnzn2vdpp7m0xxmwlwnghq57fh2fkn6b-dart-2.7.2
      /nix/store/83pvpas75ancdfxrghw6lzkkzai3gim9-dart-2.10.0
      /nix/store/s0k4p9b8pxw0fd0pp4h0ziz1xx44dmz1-dart-2.9.0-4.0.dev
      /nix/store/76znscxn89433yc9n80hwh7p472czaky-dart-2.11.0-161.0.dev
       1.24.3:0 2.7.2:0 2.10.0:0 2.9.0-4.0.dev:0 2.11.0-161.0.dev:0
      
    • other Linux distributions (n/a: only adding support for Darwin.)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests) (n/a: there are no relevant tests yet.)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
    [...]
    No diff detected, stopping review...
    [...]
    
  • Tested execution of all binary files (usually in ./result/bin/)
    $ for v in 1.24.3 2.7.2 2.10.0 2.9.0-4.0.dev 2.11.0-161.0.dev ; do
        nix-build -E "with import <nixpkgs> {}; callPackage ./default.nix {version=\"$v\";}" && for f in result/bin/* ; do
          if [ -f $f ]; then
            $f --help 2>/dev/null 1>/dev/null || ( echo "\$ $f --help"; $f --help )
          fi
        done 
      done
    /nix/store/mw3v7784iz85gp2rw8j1gld6qsjnwcji-dart-1.24.3
    /nix/store/pnzn2vdpp7m0xxmwlwnghq57fh2fkn6b-dart-2.7.2
    /nix/store/83pvpas75ancdfxrghw6lzkkzai3gim9-dart-2.10.0
    $ result/bin/dartdevc --help
    Please specify the output file location. For example:
        -o PATH/TO/OUTPUT_FILE.js
    /nix/store/s0k4p9b8pxw0fd0pp4h0ziz1xx44dmz1-dart-2.9.0-4.0.dev
    $ result/bin/dartdevc --help
    Please specify the output file location. For example:
        -o PATH/TO/OUTPUT_FILE.js
    /nix/store/76znscxn89433yc9n80hwh7p472czaky-dart-2.11.0-161.0.dev
    $ result/bin/dartdevc --help
    Please specify the output file location. For example:
        -o PATH/TO/OUTPUT_FILE.js
    
  • Determined the impact on package closure size (by running nix path-info -S before and after)
    • (I'm not sure how to do that just yet!)
  • Ensured that relevant documentation is up to date (n/a: I searched and haven't found any relevant documentation.)
  • Fits CONTRIBUTING.md.

@jtacoma jtacoma marked this pull request as ready for review November 27, 2020 01:39
@ofborg ofborg bot added 6.topic: darwin Running or building packages on Darwin 8.has: package (new) labels Nov 27, 2020
@ofborg ofborg bot requested a review from GRBurst November 27, 2020 01:54
@SuperSandro2000 SuperSandro2000 marked this pull request as draft November 27, 2020 02:05
@SuperSandro2000 SuperSandro2000 marked this pull request as ready for review November 27, 2020 02:05
Copy link
Contributor

@lukegb lukegb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On darwin, tested (2.7.2 only):

$ echo "void main() { print('Hello, world'); }" > /tmp/helloworld.dart 
$ ./result/bin/dart /tmp/helloworld.dart 
Hello, world                          
$ ./result/bin/dart2native /tmp/helloworld.dart 
Generated: /tmp/helloworld.exe        
$ file /tmp/helloworld.exe                                                                                                                                                                                                                                                                                                                          
/tmp/helloworld.exe: Mach-O 64-bit executable x86_64
$ /tmp/helloworld.exe          
Hello, world
$ ./result/bin/dart2js /tmp/helloworld.dart                                                                                                                                                                                                                                                                                                         
Compiled 7,768,796 characters Dart to 11,800 characters JavaScript in 0.34 seconds
$ nix run -f . nodejs -c node ./out.js
Hello, world

LG

@lukegb
Copy link
Contributor

lukegb commented Nov 27, 2020

Also some drive-by tests of the other versions:

$ nix run '((import ./. {}).dart.override { version = "1.24.3"; })' -c dart /tmp/helloworld.dart  
[2 built, 0.0 MiB DL]
Hello, world
$ nix run '((import ./. {}).dart.override { version = "1.24.3"; })' -c dart --version
Dart VM version: 1.24.3 (Wed Dec 13 23:26:59 2017) on "macos_x64"

$ nix run '((import ./. {}).dart.override { version = "2.10.0"; })' -c dart /tmp/helloworld.dart  
[2 built, 0.0 MiB DL]
Hello, world
$ nix run '((import ./. {}).dart.override { version = "2.10.0"; })' -c dart --version
Dart SDK version: 2.10.0 (stable) (Mon Sep 28 09:21:23 2020 +0200) on "macos_x64"

$ nix run '((import ./. {}).dart.override { version = "2.9.0-4.0.dev"; })' -c dart /tmp/helloworld.dart  
[2 built, 0.0 MiB DL]
Hello, world
$ nix run '((import ./. {}).dart.override { version = "2.9.0-4.0.dev"; })' -c dart --version
Dart VM version: 2.9.0-4.0.dev (dev) (Tue Apr 28 09:41:22 2020 +0200) on "macos_x64"

$ nix run '((import ./. {}).dart.override { version = "2.11.0-161.0.dev"; })' -c dart /tmp/helloworld.dart  
[2 built, 0.0 MiB DL]
Hello, world
$ nix run '((import ./. {}).dart.override { version = "2.11.0-161.0.dev"; })' -c dart --version
Dart SDK version: 2.11.0-161.0.dev (dev) (Thu Sep 24 17:00:45 2020 -0700) on "macos_x64"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants