New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows build script #154

Merged
merged 5 commits into from Dec 17, 2017

Conversation

Projects
None yet
3 participants
@Riatre
Contributor

Riatre commented Dec 17, 2017

Only works with the Visual Studio (>=2015) toolchains, as Loguru is not very friendly to MinGW-w64 or Clang++ on Windows.

Both bundled clang and system clang works. With system clang it is required to specify --clang-prefix as there is no llvm-config. In bundled clang mode it fetches the NSIS installer executable from releases.llvm.org and extracts the files with 7-zip, for this purpose a 7z.exe should be presented in %PATH%.

Riatre added some commits Dec 17, 2017

Upgrades to waf 2.0.2.
For VS2017 support on Windows.
[waf] Supports building on Windows.
Needs 7z.exe in PATH for extracting prebuilt clang NSIS installer (when
using bundled clang).
RPATH is "emulated" by putting a libclang.dll alongside the cquery
binary.
Tested with Visual Studio 2017 toolchain.
@MaskRay

This comment has been minimized.

Show comment
Hide comment
@MaskRay

MaskRay Dec 17, 2017

Member

講道理,so awesome.

Member

MaskRay commented Dec 17, 2017

講道理,so awesome.

@jiegec

This comment has been minimized.

Show comment
Hide comment
@jiegec

jiegec Dec 17, 2017

Contributor

Wow, really great!

Contributor

jiegec commented Dec 17, 2017

Wow, really great!

config->indexerCount =
std::thread::hardware_concurrency() * kDefaultTargetUtilization;
const float kDefaultTargetUtilization = 0.8f;
config->indexerCount = (int)(

This comment has been minimized.

@MaskRay

MaskRay Dec 17, 2017

Member

Did the old one cause warning C4244: 'initializing': conversion from 'const float' to 'int', possible loss of data?

@MaskRay

MaskRay Dec 17, 2017

Member

Did the old one cause warning C4244: 'initializing': conversion from 'const float' to 'int', possible loss of data?

This comment has been minimized.

@Riatre

Riatre Dec 17, 2017

Contributor

Yes. Actually there were two C4244 warnings: conversion from 'double' to 'float' and conversion from 'float' to 'int'.

@Riatre

Riatre Dec 17, 2017

Contributor

Yes. Actually there were two C4244 warnings: conversion from 'double' to 'float' and conversion from 'float' to 'int'.

@jiegec

This comment has been minimized.

Show comment
Hide comment
@jiegec

jiegec Dec 17, 2017

Contributor

Appveyor link: https://ci.appveyor.com/project/Riatre/cquery.
We need more windows developers to test it.

Contributor

jiegec commented Dec 17, 2017

Appveyor link: https://ci.appveyor.com/project/Riatre/cquery.
We need more windows developers to test it.

sys.stderr.write('ERROR: Unknown platform {0}\n'.format(sys.platform))
sys.exit(1)
from waflib.Tools.compiler_cxx import cxx_compiler
cxx_compiler['linux'] = ['clang++', 'g++']
if sys.version_info < (3, 0):

This comment has been minimized.

@MaskRay

MaskRay Dec 17, 2017

Member

Is this shim for https://docs.python.org/2/library/os.html#os.symlink (In Python 2, os.symlink is only available for Unix-like systems)?

@MaskRay

MaskRay Dec 17, 2017

Member

Is this shim for https://docs.python.org/2/library/os.html#os.symlink (In Python 2, os.symlink is only available for Unix-like systems)?

This comment has been minimized.

@Riatre

Riatre Dec 17, 2017

Contributor

Yes.
In Python 3 os.symlink got an additional argument target_is_directory and it is required for symbolic linking directories on Windows. To be Python 2 compatible we have to wrap os.symlink even on Unix-like systems. It is (and should be) simply ignored on Unix-like systems as per https://docs.python.org/3/library/os.html#os.symlink

@Riatre

Riatre Dec 17, 2017

Contributor

Yes.
In Python 3 os.symlink got an additional argument target_is_directory and it is required for symbolic linking directories on Windows. To be Python 2 compatible we have to wrap os.symlink even on Unix-like systems. It is (and should be) simply ignored on Unix-like systems as per https://docs.python.org/3/library/os.html#os.symlink

This comment has been minimized.

@jiegec

jiegec Dec 17, 2017

Contributor

I think putting these into a separate file is better (e.g. compat.py).

@jiegec

jiegec Dec 17, 2017

Contributor

I think putting these into a separate file is better (e.g. compat.py).

@@ -72,28 +105,43 @@ def download_and_extract(destdir, url):
if not os.path.isdir(destdir):
print('Extracting')
# TODO: make portable.
subprocess.call(['tar', '-x', '-C', out, '-f', dest])
if ext == '.exe':
subprocess.call(['7z', 'x', '-o{0}'.format(destdir), '-xr!$PLUGINSDIR', dest])

This comment has been minimized.

@MaskRay

MaskRay Dec 17, 2017

Member

What is -xr!$PLUGINSDIR for?

@MaskRay

MaskRay Dec 17, 2017

Member

What is -xr!$PLUGINSDIR for?

@jiegec

This comment has been minimized.

Show comment
Hide comment
@jiegec

jiegec Dec 17, 2017

Contributor

Why is waf changed? emmmm new version, or? This should be unrelated to the reset of the changeset.

Contributor

jiegec commented Dec 17, 2017

Why is waf changed? emmmm new version, or? This should be unrelated to the reset of the changeset.

@MaskRay

This comment has been minimized.

Show comment
Hide comment
@MaskRay

MaskRay Dec 17, 2017

Member

It would be much appreciated if you could contribute a topic in https://github.com/jacobdufault/cquery/wiki to tell Windows users what to do...

Member

MaskRay commented Dec 17, 2017

It would be much appreciated if you could contribute a topic in https://github.com/jacobdufault/cquery/wiki to tell Windows users what to do...

elif sys.platform == 'win32':
rpath = [] # Unsupported
name = os.path.basename(os.path.dirname(bld.env['LIBPATH_clang'][0]))
# Poor Windows users' RPATH

This comment has been minimized.

@jiegec

jiegec Dec 17, 2017

Contributor

Ok, man, that's just the same directory with cquery.exe.
这波吐槽我给满分

@jiegec

jiegec Dec 17, 2017

Contributor

Ok, man, that's just the same directory with cquery.exe.
这波吐槽我给满分

sys.stderr.write('ERROR: Unknown platform {0}\n'.format(sys.platform))
sys.exit(1)
from waflib.Tools.compiler_cxx import cxx_compiler
cxx_compiler['linux'] = ['clang++', 'g++']
if sys.version_info < (3, 0):

This comment has been minimized.

@jiegec

jiegec Dec 17, 2017

Contributor

I think putting these into a separate file is better (e.g. compat.py).

@jiegec

jiegec Dec 17, 2017

Contributor

I think putting these into a separate file is better (e.g. compat.py).

@Riatre

This comment has been minimized.

Show comment
Hide comment
@Riatre

Riatre Dec 17, 2017

Contributor

@jiegec waf 1.9.8 (current version in the repo) is not able to detect VS2017 properly. According to the changelog it was added in 1.9.9...

@MaskRay Thanks, I'll try to document the Windows build process.

Contributor

Riatre commented Dec 17, 2017

@jiegec waf 1.9.8 (current version in the repo) is not able to detect VS2017 properly. According to the changelog it was added in 1.9.9...

@MaskRay Thanks, I'll try to document the Windows build process.

@jiegec

This comment has been minimized.

Show comment
Hide comment
@jiegec

jiegec Dec 17, 2017

Contributor

@Riatre Ria Oh thx for your explanation. I missed your commit message.

Contributor

jiegec commented Dec 17, 2017

@Riatre Ria Oh thx for your explanation. I missed your commit message.

@MaskRay MaskRay merged commit 0beb046 into cquery-project:master Dec 17, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@MaskRay

This comment has been minimized.

Show comment
Hide comment
@MaskRay

MaskRay Dec 17, 2017

Member

This does not affect *NIX build (currently Linux only because platform_linux.cc does not compile on FreeBSD). So I think this should be fine to merge... To make Riatre's future improvement easier.

If it did not bring much trouble, using resourceDirectory shipped with bundled clang for Windows would be great. IMHO the clang_resource_dir in the project root should be removed.

  # Fallback for windows
  default_resource_directory = os.path.join(os.getcwd(), 'clang_resource_dir')  # this may be removed in favor of `clang+llvm*/lib/clang/[45].0.0`
build/release/  # this also reflects the $PREFIX/ hierarchy
  bin/
    cquery      # cquery.el: cquery-executable; LanguageClient-neovim: g:LanguageClient_serverCommands
  lib/
    clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/
      lib/
        libclang.so.5     # DT_NEEDED by bin/cquery
        clang/5.0.0/      # resourceDirectory
          include/        # implicit isystem path used by libclang
            stddef.h
            float.h
            ...

jiegec's

.
├── bin
│   └── cquery
├── cquery.log
└── lib
    └── clang+llvm-4.0.0-x86_64-apple-darwin
        └── lib
            ├── clang
            │   └── 4.0.0
            │       └── include
            │           ├── rdseedintrin.h
            │           ├── tbmintrin.h
            └── libclang.dylib
Member

MaskRay commented Dec 17, 2017

This does not affect *NIX build (currently Linux only because platform_linux.cc does not compile on FreeBSD). So I think this should be fine to merge... To make Riatre's future improvement easier.

If it did not bring much trouble, using resourceDirectory shipped with bundled clang for Windows would be great. IMHO the clang_resource_dir in the project root should be removed.

  # Fallback for windows
  default_resource_directory = os.path.join(os.getcwd(), 'clang_resource_dir')  # this may be removed in favor of `clang+llvm*/lib/clang/[45].0.0`
build/release/  # this also reflects the $PREFIX/ hierarchy
  bin/
    cquery      # cquery.el: cquery-executable; LanguageClient-neovim: g:LanguageClient_serverCommands
  lib/
    clang+llvm-5.0.0-linux-x86_64-ubuntu14.04/
      lib/
        libclang.so.5     # DT_NEEDED by bin/cquery
        clang/5.0.0/      # resourceDirectory
          include/        # implicit isystem path used by libclang
            stddef.h
            float.h
            ...

jiegec's

.
├── bin
│   └── cquery
├── cquery.log
└── lib
    └── clang+llvm-4.0.0-x86_64-apple-darwin
        └── lib
            ├── clang
            │   └── 4.0.0
            │       └── include
            │           ├── rdseedintrin.h
            │           ├── tbmintrin.h
            └── libclang.dylib

MaskRay added a commit that referenced this pull request Dec 31, 2017

Windows build script (#154)
* Cast from float explicitly.

* Upgrades to waf 2.0.2.

For VS2017 support on Windows.

* [waf] Supports building on Windows.

Needs 7z.exe in PATH for extracting prebuilt clang NSIS installer (when
using bundled clang).
RPATH is "emulated" by putting a libclang.dll alongside the cquery
binary.
Tested with Visual Studio 2017 toolchain.

* [waf] Fix default_resource_directory on Windows + system clang.

* Add AppVeyor configuration

MaskRay added a commit that referenced this pull request Dec 31, 2017

Windows build script (#154)
* Cast from float explicitly.

* Upgrades to waf 2.0.2.

For VS2017 support on Windows.

* [waf] Supports building on Windows.

Needs 7z.exe in PATH for extracting prebuilt clang NSIS installer (when
using bundled clang).
RPATH is "emulated" by putting a libclang.dll alongside the cquery
binary.
Tested with Visual Studio 2017 toolchain.

* [waf] Fix default_resource_directory on Windows + system clang.

* Add AppVeyor configuration

MaskRay added a commit that referenced this pull request Dec 31, 2017

Windows build script (#154)
* Cast from float explicitly.

* Upgrades to waf 2.0.2.

For VS2017 support on Windows.

* [waf] Supports building on Windows.

Needs 7z.exe in PATH for extracting prebuilt clang NSIS installer (when
using bundled clang).
RPATH is "emulated" by putting a libclang.dll alongside the cquery
binary.
Tested with Visual Studio 2017 toolchain.

* [waf] Fix default_resource_directory on Windows + system clang.

* Add AppVeyor configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment