CEGUI

正式名は"Crazy Eddie's GUI System"。"Crazy Eddie"はかつてアメリカにあった家電の安売りチェーン店で、NASDAQに上場していたこともあるそうな。
PythonおよびLua用のグラフィックのライブラリーらしい。
昨日、ここの開発チームにpull requestを出したらミスしまくって荒らしみたいなことになってしまった。反省している。

The following script installs CEGUI on OSX with Homebrew. You might need some other script which you find in my archive list page.

class Cegui < Formula
  desc "Crazy Eddie's GUI System Mk-2"
  homepage "http://cegui.org.uk/"
  url "https://downloads.sourceforge.net/project/crayzedsgui/CEGUI%20Mk-2/0.8/cegui-0.8.7.tar.bz2"
  sha256 "b351e8957716d9c170612c13559e49530ef911ae4bac2feeb2dacd70b430e518"

  option "with-python3", "Build with python3 instead of python2"

  depends_on "ccache" => :build
  depends_on "cmake" => :build
  depends_on "pkg-config" => :build
  depends_on "boost"
  depends_on "boost-python"
  depends_on "corona" => :optional
  depends_on "devil" => :optional
  depends_on "freeimage"
  depends_on "freetype"
  depends_on "fribidi"
  depends_on "gettext"
  depends_on "glew"
  depends_on "glm"
  depends_on "irrlicht"
  depends_on "lua"
  depends_on "minizip"
  depends_on "ois" => :optional
  depends_on "ogre" => :optional
  depends_on "pcre"
  depends_on :python if build.without? "python3"
  depends_on "python3" => :optional
  depends_on "sdl2_image"
  depends_on "silly" => :optional
  depends_on "tinyxml" => :optional
  depends_on "tolua++" => :optional
  depends_on "xerces-c" => :optional

  def install
    if build.with?("python3") && Formula["boost-python"].build.without?("python3")
      odie "Building with python3 required boost-python with \"--with-python3\""
    end
    python = (build.with?("python3") ? "python3": "python")
    python_ver = Language::Python.major_minor_version(python)
    python_executable = `which #{python}`.chomp
    ENV["PYTHONPATH"] = "#{lib}/python#{python_ver}/site-packages:#{Language::Python.homebrew_site_packages(version = python_ver)}"

    (buildpath/"OpenGLViewportTarget.add").write  <<~EOS

        template class CEGUI::OpenGLRenderTarget<CEGUI::RenderTarget>;
        template class CEGUI::OpenGLRenderTarget<CEGUI::TextureTarget>;

      EOS
    `cat OpenGLViewportTarget.add >> cegui/src/RendererModules/OpenGL/ViewportTarget.cpp`
    (buildpath/"IrrlichtTextureTarget.add").write  <<~EOS

        template class CEGUI::IrrlichtRenderTarget<CEGUI::RenderTarget>;
        template class CEGUI::IrrlichtRenderTarget<CEGUI::TextureTarget>;

      EOS
    `cat IrrlichtTextureTarget.add >> cegui/src/RendererModules/Irrlicht/TextureTarget.cpp`

    if build.with? "ogre"
      (buildpath/"OgreTextureTarget.add").write  <<~EOS

          template class CEGUI::OgreRenderTarget<CEGUI::RenderTarget>;
          template class CEGUI::OgreRenderTarget<CEGUI::TextureTarget>;

        EOS
      `cat OgreTextureTarget.add >> cegui/src/RendererModules/Ogre/TextureTarget.cpp`
    end

    args = std_cmake_args
    args << "-DPYTHON_EXECUTABLE=#{python_executable}" << "-DCEGUI_SAMPLES_ENABLED=FALSE" << "-DCEGUI_INSTALL_WITH_RPATH:BOOL=ON"
    args << "-DOGRE_LIB:FILEPATH=#{Formula["ogre"].opt_lib}/libOgreMain.dylib" if build.with? "ogre"
    system "cmake", ".", "-DCEGUI_APPLE_DYLIB_INSTALL_PATH:STRING=#{opt_lib}", *args
    if build.with? "python3"
      inreplace "cegui/src/ScriptModules/Python/bindings/CMakeFiles/PyCEGUI.dir/link.txt",
                "libboost_python-mt.dylib", "libboost_python3-mt.dylib"
      inreplace "cegui/src/ScriptModules/Python/bindings/CMakeFiles/PyCEGUIOpenGLRenderer.dir/link.txt",
                "libboost_python-mt.dylib", "libboost_python3-mt.dylib"
      inreplace "cegui/src/ScriptModules/Python/bindings/CMakeFiles/PyCEGUIOgreRenderer.dir/link.txt",
                "libboost_python-mt.dylib", "libboost_python3-mt.dylib" if build.with? "ogre"
      inreplace "cegui/src/ScriptModules/Python/bindings/cmake_install.cmake", "file(INSTALL DESTINATION \"/cegui-0.8\"",
                "file(INSTALL DESTINATION \"#{lib}/python#{python_ver}/site-packages/cegui-0.8\""
    end
    system "make", "install"
  end
end




GLESv1については結論から言うと、なんやかんやでEGLが必要らしい。
ソースファイルではGLES/glext.hにて定義されている glBindFramebufferOES というファンクションを利用しようとしているのですが、これがlibGLESv1_CM.dylib に実装されていないのです。

Undefined symbols for architecture x86_64:
  "_glBindFramebufferOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glBindRenderbufferOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glCheckFramebufferStatusOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glDeleteFramebuffersOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glDeleteRenderbuffersOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glFramebufferRenderbufferOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glFramebufferTexture2DOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glGenFramebuffersOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glGenRenderbuffersOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glGenerateMipmapOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glGetFramebufferAttachmentParameterivOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glGetRenderbufferParameterivOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glIsFramebufferOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glIsRenderbufferOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
  "_glRenderbufferStorageOES", referenced from:
      CEGUI::OpenGLESFBOTextureTarget::initializedFBOExtension() in FBOTextureTarget.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

どうやらiOSでは実装されているらしいのですが。PowerVR-SDKのlibEGLおよびlibGLESv1_CMにもこれらのシンボルは含まれてませんでした。
実装されていない機能が、どうしてヘッダーファイルに定義されているのやら。

2017.11/22 追記

toLua++をbuild出来たため、toLua++オプションを追加しました。

$ brew list cegui
/usr/local/Cellar/cegui/0.8.7/bin/toluappcegui-0.8
/usr/local/Cellar/cegui/0.8.7/include/cegui-0/ (289 files)
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUIBase-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUICommonDialogs-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUIIrrlichtRenderer-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUILuaScriptModule-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUIOgreRenderer-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/cegui-0.8/ (10 files)
/usr/local/Cellar/cegui/0.8.7/lib/python3.6/ (2 files)
/usr/local/Cellar/cegui/0.8.7/share/cegui-0/ (116 files)

で、この toluappcegui-0.8 なのですが、

$ toluappcegui-0.8 -h

usage: tolua++ [options] input_file

Command line options are:
  -v       : print version information.
  -o  file : set output file; default is stdout.
  -H  file : create include file.
  -n  name : set package name; default is input file root name.
  -p       : parse only.
  -P       : parse and print structure information (for debug).
  -S       : disable support for c++ strings.
  -1       : substract 1 to operator[] index (for compatibility with tolua5).
  -L  file : run lua file (with dofile()) before doing anything.
  -D       : disable automatic exporting of destructors for classes that have
             constructors (for compatibility with tolua5)
  -W       : disable warnings for unsupported features (for compatibility
             with tolua5)
  -k       : produce LuaDoc API export to output instead
  -C       : disable cleanup of included lua code (for easier debugging)
  -E  value[=value] : add extra values to the luastate
  -t       : export a list of types asociates with the C++ typeid name
  -h       : print this message.
Should the input file be omitted, stdin is assumed;
in that case, the package name must be explicitly set.

Usageの項目が…。えっと…。これは…。

$ toluapp -h

usage: tolua++ [options] input_file

Command line options are:
  -v       : print version information.
  -o  file : set output file; default is stdout.
  -H  file : create include file.
  -n  name : set package name; default is input file root name.
  -p       : parse only.
  -P       : parse and print structure information (for debug).
  -S       : disable support for c++ strings.
  -1       : substract 1 to operator[] index (for compatibility with tolua5).
  -L  file : run lua file (with dofile()) before doing anything.
  -D       : disable automatic exporting of destructors for classes that have
             constructors (for compatibility with tolua5)
  -W       : disable warnings for unsupported features (for compatibility
             with tolua5)
  -C       : disable cleanup of included lua code (for easier debugging)
  -E  value[=value] : add extra values to the luastate
  -t       : export a list of types asociates with the C++ typeid name
  -q       : don't print warnings to the console
  -h       : print this message.
Should the input file be omitted, stdin is assumed;
in that case, the package name must be explicitly set.

丸パクリやないかい!

2017.11/23追記

OpenGLの件、Fixしました!

$ brew list cegui
/usr/local/Cellar/cegui/0.8.7/bin/toluappcegui-0.8
/usr/local/Cellar/cegui/0.8.7/include/cegui-0/ (312 files)
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUIBase-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUICommonDialogs-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUIIrrlichtRenderer-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUILuaScriptModule-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUIOgreRenderer-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/libCEGUIOpenGLRenderer-0.dylib
/usr/local/Cellar/cegui/0.8.7/lib/cegui-0.8/ (10 files)
/usr/local/Cellar/cegui/0.8.7/lib/python3.6/ (3 files)
/usr/local/Cellar/cegui/0.8.7/share/cegui-0/ (116 files)