Windows build fixes when symlink is not available.

This commit is contained in:
Jacob Dufault 2018-02-06 21:14:24 -08:00
parent 0016d214c3
commit 0405c3a41a
2 changed files with 20 additions and 15 deletions

View File

@ -10,7 +10,7 @@ install:
environment: environment:
CLICOLOR_FORCE: 1 CLICOLOR_FORCE: 1
matrix: matrix:
- MSYSTEM: MINGW64 # - MSYSTEM: MINGW64
- MSYSTEM: MSVC - MSYSTEM: MSVC
build_script: build_script:
@ -18,7 +18,7 @@ build_script:
If ($Env:MSYSTEM -Eq "MSVC") { If ($Env:MSYSTEM -Eq "MSVC") {
$dir = "cquery-${env:appveyor_build_version}-win64" $dir = "cquery-${env:appveyor_build_version}-win64"
cd C:\projects\cquery cd C:\projects\cquery
python waf configure --msvc_version="msvc 15.0" python waf configure
python waf build python waf build
mkdir "${dir}\build\release\bin" -ea 0 mkdir "${dir}\build\release\bin" -ea 0
mkdir "${dir}\build\release\lib\LLVM-5.0.1-win64\lib\clang\5.0.1\" mkdir "${dir}\build\release\lib\LLVM-5.0.1-win64\lib\clang\5.0.1\"

29
wscript
View File

@ -133,6 +133,18 @@ def download_and_extract(destdir, url, ext):
else: else:
print('Found extracted at {0}'.format(destdir)) print('Found extracted at {0}'.format(destdir))
def copy_or_symlink(src, dst):
print('copy_or_symlink src={0}, dst={1}'.format(src, dst))
try:
os.makedirs(os.path.dirname(dst))
except OSError:
pass
try:
os.symlink(src, dst)
except (OSError, NotImplementedError):
shutil.copy(src, dst)
def configure(ctx): def configure(ctx):
ctx.resetenv(ctx.options.variant) ctx.resetenv(ctx.options.variant)
@ -300,19 +312,12 @@ def configure(ctx):
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
ctx.env.rpath = ['@loader_path/../lib/' + clang_tarball_name + '/lib'] ctx.env.rpath = ['@loader_path/../lib/' + clang_tarball_name + '/lib']
elif sys.platform == 'win32': elif sys.platform == 'win32':
# Poor Windows users' RPATH - copy libclang.lib and libclang.dll to the build directory.
ctx.env.rpath = [] # Unsupported ctx.env.rpath = [] # Unsupported
name = os.path.basename(os.path.dirname(ctx.env['LIBPATH_clang'][0])) clang_dir = os.path.dirname(ctx.env['LIBPATH_clang'][0])
# Poor Windows users' RPATH dest_dir = os.path.join(ctx.path.get_bld().abspath(), ctx.options.variant, 'bin')
out_clang_dll = os.path.join(ctx.path.get_bld().abspath(), 'bin', 'libclang.dll') # copy_or_symlink(os.path.join(clang_dir, 'lib', 'libclang.lib'), os.path.join(dest_dir, 'libclang.lib'))
try: copy_or_symlink(os.path.join(clang_dir, 'bin', 'libclang.dll'), os.path.join(dest_dir, 'libclang.dll'))
os.makedirs(os.path.dirname(out_clang_dll))
except OSError:
pass
try:
dst = os.path.join(ctx.path.get_bld().abspath(), 'lib', name, 'bin', 'libclang.dll')
os.symlink(dst, out_clang_dll)
except (OSError, NotImplementedError):
shutil.copy(out_clang_dll, dst)
else: else:
ctx.env.rpath = ctx.env['LIBPATH_clang'] ctx.env.rpath = ctx.env['LIBPATH_clang']