@@ -48,7 +48,7 @@ bool SC::Build::Configuration::applyPreset(const Project& project, Preset newPre
48
48
switch (newPreset)
49
49
{
50
50
case Configuration::Preset::DebugCoverage:
51
- if (not project.compile .enableASAN .hasBeenSet ())
51
+ if (not project.files . compile .enableASAN .hasBeenSet ())
52
52
{
53
53
compile.enableCoverage = true ;
54
54
}
@@ -60,7 +60,7 @@ bool SC::Build::Configuration::applyPreset(const Project& project, Preset newPre
60
60
}
61
61
break ;
62
62
case Configuration::Preset::Debug:
63
- if (not project.compile .enableASAN .hasBeenSet ())
63
+ if (not project.files . compile .enableASAN .hasBeenSet ())
64
64
{
65
65
// VS ASAN is unsupported on ARM64 and needs manual flags / libs with ClangCL toolset
66
66
// It also needs paths where clang_rt.asan_*.dll exist to be manually set before debugging
@@ -123,25 +123,67 @@ const SC::Build::Configuration* SC::Build::Project::getConfiguration(StringView
123
123
return nullptr ;
124
124
}
125
125
126
- bool SC::Build::Project::addDirectory (StringView subdirectory, StringView filter)
126
+ bool SC::Build::SourceFiles::addSelection (StringView directory, StringView filter)
127
+ {
128
+ return selection.push_back ({FilesSelection::Add, directory, filter});
129
+ }
130
+
131
+ bool SC::Build::SourceFiles::removeSelection (StringView directory, StringView filter)
132
+ {
133
+ return selection.push_back ({FilesSelection::Remove, directory, filter});
134
+ }
135
+
136
+ bool SC::Build::Project::addFiles (StringView subdirectory, StringView filter)
127
137
{
128
138
if (subdirectory.containsCodePoint (' *' ) or subdirectory.containsCodePoint (' ?' ))
129
139
return false ;
130
- return files.push_back ({Project::File ::Add, subdirectory, filter});
140
+ return files.selection . push_back ({FilesSelection ::Add, subdirectory, filter});
131
141
}
132
142
143
+ bool SC::Build::Project::addIncludePaths (Span<const StringView> includePaths)
144
+ {
145
+ return files.compile .includePaths .append (includePaths);
146
+ }
147
+
148
+ bool SC::Build::Project::addLinkLibraryPaths (Span<const StringView> libraryPaths)
149
+ {
150
+ return link.libraryPaths .append (libraryPaths);
151
+ }
152
+
153
+ bool SC::Build::Project::addLinkLibraries (Span<const StringView> linkLibraries)
154
+ {
155
+ return link.libraries .append (linkLibraries);
156
+ }
157
+
158
+ bool SC::Build::Project::addLinkFrameworks (Span<const StringView> frameworks)
159
+ {
160
+ return link.frameworks .append (frameworks);
161
+ }
162
+
163
+ bool SC::Build::Project::addLinkFrameworksMacOS (Span<const StringView> frameworks)
164
+ {
165
+ return link.frameworksMacOS .append (frameworks);
166
+ }
167
+
168
+ bool SC::Build::Project::addLinkFrameworksIOS (Span<const StringView> frameworks)
169
+ {
170
+ return link.frameworksIOS .append (frameworks);
171
+ }
172
+
173
+ bool SC::Build::Project::addDefines (Span<const StringView> defines) { return files.compile .defines .append (defines); }
174
+
133
175
bool SC::Build::Project::addFile (StringView singleFile)
134
176
{
135
177
if (singleFile.containsCodePoint (' *' ) or singleFile.containsCodePoint (' ?' ))
136
178
return false ;
137
- return files.push_back ({Project::File ::Add, {}, singleFile});
179
+ return files.selection . push_back ({FilesSelection ::Add, {}, singleFile});
138
180
}
139
181
140
182
bool SC::Build::Project::removeFiles (StringView subdirectory, StringView filter)
141
183
{
142
184
if (subdirectory.containsCodePoint (' *' ) or subdirectory.containsCodePoint (' ?' ))
143
185
return false ;
144
- return files.push_back ({Project::File ::Remove, subdirectory, filter});
186
+ return files.selection . push_back ({FilesSelection ::Remove, subdirectory, filter});
145
187
}
146
188
147
189
SC::Result SC::Build::Project::validate () const
@@ -187,7 +229,7 @@ SC::Result SC::Build::DefinitionCompiler::validate()
187
229
return Result (true );
188
230
}
189
231
190
- SC::Result SC::Build::DefinitionCompiler::fillPathsList (StringView path, const VectorSet<Project::File >& filters,
232
+ SC::Result SC::Build::DefinitionCompiler::fillPathsList (StringView path, const VectorSet<FilesSelection >& filters,
191
233
VectorMap<String, Vector<String>>& filtersToFiles)
192
234
{
193
235
bool doRecurse = false ;
@@ -211,11 +253,11 @@ SC::Result SC::Build::DefinitionCompiler::fillPathsList(StringView path, const V
211
253
return Result (true );
212
254
}
213
255
214
- Vector<Project::File > renderedFilters;
256
+ Vector<FilesSelection > renderedFilters;
215
257
for (const auto & filter : filters)
216
258
{
217
- Project::File file;
218
- file.operation = filter.operation ;
259
+ FilesSelection file;
260
+ file.action = filter.action ;
219
261
SC_TRY (file.mask .assign (path));
220
262
SC_TRY (Path::append (file.mask , {filter.mask .view ()}, Path::AsPosix));
221
263
SC_TRY (renderedFilters.push_back (move (file)));
@@ -249,7 +291,7 @@ SC::Result SC::Build::DefinitionCompiler::fillPathsList(StringView path, const V
249
291
250
292
SC::Result SC::Build::DefinitionCompiler::build ()
251
293
{
252
- VectorMap<String, VectorSet<Project::File >> uniquePaths;
294
+ VectorMap<String, VectorSet<FilesSelection >> uniquePaths;
253
295
SC_TRY (collectUniqueRootPaths (uniquePaths));
254
296
for (auto & it : uniquePaths)
255
297
{
@@ -259,21 +301,21 @@ SC::Result SC::Build::DefinitionCompiler::build()
259
301
}
260
302
261
303
// Collects root paths to build a stat map
262
- SC::Result SC::Build::DefinitionCompiler::collectUniqueRootPaths (VectorMap<String, VectorSet<Project::File >>& paths)
304
+ SC::Result SC::Build::DefinitionCompiler::collectUniqueRootPaths (VectorMap<String, VectorSet<FilesSelection >>& paths)
263
305
{
264
306
String buffer;
265
307
SmallVector<StringView, 16 > components;
266
308
for (const Workspace& workspace : definition.workspaces )
267
309
{
268
310
for (const Project& project : workspace.projects )
269
311
{
270
- for (const Project::File & file : project.files )
312
+ for (const FilesSelection & file : project.files . selection )
271
313
{
272
314
SC_TRY (buffer.assign (project.rootDirectory .view ()));
273
315
if (Path::isAbsolute (file.base .view (), Path::Type::AsNative))
274
316
{
275
- Project::File absFile;
276
- absFile.operation = file.operation ;
317
+ FilesSelection absFile;
318
+ absFile.action = file.action ;
277
319
SC_TRY (Path::normalize (file.base .view (), components, &absFile.base , Path::Type::AsPosix));
278
320
SC_TRY (absFile.mask .assign (file.mask .view ()));
279
321
SC_TRY (paths.getOrCreate (absFile.base .view ())->insert (absFile));
@@ -314,16 +356,16 @@ SC::Result SC::Build::DefinitionCompiler::collectUniqueRootPaths(VectorMap<Strin
314
356
}
315
357
else
316
358
{
317
- const auto overlapNew = buffer.view ().sliceStart (commonOverlap);
318
- const auto overlapExisting = it.key .view ().sliceStart (commonOverlap);
359
+ const StringView overlapNew = buffer.view ().sliceStart (commonOverlap);
360
+ const StringView overlapExisting = it.key .view ().sliceStart (commonOverlap);
319
361
if (overlapExisting.isEmpty ())
320
362
{
321
363
// Case .5 and .3 after .2
322
364
if (overlapNew.startsWithAnyOf ({' /' }))
323
365
{
324
366
// Case .3 after 2 (can be merged)
325
- Project::File mergedFile;
326
- mergedFile.operation = file.operation ;
367
+ FilesSelection mergedFile;
368
+ mergedFile.action = file.action ;
327
369
SC_TRY (mergedFile.base .assign (it.value .begin ()->base .view ()));
328
370
SC_TRY (mergedFile.mask .assign (Path::removeStartingSeparator (overlapNew)));
329
371
SC_TRY (Path::append (mergedFile.mask , {file.mask .view ()}, Path::AsPosix));
0 commit comments