actions.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Licensed under the GNU General Public License, version 3.
  5. # See the file http://www.gnu.org/licenses/gpl.txt
  6. from pisi.actionsapi import pisitools
  7. from pisi.actionsapi import shelltools
  8. from pisi.actionsapi import autotools
  9. from pisi.actionsapi import cmaketools
  10. from pisi.actionsapi import get
  11. WorkDir = "llvm-project-%s.src" % get.srcVERSION()
  12. NoStrip = ["/usr"]
  13. def setup():
  14. shelltools.export("CC", "clang")
  15. shelltools.export("CXX", "clang++")
  16. if get.buildTYPE() == "emul32" :
  17. libsuffix = "32"
  18. pisitools.ldflags.add(" -fuse-ld=lld -L/usr/lib32 -ldl -lpthread ")
  19. triple = "i686-pc-linux-gnu"
  20. pisitools.cflags.add("-m32 --target=%s" %triple)
  21. pisitools.cxxflags.add("-m32 --target=%s" %triple)
  22. options = "-DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi'"
  23. else:
  24. libsuffix = " "
  25. pisitools.ldflags.add(" -fuse-ld=lld -rtlib=compiler-rt -L/usr/lib -ldl -lpthread ")
  26. triple = "%s " % get.HOST()
  27. options = "-DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' -DLIBUNWIND_USE_COMPILER_RT=ON \
  28. -DCMAKE_STRIP=' ' \
  29. -DLIBCXXABI_USE_COMPILER_RT=ON \
  30. -DLIBCXXABI_ENABLE_EXCEPTIONS=ON \
  31. -DLIBCXXABI_ENABLE_THREADS=ON \
  32. -DLIBCXXABI_ENABLE_SHARED=OFF \
  33. -DLLVM_NO_OLD_LIBSTDCXX=TRUE \
  34. -DLIBCXX_INSTALL_HEADERS=ON \
  35. -DLIBCXX_ENABLE_EXCEPTIONS=ON \
  36. -DLIBCXX_ENABLE_THREADS=ON \
  37. -DLIBCXX_ENABLE_MONOTONIC_CLOCK=ON \
  38. -DLIBCXX_ENABLE_SHARED=ON \
  39. -DLIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG=TRUE \
  40. -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=ON \
  41. -DLIBCXX_ENABLE_FILESYSTEM=ON \
  42. -DLIBCXX_USE_COMPILER_RT=ON \
  43. -DLIBCXX_HAS_PTHREAD_API=ON \
  44. -DLIBUNWIND_ENABLE_SHARED=ON \
  45. -DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON \
  46. -DLIBCXX_ENABLE_SHARED=ON \
  47. -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE \
  48. -DCXX_SUPPORTS_CXX11=TRUE \
  49. -DLIBCXX_ENABLE_STATIC=ON \
  50. -DLIBUNWIND_TARGET_TRIPLE=%s \
  51. " % triple
  52. if get.buildTYPE() == "emul32":
  53. options += " -DLIBCXXABI_USE_LLVM_UNWINDER=OFF"
  54. else:
  55. options += " -DLIBCXXABI_USE_LLVM_UNWINDER=ON"
  56. # shelltools.system("ln -s %s/%s/libcxx llvm/projects/libcxx" %(get.workDIR(), WorkDir))
  57. # shelltools.system("ln -s %s/%s/libcxxabi llvm/projects/libcxxabi" %(get.workDIR(), WorkDir))
  58. shelltools.makedirs("build")
  59. shelltools.cd("build")
  60. shelltools.system(" cmake \
  61. -DCMAKE_BUILD_TYPE=Release \
  62. -DCMAKE_INSTALL_PREFIX=/usr \
  63. -DLIBCXX_LIBDIR_SUFFIX=%s \
  64. -DCMAKE_C_COMPILER=clang \
  65. -DCMAKE_CXX_COMPILER=clang++ \
  66. -DLLVM_ENABLE_PIC=ON \
  67. -DLLVM_DEFAULT_TARGET_TRIPLE=%s \
  68. %s \
  69. ../runtimes \
  70. " %(libsuffix, triple, options) )
  71. def build():
  72. shelltools.cd("build")
  73. autotools.make("cxx cxx_experimental")
  74. def install():
  75. shelltools.cd("build")
  76. shelltools.system("DESTDIR=%s make install-cxx-headers install-cxx" %get.installDIR())
  77. pisitools.dodoc("../libcxx/CREDITS.TXT", "../libcxx/LICENSE.TXT", "../libcxx/TODO.TXT")