Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add classpath inclusion file #667

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions haxe/ui/macros/MacroHelpers.hx
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ class MacroHelpers {
public static var classPathCache:Array<ClassPathEntry> = null;
private static var primaryClassPathExceptions:Array<EReg> = [];
private static var secondaryClassPathExceptions:Array<EReg> = [];
private static function loadClassPathExclusions(filePath:String) {

private static var inclusionClassPaths:Array<EReg> = [];

private static function loadClassPathReg(filePath:String) {
#if classpath_scan_verbose
Sys.println("classpath cache: loading classpath exclusions from '" + filePath + "'");
var str = #if haxeui_classpath_inclusions "inclusions" #else "exclusions" #end;
Sys.println('classpath cache: loading classpath $str from $filePath');
#end

var contents = sys.io.File.getContent(filePath);
Expand All @@ -166,8 +170,12 @@ class MacroHelpers {
Sys.println(" " + line);
#end

#if haxeui_classpath_inclusions
inclusionClassPaths.push(new EReg(line, "gm"));
#else
primaryClassPathExceptions.push(new EReg(line, "gm"));
secondaryClassPathExceptions.push(new EReg(line, "gm"));
#end
}
}

Expand All @@ -182,15 +190,25 @@ class MacroHelpers {

classPathCache = [];
var paths:Array<String> = Context.getClassPath();


for (path in paths) {
if (StringTools.trim(path).length == 0) {
path = Sys.getCwd();
}
#if haxeui_classpath_inclusions
path = StringTools.trim(path + "/classpath.inclusions");
#else
path = StringTools.trim(path + "/classpath.exclusions");
#end

path = Path.normalize(path);
//trace(path);
if (sys.FileSystem.exists(path)) {
loadClassPathExclusions(path);
trace(path);
loadClassPathReg(path);
}

}

for (path in paths) {
Expand All @@ -200,6 +218,14 @@ class MacroHelpers {
var originalPath = path;
path = StringTools.trim(path);
path = Path.normalize(path);
#if haxeui_classpath_inclusions
//trace(path);
for (r in inclusionClassPaths) {
if (r.match(path)) {
cacheClassPathEntries(path, classPathCache, originalPath);
}
}
#else
var exclude = false;
for (r in primaryClassPathExceptions) {
if (r.match(path) == true) {
Expand All @@ -210,9 +236,11 @@ class MacroHelpers {
if (exclude == true) {
continue;
}

cacheClassPathEntries(path, classPathCache, originalPath);
#end
}

#if haxeui_macro_times
stopTimer();
#end
Expand Down Expand Up @@ -333,4 +361,4 @@ class MacroHelpers {
}

#end
}
}