# Path: kiwixbuild/dependencies/base.py
# class Dependency(metaclass=_MetaDependency):
#     all_deps = {}
#     force_build = False
#     force_native_build = False
#     dont_skip = False
# 
#     @classmethod
#     def version(cls):
#         if cls.name in base_deps_versions:
#             return base_deps_versions[cls.name]
#         elif option('make_release'):
#             return main_project_versions.get(cls.name, None)
#         return None
# 
#     @classmethod
#     def full_name(cls):
#         if cls.version():
#             return "{}-{}".format(cls.name, cls.version())
#         return cls.name
# 
# class ReleaseDownload(Source):
#     archive_top_dir = None
# 
#     @property
#     def extract_path(self):
#         return pj(neutralEnv('source_dir'), self.source_dir)
# 
#     def _download(self, context):
#         context.try_skip(neutralEnv('archive_dir'), self.full_name)
#         neutralEnv('download')(self.archive)
# 
#     def _extract(self, context):
#         context.try_skip(self.extract_path)
#         if os.path.exists(self.extract_path):
#             shutil.rmtree(self.extract_path)
#         extract_archive(pj(neutralEnv('archive_dir'), self.archive.name),
#                         neutralEnv('source_dir'),
#                         topdir=self.archive_top_dir,
#                         name=self.source_dir)
# 
#     def prepare(self):
#         self.command('download', self._download)
#         self.command('extract', self._extract)
#         if hasattr(self, 'patches'):
#             self.command('patch', self._patch)
#         if hasattr(self, '_post_prepare_script'):
#             self.command('post_prepare_script', self._post_prepare_script)
# 
# class MesonBuilder(Builder):
#     configure_option = ""
#     test_option = ""
#     flatpak_buildsystem = 'meson'
# 
#     @property
#     def build_type(self):
#         return 'release' if option('make_release') else 'debug'
# 
#     @property
#     def strip_option(self):
#         return '--strip' if option('make_release') else ''
# 
#     @property
#     def library_type(self):
#         return 'static' if self.buildEnv.platformInfo.static else 'shared'
# 
#     def _configure(self, context):
#         context.no_skip = False
#         context.try_skip(self.build_path)
#         if os.path.exists(self.build_path):
#             shutil.rmtree(self.build_path)
#         os.makedirs(self.build_path)
#         configure_option = self.configure_option.format(buildEnv=self.buildEnv)
#         cross_option = ""
#         if not self.target.force_native_build and self.buildEnv.meson_crossfile:
#             cross_option = "--cross-file {}".format(
#                 self.buildEnv.meson_crossfile)
#         command = ("{command} . {build_path}"
#                    " --buildtype={build_type} {strip_option}"
#                    " --default-library={library_type}"
#                    " {configure_option}"
#                    " --prefix={buildEnv.install_dir}"
#                    " --libdir={buildEnv.libprefix}"
#                    " {cross_option}")
#         command = command.format(
#             command=neutralEnv('meson_command'),
#             build_type=self.build_type,
#             strip_option=self.strip_option,
#             library_type=self.library_type,
#             configure_option=configure_option,
#             build_path=self.build_path,
#             buildEnv=self.buildEnv,
#             cross_option=cross_option
#         )
#         env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
#         run_command(command, self.source_path, context, env=env)
# 
#     def _compile(self, context):
#         context.try_skip(self.build_path)
#         command = "{} -v".format(neutralEnv('ninja_command'))
#         env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
#         run_command(command, self.build_path, context, env=env)
# 
#     def _test(self, context):
#         context.try_skip(self.build_path)
#         if ( self.buildEnv.platformInfo.build == 'android'
#              or (self.buildEnv.platformInfo.build != 'native'
#                  and not self.buildEnv.platformInfo.static)
#            ):
#             raise SkipCommand()
#         command = "{} --verbose {}".format(neutralEnv('mesontest_command'), self.test_option)
#         env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
#         run_command(command, self.build_path, context, env=env)
# 
#     def _install(self, context):
#         context.try_skip(self.build_path)
#         command = "{} -v install".format(neutralEnv('ninja_command'))
#         env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
#         run_command(command, self.build_path, context, env=env)
# 
#     def _make_dist(self, context):
#         command = "{} -v dist".format(neutralEnv('ninja_command'))
#         env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
#         run_command(command, self.build_path, context, env=env)
# 
# Path: kiwixbuild/utils.py
# class Remotefile(namedtuple('Remotefile', ('name', 'sha256', 'url'))):
#     def __new__(cls, name, sha256, url=None):
#         if url is None:
#             url = REMOTE_PREFIX + name
#         return super().__new__(cls, name, sha256, url)


from .base import (
    Dependency,
    ReleaseDownload,
    MesonBuilder)
from kiwixbuild.utils import Remotefile


class Pugixml(Dependency):
    name = "pugixml"

    class Source(ReleaseDownload):
        archive = Remotefile('pugixml-1.2.tar.gz',
                             '0f422dad86da0a2e56a37fb2a88376aae6e931f22cc8b956978460c9db06136b')
        patches = ["pugixml_meson.patch"]
        flatpak_dest = "src"


# Path: kiwixbuild/dependencies/base.py
# class Dependency(metaclass=_MetaDependency):
#     all_deps = {}
#     force_build = False
#     force_native_build = False
#     dont_skip = False
# 
#     @classmethod
#     def version(cls):
#         if cls.name in base_deps_versions:
#             return base_deps_versions[cls.name]
#         elif option('make_release'):
#             return main_project_versions.get(cls.name, None)
#         return None
# 
#     @classmethod
#     def full_name(cls):
#         if cls.version():
#             return "{}-{}".format(cls.name, cls.version())
#         return cls.name
# 
# class ReleaseDownload(Source):
#     archive_top_dir = None
# 
#     @property
#     def extract_path(self):
#         return pj(neutralEnv('source_dir'), self.source_dir)
# 
#     def _download(self, context):
#         context.try_skip(neutralEnv('archive_dir'), self.full_name)
#         neutralEnv('download')(self.archive)
# 
#     def _extract(self, context):
#         context.try_skip(self.extract_path)
#         if os.path.exists(self.extract_path):
#             shutil.rmtree(self.extract_path)
#         extract_archive(pj(neutralEnv('archive_dir'), self.archive.name),
#                         neutralEnv('source_dir'),
#                         topdir=self.archive_top_dir,
#                         name=self.source_dir)
# 
#     def prepare(self):
#         self.command('download', self._download)
#         self.command('extract', self._extract)
#         if hasattr(self, 'patches'):
#             self.command('patch', self._patch)
#         if hasattr(self, '_post_prepare_script'):
#             self.command('post_prepare_script', self._post_prepare_script)
# 
# class MesonBuilder(Builder):
#     configure_option = ""
#     test_option = ""
#     flatpak_buildsystem = 'meson'
# 
#     @property
#     def build_type(self):
#         return 'release' if option('make_release') else 'debug'
# 
#     @property
#     def strip_option(self):
#         return '--strip' if option('make_release') else ''
# 
#     @property
#     def library_type(self):
#         return 'static' if self.buildEnv.platformInfo.static else 'shared'
# 
#     def _configure(self, context):
#         context.no_skip = False
#         context.try_skip(self.build_path)
#         if os.path.exists(self.build_path):
#             shutil.rmtree(self.build_path)
#         os.makedirs(self.build_path)
#         configure_option = self.configure_option.format(buildEnv=self.buildEnv)
#         cross_option = ""
#         if not self.target.force_native_build and self.buildEnv.meson_crossfile:
#             cross_option = "--cross-file {}".format(
#                 self.buildEnv.meson_crossfile)
#         command = ("{command} . {build_path}"
#                    " --buildtype={build_type} {strip_option}"
#                    " --default-library={library_type}"
#                    " {configure_option}"
#                    " --prefix={buildEnv.install_dir}"
#                    " --libdir={buildEnv.libprefix}"
#                    " {cross_option}")
#         command = command.format(
#             command=neutralEnv('meson_command'),
#             build_type=self.build_type,
#             strip_option=self.strip_option,
#             library_type=self.library_type,
#             configure_option=configure_option,
#             build_path=self.build_path,
#             buildEnv=self.buildEnv,
#             cross_option=cross_option
#         )
#         env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
#         run_command(command, self.source_path, context, env=env)
# 
#     def _compile(self, context):
#         context.try_skip(self.build_path)
#         command = "{} -v".format(neutralEnv('ninja_command'))
#         env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
#         run_command(command, self.build_path, context, env=env)
# 
#     def _test(self, context):
#         context.try_skip(self.build_path)
#         if ( self.buildEnv.platformInfo.build == 'android'
#              or (self.buildEnv.platformInfo.build != 'native'
#                  and not self.buildEnv.platformInfo.static)
#            ):
#             raise SkipCommand()
#         command = "{} --verbose {}".format(neutralEnv('mesontest_command'), self.test_option)
#         env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
#         run_command(command, self.build_path, context, env=env)
# 
#     def _install(self, context):
#         context.try_skip(self.build_path)
#         command = "{} -v install".format(neutralEnv('ninja_command'))
#         env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
#         run_command(command, self.build_path, context, env=env)
# 
#     def _make_dist(self, context):
#         command = "{} -v dist".format(neutralEnv('ninja_command'))
#         env = self.get_env(cross_comp_flags=False, cross_compilers=False, cross_path=True)
#         run_command(command, self.build_path, context, env=env)
# 
# Path: kiwixbuild/utils.py
# class Remotefile(namedtuple('Remotefile', ('name', 'sha256', 'url'))):
#     def __new__(cls, name, sha256, url=None):
#         if url is None:
#             url = REMOTE_PREFIX + name
#         return super().__new__(cls, name, sha256, url)


# Path: kiwixbuild/dependencies/pugixml.py
from .base import (
    Dependency,
    ReleaseDownload,
    MesonBuilder)
from kiwixbuild.utils import Remotefile



class Pugixml(Dependency):
    name = "pugixml"

    class Source(ReleaseDownload):
        archive = Remotefile('pugixml-1.2.tar.gz',
                             '0f422dad86da0a2e56a37fb2a88376aae6e931f22cc8b956978460c9db06136b')
        patches = ["pugixml_meson.patch"]
        flatpak_dest = "src"


    class Builder(MesonBuilder):