-
Notifications
You must be signed in to change notification settings - Fork 0
/
chibi-internal.h
195 lines (146 loc) · 3.73 KB
/
chibi-internal.h
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#pragma
#include <map>
#include <set>
#include <string>
#include <vector>
#include "stringhelpers.h" // todo : move to cpp file
#define ENABLE_PKGCONFIG 0 // todo : pkgconfig shouldn't be used in chibi.txt files. but it would be nice to define libraries using pkgconfig externally, as a sort of aliases, which can be used in a normalized fashion as a regular library
struct ChibiLibraryFile
{
std::string filename;
std::string group;
std::string conglomerate_filename;
bool compile = true;
};
struct ChibiLibraryDependency
{
enum Type
{
kType_Undefined,
kType_Generated,
kType_Local,
kType_Find,
kType_Global
};
std::string name;
std::string path;
Type type = kType_Undefined;
bool embed_framework = false;
};
struct ChibiPackageDependency
{
enum Type
{
kType_Undefined,
kType_FindPackage,
#if ENABLE_PKGCONFIG
kType_PkgConfig
#endif
};
std::string name;
std::string variable_name;
Type type = kType_Undefined;
};
struct ChibiHeaderPath
{
std::string path;
bool expose = false;
std::string alias_through_copy;
std::string alias_through_copy_path;
};
struct ChibiCompileDefinition
{
std::string name;
std::string value;
bool expose = false;
std::string toolchain;
std::vector<std::string> configs;
};
struct ChibiLibrary
{
std::string name;
std::string path;
std::string group_name;
std::string chibi_file;
bool shared = false; // generate a shared library
bool prebuilt = false; // library contains prebuilt files instead of source files
bool objc_arc = false; // enable objective-c's automatic reference counting feature
bool isExecutable = false;
std::vector<ChibiLibraryFile> files;
std::vector<ChibiLibraryDependency> library_dependencies;
std::vector<ChibiPackageDependency> package_dependencies;
std::vector<ChibiHeaderPath> header_paths;
std::vector<ChibiCompileDefinition> compile_definitions;
std::map<std::string, std::string> conglomerate_groups; // best-guess group names for conglomerate files
std::string resource_path;
std::vector<std::string> resource_excludes;
std::vector<std::string> dist_files;
std::vector<std::string> license_files;
std::vector<std::string> link_translation_unit_using_function_calls;
void dump_info() const
{
printf("%s: %s\n", isExecutable ? "app" : "library", name.c_str());
for (auto & file : files)
{
printf("\tfile: %s\n", file.filename.c_str());
if (file.group.empty() == false)
printf("\t\tgroup: %s\n", file.group.c_str());
}
for (auto & header_path : header_paths)
{
printf("\theader path: %s\n", header_path.path.c_str());
if (header_path.expose)
printf("\t\texpose\n");
if (header_path.alias_through_copy.empty() == false)
printf("\t\talias_through_copy: %s\n", header_path.alias_through_copy.c_str());
}
}
};
struct ChibiInfo
{
std::set<std::string> build_targets;
std::vector<ChibiLibrary*> libraries;
std::vector<std::string> cmake_module_paths;
~ChibiInfo()
{
for (auto * library : libraries)
delete library;
}
bool library_exists(const char * name) const
{
for (auto & library : libraries)
{
if (library->name == name)
return true;
}
return false;
}
ChibiLibrary * find_library(const char * name) const
{
for (auto & library : libraries)
if (library->name == name)
return library;
return nullptr;
}
bool should_build_target(const char * name) const
{
if (build_targets.empty())
return true;
else if (build_targets.count(name) != 0)
return true;
else
{
for (auto & build_target : build_targets)
if (chibi::match_wildcard(name, build_target.c_str(), ';'))
return true;
}
return false;
}
void dump_info() const
{
for (auto & library : libraries)
{
library->dump_info();
}
}
};