from mesonbuild import coredata
# Elementtree does not support CDATA. So hack it.
-WINVER_CHECK = 'Installed OR (VersionNT64 > 602)>'
+WINVER_CHECK = '<![CDATA[Installed OR (VersionNT64 > 602)]]>'
def gen_guid():
'''
'''
return str(uuid.uuid4()).upper()
+def get_all_modules_from_dir(dirname):
+ '''
+ Get all modules required for Meson build MSI package
+ from directories.
+ '''
+ modname = os.path.basename(dirname)
+ modules = [os.path.splitext(os.path.split(x)[1])[0] for x in glob(os.path.join(dirname, '*'))]
+ modules = ['mesonbuild.' + modname + '.' + x for x in modules if not x.startswith('_')]
+ return modules
+
+def get_more_modules():
+ '''
+ Getter for missing Modules.
+ Python packagers want to be minimal and only copy the things
+ that they can see that being used. They are blind to many things.
+ '''
+ return ['distutils.archive_util',
+ 'distutils.cmd',
+ 'distutils.config',
+ 'distutils.core',
+ 'distutils.debug',
+ 'distutils.dep_util',
+ 'distutils.dir_util',
+ 'distutils.dist',
+ 'distutils.errors',
+ 'distutils.extension',
+ 'distutils.fancy_getopt',
+ 'distutils.file_util',
+ 'distutils.spawn',
+ 'distutils.util',
+ 'distutils.version',
+ 'distutils.command.build_ext',
+ 'distutils.command.build',
+ 'filecmp',
+ ]
+
+def get_modules():
+ modules = get_all_modules_from_dir('mesonbuild/modules')
+ modules += get_all_modules_from_dir('mesonbuild/scripts')
+ modules += get_more_modules()
+ return modules
+
class Node:
'''
Node to hold path and directory values
self.staging_dirs = ['dist', 'dist2']
self.progfile_dir = 'ProgramFiles64Folder'
redist_globs = ['C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Redist\\MSVC\\v*\\MergeModules\\Microsoft_VC142_CRT_x64.msm',
- 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Redist\\MSVC\\v*\\MergeModules\\Microsoft_VC143_CRT_x64.msm']
+ 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\VC\\Redist\\MSVC\\v*\\MergeModules\\Microsoft_VC143_CRT_x64.msm']
redist_path = None
for g in redist_globs:
trials = glob(g)
'Title': 'Meson',
'Description': 'Meson executables',
'Level': '1',
- 'AllowAbsent': 'no',
+ 'Absent': 'disallow',
},
self.staging_dirs[1]: {
'Id': 'NinjaProgram',
if os.path.exists(sdir):
shutil.rmtree(sdir)
main_stage, ninja_stage = self.staging_dirs
+ modules = get_modules()
pyinstaller = shutil.which('pyinstaller')
if not pyinstaller:
shutil.rmtree(pyinstaller_tmpdir)
pyinst_cmd = [pyinstaller,
'--clean',
- '--additional-hooks-dir=packaging',
'--distpath',
pyinstaller_tmpdir]
+ for m in modules:
+ pyinst_cmd += ['--hidden-import', m]
pyinst_cmd += ['meson.py']
subprocess.check_call(pyinst_cmd)
shutil.move(pyinstaller_tmpdir + '/meson', main_stage)
'''
Generate package files for MSI installer package
'''
- self.root = ET.Element('Wix', {
- 'xmlns': 'http://wixtoolset.org/schemas/v4/wxs',
- 'xmlns:ui': 'http://wixtoolset.org/schemas/v4/wxs/ui'
- })
-
- package = ET.SubElement(self.root, 'Package', {
+ 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(package, 'SummaryInformation', {
+ package = ET.SubElement(product, 'Package', {
+ 'Id': '*',
'Keywords': 'Installer',
'Description': f'Meson {self.version} installer',
+ 'Comments': 'Meson is a high performance build system',
'Manufacturer': 'The Meson Development Team',
+ 'InstallerVersion': '500',
+ 'Languages': '1033',
+ 'Compressed': 'yes',
+ 'SummaryCodepage': '1252',
})
- ET.SubElement(package,
- 'Launch',
- {'Message': 'This application is only supported on Windows 10 or higher.',
- 'Condition': 'X'*len(WINVER_CHECK)})
+ condition = ET.SubElement(product, 'Condition', {'Message': 'This application is only supported on Windows 10 or higher.'})
- ET.SubElement(package, 'MajorUpgrade',
- {'DowngradeErrorMessage':
- 'A newer version of Meson is already installed.'})
+ condition.text = 'X'*len(WINVER_CHECK)
+ ET.SubElement(product, 'MajorUpgrade',
+ {'DowngradeErrorMessage': 'A newer version of Meson is already installed.'})
- ET.SubElement(package, 'Media', {
+ package.set('Platform', 'x64')
+ ET.SubElement(product, 'Media', {
'Id': '1',
'Cabinet': 'meson.cab',
'EmbedCab': 'yes',
})
- targetdir = ET.SubElement(package, 'StandardDirectory', {
- 'Id': 'ProgramFiles64Folder',
+ targetdir = ET.SubElement(product, 'Directory', {
+ 'Id': 'TARGETDIR',
+ 'Name': 'SourceDir',
+ })
+ progfiledir = ET.SubElement(targetdir, 'Directory', {
+ 'Id': self.progfile_dir,
})
- installdir = ET.SubElement(targetdir, 'Directory', {
+ installdir = ET.SubElement(progfiledir, 'Directory', {
'Id': 'INSTALLDIR',
'Name': 'Meson',
})
'Language': '0',
})
- ET.SubElement(package, 'ui:WixUI', {
+ ET.SubElement(product, 'Property', {
+ 'Id': 'WIXUI_INSTALLDIR',
+ 'Value': 'INSTALLDIR',
+ })
+ ET.SubElement(product, 'UIRef', {
'Id': 'WixUI_FeatureTree',
})
for s_d in self.staging_dirs:
assert os.path.isdir(s_d)
- top_feature = ET.SubElement(package, 'Feature', {
+ top_feature = ET.SubElement(product, 'Feature', {
'Id': 'Complete',
'Title': 'Meson ' + self.version,
'Description': 'The complete package',
})
ET.SubElement(vcredist_feature, 'MergeRef', {'Id': 'VCRedist'})
ET.ElementTree(self.root).write(self.main_xml, encoding='utf-8', xml_declaration=True)
- # ElementTree cannot do pretty-printing, so do it manually
+ # ElementTree can not do prettyprinting so do it manually
import xml.dom.minidom
doc = xml.dom.minidom.parse(self.main_xml)
with open(self.main_xml, 'w') as open_file:
component_id = f'ApplicationFiles{self.component_num}'
comp_xml_node = ET.SubElement(parent_xml_node, 'Component', {
'Id': component_id,
- 'Bitness': 'always64',
'Guid': gen_guid(),
})
self.feature_components[staging_dir].append(component_id)
+ comp_xml_node.set('Win64', 'yes')
if self.component_num == 0:
ET.SubElement(comp_xml_node, 'Environment', {
'Id': 'Environment',
})
for dirname in cur_node.dirs:
- dir_id = os.path.join(current_dir, dirname).replace('\\', '_').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,
'''
Generate the Meson build MSI package.
'''
- subprocess.check_call(['wix',
- 'build',
- '-bindvariable', 'WixUILicenseRtf=packaging\\License.rtf',
- '-ext', 'WixToolset.UI.wixext',
- '-culture', 'en-us',
- '-arch', 'x64',
- '-o',
- self.final_output,
- self.main_xml,
- ])
-
-
-def install_wix():
- subprocess.check_call(['dotnet',
- 'nuget',
- 'add',
- 'source',
- 'https://api.nuget.org/v3/index.json'])
- subprocess.check_call(['dotnet',
- 'tool',
- 'install',
- '--global',
- 'wix'])
- subprocess.check_call(['wix',
- 'extension',
- 'add',
- 'WixToolset.UI.wixext',
- ])
+ wixdir = 'c:\\Program Files\\Wix Toolset v3.11\\bin'
+ if not os.path.isdir(wixdir):
+ wixdir = 'c:\\Program Files (x86)\\Wix Toolset v3.11\\bin'
+ if not os.path.isdir(wixdir):
+ print("ERROR: This script requires WIX")
+ sys.exit(1)
+ subprocess.check_call([os.path.join(wixdir, 'candle'), self.main_xml])
+ subprocess.check_call([os.path.join(wixdir, 'light'),
+ '-ext', 'WixUIExtension',
+ '-cultures:en-us',
+ '-dWixUILicenseRtf=packaging\\License.rtf',
+ '-out', self.final_output,
+ self.main_o])
if __name__ == '__main__':
if not os.path.exists('meson.py'):
sys.exit(print('Run me in the top level source dir.'))
- if not shutil.which('wix'):
- install_wix()
subprocess.check_call(['pip', 'install', '--upgrade', 'pyinstaller'])
p = PackageGenerator()
import subprocess
import shutil, sys, os
-from glob import glob
import xml.etree.ElementTree as ET
sys.path.append(os.getcwd())
from mesonbuild import coredata
+from createmsi import get_modules
+
class PkgGenerator:
def __init__(self):
if os.path.exists(self.pkg_dir):
shutil.rmtree(self.pkg_dir)
os.mkdir(self.pkg_dir)
- pyinstaller_bin = glob('/Users/jpakkane/Library/Python/*/bin/pyinstaller')
- if len(pyinstaller_bin) != 1:
- sys.exit('Could not determine unique installer.')
- pyinstaller_bin = pyinstaller_bin[0]
+ pyinstaller_bin = '/Users/jpakkane/Library/Python/3.8/bin/pyinstaller'
pyinst_cmd = [pyinstaller_bin,
'--clean',
- '--additional-hooks-dir=packaging',
'--distpath',
self.pkg_dir]
+ for m in get_modules():
+ pyinst_cmd += ['--hidden-import', m]
pyinst_cmd += ['meson.py']
subprocess.check_call(pyinst_cmd)
tmpdir = os.path.join(self.pkg_dir, 'meson')
ET.SubElement(root, 'pkg-ref', {'id': self.identifier})
ET.SubElement(root, 'options', {'customize': 'never',
'require-scripts': 'false',
- 'hostArchitectures': 'x86_64,arm64'})
+ 'hostArhcitectures': 'x86_64,arm64'})
choices_outline = ET.SubElement(root, 'choices-outline')
line = ET.SubElement(choices_outline, 'line', {'choice': 'default'})
ET.SubElement(line, 'line', {'choice': self.identifier})
'version': '0', # self.version,
'onConclusion': 'none'}).text = self.pkgname
ET.ElementTree(root).write(self.distribution_file, encoding='utf-8', xml_declaration=True)
- # ElementTree cannot do pretty-printing, so do it manually
+ # ElementTree can not do prettyprinting so do it manually
import xml.dom.minidom
doc = xml.dom.minidom.parse(self.distribution_file)
with open(self.distribution_file, 'w') as open_file:
--- /dev/null
+%define _name mesonbuild
+Name: meson
+Version: 1.3.0
+Release: 0
+Summary: Python-based build system
+License: Apache-2.0
+Group: Development/Tools/Building
+Url: http://mesonbuild.com/
+Source: https://github.com/%{_name}/meson/releases/download/%{version}/meson-%{version}.tar.gz
+SOURCE1001: meson.manifest
+SOURCE1002: macros.meson
+SOURCE1003: meson-1.3.0-py3-none-any.whl
+
+BuildRequires: python3 >= 3.4
+BuildRequires: python3-setuptools
+
+BuildRequires: python3-build
+BuildRequires: python3-wheel
+BuildRequires: python3-pip
+BuildRequires: ninja
+
+Requires: ninja
+Requires: python3-xml
+Requires: python3-setuptools
+
+BuildArch: noarch
+
+Provides: meson-gui = %{version}
+Obsoletes: meson-gui < %{version}
+
+%description
+Meson is a build system designed to optimise programmer productivity.
+It aims to do this by providing support for software development
+tools and practices, such as unit tests, coverage reports, Valgrind,
+CCache and the like. Supported languages include C, C++, Fortran,
+Java, Rust. Build definitions are written in a non-turing complete
+Domain Specific Language.
+
+%package vim
+%{!?vim_data_dir:%global vim_data_dir %{_datadir}/vim}
+Summary: Vim support for meson.build files
+Group: Productivity/Text/Editors
+Requires: vim
+Supplements: packageand(vim:%{name})
+BuildArch: noarch
+
+%description vim
+Meson is a build system designed to optimise programmer productivity.
+It aims to do this by providing support for software development
+tools and practices, such as unit tests, coverage reports, Valgrind,
+CCache and the like. Supported languages include C, C++, Fortran,
+Java, Rust. Build definitions are written in a non-turing complete
+Domain Specific Language.
+
+This package provides support for meson.build files in Vim.
+
+%prep
+%setup -q -n meson-%{version}
+cp %{SOURCE1001} .
+cp -f %{SOURCE1002} ./data
+
+%build
+
+%install
+%{_bindir}/python3 -m pip install --root %{buildroot} %{SOURCE1003}
+
+install -Dpm 0644 data/macros.meson \
+ %{buildroot}%{_rpmconfigdir}/macros.d/macros.meson
+
+mkdir -p %{buildroot}%{vim_data_dir}/site/ftdetect
+install -Dpm 0644 data/syntax-highlighting/vim/ftdetect/meson.vim \
+ -t %{buildroot}%{vim_data_dir}/site/ftdetect
+
+mkdir -p %{buildroot}%{vim_data_dir}/site/indent
+install -Dpm 0644 data/syntax-highlighting/vim/indent/meson.vim \
+ -t %{buildroot}%{vim_data_dir}/site/indent
+
+mkdir -p %{buildroot}%{vim_data_dir}/site/syntax
+install -Dpm 0644 data/syntax-highlighting/vim/syntax/meson.vim \
+ -t %{buildroot}%{vim_data_dir}/site/syntax
+
+%remove_docs
+
+%files
+%manifest %{name}.manifest
+%license COPYING
+%{_bindir}/meson
+%{python3_sitelib}/%{_name}/
+%{python3_sitelib}/meson-*
+%{_rpmconfigdir}/macros.d/macros.meson
+%{_datadir}/polkit-1/actions/com.mesonbuild.install.policy
+
+%files vim
+%manifest %{name}.manifest
+%dir %{vim_data_dir}
+%dir %{vim_data_dir}/site
+%dir %{vim_data_dir}/site/ftdetect
+%dir %{vim_data_dir}/site/indent
+%dir %{vim_data_dir}/site/syntax
+%{vim_data_dir}/site/ftdetect/meson.vim
+%{vim_data_dir}/site/indent/meson.vim
+%{vim_data_dir}/site/syntax/meson.vim
+
+%changelog