diff --git a/build.xml b/build.xml
index 794587a..7d4cae9 100644
--- a/build.xml
+++ b/build.xml
@@ -1,7 +1,7 @@
-
+
@@ -55,7 +55,22 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mkbuildxml.py b/mkbuildxml.py
index 55bffd3..3ba5989 100755
--- a/mkbuildxml.py
+++ b/mkbuildxml.py
@@ -18,35 +18,35 @@ HERE = dirname(abspath(__file__))
AUTOGEN_WARNING = ('').format(basename(sys.argv[0]))
-ROOT = BytesIO(''.join([_line.strip() for _line in """\
-
-
-
-
-
-
-
-
+ROOT = ''.join([_line.strip() for _line in """\
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-""".splitlines() if _line.strip()]))
-# TARGET_FMT = '{target}:' + DEP_SEP + '{deps}'
-# RULE_FMT = '\\\n\t'.join([
-# '\t$(MXMLC) {primary_dep} ',
-# '$(MXMLC_FLAGS) ',
-# '-l+={parent_dir} ',
-# '-l+={package_base} ',
-# '-l+={flexunit} ',
-# '-sp+={package_base} ',
-# '-sp+={flexunit} ',
-# '-o {target}',
-# ])
+""".splitlines() if _line.strip()])
def main(sysargs=sys.argv[:]):
build_xml = pathjoin(HERE, 'build.xml')
os.chmod(build_xml, 0600)
- buildxml_maker = BuildXMLMaker(outstream=open(build_xml, 'wb'))
+ buildxml_maker = \
+ BuildXMLMaker(project_name=sysargs[1], outstream=open(build_xml, 'wb'))
buildxml_maker.make()
os.chmod(build_xml, 0444)
return 0
@@ -59,10 +59,10 @@ class BuildXMLMaker(object):
)
_source_fileexts = ('.mxml', '.as', '.css')
- def __init__(self, outstream=sys.stdout):
+ def __init__(self, project_name='%PROJECT%', outstream=sys.stdout):
self.outstream = outstream
self.targets = {'compc': {}, 'mxmlc': {}}
- self.tree = ET.parse(ROOT)
+ self.tree = ET.parse(BytesIO(ROOT.format(PROJECT_NAME=project_name)))
self.root = self.tree.getroot()
self.build = self.tree.xpath('//target[@name="build"]')[0]
@@ -86,7 +86,7 @@ class BuildXMLMaker(object):
def _add_target_from_test_suite(self, test_suite):
rel_class = relpath(test_suite, HERE)
- self.targets['compc'][rel_class] = dict()
+ self.targets['compc'][rel_class] = {}
def _add_target_from_mxml(self, mxml):
rel_mxml = relpath(mxml, HERE)
@@ -115,9 +115,17 @@ class BuildXMLMaker(object):
for as3 in sorted(self.targets['compc'].iterkeys()):
rel_target = './' + as3.lstrip('./')
as_swf = re.sub('(.*).as$', '\\1.swf', rel_target)
- attrs = dict(output=as_swf)
+ as_class = re.sub('(.*).as$', '\\1', rel_target).replace('/', '.')
+ class_parts = as_class.strip('./').split('.')
+ as_class = '.'.join(class_parts[1:])
+ source_path_dir = './' + '/'.join(class_parts[:1])
+ attrs = {'output': as_swf, 'include-classes': as_class}
attrs.update(self.targets['compc'][as3])
- ET.SubElement(self.build, 'compc', **attrs)
+ compc_element = ET.SubElement(self.build, 'compc', **attrs)
+ ET.SubElement(compc_element, 'sp',
+ **{'path-element': source_path_dir})
+ library_path = ET.SubElement(compc_element, 'l',
+ **{'dir': '${FLEXUNIT_HOME}', 'append': 'yes'})
print(ET.tostring(self.root, pretty_print=True),
file=self.outstream)