Skip to content
This repository has been archived by the owner on Feb 4, 2020. It is now read-only.

Add support for loading config from a clcache.conf file #320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

formiaczek
Copy link
Contributor

@formiaczek formiaczek commented Jul 29, 2018

This is useful and the GCC version of ccache also implements a similar concept.

It might be useful in situations where some default settings could be
specified or when environment is not passed correctly down to the compiler
chain.

This change introduces support for clcache.conf file to allow clcache
to read settings from there.

The precedence is as follows:

  1. If present, the Environment variable's value is used, or
  2. [current_working_dir]/clcache.conf is loaded, or, if not found
  3. [%USERPROFILE% or ~/].clcache/clcache.conf is be loaded, or if not found
  4. [%ALLUSERSPROFILE% or /etc/].clcache/clcache.conf is loaded.

In each case, once a clcache.conf file is found, no other conf file is
considered and values only from this file are used. It is also loaded
only once (and all its values then cached) - all to avoid unnecessary
performance penalties.

(relevant tests were also added)

@formiaczek
Copy link
Contributor Author

formiaczek commented Jul 29, 2018

There seems to be an issue with continuous-integration builds:

Python 3.6.6
pip install -U pip setuptools wheel
ERROR: To modify pip, please run the following command:
c:\python36\python.exe -m pip install -U pip setuptools wheel
You are using pip version 10.0.1, however version 18.0 is available.

But it doesn't seem like in scope of this PR, so I didn't try to fix it, sorry. I could still run tests manually though and they all pass.

Also, another thing to add to compliment the above would be to add CLCACHE_MAX_SIZE to settings / Environment config: just so that different CLCACHEs don't really require having to call 'clcache -M'.

And another nice (and really easy) thing to add would be suffixes. CCACHE allows for something like:

ccache -M 100M  # sets it to   100,000,000 bytes
ccache -M 1G    # sets it to 1,000,000,000 bytes

Hope you like the change and will pull it, I'm sure it'll be useful.

@formiaczek
Copy link
Contributor Author

Oh, and another useful thing would be for tests to override CLCACHE_CL with some 'dummy (mock)' 'cl.exe' (e.g. a python script) - so that one could run tests without having VisualStudio compiler suite installed. It'd allow for maybe faster / cleaner test execution.

@formiaczek
Copy link
Contributor Author

I have another idea for a suggestion (if you don't mind, sorry for spamming).

The 'Integration' part of Wiki (https://github.com/frerich/clcache/wiki/Integration)
could probably benefit from having the CLTask integration information as described in Caveats (https://github.com/frerich/clcache/wiki/Caveats) as a main way to integrate it (as it's clean), and maybe the compiler binary replacement could be really a 'workaround' than a 'main way of integrating' with MSVC? I've spend some time searching / trying myself how to avoid modifications to system installation until I really bothered to read Caveats.. which had this information I was looking for.. maybe just me, but again - it's just a suggestion :)).

@formiaczek formiaczek force-pushed the read-options-from-config-file branch from b2486d5 to 89c7c61 Compare July 29, 2018 16:59
@siu
Copy link
Contributor

siu commented Jul 30, 2018

👍 Good suggestions

@frerich
Copy link
Owner

frerich commented Jul 30, 2018

I think your suggestions sound really good, but unfortunately I have to admit that I didn't get around to maintaining this project as much as I'd like to; I only just returned from my summer vacation and on my desk there's a pile of other tasks to work on unfortunately - only little time left for 'recreational programming' in my spare time. Furthemore, I stopped using clcache myself a couple of months ago, the remaining C++ project I'm involved with (using a proprietary build system) doesn't really benefit from it anymore.

Hence, I wonder: what would be a good way to contact users/contributors to the project and invite others to step forward and take over maintainership? There are a number of users of this tool in various projects and I feel it's still very worthwhile to continue putting work into clcache, e.g. by implementing improvements such as the one you describe.

@formiaczek
Copy link
Contributor Author

formiaczek commented Jul 30, 2018

I didn't get around to maintaining this project as much as I'd like to

Understood, no worries - I think it's in a good state, and it seems to work for me :) I had the same with some of my pet projects: it's not easy to keep up with out-of-work stuff in one's spare time. But it's still worth it - as if not people who do this, there'd be no useful software for those who need & use it :)

I wonder: what would be a good way to contact users/contributors to the project and invite others to step forward and take over maintainership?

I'm not sure. But I think maybe mentioning this on a Wiki / README page in form of 'new maintainers needed' or something? There are many people who often ask on various forums/groups how they could get into open-source. They usually get generic (and not very useful) replies like: 'Find something on github/sourceforge and try contributing / fixing some issue etc'. This project already has a fair and friendly invite for contributions IMO.

There are a number of users of this tool in various projects and I feel it's still very worthwhile to continue putting work into clcache,

Agreed! 👍 Myself including, I've recently picked up clcache - thanks for creating it! (I'm really a Linux person, but I need MSVC tools and would like to use tools like this one whenever possible). I've been using CCACHE, icecc/icecream for years and I think they're great. They fill out an important gap in the toolchain (IMO compilers could really offer this out of the box..maybe someday?).

Anyway, I don't want to volunteer that much as I can't promise too much regarding time to maintain it, but I don't mind from time to time having a look / code-review or something? I for sure won't mind providing features that I think are needed / helpful to make it more useful (and I'll try to do it keeping high quality standards, as required) so they hopefully could be merged.

I think the most important thing would be to fix the continuous integration as this is really a first source of truth on sanity of proposed changes ;)

@formiaczek formiaczek force-pushed the read-options-from-config-file branch 5 times, most recently from 4751ac8 to 2cc04bb Compare July 31, 2018 21:23
@formiaczek formiaczek force-pushed the read-options-from-config-file branch 10 times, most recently from 9733cdd to b05cf8c Compare September 6, 2018 00:07
@codecov-io
Copy link

codecov-io commented Sep 6, 2018

Codecov Report

Merging #320 into master will increase coverage by 0.09%.
The diff coverage is 84.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #320      +/-   ##
==========================================
+ Coverage   88.23%   88.32%   +0.09%     
==========================================
  Files           4        4              
  Lines        1275     1302      +27     
  Branches      190      196       +6     
==========================================
+ Hits         1125     1150      +25     
- Misses        111      112       +1     
- Partials       39       40       +1
Flag Coverage Δ
#integrationtests_memcached 67% <64.44%> (+0.15%) ⬆️
#unittests 85.4% <80%> (+0.15%) ⬆️
Impacted Files Coverage Δ
clcache/__main__.py 90.17% <84.44%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d62cc1...40b5736. Read the comment docs.

@frerich frerich added the feature label Sep 6, 2018
@formiaczek formiaczek force-pushed the read-options-from-config-file branch from b05cf8c to 15cfa30 Compare September 6, 2018 22:04
@formiaczek formiaczek force-pushed the read-options-from-config-file branch from 15cfa30 to ceed29f Compare September 20, 2018 00:03
This is useful and the GCC version of ccache also implements a similar concept.

It might be useful in situations where some default settings could be
specified or when environment is not passed correctly down to the compiler
chain.

This change introduces support for clcache.conf file to allow clcache
to read settings from there.

The precedence is as follows:
 1. If present, Environment variable(s) are used, or
 2. [current_working_dir]\clcache.conf is loaded, or, if not found
 3. [%HOME% or ~\].clcache\clcache.conf is be loaded, or if not found
 4. [%ALLUSERSPROFILE% or C:\Users\].clcache\clcache.conf is loaded.

In each case, once a clcache.conf file is found, no other conf file is
considered and values only from this file are used. It is also loaded
only once (and all its values then cached) - all to avoid unnecessary
performance penalties.
@formiaczek formiaczek force-pushed the read-options-from-config-file branch from ceed29f to 40b5736 Compare September 20, 2018 00:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants