mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 01:21:57 +00:00
easy building on linux/mac
This commit is contained in:
parent
82d6249358
commit
b7c9f55e51
78
wscript
78
wscript
@ -1,7 +1,11 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
import urllib2
|
from urllib2 import urlopen # Python 2
|
||||||
|
# from urllib.request import urlopen # Python 3
|
||||||
|
import os.path
|
||||||
|
from subprocess import call
|
||||||
|
import sys
|
||||||
|
|
||||||
VERSION='0.0.1'
|
VERSION='0.0.1'
|
||||||
APPNAME='indexer'
|
APPNAME='indexer'
|
||||||
@ -9,6 +13,38 @@ APPNAME='indexer'
|
|||||||
top = '.'
|
top = '.'
|
||||||
out = 'build'
|
out = 'build'
|
||||||
|
|
||||||
|
|
||||||
|
# Example URLs
|
||||||
|
# http://releases.llvm.org/4.0.0/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04.tar.xz
|
||||||
|
# http://releases.llvm.org/4.0.0/clang+llvm-4.0.0-x86_64-apple-darwin.tar.xz
|
||||||
|
# http://releases.llvm.org/4.0.0/LLVM-4.0.0-win64.exe
|
||||||
|
# TODO: windows support (it's an exe!)
|
||||||
|
|
||||||
|
global CLANG_PLATFORM_NAME
|
||||||
|
global CLANG_TARBALL_PLATFORM_NAME
|
||||||
|
|
||||||
|
if sys.platform == 'linux' or sys.platform == 'linux2':
|
||||||
|
CLANG_PLATFORM_NAME = 'x86_64-linux-gnu-ubuntu-14.04'
|
||||||
|
CLANG_TARBALL_PLATFORM_NAME = 'clang+llvm'
|
||||||
|
elif sys.platform == 'darwin':
|
||||||
|
CLANG_PLATFORM_NAME = 'x86_64-apple-darwin'
|
||||||
|
CLANG_TARBALL_PLATFORM_NAME = 'clang+llvm'
|
||||||
|
else:
|
||||||
|
sys.stderr.write('ERROR: Unknown platform {0}\n'.format(sys.platform))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Version of clang to download and use.
|
||||||
|
CLANG_VERSION = '4.0.0'
|
||||||
|
# Tarball name on clang servers that should be used.
|
||||||
|
CLANG_TARBALL_NAME = '{0}-{1}-{2}'.format(CLANG_TARBALL_PLATFORM_NAME, CLANG_VERSION, CLANG_PLATFORM_NAME)
|
||||||
|
# Directory clang has been extracted to.
|
||||||
|
CLANG_DIRECTORY = '{0}/{1}'.format(out, CLANG_TARBALL_NAME)
|
||||||
|
# URL of the tarball to download.
|
||||||
|
CLANG_TARBALL_URL = 'http://releases.llvm.org/{0}/{1}.tar.xz'.format(CLANG_VERSION, CLANG_TARBALL_NAME)
|
||||||
|
# Path to locally tarball.
|
||||||
|
CLANG_TARBALL_LOCAL_PATH = '{0}.tar.xz'.format(CLANG_DIRECTORY)
|
||||||
|
|
||||||
|
|
||||||
from waflib.Tools.compiler_cxx import cxx_compiler
|
from waflib.Tools.compiler_cxx import cxx_compiler
|
||||||
cxx_compiler['linux'] = ['clang++', 'g++']
|
cxx_compiler['linux'] = ['clang++', 'g++']
|
||||||
|
|
||||||
@ -19,24 +55,44 @@ def configure(conf):
|
|||||||
conf.load('compiler_cxx')
|
conf.load('compiler_cxx')
|
||||||
conf.check(header_name='stdio.h', features='cxx cxxprogram', mandatory=True)
|
conf.check(header_name='stdio.h', features='cxx cxxprogram', mandatory=True)
|
||||||
|
|
||||||
# https://github.com/Andersbakken/rtags/blob/master/scripts/getclang.sh
|
# Download and save the compressed tarball as |compressed_file_name|.
|
||||||
def download_clang(conf):
|
if not os.path.isfile(CLANG_TARBALL_LOCAL_PATH):
|
||||||
url = 'http://releases.llvm.org/3.9.0/clang+llvm-3.9.0-x86_64-apple-darwin.tar.xz'
|
print('Downloading clang tarball')
|
||||||
response = urllib2.urlopen(url)
|
print(' destination: {0}'.format(CLANG_TARBALL_LOCAL_PATH))
|
||||||
html = response.read()
|
print(' source: {0}'.format(CLANG_TARBALL_URL))
|
||||||
pass
|
# TODO: verify checksum
|
||||||
|
response = urlopen(CLANG_TARBALL_URL)
|
||||||
|
with open(CLANG_TARBALL_LOCAL_PATH, 'wb') as f:
|
||||||
|
f.write(response.read())
|
||||||
|
else:
|
||||||
|
print('Found clang tarball at {0}'.format(CLANG_TARBALL_LOCAL_PATH))
|
||||||
|
|
||||||
|
# Extract the tarball.
|
||||||
|
if not os.path.isdir(CLANG_DIRECTORY):
|
||||||
|
print('Extracting clang')
|
||||||
|
# TODO: make portable.
|
||||||
|
call(['tar', 'xf', CLANG_TARBALL_LOCAL_PATH, '-C', out])
|
||||||
|
else:
|
||||||
|
print('Found extracted clang at {0}'.format(CLANG_DIRECTORY))
|
||||||
|
|
||||||
def build(bld):
|
def build(bld):
|
||||||
|
# todo: configure vars
|
||||||
|
CLANG_INCLUDE_DIR = '{0}/include'.format(CLANG_DIRECTORY)
|
||||||
|
CLANG_LIB_DIR = '{0}/lib'.format(CLANG_DIRECTORY)
|
||||||
|
CLANG_INCLUDE_DIR = os.path.abspath(CLANG_INCLUDE_DIR)
|
||||||
|
CLANG_LIB_DIR = os.path.abspath(CLANG_LIB_DIR)
|
||||||
|
print('CLANG_INCLUDE_DIR: {0}'.format(CLANG_INCLUDE_DIR))
|
||||||
|
print('CLANG_LIB_DIR: {0}'.format(CLANG_LIB_DIR))
|
||||||
|
|
||||||
cc_files = bld.path.ant_glob(['**/*.cpp', '**/*.cc'],
|
cc_files = bld.path.ant_glob(['**/*.cpp', '**/*.cc'],
|
||||||
excl=['*tests/*', 'third_party/*'])
|
excl=['*tests/*', 'third_party/*'])
|
||||||
bld.program(
|
bld.program(
|
||||||
source=cc_files,
|
source=cc_files,
|
||||||
cxxflags=['-std=c++11'],
|
cxxflags=['-std=c++11'],
|
||||||
includes=['third_party/rapidjson/include',
|
includes=['third_party/rapidjson/include', CLANG_INCLUDE_DIR],
|
||||||
'/usr/local/google/home/jdufault/super-clang-index/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/include'],
|
|
||||||
lib=['clang', 'rt', 'pthread'],
|
lib=['clang', 'rt', 'pthread'],
|
||||||
libpath=['/usr/local/google/home/jdufault/super-clang-index/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/lib'],
|
libpath=[CLANG_LIB_DIR],
|
||||||
rpath=['/usr/local/google/home/jdufault/super-clang-index/clang+llvm-4.0.0-x86_64-linux-gnu-ubuntu-14.04/lib'],
|
rpath=[CLANG_LIB_DIR],
|
||||||
target='app')
|
target='app')
|
||||||
|
|
||||||
#bld.shlib(source='a.cpp', target='mylib', vnum='9.8.7')
|
#bld.shlib(source='a.cpp', target='mylib', vnum='9.8.7')
|
||||||
|
Loading…
Reference in New Issue
Block a user