From 61e57e2012ef28471e7196cd44e2bece4ade0488 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 7 Jun 2018 10:17:22 +0000 Subject: [PATCH] update_homebrew:dart: also make a dart@2, for Dart 2 migration This PR modifies update_homebrew to also generate a dart@2 versioned formula. The new file is dropped out right next to the old `dart.rb` file. The dart@2 formula is a temporary measure to aid application developers migrating from Dart 1 to Dart 2. Supersedes https://github.com/dart-lang/homebrew-dart/pull/52. This looks right by inspection, but I haven't been able to test it yet: my local `dart` environment is all messed up, and I am a Dart newbie. Still, I'm putting this out here as a PR so the discussion from https://github.com/dart-lang/homebrew-dart/pull/52 can proceed. Closes #33318 https://github.com/dart-lang/sdk/pull/33318 GitOrigin-RevId: 5230782aabf4f45199cff9b1fb9c5304e5dcb21c Change-Id: I78cf5b066d85ac8b0ef51ed44e6eb1a15192b23c Reviewed-on: https://dart-review.googlesource.com/58120 Commit-Queue: William Hesse Reviewed-by: William Hesse --- .../update_homebrew/lib/update_homebrew.dart | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tools/apps/update_homebrew/lib/update_homebrew.dart b/tools/apps/update_homebrew/lib/update_homebrew.dart index 0d2fcbb4703..3db0e684781 100644 --- a/tools/apps/update_homebrew/lib/update_homebrew.dart +++ b/tools/apps/update_homebrew/lib/update_homebrew.dart @@ -23,6 +23,7 @@ const dartiumFile = 'dartium/dartium-macos-x64-release.zip'; const contentShellFile = 'dartium/content_shell-macos-x64-release.zip'; const dartRbFileName = 'dart.rb'; +const dart2RbFileName = 'dart@2.rb'; Future getHash256( String channel, String revision, String download) async { @@ -107,6 +108,9 @@ Future writeHomebrewInfo( await new File(p.join(repository, dartRbFileName)).writeAsString( createDartFormula(revisions, hashes, devVersion, stableVersion), flush: true); + await new File(p.join(repository, dart2RbFileName)).writeAsString( + createDart2Formula(revisions, hashes, devVersion, stableVersion), + flush: true); } String createDartFormula( @@ -200,6 +204,61 @@ class Dart < Formula end '''; +/// TODO: Remove this formula after Dart 2 is released as stable. +/// This is a transitional mechanism to support developers migrating +/// from Dart 1 to Dart 2 while it's in pre-release. +String createDart2Formula( + Map revisions, Map hashes, String devVersion, String stableVersion) => + ''' +class DartAT2 < Formula + desc "The Dart 2 SDK" + homepage "https://www.dartlang.org/" + version "$devVersion" + + keg_only :versioned_formula + + if MacOS.prefer_64_bit? + url "$urlBase/dev/release/${revisions['dev']}/$x64File" + sha256 "${hashes['dev'][x64File]}" + else + url "$urlBase/dev/release/${revisions['dev']}/$ia32File" + sha256 "${hashes['dev'][ia32File]}" + end + + def install + libexec.install Dir["*"] + bin.install_symlink "#{libexec}/bin/dart" + bin.write_exec_script Dir["#{libexec}/bin/{pub,dart?*}"] + end + + def shim_script(target) + <<~EOS + #!/usr/bin/env bash + exec "#{prefix}/#{target}" "$@" + EOS + end + + def caveats; <<~EOS + Note that this is a prerelease version of Dart. + + Please note the path to the Dart SDK: + #{opt_libexec} + EOS + end + + test do + (testpath/"sample.dart").write <<~EOS + void main() { + print(r"test message"); + } + EOS + + assert_equal "test message\n", shell_output("#{bin}/dart sample.dart") + end +end +'''; + + Future runGit(List args, String repository, Map gitEnvironment) async { print("git ${args.join(' ')}");