actions.py 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # -*- coding: utf-8 -*-
  2. #
  3. # Licensed under the GNU General Public License, version 3.
  4. # See the file http://www.gnu.org/licenses/gpl.txt
  5. from pisi.actionsapi import autotools
  6. from pisi.actionsapi import pisitools
  7. from pisi.actionsapi import shelltools
  8. from pisi.actionsapi import get
  9. from pisi.actionsapi import cmaketools
  10. libdir = "/usr/lib32/llvm" if get.buildTYPE() == "emul32" else "/usr/lib/llvm"
  11. lib = "lib32" if get.buildTYPE() == "emul32" else "lib"
  12. def setup():
  13. if get.buildTYPE() != "emul32":
  14. if not shelltools.can_access_directory("tools/clang"):
  15. shelltools.system("tar xf ../cfe-%s.src.tar.xz -C tools" % get.srcVERSION())
  16. shelltools.move("tools/cfe-%s.src" % get.srcVERSION(), "tools/clang")
  17. shelltools.system("tar xf ../clang-tools-extra-%s.src.tar.xz -C tools" % get.srcVERSION())
  18. shelltools.move("tools/clang-tools-extra-*", "tools/clang/extra")
  19. shelltools.system("tar xf ../lldb-%s.src.tar.xz -C tools" % get.srcVERSION())
  20. shelltools.move("tools/lldb-*", "tools/lldb")
  21. if not shelltools.can_access_directory("projects/compiler-rt"):
  22. shelltools.system("tar xf ../compiler-rt-%s.src.tar.xz -C projects" % get.srcVERSION())
  23. shelltools.move("projects/compiler-rt-%s.src" % get.srcVERSION(), "projects/compiler-rt")
  24. shelltools.export("CC", "gcc")
  25. shelltools.export("CXX", "g++")
  26. if get.buildTYPE() == "emul32":
  27. shelltools.export("CC", "gcc -m32")
  28. shelltools.export("CXX", "g++ -m32")
  29. shelltools.export("PKG_CONFIG_PATH","/usr/lib32/pkgconfig")
  30. shelltools.makedirs("build")
  31. shelltools.cd("build")
  32. if get.buildTYPE() != "emul32":
  33. options = "-DCMAKE_C_FLAGS:STRING=-m64 \
  34. -DCMAKE_INSTALL_PREFIX=/usr \
  35. -DCMAKE_CXX_FLAGS:STRING=-m64 \
  36. -DLLVM_TARGET_ARCH:STRING=x86_64 \
  37. -DLLVM_DEFAULT_TARGET_TRIPLE=%s " % get.HOST()
  38. if get.buildTYPE() == "emul32":
  39. options = " -DCMAKE_C_FLAGS:STRING=-m32 \
  40. -DCMAKE_INSTALL_PREFIX=/emul32 \
  41. -DLLVM_TARGET_ARCH:STRING=i686 \
  42. -DLLVM_LIBDIR_SUFFIX=32 \
  43. -DLLVM_DEFAULT_TARGET_TRIPLE='i686-pc-linux-gnu' \
  44. -DCMAKE_CXX_FLAGS:STRING=-m32"
  45. cmaketools.configure("-DCMAKE_BUILD_TYPE=Release \
  46. %s \
  47. -DLLVM_ENABLE_FFI=ON \
  48. -DLLVM_BUILD_DOCS=OFF \
  49. -DBUILD_SHARED_LIBS=ON \
  50. -DLLVM_ENABLE_RTTI=ON \
  51. -DLLVM_INCLUDEDIR=/usr/include \
  52. -DLLVM_ENABLE_ASSERTIONS=OFF \
  53. -DFFI_INCLUDE_DIR=/usr/lib/libffi-3.2.1/include \
  54. -DENABLE_SHARED=ON" % options, sourceDir=".." )
  55. def build():
  56. shelltools.makedirs("build")
  57. shelltools.cd("build")
  58. cmaketools.make()
  59. def install():
  60. shelltools.makedirs("build")
  61. shelltools.cd("build")
  62. cmaketools.rawInstall("DESTDIR=%s" % get.installDIR())
  63. if get.buildTYPE() == "emul32":
  64. pisitools.domove("/emul32/lib32/", "/usr/")
  65. pisitools.insinto("/usr/include/llvm/Config/","%s/emul32/include/llvm/Config/llvm-config.h" % get.installDIR(),"llvm-config-32.h")
  66. pisitools.insinto("/usr/bin/","%s/emul32/bin/llvm-config" % get.installDIR(),"llvm-config-32")
  67. pisitools.removeDir("/emul32")
  68. pisitools.remove("/usr/lib/python2.7/site-packages/six.py")
  69. shelltools.cd ("..")
  70. pisitools.dodoc("CREDITS.TXT", "LICENSE.TXT", "README.txt")