-
Notifications
You must be signed in to change notification settings - Fork 75
/
ogre2.2.rb
144 lines (126 loc) · 5.14 KB
/
ogre2.2.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
134
135
136
137
138
139
140
141
142
143
144
class Ogre22 < Formula
desc "Scene-oriented 3D engine written in c++"
homepage "https://www.ogre3d.org/"
url "https://github.com/OGRECave/ogre-next/archive/312bf406a77244afe230930e67e3e5d52a119507.tar.gz"
version "2.2.6+20211021~312bf40"
sha256 "b9dbd84ef0c1731d0d1abc55499532358b9a9e5f0b3dc2b8e02ba76db0a112fd"
license "MIT"
revision 1
head "https://github.com/OGRECave/ogre-next.git", branch: "v2-2"
bottle do
root_url "https://osrf-distributions.s3.amazonaws.com/bottles-simulation"
sha256 cellar: :any, big_sur: "fae5da6d6bb34344f04e4f78f162f3872124e915fbd50d883e6509c6f1640cbd"
sha256 cellar: :any, catalina: "222487899f723c60367694395875898f742cd2247e54eaa348f99fcb023c6ebc"
end
depends_on "cmake" => :build
depends_on "pkg-config" => :test
depends_on "doxygen"
depends_on "freeimage"
depends_on "freetype"
depends_on "libx11"
depends_on "libzzip"
depends_on "rapidjson"
depends_on "tbb"
patch do
# fix for cmake3 and c++11
url "https://github.com/scpeters/ogre-next/commit/3486b772b35b3e5f8cf6da5b7a41e6c195408d7d.patch?full_index=1"
sha256 "30a60758401980260f3a5abdd6513505327028a983af9e911908b4f7da140625"
end
patch do
# implement override for MetalTextureGpu::getCustomAttribute
url "https://github.com/OGRECave/ogre-next/commit/b7187a55a9ad5ba65ed24d1c212d1749833923ac.patch?full_index=1"
sha256 "38975001bfa903194565ed0bf411cf29857cd5b2f0f71a651d64543f610c4ff6"
end
# patch do
# fix GL3+ compilation with Xcode 10
# url "https://github.com/OGRECave/ogre-next/commit/b00a880a4aea5492615ce8e3363e81631a53bb5c.patch?full_index=1"
# sha256 "8fe5beab9e50dfe1f0164e8dbffd20a79f5e9afe79802ab0ce29d8d83e4e0fe8"
# end
patch do
# fix for m1 arch -- adapted from OGRECave/ogre-next@ff01338
url "https://gist.githubusercontent.com/iche033/5685dcbb3efc14bb263718a91039bab8/raw/dd3ccbefda8abf1b9ff7b5a4898e3e63cbe06b4b/ogre2.2-m1-platform.patch"
sha256 "edacb1992550c78e746d9bd545c8f5b278c2f987533349a0db56d7b13ebab480"
end
# fix for m1 arch -- adapted from OGRECave/ogre-next@23d8261
patch do
url "https://github.com/OGRECave/ogre-next/commit/23d82616a785f6aa26f58d5bf38a7114e2c00f88.patch?full_index=1"
sha256 "ade27e55e7be5510f5eeb95f17c9ba90e61575ad610cc35f24179d061b1756a1"
end
def install
cmake_args = [
"-DOGRE_LIB_DIRECTORY=lib/OGRE-2.2",
"-DOGRE_BUILD_LIBS_AS_FRAMEWORKS=OFF",
"-DOGRE_FULL_RPATH:BOOL=FALSE",
"-DOGRE_BUILD_DOCS:BOOL=FALSE",
"-DOGRE_INSTALL_DOCS:BOOL=FALSE",
"-DOGRE_BUILD_SAMPLES:BOOL=FALSE",
"-DOGRE_BUILD_SAMPLES2:BOOL=FALSE",
"-DOGRE_INSTALL_SAMPLES:BOOL=FALSE",
"-DOGRE_INSTALL_SAMPLES_SOURCE:BOOL=FALSE",
]
# use the following to disable GL3Plus render engine which won't work when OpenGL is removed
# cmake_args << "-DOGRE_BUILD_RENDERSYSTEM_GL3PLUS:BOOL=OFF" if MacOS::Xcode.version >= "10"
cmake_args.concat std_cmake_args
mkdir "build" do
system "cmake", "..", *cmake_args
system "make", "install"
end
# Put these cmake files where Debian puts them
(share/"OGRE-2.2/cmake/modules").install Dir[prefix/"CMake/*.cmake"]
rmdir prefix/"CMake"
# Support side-by-side OGRE installs
# Rename executables to avoid conflicts with ogre2.1
Dir[bin/"*"].each do |exe|
mv exe, "#{exe}-2.2"
end
# Move headers
(include/"OGRE-2.2").install Dir[include/"OGRE/*"]
rmdir include/"OGRE"
# Move and update .pc files
lib.install Dir[lib/"OGRE-2.2/pkgconfig"]
Dir[lib/"pkgconfig/*"].each do |pc|
mv pc, pc.sub("pkgconfig/OGRE", "pkgconfig/OGRE-2.2")
end
inreplace Dir[lib/"pkgconfig/*"] do |s|
s.gsub! prefix, opt_prefix
s.sub! "Name: OGRE", "Name: OGRE-2.2"
s.sub!(/^includedir=.*$/, "includedir=${prefix}/include/OGRE-2.2")
end
inreplace (lib/"pkgconfig/OGRE-2.2.pc"), " -I${includedir}\/OGRE", ""
inreplace (lib/"pkgconfig/OGRE-2.2-MeshLodGenerator.pc"), "-I${includedir}/OGRE/", "-I${includedir}/"
inreplace (lib/"pkgconfig/OGRE-2.2-Overlay.pc"), "-I${includedir}/OGRE/", "-I${includedir}/"
# Move versioned libraries (*.2.2.6.dylib) to standard location and remove symlinks
lib.install Dir[lib/"OGRE-2.2/lib*.2.2.6.dylib"]
rm Dir[lib/"OGRE-2.2/lib*"]
# Move plugins to subfolder
(lib/"OGRE-2.2/OGRE").install Dir[lib/"OGRE-2.2/*.dylib"]
# Restore lib symlinks
Dir[lib/"lib*"].each do |l|
(lib/"OGRE-2.2").install_symlink l => File.basename(l.sub(".2.2.6", ""))
end
end
test do
(testpath/"test.cpp").write <<-EOS
#include <Ogre.h>
int main()
{
Ogre::Root *root = new Ogre::Root("", "", "");
delete root;
return 0;
}
EOS
system "pkg-config", "OGRE-2.2"
cflags = `pkg-config --cflags OGRE-2.2`.split
libs = `pkg-config --libs OGRE-2.2`.split
system ENV.cc, "test.cpp",
*cflags,
"-std=c++11",
*libs,
"-lc++",
"-o", "test"
system "./test"
# check for Xcode frameworks in bottle
cmd_not_grep_xcode = "! grep -rnI 'Applications[/]Xcode' #{prefix}"
system cmd_not_grep_xcode
end
end