# 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 GitClone(Source):
#     base_git_ref = "master"
#     force_full_clone = False
# 
#     @property
#     def release_git_ref(self):
#         return main_project_versions.get(self.name, "master")
# 
#     @property
#     def source_dir(self):
#         if option('make_release'):
#             return "{}_release".format(self.git_dir)
#         else:
#             return self.git_dir
# 
#     @property
#     def git_path(self):
#         return pj(neutralEnv('source_dir'), self.source_dir)
# 
#     @property
#     def git_ref(self):
#         if option('make_release'):
#             return self.release_git_ref
#         else:
#             return self.base_git_ref
# 
#     def _git_init(self, context):
#         if option('fast_clone') and self.force_full_clone == False:
#             command = "git clone --depth=1 --branch {} {} {}".format(
#                 self.git_ref, self.git_remote, self.source_dir)
#             run_command(command, neutralEnv('source_dir'), context)
#         else:
#             command = "git clone {} {}".format(self.git_remote, self.source_dir)
#             run_command(command, neutralEnv('source_dir'), context)
#             command = "git checkout {}".format(self.git_ref)
#             run_command(command, self.git_path, context)
# 
#     def _git_update(self, context):
#         command = "git fetch origin {}".format(self.git_ref)
#         run_command(command, self.git_path, context)
#         try:
#             command = "git merge --ff-only origin/{}".format(self.git_ref)
#             run_command(command, self.git_path, context)
#         except subprocess.CalledProcessError:
#             raise WarningMessage("Cannot update, please check log for information")
# 
#     def prepare(self):
#         if not os.path.exists(self.git_path):
#             self.command('gitinit', self._git_init)
#         else:
#             self.command('gitupdate', self._git_update)
#         if hasattr(self, '_post_prepare_script'):
#             self.command('post_prepare_script', self._post_prepare_script)
# 
# class QMakeBuilder(MakeBuilder):
#     qmake_target = ""
#     flatpak_buildsystem = 'qmake'
# 
#     @property
#     def env_option(self):
#         options = ""
#         if 'QMAKE_CC' in os.environ:
#             options += 'QMAKE_CC={} '.format(os.environ['QMAKE_CC'])
#         if 'QMAKE_CXX' in os.environ:
#             options += 'QMAKE_CXX={} '.format(os.environ['QMAKE_CXX'])
#         return options
# 
#     def _configure(self, context):
#         context.try_skip(self.build_path)
#         cross_option = ""
#         command = ("{command} {configure_option}"
#                    " {env_option}"
#                    " {source_path}"
#                    " {cross_option}")
#         command = command.format(
#             command = neutralEnv('qmake_command'),
#             configure_option=self.configure_option,
#             env_option=self.env_option,
#             source_path=self.source_path,
#             cross_option=cross_option
#         )
#         env = self.get_env(cross_comp_flags=True, cross_compilers=False, cross_path=True)
#         self.set_configure_env(env)
#         run_command(command, self.build_path, context, env=env)
# 
#     def _make_dist(self, context):
#         command = "git archive -o {build_dir}/{name}.tar.gz --prefix={name}/ HEAD"
#         command = command.format(
#             build_dir = self.build_path,
#             name = self.target.full_name()
#         )
#         run_command(command, self.source_path, context)


from .base import (
    Dependency,
    GitClone,
    QMakeBuilder)

class KiwixDesktop(Dependency):
    name = "kiwix-desktop"
    force_build = True


# 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 GitClone(Source):
#     base_git_ref = "master"
#     force_full_clone = False
# 
#     @property
#     def release_git_ref(self):
#         return main_project_versions.get(self.name, "master")
# 
#     @property
#     def source_dir(self):
#         if option('make_release'):
#             return "{}_release".format(self.git_dir)
#         else:
#             return self.git_dir
# 
#     @property
#     def git_path(self):
#         return pj(neutralEnv('source_dir'), self.source_dir)
# 
#     @property
#     def git_ref(self):
#         if option('make_release'):
#             return self.release_git_ref
#         else:
#             return self.base_git_ref
# 
#     def _git_init(self, context):
#         if option('fast_clone') and self.force_full_clone == False:
#             command = "git clone --depth=1 --branch {} {} {}".format(
#                 self.git_ref, self.git_remote, self.source_dir)
#             run_command(command, neutralEnv('source_dir'), context)
#         else:
#             command = "git clone {} {}".format(self.git_remote, self.source_dir)
#             run_command(command, neutralEnv('source_dir'), context)
#             command = "git checkout {}".format(self.git_ref)
#             run_command(command, self.git_path, context)
# 
#     def _git_update(self, context):
#         command = "git fetch origin {}".format(self.git_ref)
#         run_command(command, self.git_path, context)
#         try:
#             command = "git merge --ff-only origin/{}".format(self.git_ref)
#             run_command(command, self.git_path, context)
#         except subprocess.CalledProcessError:
#             raise WarningMessage("Cannot update, please check log for information")
# 
#     def prepare(self):
#         if not os.path.exists(self.git_path):
#             self.command('gitinit', self._git_init)
#         else:
#             self.command('gitupdate', self._git_update)
#         if hasattr(self, '_post_prepare_script'):
#             self.command('post_prepare_script', self._post_prepare_script)
# 
# class QMakeBuilder(MakeBuilder):
#     qmake_target = ""
#     flatpak_buildsystem = 'qmake'
# 
#     @property
#     def env_option(self):
#         options = ""
#         if 'QMAKE_CC' in os.environ:
#             options += 'QMAKE_CC={} '.format(os.environ['QMAKE_CC'])
#         if 'QMAKE_CXX' in os.environ:
#             options += 'QMAKE_CXX={} '.format(os.environ['QMAKE_CXX'])
#         return options
# 
#     def _configure(self, context):
#         context.try_skip(self.build_path)
#         cross_option = ""
#         command = ("{command} {configure_option}"
#                    " {env_option}"
#                    " {source_path}"
#                    " {cross_option}")
#         command = command.format(
#             command = neutralEnv('qmake_command'),
#             configure_option=self.configure_option,
#             env_option=self.env_option,
#             source_path=self.source_path,
#             cross_option=cross_option
#         )
#         env = self.get_env(cross_comp_flags=True, cross_compilers=False, cross_path=True)
#         self.set_configure_env(env)
#         run_command(command, self.build_path, context, env=env)
# 
#     def _make_dist(self, context):
#         command = "git archive -o {build_dir}/{name}.tar.gz --prefix={name}/ HEAD"
#         command = command.format(
#             build_dir = self.build_path,
#             name = self.target.full_name()
#         )
#         run_command(command, self.source_path, context)


# Path: kiwixbuild/dependencies/kiwix_desktop.py
from .base import (
    Dependency,
    GitClone,
    QMakeBuilder)


class KiwixDesktop(Dependency):
    name = "kiwix-desktop"
    force_build = True


    class Source(GitClone):