-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tinyxml1 extracted from homebrew/core/tinyxml
- Loading branch information
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
class Tinyxml1 < Formula | ||
desc "XML parser" | ||
homepage "http://www.grinninglizard.com/tinyxml/" | ||
url "https://downloads.sourceforge.net/project/tinyxml/tinyxml/2.6.2/tinyxml_2_6_2.tar.gz" | ||
sha256 "15bdfdcec58a7da30adc87ac2b078e4417dbe5392f3afb719f9ba6d062645593" | ||
license "Zlib" | ||
|
||
depends_on "cmake" => :build | ||
|
||
conflicts_with "tinyxml", because: "differing version of the same formula" | ||
|
||
# The first two patches are taken from the debian packaging of tinyxml. | ||
# The first patch enforces use of stl strings, rather than a custom string type. | ||
# The second patch is a fix for incorrect encoding of elements with special characters | ||
# originally posted at https://sourceforge.net/p/tinyxml/patches/51/ | ||
# The third patch adds a CMakeLists.txt file to build a shared library and provide an install target | ||
# submitted upstream as https://sourceforge.net/p/tinyxml/patches/66/ | ||
patch do | ||
url "https://raw.githubusercontent.com/robotology/yarp/59eedfbaa1069aa5f03a4a9980d984d59decd55c/extern/tinyxml/patches/enforce-use-stl.patch" | ||
sha256 "16a5b5e842eb0336be606131e5fb12a9165970f7bd943780ba09df2e1e8b29b1" | ||
end | ||
|
||
patch do | ||
url "https://raw.githubusercontent.com/robotology/yarp/59eedfbaa1069aa5f03a4a9980d984d59decd55c/extern/tinyxml/patches/entity-encoding.patch" | ||
sha256 "c5128e03933cd2e22eb85554d58f615f4dbc9177bd144cae2913c0bd7b140c2b" | ||
end | ||
|
||
patch do | ||
url "https://gist.githubusercontent.com/scpeters/6325123/raw/cfb079be67997cb19a1aee60449714a1dedefed5/tinyxml_CMakeLists.patch" | ||
sha256 "32160135c27dc9fb7f7b8fb6cf0bf875a727861db9a07cf44535d39770b1e3c7" | ||
end | ||
|
||
def install | ||
system "cmake", ".", *std_cmake_args | ||
system "make", "install" | ||
(lib+"pkgconfig/tinyxml.pc").write pc_file | ||
end | ||
|
||
def pc_file | ||
<<~EOS | ||
prefix=#{opt_prefix} | ||
exec_prefix=${prefix} | ||
libdir=${exec_prefix}/lib | ||
includedir=${prefix}/include | ||
Name: TinyXml | ||
Description: Simple, small, C++ XML parser | ||
Version: #{version} | ||
Libs: -L${libdir} -ltinyxml | ||
Cflags: -I${includedir} | ||
EOS | ||
end | ||
|
||
test do | ||
(testpath/"test.xml").write <<~EOS | ||
<?xml version="1.0" ?> | ||
<Hello>World</Hello> | ||
EOS | ||
(testpath/"test.cpp").write <<~EOS | ||
#include <tinyxml.h> | ||
int main() | ||
{ | ||
TiXmlDocument doc ("test.xml"); | ||
doc.LoadFile(); | ||
return 0; | ||
} | ||
EOS | ||
system ENV.cxx, "test.cpp", "-L#{lib}", "-ltinyxml", "-o", "test" | ||
system "./test" | ||
end | ||
end |