Merge pull request #208 from epfl-scitas/features/resource_directive
resource directive : implementation + clang / llvm use case
This commit is contained in:
@@ -22,8 +22,13 @@
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
|
||||
|
||||
from spack import *
|
||||
|
||||
import os
|
||||
import os.path
|
||||
|
||||
class Clang(Package):
|
||||
"""The goal of the Clang project is to create a new C, C++,
|
||||
Objective C and Objective C++ front-end for the LLVM compiler.
|
||||
@@ -39,13 +44,52 @@ class Clang(Package):
|
||||
version('3.6.2', 'ff862793682f714bb7862325b9c06e20', url='http://llvm.org/releases/3.6.2/cfe-3.6.2.src.tar.xz')
|
||||
version('3.5.1', '93f9532f8f7e6f1d8e5c1116907051cb', url='http://llvm.org/releases/3.5.1/cfe-3.5.1.src.tar.xz')
|
||||
|
||||
##########
|
||||
# @3.7.0
|
||||
resource(name='clang-tools-extra',
|
||||
url='http://llvm.org/releases/3.7.0/clang-tools-extra-3.7.0.src.tar.xz',
|
||||
md5='d5a87dacb65d981a427a536f6964642e', destination='tools', when='@3.7.0')
|
||||
##########
|
||||
|
||||
def install(self, spec, prefix):
|
||||
env['CXXFLAGS'] = self.compiler.cxx11_flag
|
||||
|
||||
with working_dir('spack-build', create=True):
|
||||
|
||||
options = []
|
||||
if '@3.7.0:' in spec:
|
||||
options.append('-DCLANG_DEFAULT_OPENMP_RUNTIME:STRING=libomp')
|
||||
options.extend(std_cmake_args)
|
||||
|
||||
cmake('..',
|
||||
'-DCLANG_PATH_TO_LLVM_BUILD=%s' % spec['llvm'].prefix,
|
||||
'-DLLVM_MAIN_SRC_DIR=%s' % spec['llvm'].prefix,
|
||||
*std_cmake_args)
|
||||
'-DCLANG_PATH_TO_LLVM_BUILD:PATH=%s' % spec['llvm'].prefix,
|
||||
'-DLLVM_MAIN_SRC_DIR:PATH=%s' % spec['llvm'].prefix,
|
||||
*options)
|
||||
make()
|
||||
make("install")
|
||||
# CLang doesn't look in llvm folders for system headers...
|
||||
self.link_llvm_directories(spec)
|
||||
|
||||
def link_llvm_directories(self, spec):
|
||||
|
||||
def clang_include_dir_at(root):
|
||||
return join_path(root, 'include')
|
||||
|
||||
def clang_lib_dir_at(root):
|
||||
return join_path(root, 'lib/clang/', str(self.version), 'include')
|
||||
|
||||
def do_link(source_dir, destination_dir):
|
||||
if os.path.exists(source_dir):
|
||||
for name in os.listdir(source_dir):
|
||||
source = join_path(source_dir, name)
|
||||
link = join_path(destination_dir, name)
|
||||
os.symlink(source, link)
|
||||
|
||||
# Link folder and files in include
|
||||
llvm_dir = clang_include_dir_at(spec['llvm'].prefix)
|
||||
clang_dir = clang_include_dir_at(self.prefix)
|
||||
do_link(llvm_dir, clang_dir)
|
||||
# Link folder and files in lib
|
||||
llvm_dir = clang_lib_dir_at(spec['llvm'].prefix)
|
||||
clang_dir = clang_lib_dir_at(self.prefix)
|
||||
do_link(llvm_dir, clang_dir)
|
@@ -42,13 +42,31 @@ class Llvm(Package):
|
||||
|
||||
depends_on('python@2.7:')
|
||||
|
||||
variant('libcxx', default=False, description="Builds the LLVM Standard C++ library targeting C++11")
|
||||
|
||||
##########
|
||||
# @3.7.0
|
||||
resource(name='compiler-rt',
|
||||
url='http://llvm.org/releases/3.7.0/compiler-rt-3.7.0.src.tar.xz', md5='383c10affd513026f08936b5525523f5',
|
||||
destination='projects', when='@3.7.0')
|
||||
resource(name='openmp',
|
||||
url='http://llvm.org/releases/3.7.0/openmp-3.7.0.src.tar.xz', md5='f482c86fdead50ba246a1a2b0bbf206f',
|
||||
destination='projects', when='@3.7.0')
|
||||
resource(name='libcxx',
|
||||
url='http://llvm.org/releases/3.7.0/libcxx-3.7.0.src.tar.xz', md5='46aa5175cbe1ad42d6e9c995968e56dd',
|
||||
destination='projects', placement='libcxx', when='+libcxx@3.7.0')
|
||||
resource(name='libcxxabi',
|
||||
url='http://llvm.org/releases/3.7.0/libcxxabi-3.7.0.src.tar.xz', md5='5aa769e2fca79fa5335cfae8f6258772',
|
||||
destination='projects', placement='libcxxabi', when='+libcxx@3.7.0')
|
||||
##########
|
||||
|
||||
def install(self, spec, prefix):
|
||||
env['CXXFLAGS'] = self.compiler.cxx11_flag
|
||||
|
||||
with working_dir('spack-build', create=True):
|
||||
cmake('..',
|
||||
'-DLLVM_REQUIRES_RTTI=1',
|
||||
'-DPYTHON_EXECUTABLE=%s/bin/python' % spec['python'].prefix,
|
||||
'-DLLVM_REQUIRES_RTTI:BOOL=ON',
|
||||
'-DPYTHON_EXECUTABLE:PATH=%s/bin/python' % spec['python'].prefix,
|
||||
*std_cmake_args)
|
||||
make()
|
||||
make("install")
|
||||
|
Reference in New Issue
Block a user