Skip to content

Commit fdb75ec

Browse files
committed
Add support for Windows to load from ~/.Wuild/Wuild.ini by default and update the docs.
1 parent 575ff2c commit fdb75ec

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ listenPort=7767 ; exact same as [toolServer] coordinatorPort. make
169169
```
170170
Now you can stop WuildCoordinator and WuildToolServer on the client, and run both on the server (192.168.0.2) machine. Now you will have build distributed between two hosts.
171171

172+
# Configuration: commandline and config file
173+
For every option in ini file, you can also provide its value form the commandline; you need to add ```--wuild-``` prefix to it, for example:
174+
```
175+
WuildNinja --wuild-logLevel=7 --wuild-coordinatorHost=testhost
176+
```
177+
Any commandline option has higher priority that ini option. However, keep in mind, that all commandline variable placed in 'global' scope, so you can't provide different 'listenPort' for different scopes.
178+
179+
Let's now talk about ini config file location. It tries to load these locations in order:
180+
- ```--wuild-config=/path/file.ini``` command line parameter (and stops with error if path provided but invalid);
181+
- ```WUILD_CONFIG=/path/file.ini``` environment variable (and stops with error if path provided but invalid);
182+
- ```~/.Wuild/Wuild.ini``` (for Windows ~ is %USERPROFILE%);
183+
- (Windows only) ```~/Wuild.ini```;
184+
- Final attempt, it will try to load ```Wuild.ini``` in the same directory with main executable (e.g. WuildNinja).
185+
If first two was not set and search is ended, then Wuild is set to "unconfigured mode". For WuildNinja it means it will fallback to plain ninja.
172186

173187
# Advanced usage
174188
After Quick Start, next step is to add more ToolServers and maybe Coordinators (so you can safely shutown one server without disabling all builds on CI).

src/ConfiguredApplication/ConfiguredApplication.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,9 @@
2727
#include <memory>
2828

2929
namespace {
30-
const std::string g_defaultConfigSubfolder =
31-
#ifndef _WIN32
32-
".Wuild/"
33-
#else
34-
""
35-
#endif
36-
;
37-
const std::string g_defaultConfig = "Wuild.ini";
38-
const std::string g_envConfig = "WUILD_CONFIG";
30+
const std::string g_defaultConfigSubfolder = ".Wuild/";
31+
const std::string g_defaultConfig = "Wuild.ini";
32+
const std::string g_envConfig = "WUILD_CONFIG";
3933
}
4034

4135
namespace Wuild {
@@ -62,6 +56,9 @@ ConfiguredApplication::ConfiguredApplication(const StringVector& argConfig, cons
6256
unexistendConfigIsError = false;
6357
const std::vector<std::string> configPaths{
6458
Application::Instance().GetHomeDir() + "/" + g_defaultConfigSubfolder + g_defaultConfig,
59+
#ifdef _WIN32
60+
Application::Instance().GetHomeDir() + "/" + g_defaultConfig,
61+
#endif
6562
Application::Instance().GetExecutablePath() + g_defaultConfig,
6663
};
6764
for (const auto& path : configPaths)
@@ -70,6 +67,7 @@ ConfiguredApplication::ConfiguredApplication(const StringVector& argConfig, cons
7067
break;
7168
}
7269
}
70+
7371
if (!config.ReadIniFile(configPath) && unexistendConfigIsError) {
7472
Syslogger(Syslogger::Err) << "Failed to load:" << configPath;
7573
}
@@ -85,6 +83,8 @@ ConfiguredApplication::ConfiguredApplication(const StringVector& argConfig, cons
8583

8684
InitLogging(m_loggerConfig);
8785

86+
Syslogger() << "Using Wuild config = " << configPath;
87+
8888
m_tempDir = m_config->GetString(m_defaultGroupName, "tempDir", Application::Instance().GetTempDir());
8989
}
9090

0 commit comments

Comments
 (0)