Skip to content

Commit 91520c3

Browse files
committed
classpath.inclusions
1 parent 2a962a6 commit 91520c3

File tree

1 file changed

+50
-6
lines changed

1 file changed

+50
-6
lines changed

haxe/ui/macros/MacroHelpers.hx

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package haxe.ui.macros;
22

33
#if macro
4-
import haxe.macro.Type.ClassType;
54
import haxe.io.Path;
65
import haxe.macro.Context;
76
import haxe.macro.Expr;
7+
import haxe.macro.Type.ClassType;
88
import haxe.ui.macros.helpers.CodeBuilder;
99
import haxe.ui.util.GenericConfig;
1010
#end
@@ -171,6 +171,28 @@ class MacroHelpers {
171171
}
172172
}
173173

174+
private static var classPathInclusions:Array<EReg> = [];
175+
private static function loadClassPathInclusions(filePath:String) {
176+
#if classpath_scan_verbose
177+
Sys.println("classpath cache: loading classpath inclusions from '" + filePath + "'");
178+
#end
179+
180+
var contents = sys.io.File.getContent(filePath);
181+
var lines = contents.split("\n");
182+
for (line in lines) {
183+
line = StringTools.trim(line);
184+
if (line.length == 0 || StringTools.startsWith(line, ";")) {
185+
continue;
186+
}
187+
188+
#if classpath_scan_verbose
189+
Sys.println(" " + line);
190+
#end
191+
192+
classPathInclusions.push(new EReg(line, "gm"));
193+
}
194+
}
195+
174196
private static function buildClassPathCache() {
175197
if (classPathCache != null) {
176198
return;
@@ -186,13 +208,21 @@ class MacroHelpers {
186208
if (StringTools.trim(path).length == 0) {
187209
path = Sys.getCwd();
188210
}
189-
path = StringTools.trim(path + "/classpath.exclusions");
190-
path = Path.normalize(path);
191-
if (sys.FileSystem.exists(path)) {
192-
loadClassPathExclusions(path);
211+
var exclusionsFile = Path.normalize(StringTools.trim(path + "/classpath.exclusions"));
212+
if (sys.FileSystem.exists(exclusionsFile)) {
213+
loadClassPathExclusions(exclusionsFile);
214+
}
215+
var inclusionsFile = Path.normalize(StringTools.trim(path + "/classpath.inclusions"));
216+
if (sys.FileSystem.exists(inclusionsFile)) {
217+
loadClassPathInclusions(inclusionsFile);
193218
}
194219
}
195220

221+
if (classPathInclusions.length != 0) {
222+
primaryClassPathExceptions = [];
223+
secondaryClassPathExceptions = [];
224+
}
225+
196226
for (path in paths) {
197227
if (StringTools.trim(path).length == 0) {
198228
path = Sys.getCwd();
@@ -207,6 +237,20 @@ class MacroHelpers {
207237
break;
208238
}
209239
}
240+
if (classPathInclusions.length != 0) {
241+
exclude = true;
242+
for (r in classPathInclusions) {
243+
if (r.match(path)) {
244+
exclude = false;
245+
break;
246+
}
247+
}
248+
#if classpath_scan_verbose
249+
if (exclude) {
250+
Sys.println("classpath cache: excluding '" + path + "' based on classpath.inclusions");
251+
}
252+
#end
253+
}
210254
if (exclude == true) {
211255
continue;
212256
}
@@ -235,7 +279,7 @@ class MacroHelpers {
235279
break;
236280
}
237281
}
238-
if (exclude == true || ! sys.FileSystem.exists(path)) {
282+
if (exclude == true || !sys.FileSystem.exists(path)) {
239283
#if classpath_scan_verbose
240284
Sys.println("classpath cache: excluding '" + path + "'");
241285
#end

0 commit comments

Comments
 (0)