Bump to meson 1.3.0 accepted/tizen_base accepted/tizen_base_asan accepted/tizen_base_toolchain accepted/tizen_base_x accepted/tizen_base_x_asan sandbox/meson_1.3.0 tizen_base accepted/tizen/base/20240328.043040 accepted/tizen/base/asan/20240406.082259 accepted/tizen/base/toolchain/20240424.234701 accepted/tizen/base/x/20240328.090034 accepted/tizen/base/x/asan/20240412.002903
authorTizenOpenSource <tizenopensrc@samsung.com>
Fri, 22 Dec 2023 09:21:17 +0000 (18:21 +0900)
committerTizenOpenSource <tizenopensrc@samsung.com>
Fri, 22 Dec 2023 09:21:17 +0000 (18:21 +0900)
Signed-off-by: TizenOpenSource <tizenopensrc@samsung.com>
packaging/create_zipapp.py
packaging/createmsi.py
packaging/createpkg.py
packaging/hook-mesonbuild.py [changed mode: 0644->0755]
packaging/macros.meson [new file with mode: 0644]
packaging/meson-1.3.0-py3-none-any.whl [new file with mode: 0644]
packaging/meson.manifest [new file with mode: 0644]
packaging/meson.spec [new file with mode: 0644]

index 9fd0f5b..4e018bf 100755 (executable)
@@ -11,7 +11,6 @@ parser = argparse.ArgumentParser()
 parser.add_argument('source', nargs='?', default='.', help='Source directory')
 parser.add_argument('--outfile', default='meson.pyz', help='Output file for the zipapp')
 parser.add_argument('--interpreter', default='/usr/bin/env python3', help='The name of the Python interpreter to use')
-parser.add_argument('--compress', action='store_true', default=False, help='Compress files')
 
 options = parser.parse_args(sys.argv[1:])
 
@@ -20,4 +19,4 @@ source = Path(options.source).resolve()
 with tempfile.TemporaryDirectory() as d:
     shutil.copy2(source / 'meson.py', Path(d, '__main__.py'))
     shutil.copytree(source / 'mesonbuild', Path(d, 'mesonbuild'))
-    zipapp.create_archive(d, interpreter=options.interpreter, target=options.outfile, compressed=options.compress)
+    zipapp.create_archive(d, interpreter=options.interpreter, target=options.outfile)
index fef2b38..0139877 100755 (executable)
@@ -31,7 +31,7 @@ sys.path.append(os.getcwd())
 from mesonbuild import coredata
 
 # Elementtree does not support CDATA. So hack it.
-WINVER_CHECK = 'Installed OR (VersionNT64 &gt; 602)>'
+WINVER_CHECK = '<![CDATA[Installed OR (VersionNT64 > 602)]]>'
 
 def gen_guid():
     '''
@@ -39,6 +39,48 @@ 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
@@ -83,7 +125,7 @@ class PackageGenerator:
         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)
@@ -102,7 +144,7 @@ class PackageGenerator:
                 'Title': 'Meson',
                 'Description': 'Meson executables',
                 'Level': '1',
-                'AllowAbsent': 'no',
+                'Absent': 'disallow',
             },
             self.staging_dirs[1]: {
                 'Id': 'NinjaProgram',
@@ -123,6 +165,7 @@ class PackageGenerator:
             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:
@@ -134,9 +177,10 @@ class PackageGenerator:
             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)
@@ -160,44 +204,49 @@ class PackageGenerator:
         '''
            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',
         })
@@ -208,12 +257,16 @@ class PackageGenerator:
             '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',
@@ -237,7 +290,7 @@ class PackageGenerator:
         })
         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:
@@ -268,10 +321,10 @@ class PackageGenerator:
             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',
@@ -291,7 +344,7 @@ class PackageGenerator:
                 })
 
         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,
@@ -302,40 +355,23 @@ class PackageGenerator:
         '''
            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()
index fd022d9..533b3b9 100755 (executable)
 
 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):
@@ -42,15 +43,13 @@ class PkgGenerator:
         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')
@@ -89,7 +88,7 @@ class PkgGenerator:
         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})
@@ -100,7 +99,7 @@ class PkgGenerator:
                                         '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:
old mode 100644 (file)
new mode 100755 (executable)
index d6b06cd..b076c50
@@ -21,15 +21,11 @@ def get_all_modules_from_dir(dirname):
     modules = ['mesonbuild.' + modname + '.' + x for x in modules if not x.startswith('_')]
     return modules
 
-datas += collect_data_files('mesonbuild.scripts', include_py_files=True, excludes=['**/__pycache__'])
+datas += collect_data_files('mesonbuild.scripts')
 datas += collect_data_files('mesonbuild.cmake.data')
 datas += collect_data_files('mesonbuild.dependencies.data')
 
-# lazy-loaded
-hiddenimports += get_all_modules_from_dir('mesonbuild/dependencies')
-# imported by meson.build files
 hiddenimports += get_all_modules_from_dir('mesonbuild/modules')
-# executed when named on CLI
 hiddenimports += get_all_modules_from_dir('mesonbuild/scripts')
 
 # Python packagers want to be minimal and only copy the things
diff --git a/packaging/macros.meson b/packaging/macros.meson
new file mode 100644 (file)
index 0000000..8c3b394
--- /dev/null
@@ -0,0 +1,45 @@
+%__meson %{_bindir}/meson
+%__meson_wrap_mode nodownload
+%__meson_auto_features enabled
+
+%_vpath_srcdir .
+%_vpath_builddir %{_target_platform}
+
+%meson \\\
+    %{__meson} \\\
+    --buildtype=plain \\\
+    --prefix=%{_prefix} \\\
+    --libdir=%{_libdir} \\\
+    --libexecdir=%{_libexecdir} \\\
+    --bindir=%{_bindir} \\\
+    --sbindir=%{_sbindir} \\\
+    --includedir=%{_includedir} \\\
+    --datadir=%{_datadir} \\\
+    --mandir=%{_mandir} \\\
+    --infodir=%{_infodir} \\\
+    --localedir=%{_datadir}/locale \\\
+    --sysconfdir=%{_sysconfdir} \\\
+    --localstatedir=%{_localstatedir} \\\
+    --sharedstatedir=%{_sharedstatedir} \\\
+    --wrap-mode=%{__meson_wrap_mode} \\\
+    --auto-features=%{__meson_auto_features} \\\
+    %{_vpath_srcdir} %{_vpath_builddir} \\\
+    %{nil}
+
+%meson_build \\\
+    %{__meson} compile \\\
+    -C %{_vpath_builddir} \\\
+    --verbose \\\
+    %{nil}
+
+%meson_install \\\
+    DESTDIR=%{buildroot} %{__meson} install \\\
+    -C %{_vpath_builddir} \\\
+    --no-rebuild \\\
+    %{nil}
+
+%meson_test \\\
+    %{__meson} test \\\
+        -C %{_vpath_builddir} \\\
+        --print-errorlogs \\\
+        %{nil}}
diff --git a/packaging/meson-1.3.0-py3-none-any.whl b/packaging/meson-1.3.0-py3-none-any.whl
new file mode 100644 (file)
index 0000000..6a85531
Binary files /dev/null and b/packaging/meson-1.3.0-py3-none-any.whl differ
diff --git a/packaging/meson.manifest b/packaging/meson.manifest
new file mode 100644 (file)
index 0000000..017d22d
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+    <domain name="_"/>
+ </request>
+</manifest>
diff --git a/packaging/meson.spec b/packaging/meson.spec
new file mode 100644 (file)
index 0000000..e9f64c6
--- /dev/null
@@ -0,0 +1,104 @@
+%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