Skip to content

Commit

Permalink
Merge pull request #135 from jorix/3496-Build_force_exclude
Browse files Browse the repository at this point in the history
Skip files that are listed in the exclude config list even if they are dependencies of other files.  Thanks @jorix for the enhancement.
  • Loading branch information
tschaub committed Jan 17, 2012
2 parents d34d8f2 + 6ca10ee commit a5f4daa
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions tools/mergejs.py
Expand Up @@ -53,12 +53,21 @@ class SourceFile:
Represents a Javascript source code file.
"""

def __init__(self, filepath, source):
def __init__(self, filepath, source, cfgExclude):
"""
"""
self.filepath = filepath
self.source = source

self.excludedFiles = []
self.requiredFiles = []
auxReq = re.findall(RE_REQUIRE, self.source)
for filename in auxReq:
if undesired(filename, cfgExclude):
self.excludedFiles.append(filename)
else:
self.requiredFiles.append(filename)

self.requiredBy = []


Expand All @@ -67,8 +76,7 @@ def _getRequirements(self):
Extracts the dependencies specified in the source code and returns
a list of them.
"""
# TODO: Cache?
return re.findall(RE_REQUIRE, self.source)
return self.requiredFiles

requires = property(fget=_getRequirements, doc="")

Expand Down Expand Up @@ -176,7 +184,7 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
print "Importing: %s" % filepath
fullpath = os.path.join(sourceDirectory, filepath).strip()
content = open(fullpath, "U").read() # TODO: Ensure end of line @ EOF?
files[filepath] = SourceFile(filepath, content) # TODO: Chop path?
files[filepath] = SourceFile(filepath, content, cfg.exclude) # TODO: Chop path?

print

Expand All @@ -200,7 +208,7 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
if os.path.exists(fullpath):
print "Importing: %s" % path
content = open(fullpath, "U").read() # TODO: Ensure end of line @ EOF?
files[path] = SourceFile(path, content) # TODO: Chop path?
files[path] = SourceFile(path, content, cfg.exclude) # TODO: Chop path?
else:
raise MissingImport("File '%s' not found (required by '%s')." % (path, filepath))

Expand Down Expand Up @@ -229,6 +237,9 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
for fp in order:
fName = os.path.normpath(os.path.join(sourceDirectory, fp)).replace("\\","/")
print "Append: ", fName
f = files[fp]
for fExclude in f.excludedFiles:
print " Required file \"%s\" is excluded." % fExclude
result.append(fName)
print "\nTotal files: %d " % len(result)
return result
Expand All @@ -237,6 +248,8 @@ def run (sourceDirectory, outputFilename = None, configFile = None,
for fp in order:
f = files[fp]
print "Exporting: ", f.filepath
for fExclude in f.excludedFiles:
print " Required file \"%s\" is excluded." % fExclude
result.append(HEADER % f.filepath)
source = f.source
result.append(source)
Expand Down

0 comments on commit a5f4daa

Please sign in to comment.