Skip to content

Commit 1bceeff

Browse files
committed
Update: Added officially CPP to json recipe
1 parent 70749d4 commit 1bceeff

File tree

4 files changed

+44
-30
lines changed

4 files changed

+44
-30
lines changed

adv_diff/source/redub/libs/adv_diff/files.d

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,28 @@ enum DirectoryFilterType : ubyte
9797
c,
9898
cpp,
9999
}
100+
101+
bool shouldIncludeByExt(DirectoryFilterType filter, string target)
102+
{
103+
import std.path;
104+
string ext = target.extension;
105+
final switch(filter)
106+
{
107+
case DirectoryFilterType.c:
108+
return ext == ".c" || ext == ".i" || ext == ".h";
109+
case DirectoryFilterType.cpp:
110+
return ext == ".c" || ext == ".i" || ext == ".h" || ext == ".cpp" || ext == ".cc" || ext == ".cxx" || ext == ".c++" || ext == ".hpp";
111+
case DirectoryFilterType.d:
112+
if(ext.length == 0 || ext.length > 3) return false;
113+
if(ext[1] == 'd') {
114+
return ext.length == 2 ||
115+
(ext.length == 3 && ext[2] == 'i');
116+
}
117+
return false;
118+
case DirectoryFilterType.none: return true;
119+
}
120+
}
121+
100122
struct DirectoriesWithFilter
101123
{
102124
const string[] dirs;
@@ -108,32 +130,10 @@ struct DirectoriesWithFilter
108130
///Uses the simplified hashing whenever inside that dir. May be used on directories with bigger files
109131
bool useSimplifiedHashing;
110132

111-
pragma(inline, true)
112-
bool shouldIncludeByExt(string target)
113-
{
114-
import std.path;
115-
string ext = target.extension;
116-
final switch(filterType)
117-
{
118-
case DirectoryFilterType.c:
119-
return ext == ".c" || ext == ".i" || ext == ".h";
120-
case DirectoryFilterType.cpp:
121-
return ext == ".c" || ext == ".i" || ext == ".h" || ext == ".cpp" || ext == ".cc" || ext == ".cxx" || ext == ".c++" || ext == ".hpp";
122-
case DirectoryFilterType.d:
123-
if(ext.length == 0 || ext.length > 3) return false;
124-
if(ext[1] == 'd') {
125-
return ext.length == 2 ||
126-
(ext.length == 3 && ext[2] == 'i');
127-
}
128-
return false;
129-
case DirectoryFilterType.none: return true;
130-
}
131-
}
132-
133133
pragma(inline, true) bool shouldInclude(string target)
134134
{
135135
import redub.libs.adv_diff.helpers.index_of;
136-
return shouldIncludeByExt(target) && indexOf(ignoreFiles, target) == -1;
136+
return filterType.shouldIncludeByExt(target) && indexOf(ignoreFiles, target) == -1;
137137
}
138138
}
139139

source/redub/buildapi.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ RedubLanguages redubLanguage(string input)
160160
enum RedubLanguages : ubyte
161161
{
162162
D,
163-
C
163+
C,
164+
CPP
164165
}
165166

166167
enum RedubCommands : ubyte
@@ -315,6 +316,7 @@ struct BuildConfiguration
315316
final switch(language)
316317
{
317318
case RedubLanguages.C: return c.c;
319+
case RedubLanguages.CPP: return c.c;
318320
case RedubLanguages.D: return c.d;
319321
}
320322
}

source/redub/command_generators/commons.d

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module redub.command_generators.commons;
22
public import redub.libs.semver;
33
public import std.system;
44
public import redub.tooling.compiler_identification;
5+
public import redub.libs.adv_diff.files : DirectoriesWithFilter, DirectoryFilterType;
56

67
//Import the commonly shared buildapi
78
import redub.buildapi;
@@ -217,6 +218,20 @@ bool isApple(OS os)
217218
return (os == OS.osx || os == OS.iOS || os == OS.tvOS || os == OS.watchOS);
218219
}
219220

221+
222+
DirectoryFilterType sourceFilter(const ref BuildConfiguration cfg)
223+
{
224+
final switch(cfg.language)
225+
{
226+
case RedubLanguages.C:
227+
return DirectoryFilterType.c;
228+
case RedubLanguages.CPP:
229+
return DirectoryFilterType.cpp;
230+
case RedubLanguages.D:
231+
return DirectoryFilterType.d;
232+
}
233+
}
234+
220235
/**
221236
*
222237
* Params:
@@ -229,7 +244,7 @@ bool hasAnySource(const ref BuildConfiguration cfg, ref bool[string] sourceCache
229244
import redub.libs.adv_diff.files;
230245

231246
if(cfg.sourceFiles.length) return true;
232-
DirectoriesWithFilter filter = DirectoriesWithFilter(cfg.sourcePaths, cfg.language == RedubLanguages.D ? DirectoryFilterType.d : DirectoryFilterType.cpp, cfg.excludeSourceFiles);
247+
DirectoriesWithFilter filter = DirectoriesWithFilter(cfg.sourcePaths, sourceFilter(cfg), cfg.excludeSourceFiles);
233248

234249
foreach(path; cfg.sourcePaths)
235250
{

source/redub/extensions/watcher.d

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,8 @@ int watchMain(string[] args)
192192
// break WATCHERS_LOOP;
193193
// }
194194
// else
195-
if(event.path.endsWith(".d") || event.path.endsWith(".di"))
196-
{
197-
d = doProjectBuild(d);
198-
break WATCHERS_LOOP;
199-
}
195+
d = doProjectBuild(d);
196+
break WATCHERS_LOOP;
200197
}
201198
}
202199
}

0 commit comments

Comments
 (0)