Skip to content

Commit a8dde00

Browse files
fheroes2: build app bundle on macOS
1 parent 124a988 commit a8dde00

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

Formula/f/fheroes2.rb

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class Fheroes2 < Formula
44
url "https://github.com/ihhub/fheroes2/archive/refs/tags/1.1.7.tar.gz"
55
sha256 "6419ad0bd0f1f684a9256c39fb6c02a026fc76581b0bc9632a597fbc8443fc03"
66
license "GPL-2.0-or-later"
7+
revision 1
78
head "https://github.com/ihhub/fheroes2.git", branch: "master"
89

910
livecheck do
@@ -30,13 +31,34 @@ class Fheroes2 < Formula
3031

3132
uses_from_macos "zlib"
3233

34+
on_macos do
35+
depends_on "dylibbundler" => :build
36+
end
37+
3338
def install
34-
system "cmake", "-S", ".", "-B", "build", *std_cmake_args
39+
args = std_cmake_args
40+
args << "-DMACOS_APP_BUNDLE=ON" if OS.mac?
41+
system "cmake", "-S", ".", "-B", "build", *args
3542
system "cmake", "--build", "build"
3643
system "cmake", "--install", "build"
3744

38-
bin.install "script/demo/download_demo_version.sh" => "fheroes2-install-demo"
39-
bin.install "script/homm2/extract_homm2_resources.sh" => "fheroes2-extract-resources"
45+
if OS.mac?
46+
prefix.install "build/fheroes2.app"
47+
bin.write_exec_script "#{prefix}/fheroes2.app/Contents/MacOS/fheroes2"
48+
49+
libexec.install "script/demo/download_demo_version.sh"
50+
libexec.install "script/demo/download_demo_version_for_app_bundle.sh"
51+
libexec.install "script/homm2/extract_homm2_resources.sh"
52+
libexec.install "script/homm2/extract_homm2_resources_for_app_bundle.sh"
53+
chmod "+x", Dir["#{libexec}/*"]
54+
bin.write_exec_script libexec/"download_demo_version_for_app_bundle.sh"
55+
bin.write_exec_script libexec/"extract_homm2_resources_for_app_bundle.sh"
56+
mv bin/"download_demo_version_for_app_bundle.sh", bin/"fheroes2-install-demo"
57+
mv bin/"extract_homm2_resources_for_app_bundle.sh", bin/"fheroes2-extract-resources"
58+
else
59+
bin.install "script/demo/download_demo_version.sh" => "fheroes2-install-demo"
60+
bin.install "script/homm2/extract_homm2_resources.sh" => "fheroes2-extract-resources"
61+
end
4062
end
4163

4264
def caveats
@@ -53,9 +75,21 @@ def caveats
5375
end
5476

5577
test do
56-
io = IO.popen("#{bin}/fheroes2 2>&1")
57-
io.any? do |line|
58-
line.include?("fheroes2 engine, version:")
78+
assert_path_exists bin/"fheroes2"
79+
assert_predicate bin/"fheroes2", :executable?
80+
if OS.mac?
81+
begin
82+
pid = spawn(bin/"fheroes2")
83+
sleep 2
84+
ensure
85+
Process.kill("SIGINT", pid)
86+
Process.wait(pid)
87+
end
88+
else
89+
io = IO.popen("#{bin}/fheroes2 2>&1")
90+
io.any? do |line|
91+
line.include?("fheroes2 engine, version:")
92+
end
5993
end
6094
end
6195
end

0 commit comments

Comments
 (0)