|
|
|
@ -17,6 +17,7 @@ |
|
|
|
|
import sys, os, subprocess, shutil, uuid |
|
|
|
|
from glob import glob |
|
|
|
|
import platform |
|
|
|
|
import xml.etree.ElementTree as ET |
|
|
|
|
|
|
|
|
|
sys.path.append(os.getcwd()) |
|
|
|
|
from mesonbuild import coredata |
|
|
|
@ -78,11 +79,13 @@ class Node: |
|
|
|
|
class PackageGenerator: |
|
|
|
|
|
|
|
|
|
def __init__(self): |
|
|
|
|
self.product_name = 'Meson Build System' |
|
|
|
|
self.manufacturer = 'The Meson Development Team' |
|
|
|
|
self.version = coredata.version.replace('dev', '') |
|
|
|
|
self.guid = 'DF5B3ECA-4A31-43E3-8CE4-97FC8A97212E' |
|
|
|
|
self.update_guid = '141527EE-E28A-4D14-97A4-92E6075D28B2' |
|
|
|
|
self.main_xml = 'Meson.wxs' |
|
|
|
|
self.main_o = 'Meson.wixobj' |
|
|
|
|
self.main_xml = 'meson.wxs' |
|
|
|
|
self.main_o = 'meson.wixobj' |
|
|
|
|
self.bytesize = '32' if '32' in platform.architecture()[0] else '64' |
|
|
|
|
self.final_output = 'meson-%s-%s.msi' % (self.version, self.bytesize) |
|
|
|
|
self.staging_dir = 'dist' |
|
|
|
@ -91,7 +94,7 @@ class PackageGenerator: |
|
|
|
|
self.progfile_dir = 'ProgramFiles64Folder' |
|
|
|
|
self.component_platform = 'Win64="yes"' |
|
|
|
|
else: |
|
|
|
|
self.platform_sr = '' |
|
|
|
|
self.platform_str = '' |
|
|
|
|
self.progfile_dir = 'ProgramFilesFolder' |
|
|
|
|
self.component_platform = '' |
|
|
|
|
|
|
|
|
@ -116,6 +119,51 @@ class PackageGenerator: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_files(self): |
|
|
|
|
self.root = ET.Element('Wix', {'xmlns': 'http://schemas.microsoft.com/wix/2006/wi'}) |
|
|
|
|
product = ET.SubElement(self.root, 'Product', { |
|
|
|
|
'Name': self.product_name, |
|
|
|
|
'Manufacturer': 'The Meson Development Team', |
|
|
|
|
'Id': self.guid, |
|
|
|
|
'UpgradeCode': self.update_guid, |
|
|
|
|
'Language': '1033', |
|
|
|
|
'Codepage': '1252', |
|
|
|
|
'Version': self.version, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
ET.SubElement(product, 'Package', { |
|
|
|
|
'Id': '*', |
|
|
|
|
'Keywords': 'Installer', |
|
|
|
|
'Description': 'Meson %s installer' % self.version, |
|
|
|
|
'Comments': 'Meson is a high performance build system', |
|
|
|
|
'Manufacturer': 'The Meson Development Team', |
|
|
|
|
'InstallerVersion': '100', |
|
|
|
|
'Languages': '1033', |
|
|
|
|
'Compressed': 'yes', |
|
|
|
|
'SummaryCodepage': '1252', |
|
|
|
|
}) |
|
|
|
|
ET.SubElement(product, 'Media', { |
|
|
|
|
'Id': '1', |
|
|
|
|
'Cabinet': 'meson.cab', |
|
|
|
|
'EmbedCab': 'yes', |
|
|
|
|
}) |
|
|
|
|
targetdir = ET.SubElement(product, 'Directory', { |
|
|
|
|
'Id': 'TARGETDIR', |
|
|
|
|
'Name': 'SourceDir', |
|
|
|
|
}) |
|
|
|
|
progfiledir = ET.SubElement(targetdir, 'Directory', { |
|
|
|
|
'Id' : self.progfile_dir, |
|
|
|
|
}) |
|
|
|
|
installdir = ET.SubElement(progfiledir, 'Directory', { |
|
|
|
|
'Id': 'INSTALLDIR', |
|
|
|
|
'Name': 'Meson'}) |
|
|
|
|
|
|
|
|
|
ET.SubElement(product, 'Property', { |
|
|
|
|
'Id': 'WIXUI_INSTALLDIR', |
|
|
|
|
'Value': 'INSTALLDIR', |
|
|
|
|
}) |
|
|
|
|
ET.SubElement(product, 'UIRef', { |
|
|
|
|
'Id': 'WixUI_InstallDir', |
|
|
|
|
}) |
|
|
|
|
assert(os.path.isdir(self.staging_dir)) |
|
|
|
|
comp_ref_xml = '' |
|
|
|
|
nodes = {} |
|
|
|
@ -126,29 +174,64 @@ class PackageGenerator: |
|
|
|
|
ofile.write(xml_templ % (self.guid, self.update_guid, self.version, self.version, |
|
|
|
|
self.platform_str, self.progfile_dir)) |
|
|
|
|
self.component_num = 0 |
|
|
|
|
self.create_xml(nodes, ofile, self.staging_dir) |
|
|
|
|
self.create_xml(nodes, ofile, self.staging_dir, installdir) |
|
|
|
|
feature = ET.SubElement(product, 'Feature', { |
|
|
|
|
'Id': 'DefaultFeature', |
|
|
|
|
'Level': '1', |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
for i in range(self.component_num): |
|
|
|
|
ET.SubElement(feature, 'ComponentRef', { |
|
|
|
|
'Id': 'ApplicationFiles%d' % i, |
|
|
|
|
}) |
|
|
|
|
comp_ref_xml += comp_ref_templ % ('ApplicationFiles%d' % i) |
|
|
|
|
ofile.write(xml_footer_templ % comp_ref_xml) |
|
|
|
|
|
|
|
|
|
def create_xml(self, nodes, ofile, root): |
|
|
|
|
cur_node = nodes[root] |
|
|
|
|
ET.ElementTree(self.root).write(self.main_xml, encoding='utf-8',xml_declaration=True) |
|
|
|
|
|
|
|
|
|
def create_xml(self, nodes, ofile, current_dir, parent_xml_node): |
|
|
|
|
cur_node = nodes[current_dir] |
|
|
|
|
if cur_node.files: |
|
|
|
|
comp_xml_node = ET.SubElement(parent_xml_node, 'Component', { |
|
|
|
|
'Id': 'ApplicationFiles%d' % self.component_num, |
|
|
|
|
'Guid': gen_guid(), |
|
|
|
|
}) |
|
|
|
|
if self.bytesize == 64: |
|
|
|
|
comp_xml_node.set('Win64', 'yes') |
|
|
|
|
if self.component_num == 0: |
|
|
|
|
ET.SubElement(comp_xml_node, 'Environment', { |
|
|
|
|
'Id': 'Environment', |
|
|
|
|
'Name': 'PATH', |
|
|
|
|
'Part': 'last', |
|
|
|
|
'System': 'yes', |
|
|
|
|
'Action': 'set', |
|
|
|
|
'Value': '[INSTALLDIR]', |
|
|
|
|
}) |
|
|
|
|
ofile.write("<Component Id='ApplicationFiles%d' Guid='%s' %s>\n" % (self.component_num, gen_guid(), self.component_platform)) |
|
|
|
|
if self.component_num == 0: |
|
|
|
|
ofile.write(path_addition_xml) |
|
|
|
|
self.component_num += 1 |
|
|
|
|
for f in cur_node.files: |
|
|
|
|
file_source = os.path.join(root, f).replace('\\', '\\\\') |
|
|
|
|
file_id = os.path.join(root, f).replace('\\', '_').replace('#', '_').replace('-', '_') |
|
|
|
|
file_source = os.path.join(current_dir, f).replace('\\', '\\\\') |
|
|
|
|
file_id = os.path.join(current_dir, f).replace('\\', '_').replace('#', '_').replace('-', '_') |
|
|
|
|
ET.SubElement(comp_xml_node, 'File', { |
|
|
|
|
'Id': file_id, |
|
|
|
|
'Name': f, |
|
|
|
|
'Source': os.path.join(current_dir, f), |
|
|
|
|
}) |
|
|
|
|
ofile.write(file_templ % (file_id, f, file_source)) |
|
|
|
|
ofile.write('</Component>\n') |
|
|
|
|
|
|
|
|
|
for dirname in cur_node.dirs: |
|
|
|
|
dir_id = os.path.join(root, dirname).replace('\\', '_').replace('/', '_') |
|
|
|
|
dir_id = os.path.join(current_dir, dirname).replace('\\', '_').replace('/', '_') |
|
|
|
|
dir_node = ET.SubElement(parent_xml_node, 'Directory', { |
|
|
|
|
'Id': dir_id, |
|
|
|
|
'Name': dirname, |
|
|
|
|
}) |
|
|
|
|
ofile.write('''<Directory Id="%s" Name="%s">\n''' % (dir_id, dirname)) |
|
|
|
|
self.create_xml(nodes, ofile, os.path.join(root, dirname)) |
|
|
|
|
self.create_xml(nodes, ofile, os.path.join(current_dir, dirname), dir_node) |
|
|
|
|
ofile.write('</Directory>\n') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_package(self): |
|
|
|
|