Skip to content

Commit f964cb1

Browse files
committed
Do not load local settings project deps on init.
1 parent f86d701 commit f964cb1

5 files changed

Lines changed: 42 additions & 11 deletions

File tree

src/client/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ void load_current_config()
512512
{
513513
// load local settings for storage dir
514514
Config c;
515-
c.allow_relative_project_names = true;
516-
c.allow_local_dependencies = true;
517-
c.load_current_config();
515+
//c.allow_relative_project_names = true;
516+
//c.allow_local_dependencies = true;
517+
c.load_current_config_settings();
518518
}
519519
catch (...)
520520
{

src/common/config.cpp

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ void Config::load_current_config()
7878
addDefaultProject();
7979
}
8080

81+
void Config::load_current_config_settings()
82+
{
83+
if (!fs::exists(dir / CPPAN_FILENAME))
84+
return addDefaultProject();
85+
auto root = load_yaml_config(dir / CPPAN_FILENAME);
86+
load_settings(root, false);
87+
}
88+
8189
void Config::load(const path &p)
8290
{
8391
auto root = load_yaml_config(p);
@@ -90,22 +98,40 @@ void Config::load(const String &s)
9098
load(root);
9199
}
92100

93-
void Config::load(const yaml &root)
101+
void Config::load_settings(const yaml &root, bool load_project)
94102
{
95-
if (root.IsNull() || !root.IsMap())
96-
{
97-
addDefaultProject();
98-
LOG_DEBUG(logger, "Spec file should be a map");
103+
if (!check_config_root(root))
99104
return;
100-
}
101105

102106
auto ls = root["local_settings"];
103107
if (ls.IsDefined())
104108
{
105109
if (!ls.IsMap())
106110
throw std::runtime_error("'local_settings' should be a map");
107-
Settings::get_local_settings().load(root["local_settings"], SettingsType::Local);
111+
auto &ls = Settings::get_local_settings();
112+
ls.load_project = load_project;
113+
ls.load(root["local_settings"], SettingsType::Local);
114+
ls.load_project = true;
108115
}
116+
}
117+
118+
bool Config::check_config_root(const yaml &root)
119+
{
120+
if (root.IsNull() || !root.IsMap())
121+
{
122+
addDefaultProject();
123+
LOG_DEBUG(logger, "Spec file should be a map");
124+
return false;
125+
}
126+
return true;
127+
}
128+
129+
void Config::load(const yaml &root)
130+
{
131+
if (!check_config_root(root))
132+
return;
133+
134+
load_settings(root);
109135

110136
ProjectPath root_project;
111137
EXTRACT(root_project, String);

src/common/config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct Config
3939
void reload(const path &p);
4040

4141
void load_current_config();
42+
void load_current_config_settings();
4243

4344
void process(const path &p = path()) const;
4445
void post_download() const;
@@ -66,6 +67,9 @@ struct Config
6667
void addDefaultProject();
6768
Project &getProject1(const ProjectPath &ppath);
6869

70+
bool check_config_root(const yaml &root);
71+
void load_settings(const yaml &root, bool load_project = true);
72+
6973
public:
7074
bool defaults_allowed = true;
7175
bool allow_relative_project_names = false;

src/common/settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void Settings::load_main(const yaml &root, const SettingsType type)
201201
}
202202

203203
// read project settings (deps etc.)
204-
if (type == SettingsType::Local)
204+
if (type == SettingsType::Local && load_project)
205205
{
206206
Project p;
207207
p.allow_relative_project_names = true;

src/common/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct Settings
128128

129129
// not for loading from config
130130
bool generate_only = false;
131+
bool load_project = true;
131132

132133
public:
133134
Settings();

0 commit comments

Comments
 (0)