|
| 1 | +# Track Chrome stable. |
| 2 | +# https://omahaproxy.appspot.com/ |
| 3 | +class V8 < Formula |
| 4 | + desc "Google's JavaScript engine" |
| 5 | + homepage "https://code.google.com/p/v8/" |
| 6 | + url "https://chromium.googlesource.com/v8/v8.git/+archive/5.2.371.tar.gz" |
| 7 | + sha256 "526134c9f543def42e96ab55fb9ef4b0f5f741aa755d9dad59cad1120dcda0f7" |
| 8 | + head "https://chromium.googlesource.com/v8/v8.git" |
| 9 | + |
| 10 | + bottle do |
| 11 | + cellar :any |
| 12 | + end |
| 13 | + |
| 14 | + option "with-readline", "Use readline instead of libedit" |
| 15 | + |
| 16 | + # not building on Snow Leopard: |
| 17 | + # https://github.com/Homebrew/homebrew/issues/21426 |
| 18 | + depends_on :macos => :lion |
| 19 | + |
| 20 | + depends_on :python => :build # gyp doesn't run under 2.6 or lower |
| 21 | + depends_on "readline" => :optional |
| 22 | + depends_on "icu4c" => :recommended |
| 23 | + |
| 24 | + needs :cxx11 |
| 25 | + |
| 26 | + # Update from "DEPS" file in tarball. |
| 27 | + |
| 28 | + # resources definition, do not edit, autogenerated |
| 29 | + |
| 30 | + resource "mozilla-tests" do |
| 31 | + url "https://chromium.googlesource.com/v8/deps/third_party/mozilla-tests.git", |
| 32 | + :revision => "f6c578a10ea707b1a8ab0b88943fe5115ce2b9be" |
| 33 | + end |
| 34 | + |
| 35 | + resource "buildtools" do |
| 36 | + url "https://chromium.googlesource.com/chromium/buildtools.git", |
| 37 | + :revision => "06e80a0e17319868d4a9b13f9bb6a248dc8d8b20" |
| 38 | + end |
| 39 | + |
| 40 | + resource "ecmascript_simd" do |
| 41 | + url "https://chromium.googlesource.com/external/github.com/tc39/ecmascript_simd.git", |
| 42 | + :revision => "c8ef63c728283debc25891123eb00482fee4b8cd" |
| 43 | + end |
| 44 | + |
| 45 | + resource "googlemock" do |
| 46 | + url "https://chromium.googlesource.com/external/googlemock.git", |
| 47 | + :revision => "0421b6f358139f02e102c9c332ce19a33faf75be" |
| 48 | + end |
| 49 | + |
| 50 | + resource "clang" do |
| 51 | + url "https://chromium.googlesource.com/chromium/src/tools/clang.git", |
| 52 | + :revision => "996bab489f816e51dde704bd215fb3403919f07e" |
| 53 | + end |
| 54 | + |
| 55 | + resource "googletest" do |
| 56 | + url "https://chromium.googlesource.com/external/github.com/google/googletest.git", |
| 57 | + :revision => "6f8a66431cb592dad629028a50b3dd418a408c87" |
| 58 | + end |
| 59 | + |
| 60 | + resource "common" do |
| 61 | + url "https://chromium.googlesource.com/chromium/src/base/trace_event/common.git", |
| 62 | + :revision => "54b8455be9505c2cb0cf5c26bb86739c236471aa" |
| 63 | + end |
| 64 | + |
| 65 | + resource "benchmarks" do |
| 66 | + url "https://chromium.googlesource.com/v8/deps/third_party/benchmarks.git", |
| 67 | + :revision => "05d7188267b4560491ff9155c5ee13e207ecd65f" |
| 68 | + end |
| 69 | + |
| 70 | + resource "gyp" do |
| 71 | + url "https://chromium.googlesource.com/external/gyp.git", |
| 72 | + :revision => "bce1c7793010574d88d7915e2d55395213ac63d1" |
| 73 | + end |
| 74 | + |
| 75 | + resource "test262" do |
| 76 | + url "https://chromium.googlesource.com/external/github.com/tc39/test262.git", |
| 77 | + :revision => "9c45e2ac684bae64614d8eb55789cae97323a7e7" |
| 78 | + end |
| 79 | + |
| 80 | + resource "swarming" do |
| 81 | + url "https://chromium.googlesource.com/external/swarming.client.git", |
| 82 | + :revision => "df6e95e7669883c8fe9ef956c69a544154701a49" |
| 83 | + end |
| 84 | + |
| 85 | + resource "icu" do |
| 86 | + url "https://chromium.googlesource.com/chromium/deps/icu.git", |
| 87 | + :revision => "c291cde264469b20ca969ce8832088acb21e0c48" |
| 88 | + end |
| 89 | + |
| 90 | + resource "build" do |
| 91 | + url "https://chromium.googlesource.com/chromium/src/build.git", |
| 92 | + :revision => "b2d15686436cdc17f67c3621c314f8d96b5b6fd9" |
| 93 | + end |
| 94 | + |
| 95 | + def install |
| 96 | + # Bully GYP into correctly linking with c++11 |
| 97 | + ENV.cxx11 |
| 98 | + ENV["GYP_DEFINES"] = "clang=1 mac_deployment_target=#{MacOS.version}" |
| 99 | + # https://code.google.com/p/v8/issues/detail?id=4511#c3 |
| 100 | + ENV.append "GYP_DEFINES", "v8_use_external_startup_data=0" |
| 101 | + |
| 102 | + if build.with? "icu4c" |
| 103 | + ENV.append "GYP_DEFINES", "use_system_icu=1" |
| 104 | + i18nsupport = "i18nsupport=on" |
| 105 | + else |
| 106 | + i18nsupport = "i18nsupport=off" |
| 107 | + end |
| 108 | + |
| 109 | + # fix up libv8.dylib install_name |
| 110 | + # https://github.com/Homebrew/homebrew/issues/36571 |
| 111 | + # https://code.google.com/p/v8/issues/detail?id=3871 |
| 112 | + inreplace "src/v8.gyp", |
| 113 | + "'OTHER_LDFLAGS': ['-dynamiclib', '-all_load']", |
| 114 | + "\\0, 'DYLIB_INSTALL_NAME_BASE': '#{opt_lib}'" |
| 115 | + |
| 116 | + # fix gyp: Error importing pymod_do_mainmodule (detect_v8_host_arch): No module named detect_v8_host_arch |
| 117 | + # https://groups.google.com/forum/#!topic/v8-dev/T8CTU6n5EQw |
| 118 | + inreplace "Makefile", |
| 119 | + 'PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/tools/gyp/pylib:$(PYTHONPATH)"', |
| 120 | + 'PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(shell pwd)/gypfiles:$(PYTHONPATH):$(shell pwd)/tools/gyp/pylib:$(PYTHONPATH)"' |
| 121 | + |
| 122 | + # resources installation, do not edit, autogenerated |
| 123 | + (buildpath/"test/mozilla/data").install resource("mozilla-tests") |
| 124 | + (buildpath/"buildtools").install resource("buildtools") |
| 125 | + (buildpath/"test/simdjs/data").install resource("ecmascript_simd") |
| 126 | + (buildpath/"testing/gmock").install resource("googlemock") |
| 127 | + (buildpath/"tools/clang").install resource("clang") |
| 128 | + (buildpath/"testing/gtest").install resource("googletest") |
| 129 | + (buildpath/"base/trace_event/common").install resource("common") |
| 130 | + (buildpath/"test/benchmarks/data").install resource("benchmarks") |
| 131 | + (buildpath/"tools/gyp").install resource("gyp") |
| 132 | + (buildpath/"test/test262/data").install resource("test262") |
| 133 | + (buildpath/"tools/swarming_client").install resource("swarming") |
| 134 | + (buildpath/"third_party/icu").install resource("icu") |
| 135 | + (buildpath/"build").install resource("build") |
| 136 | + |
| 137 | + system "make", "native", "library=shared", "snapshot=on", |
| 138 | + "console=readline", i18nsupport, |
| 139 | + "strictaliasing=off" |
| 140 | + |
| 141 | + include.install Dir["include/*"] |
| 142 | + |
| 143 | + cd "out/native" do |
| 144 | + rm ["libgmock.a", "libgtest.a"] |
| 145 | + lib.install Dir["lib*"] |
| 146 | + bin.install "d8", "mksnapshot", "process", "v8_shell" => "v8" |
| 147 | + end |
| 148 | + end |
| 149 | + |
| 150 | + test do |
| 151 | + assert_equal "Hello World!", pipe_output("#{bin}/v8 -e 'print(\"Hello World!\")'").chomp |
| 152 | + end |
| 153 | +end |
0 commit comments