Skip to content
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

[READY] Improve LLVM root path search for prebuilt binaries #820

Merged
merged 1 commit into from
Aug 29, 2017

Conversation

micbou
Copy link
Collaborator

@micbou micbou commented Aug 27, 2017

This PR simplifies the way we determine PATH_TO_LLVM_ROOT for Clang prebuilt binaries by using a glob pattern.

Fixes ycm-core/YouCompleteMe#2756.


This change is Reviewable

@bstaletic
Copy link
Collaborator

:lgtm:


Reviewed 1 of 1 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@codecov-io
Copy link

codecov-io commented Aug 27, 2017

Codecov Report

Merging #820 into master will increase coverage by 0.05%.
The diff coverage is 70%.

@@            Coverage Diff             @@
##           master     #820      +/-   ##
==========================================
+ Coverage   94.78%   94.84%   +0.05%     
==========================================
  Files          79       79              
  Lines        5373     5373              
  Branches      170      169       -1     
==========================================
+ Hits         5093     5096       +3     
+ Misses        233      231       -2     
+ Partials       47       46       -1

@puremourning
Copy link
Member

Review status: all files reviewed at latest revision, 3 unresolved discussions.


cpp/ycm/CMakeLists.txt, line 132 at r1 (raw file):
So, while I'm sure this works, I can't find any evidence in the (abysmal) cmake docs that ** is portably supported in glob expressions. Or at least, whether it has a special meaning. I suspect this is actually representing 2 consecutive * matches, which seems redundant.

I quickly checked the man pages on my OS (macOS) for:

  • man -s 3 glob - the c glob function
  • man bash - the bash shell expansion
  • man tcsh - the csh shell expansion

The only indication of special behaviour i found was in tcsh:

   The globstar shell variable can be set to allow `**' or `***' as a file glob pattern that matches any string of characters including `/', recursively traversing any existing sub-directories.  For example, `ls **.c' will list  all
   the  .c  files  in  the  current  directory  tree.   If  used by itself, it will match match zero or more sub-directories (e.g. `ls /usr/include/**/time.h' will list any file named `time.h' in the /usr/include directory tree; `ls
   /usr/include/**time.h' will match any file in the /usr/include directory tree ending in `time.h'; and `ls /usr/include/**time**.h' will match any .h file with `time' either in a subdirectory name or in the filename  itself).   To
   prevent problems with recursion, the `**' glob-pattern will not descend into a symbolic link containing a directory.  To override this, use `***' (+)

So I'm unsure how the ** is being interpreted here, and I struggled to find out. So the question is, are you confident in this? If so, meh :)


cpp/ycm/CMakeLists.txt, line 133 at r1 (raw file):

  # CMake build folder.
  file( GLOB_RECURSE PATH_TO_LLVM_ROOT ${CMAKE_BINARY_DIR}/**/libclang.* )
  list( GET PATH_TO_LLVM_ROOT 0 PATH_TO_LLVM_ROOT )

Because I don't grok cmake (and the documentation for cmake is appalling), what the behaviour in the case that this list has 0 elements?


cpp/ycm/CMakeLists.txt, line 134 at r1 (raw file):

  file( GLOB_RECURSE PATH_TO_LLVM_ROOT ${CMAKE_BINARY_DIR}/**/libclang.* )
  list( GET PATH_TO_LLVM_ROOT 0 PATH_TO_LLVM_ROOT )
  get_filename_component( PATH_TO_LLVM_ROOT "${PATH_TO_LLVM_ROOT}/../.."

It's not super obvious to me why we need ../.. here or why that's (canonically) correct. I'm sure it is (e.g. it represents usr/lib or something), but perhaps we need a comment?


Comments from Reviewable

@micbou micbou changed the title [READY] Improve LLVM root path search for prebuilt binaries [WIP] Improve LLVM root path search for prebuilt binaries Aug 28, 2017
Use a glob pattern to determine PATH_TO_LLVM_ROOT for Clang prebuilt binaries.
@micbou
Copy link
Collaborator Author

micbou commented Aug 28, 2017

Thanks for the review.


Reviewed 1 of 1 files at r1, 1 of 1 files at r2.
Review status: all files reviewed at latest revision, 3 unresolved discussions.


cpp/ycm/CMakeLists.txt, line 132 at r1 (raw file):

Previously, puremourning (Ben Jackson) wrote…

So, while I'm sure this works, I can't find any evidence in the (abysmal) cmake docs that ** is portably supported in glob expressions. Or at least, whether it has a special meaning. I suspect this is actually representing 2 consecutive * matches, which seems redundant.

I quickly checked the man pages on my OS (macOS) for:

  • man -s 3 glob - the c glob function
  • man bash - the bash shell expansion
  • man tcsh - the csh shell expansion

The only indication of special behaviour i found was in tcsh:

   The globstar shell variable can be set to allow `**' or `***' as a file glob pattern that matches any string of characters including `/', recursively traversing any existing sub-directories.  For example, `ls **.c' will list  all
   the  .c  files  in  the  current  directory  tree.   If  used by itself, it will match match zero or more sub-directories (e.g. `ls /usr/include/**/time.h' will list any file named `time.h' in the /usr/include directory tree; `ls
   /usr/include/**time.h' will match any file in the /usr/include directory tree ending in `time.h'; and `ls /usr/include/**time**.h' will match any .h file with `time' either in a subdirectory name or in the filename  itself).   To
   prevent problems with recursion, the `**' glob-pattern will not descend into a symbolic link containing a directory.  To override this, use `***' (+)

So I'm unsure how the ** is being interpreted here, and I struggled to find out. So the question is, are you confident in this? If so, meh :)

For some reason, I thought I could use ** like in Zsh. In fact, it's totally useless when using GLOB_RECURSE (see the /dir/*.py example in the docs). I've modified the pattern.


cpp/ycm/CMakeLists.txt, line 133 at r1 (raw file):

Previously, puremourning (Ben Jackson) wrote…

Because I don't grok cmake (and the documentation for cmake is appalling), what the behaviour in the case that this list has 0 elements?

If the list is empty, CMake returns the following error:

CMake Error at CMakeLists.txt:7 (list):
  list GET given empty list

but continues to execute the script. This results in PATH_TO_LLVM_ROOT being set to / in the next line. Probably harmless but still better to check if the list is empty and abort the script if so.


cpp/ycm/CMakeLists.txt, line 134 at r1 (raw file):

Previously, puremourning (Ben Jackson) wrote…

It's not super obvious to me why we need ../.. here or why that's (canonically) correct. I'm sure it is (e.g. it represents usr/lib or something), but perhaps we need a comment?

Added a comment to clarify the /../.. part.


Comments from Reviewable

@micbou micbou changed the title [WIP] Improve LLVM root path search for prebuilt binaries [READY] Improve LLVM root path search for prebuilt binaries Aug 28, 2017
@puremourning
Copy link
Member

:lgtm:


Review status: all files reviewed at latest revision, 3 unresolved discussions.


Comments from Reviewable

@Valloric
Copy link
Member

Thanks for the PR!

@zzbot r=bstaletic


Review status: all files reviewed at latest revision, 3 unresolved discussions.


Comments from Reviewable

@zzbot
Copy link
Contributor

zzbot commented Aug 29, 2017

📌 Commit db63cef has been approved by bstaletic

zzbot added a commit that referenced this pull request Aug 29, 2017
[READY] Improve LLVM root path search for prebuilt binaries

This PR simplifies the way we determine `PATH_TO_LLVM_ROOT` for Clang prebuilt binaries by using a glob pattern.

Fixes ycm-core/YouCompleteMe#2756.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/820)
<!-- Reviewable:end -->
@zzbot
Copy link
Contributor

zzbot commented Aug 29, 2017

⌛ Testing commit db63cef with merge 0afdba4...

@zzbot
Copy link
Contributor

zzbot commented Aug 29, 2017

☀️ Test successful - status-travis
Approved by: bstaletic
Pushing 0afdba4 to master...

@zzbot zzbot merged commit db63cef into ycm-core:master Aug 29, 2017
@micbou micbou deleted the path-to-llvm-root-binaries branch August 29, 2017 09:33
zzbot added a commit to ycm-core/YouCompleteMe that referenced this pull request Sep 10, 2017
[READY] Update ycmd

This new version of ycmd includes the following changes:

 - PR ycm-core/ycmd#795: add option to make relative paths in flags from extra conf absolute;
 - PR ycm-core/ycmd#802: fix compilation on Haiku;
 - PR ycm-core/ycmd#804: add libclang detection on FreeBSD;
 - PR ycm-core/ycmd#808: write python used during build before installing completers;
 - PR ycm-core/ycmd#810: support unknown languages from tags;
 - PR ycm-core/ycmd#811: update Universal Ctags languages list;
 - PR ycm-core/ycmd#814: resolve symlinks in extra conf glob patterns;
 - PR ycm-core/ycmd#815: update JediHTTP;
 - PR ycm-core/ycmd#816: update Boost to 1.65.0;
 - PR ycm-core/ycmd#819: filter and sort candidates when query is empty;
 - PR ycm-core/ycmd#820: improve LLVM root path search for prebuilt binaries;
 - PR ycm-core/ycmd#822: inline critical utility functions;
 - PR ycm-core/ycmd#824: do not sort header paths in filename completer;
 - PR ycm-core/ycmd#825: implement partial sorting;
 - PR ycm-core/ycmd#830: add max_num_candidates option;
 - PR ycm-core/ycmd#831: fix multiline comments and strings issues;
 - PR ycm-core/ycmd#832: update Clang to 5.0.0.

The `g:ycm_max_num_candidates` and `g:ycm_max_num_identifier_candidates` options are added to the documentation.

The link to ycmd extra conf is updated.

Fixes #2562.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2768)
<!-- Reviewable:end -->
zzbot added a commit to ycm-core/YouCompleteMe that referenced this pull request Sep 10, 2017
[READY] Update ycmd

This new version of ycmd includes the following changes:

 - PR ycm-core/ycmd#795: add option to make relative paths in flags from extra conf absolute;
 - PR ycm-core/ycmd#802: fix compilation on Haiku;
 - PR ycm-core/ycmd#804: add libclang detection on FreeBSD;
 - PR ycm-core/ycmd#808: write python used during build before installing completers;
 - PR ycm-core/ycmd#810: support unknown languages from tags;
 - PR ycm-core/ycmd#811: update Universal Ctags languages list;
 - PR ycm-core/ycmd#814: resolve symlinks in extra conf glob patterns;
 - PR ycm-core/ycmd#815: update JediHTTP;
 - PR ycm-core/ycmd#816: update Boost to 1.65.0;
 - PR ycm-core/ycmd#819: filter and sort candidates when query is empty;
 - PR ycm-core/ycmd#820: improve LLVM root path search for prebuilt binaries;
 - PR ycm-core/ycmd#822: inline critical utility functions;
 - PR ycm-core/ycmd#824: do not sort header paths in filename completer;
 - PR ycm-core/ycmd#825: implement partial sorting;
 - PR ycm-core/ycmd#830: add max_num_candidates option;
 - PR ycm-core/ycmd#831: fix multiline comments and strings issues;
 - PR ycm-core/ycmd#832: update Clang to 5.0.0.

The `g:ycm_max_num_candidates` and `g:ycm_max_num_identifier_candidates` options are added to the documentation.

The link to ycmd extra conf is updated.

Fixes #2562.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2768)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants