-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathsettings.h
More file actions
177 lines (147 loc) · 4.83 KB
/
settings.h
File metadata and controls
177 lines (147 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
* Copyright (C) 2016-2017, Egor Pugin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "cppan_string.h"
#include "filesystem.h"
#include "http.h"
#include "remote.h"
#include "version.h"
#include "yaml.h"
#include "printers/printer.h"
#include <primitives/executor.h>
#include <map>
void cleanConfig(const String &config);
void cleanConfigs(const Strings &configs);
struct BuildSettings
{
bool allow_links = true;
bool disable_checks = false;
bool test_run = false;
String filename;
String filename_without_ext;
path source_directory;
path binary_directory;
String source_directory_hash;
String config;
mutable String config_fullname;
void set_build_dirs(const String &name);
void append_build_dirs(const path &p);
void append_config_name(String &s) const;
};
struct Settings
{
enum CMakeConfigurationType
{
Debug,
MinSizeRel,
Release,
RelWithDebInfo,
Max
};
// connection
Remotes remotes{ get_default_remotes() };
ProxySettings proxy;
// sys/user config settings
SettingsType storage_dir_type{ SettingsType::User };
path storage_dir;
SettingsType build_dir_type{ SettingsType::Local };
path build_dir;
path cppan_dir = ".cppan";
path output_dir = "bin";
// printer
PrinterType printerType{ PrinterType::CMake };
// do not check for new cppan version
bool disable_update_checks = false;
int max_download_threads = get_max_threads(8);
bool debug_generated_cmake_configs = false;
bool install_local_packages = false;
// build settings
String c_compiler;
String cxx_compiler;
String compiler;
String c_compiler_flags;
String c_compiler_flags_conf[CMakeConfigurationType::Max];
String cxx_compiler_flags;
String cxx_compiler_flags_conf[CMakeConfigurationType::Max];
String compiler_flags;
String compiler_flags_conf[CMakeConfigurationType::Max];
String link_flags;
String link_flags_conf[CMakeConfigurationType::Max];
String link_libraries;
String configuration{ "Release" };
String default_configuration{ "Release" }; // for global settings
String generator;
String system_version;
String toolset;
bool crosscompilation = false;
String host_c_compiler;
String host_cxx_compiler;
String host_compiler;
// wrap target fields into structure and add additional variable 'host' here?
//
std::map<String, String> env;
std::vector<String> cmake_options;
bool use_shared_libs = true;
// do not create links to projects (.sln, CMakeLists.txt)
bool silent = false;
// number of parallel jobs for variable checks
int var_check_jobs = 0;
// level of warnings on dependencies
int build_warning_level = 0;
// following settings can be overriden in current build config
bool use_cache = true;
bool show_ide_projects = false;
// auto re-run cppan when spec file is changed
bool add_run_cppan_target = false;
bool cmake_verbose = false;
bool build_system_verbose = true;
bool force_server_query = false;
bool verify_all = false;
bool copy_all_libraries_to_output = false;
bool copy_import_libs = false;
bool full_path_executables = false;
bool rc_enabled = true;
bool short_local_names = false;
String install_prefix;
// for build command
Strings additional_build_args;
// to differentiate different cmake invocations
String meta_target_suffix;
// some project-like variables
// later this could be replaced with local_settings' Config c;
Packages dependencies;
// not for loading from config
bool generate_only = false;
bool load_project = true;
bool can_update_packages_db = true;
public:
Settings();
void load(const path &p, const SettingsType type);
void load(const yaml &root, const SettingsType type);
void save(const path &p) const;
bool is_custom_build_dir() const;
String get_hash() const;
bool checkForUpdates() const;
private:
void load_main(const yaml &root, const SettingsType type);
void load_build(const yaml &root);
public:
static Settings &get(SettingsType type);
static Settings &get_system_settings();
static Settings &get_user_settings();
static Settings &get_local_settings();
static void clear_local_settings();
};