build script: package meson as zipped app

This commit is contained in:
alexey.lysiuk 2020-12-06 11:14:15 +02:00
parent bdb135ec38
commit a1f2a7d6b4

View file

@ -32,6 +32,7 @@ import re
import shutil import shutil
import subprocess import subprocess
import urllib.request import urllib.request
import zipapp
class CommandLineOptions(dict): class CommandLineOptions(dict):
@ -701,28 +702,19 @@ class MesonTarget(Target):
return os.path.exists(builder.source_path + 'meson.py') return os.path.exists(builder.source_path + 'meson.py')
def post_build(self, builder: 'Builder'): def post_build(self, builder: 'Builder'):
dest_path = builder.deps_path + self.name + os.sep script = '__main__.py'
lib_path = 'lib' + os.sep + self.name + os.sep shutil.copy(builder.source_path + script, builder.build_path)
dest_lib_path = dest_path + lib_path
os.makedirs(dest_lib_path, exist_ok=True)
script = 'meson.py'
shutil.copy(builder.source_path + script, dest_lib_path)
module = 'mesonbuild' module = 'mesonbuild'
module_path = dest_lib_path + module module_path = builder.build_path + module
if os.path.exists(module_path): if os.path.exists(module_path):
shutil.rmtree(module_path) shutil.rmtree(module_path)
shutil.copytree(builder.source_path + module, module_path) shutil.copytree(builder.source_path + module, module_path)
dest_bin_path = dest_path + 'bin' + os.sep dest_path = builder.deps_path + self.name + os.sep + 'bin' + os.sep
os.makedirs(dest_bin_path, exist_ok=True) os.makedirs(dest_path, exist_ok=True)
exe_path = dest_bin_path + self.name zipapp.create_archive(builder.build_path, dest_path + self.name, '/usr/bin/env python3', compressed=True)
if os.path.exists(exe_path):
os.unlink(exe_path)
os.symlink(os.pardir + os.sep + lib_path + script, exe_path)
class Mpg123Target(ConfigureMakeStaticDependencyTarget): class Mpg123Target(ConfigureMakeStaticDependencyTarget):