forked from Homebrew/homebrew-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gjs.rb
133 lines (118 loc) · 4.8 KB
/
gjs.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
class Gjs < Formula
desc "JavaScript Bindings for GNOME"
homepage "https://gitlab.gnome.org/GNOME/gjs/wikis/Home"
url "https://download.gnome.org/sources/gjs/1.68/gjs-1.68.0.tar.xz"
sha256 "f00e74a00e81ab61bb92669e0f1c8bb613cc019586097f06aed0572efcaf1aef"
license all_of: ["LGPL-2.0-or-later", "MIT"]
revision 1
bottle do
sha256 big_sur: "1e8638f3021ec9ca2f6ea9de615e7f148ee473c2e81238f7dd9769f7a3f48c14"
sha256 catalina: "3324cac672de14375a18665f8ab123a8ddb2e776b1c10c9855d82c73d3c7eae3"
sha256 mojave: "09da7913ef958dbb02938be3a60984a3e6eb11fcb824be4d3ec44fa91a5664b3"
end
depends_on "meson" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "python@3.8" => :build
depends_on "rust" => :build
depends_on "gobject-introspection"
depends_on "gtk+3"
depends_on "llvm"
depends_on "nspr"
depends_on "readline"
resource "autoconf@213" do
url "https://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz"
mirror "https://ftpmirror.gnu.org/autoconf/autoconf-2.13.tar.gz"
sha256 "f0611136bee505811e9ca11ca7ac188ef5323a8e2ef19cffd3edb3cf08fd791e"
end
resource "six" do
url "https://files.pythonhosted.org/packages/6b/34/415834bfdafca3c5f451532e8a8d9ba89a21c9743a0c59fbd0205c7f9426/six-1.15.0.tar.gz"
sha256 "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"
end
resource "mozjs78" do
url "https://archive.mozilla.org/pub/firefox/releases/78.8.0esr/source/firefox-78.8.0esr.source.tar.xz"
sha256 "1cf2dfdee2e31fd0a5ecced6275a33fa11bee1d2a7c65e23350b26992584a110"
end
def install
ENV.cxx11
resource("autoconf@213").stage do
system "./configure", "--disable-debug",
"--disable-dependency-tracking",
"--program-suffix=213",
"--prefix=#{buildpath}/autoconf",
"--infodir=#{buildpath}/autoconf/share/info",
"--datadir=#{buildpath}/autoconf/share"
system "make", "install"
end
resource("six").stage do
system Formula["python@3.8"].opt_bin/"python3", *Language::Python.setup_install_args(buildpath/"vendor")
end
resource("mozjs78").stage do
inreplace "build/moz.configure/toolchain.configure",
"sdk_max_version = Version('10.15.4')",
"sdk_max_version = Version('11.99')"
inreplace "config/rules.mk",
"-install_name $(_LOADER_PATH)/$(SHARED_LIBRARY) ",
"-install_name #{lib}/$(SHARED_LIBRARY) "
inreplace "old-configure", "-Wl,-executable_path,${DIST}/bin", ""
mkdir("build") do
xy = Language::Python.major_minor_version "python3"
ENV.prepend_create_path "PYTHONPATH", buildpath/"vendor/lib/python#{xy}/site-packages"
ENV["PYTHON"] = Formula["python@3.8"].opt_bin/"python3"
ENV["_MACOSX_DEPLOYMENT_TARGET"] = ENV["MACOSX_DEPLOYMENT_TARGET"]
ENV["CC"] = Formula["llvm"].opt_bin/"clang"
ENV["CXX"] = Formula["llvm"].opt_bin/"clang++"
ENV.prepend_path "PATH", buildpath/"autoconf/bin"
system "../js/src/configure", "--prefix=#{prefix}",
"--with-system-nspr",
"--with-system-zlib",
"--with-system-icu",
"--enable-readline",
"--enable-shared-js",
"--enable-optimize",
"--enable-release",
"--with-intl-api",
"--disable-jemalloc"
system "make"
system "make", "install"
rm Dir["#{bin}/*"]
end
# headers were installed as softlinks, which is not acceptable
cd(include.to_s) do
`find . -type l`.chomp.split.each do |link|
header = File.readlink(link)
rm link
cp header, link
end
end
ENV.append_path "PKG_CONFIG_PATH", "#{lib}/pkgconfig"
rm "#{lib}/libjs_static.ajs"
end
# ensure that we don't run the meson post install script
ENV["DESTDIR"] = "/"
args = std_meson_args + %w[
-Dprofiler=disabled
-Dinstalled_tests=false
-Dbsymbolic_functions=false
-Dskip_dbus_tests=true
-Dskip_gtk_tests=true
]
mkdir "build" do
system "meson", *args, ".."
system "ninja", "-v"
system "ninja", "install", "-v"
end
end
def post_install
system "#{Formula["glib"].opt_bin}/glib-compile-schemas", "#{HOMEBREW_PREFIX}/share/glib-2.0/schemas"
end
test do
(testpath/"test.js").write <<~EOS
#!/usr/bin/env gjs
const GLib = imports.gi.GLib;
if (31 != GLib.Date.get_days_in_month(GLib.DateMonth.JANUARY, 2000))
imports.system.exit(1)
EOS
system "#{bin}/gjs", "test.js"
end
end