Skip to content

Commit 124ff4c

Browse files
authored
Merge pull request Homebrew#220709 from Homebrew/fheroes2-mac-bundle
fheroes2: build app bundle on macOS
2 parents 456909f + baea641 commit 124ff4c

File tree

1 file changed

+47
-13
lines changed

1 file changed

+47
-13
lines changed

Formula/f/fheroes2.rb

Lines changed: 47 additions & 13 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
@@ -12,13 +13,13 @@ class Fheroes2 < Formula
1213
end
1314

1415
bottle do
15-
sha256 arm64_sequoia: "923052a337d4f1c2fb9fda17c0583db1838d9e69c7ee21ff952baf7728444581"
16-
sha256 arm64_sonoma: "dd0f91994a1b6a2ba399305894eeef5787c4a4815e0182243b80a38a8ee4e667"
17-
sha256 arm64_ventura: "489962fc4e969c04ed374647abc303f0138280512d16671dcc3732857315b192"
18-
sha256 sonoma: "44440672a2b1da48ed6288afad3a4dea7e9d9507d1a4d340b728f78876d8cb08"
19-
sha256 ventura: "a76fa029a98145dca97759a6e66188f143ef8400da6963011858f7b293acd368"
20-
sha256 arm64_linux: "a3b80cc8e2137752d68056e0827e672b7e3eed19b740018b4b94512801fa5a23"
21-
sha256 x86_64_linux: "b0001f5a990deaeaae3f6b4bd1927a198caf29a13b95f45b64827cf383e4a6b0"
16+
sha256 arm64_sequoia: "bc01ee94d9ecd36f09f149366c23f85cd0f363ff70057be2752c5d84cd1c20ec"
17+
sha256 arm64_sonoma: "9bfa43f76dbdf75d4080a2b485958dea69aa7229e54f6994d91f21c522d81d91"
18+
sha256 arm64_ventura: "8f5cf53765b7c2557a4878a8584cbf3f680a1796f03198dd71a74aa4054f8ab7"
19+
sha256 sonoma: "2d3c25d9088d2bcdb9b14798fd1ba229df52397278a6808f418810da98899cc8"
20+
sha256 ventura: "f24d762fb936c938b25b94bfbf9df00f98aadad30ef1cdc5b97f76bc7459b7b4"
21+
sha256 arm64_linux: "b24eec3d0dde1f216b7d13770a45a25af180c8e9c0de76ed846bd7645ae224e3"
22+
sha256 x86_64_linux: "cad5dfc921539d0252a5b4ebf44678ca7a194aafcde720bec8259773f9497fd2"
2223
end
2324

2425
depends_on "cmake" => :build
@@ -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)