# Path: scripts/pkgs/constants.py
# def uniq(vals):
#     def cpu_count():
# def build_dir():
# def set_build_dir(x):
# def current_source():
# def set_current_source(x):
# def set_tdir(x):
# def mkdtemp(prefix=''):
# def putenv(**kw):
# ROOT = 'C:\\' if iswindows else '/'
# SW = ROOT + 'sw'
# SOURCES = ROOT + 'sources'
# PATCHES = ROOT + 'patches'
# SCRIPTS = ROOT + 'scripts'
# CALIBRE_DIR = ROOT + 'calibre'
# PREFIX = os.path.join(SW, 'sw')
# BIN = os.path.join(PREFIX, 'bin')
# PYTHON = os.path.join(PREFIX, 'private', 'python', 'python.exe') if iswindows else os.path.join(BIN, 'python')
#     CFLAGS = CPPFLAGS = LIBDIR = LDFLAGS = ''
#     CFLAGS = worker_env['CFLAGS'] = '-I' + os.path.join(PREFIX, 'include')
#     CPPFLAGS = worker_env['CPPFLAGS'] = '-I' + os.path.join(PREFIX, 'include')
#     LIBDIR = os.path.join(PREFIX, 'lib')
#     LDFLAGS = worker_env['LDFLAGS'] = '-L{0} -Wl,-rpath-link,{0}'.format(LIBDIR)
#     LDFLAGS = worker_env['LDFLAGS'] = '-headerpad_max_install_names -L{}'.format(LIBDIR)
# MAKEOPTS = '-j%d' % cpu_count()
# PKG_CONFIG_PATH = worker_env['PKG_CONFIG_PATH'] = os.path.join(PREFIX, 'lib', 'pkgconfig')
# CMAKE = os.path.join(PREFIX, 'bin', 'cmake') if isosx else 'cmake'
# QT_PREFIX = os.path.join(PREFIX, 'qt')
# QT_DLLS = ['Qt5' + x for x in (
#     'Core', 'Gui', 'Network', 'PrintSupport', 'Positioning', 'Sensors', 'Sql',
#     'Svg', 'WebKit', 'WebKitWidgets', 'Widgets', 'Multimedia', 'OpenGL',
#     'MultimediaWidgets', 'Xml',  # 'XmlPatterns',
# )]
# QT_PLUGINS = [
#     'imageformats', 'iconengines', 'mediaservice', 'platforms',
#     'playlistformats', 'sqldrivers',
#     # 'audio', 'printsupport', 'bearer', 'position',
# ]
# PYQT_MODULES = ('Qt', 'QtCore', 'QtGui', 'QtNetwork',  # 'QtMultimedia', 'QtMultimediaWidgets',
#                 'QtPrintSupport', 'QtSensors', 'QtSvg', 'QtWebKit', 'QtWebKitWidgets', 'QtWidgets')
# CODESIGN_KEYCHAIN = '/Users/kovid/codesign.keychain'
#     class SYSTEM_INFO(ctypes.Structure):
# 
# Path: scripts/pkgs/utils.py
#     def split(x):
#     def issymlink(x):
#     def __init__(self, **kwargs):
#     def apply(self, mods):
#     def __enter__(self):
#     def __exit__(self, *args):
# def current_env(library_path=False):
# def isatty():
# def run_shell(library_path=False):
# def run(*args, **kw):
# def extract(source):
# def chdir_for_extract(name):
# def extract_source():
# def apply_patch(name, level=0, reverse=False, convert_line_endings=False):
# def simple_build(configure_args=(), make_args=(), install_args=(), library_path=None, override_prefix=None, no_parallel=False, configure_name='./configure'):
# def python_build(extra_args=()):
# def python_install():
# def replace_in_file(path, old, new, missing_ok=False):
#     def hardlink(src, dst):
#     def rmtree(x, tries=10):
# def lcopy(src, dst, no_hardlinks=False):
# def install_binaries(pattern, destdir='lib', do_symlinks=False, fname_map=os.path.basename):
# def install_tree(src, dest_parent='include', ignore=None):
# def copy_headers(pattern, destdir='include'):
# def library_symlinks(full_name, destdir='lib'):
# def ensure_dir(path):
# def create_package(module, src_dir, outpath):
#         def get_name(x):
#         def is_ok(name):
# def install_package(pkg_path, dest_dir):
# def set_title(x):
# def walk(path='.'):
# def read_lib_names(p):
# def flipwritable(fn, mode=None):
# def change_lib_names(p, changes):
# def is_macho_binary(p):
# def fix_install_names(m, output_dir):
# def timeit():
# def current_dir(path):
# def tempdir(prefix='tmp-'):
# def windows_cmake_build(headers=None, binaries=None, libraries=None, header_dest='include', nmake_target='', **kw):
# class ModifiedEnv(object):


import os
from .constants import build_dir, isosx, PREFIX
from .utils import simple_build, windows_cmake_build, iswindows, install_binaries
#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>

from __future__ import (unicode_literals, division, absolute_import,
                        print_function)



def main(args):
    if iswindows:
        windows_cmake_build()
        install_binaries('build/jpegtran-static.exe', 'bin', fname_map=lambda x: 'jpegtran-calibre.exe')

# Path: scripts/pkgs/constants.py
# def uniq(vals):
#     def cpu_count():
# def build_dir():
# def set_build_dir(x):
# def current_source():
# def set_current_source(x):
# def set_tdir(x):
# def mkdtemp(prefix=''):
# def putenv(**kw):
# ROOT = 'C:\\' if iswindows else '/'
# SW = ROOT + 'sw'
# SOURCES = ROOT + 'sources'
# PATCHES = ROOT + 'patches'
# SCRIPTS = ROOT + 'scripts'
# CALIBRE_DIR = ROOT + 'calibre'
# PREFIX = os.path.join(SW, 'sw')
# BIN = os.path.join(PREFIX, 'bin')
# PYTHON = os.path.join(PREFIX, 'private', 'python', 'python.exe') if iswindows else os.path.join(BIN, 'python')
#     CFLAGS = CPPFLAGS = LIBDIR = LDFLAGS = ''
#     CFLAGS = worker_env['CFLAGS'] = '-I' + os.path.join(PREFIX, 'include')
#     CPPFLAGS = worker_env['CPPFLAGS'] = '-I' + os.path.join(PREFIX, 'include')
#     LIBDIR = os.path.join(PREFIX, 'lib')
#     LDFLAGS = worker_env['LDFLAGS'] = '-L{0} -Wl,-rpath-link,{0}'.format(LIBDIR)
#     LDFLAGS = worker_env['LDFLAGS'] = '-headerpad_max_install_names -L{}'.format(LIBDIR)
# MAKEOPTS = '-j%d' % cpu_count()
# PKG_CONFIG_PATH = worker_env['PKG_CONFIG_PATH'] = os.path.join(PREFIX, 'lib', 'pkgconfig')
# CMAKE = os.path.join(PREFIX, 'bin', 'cmake') if isosx else 'cmake'
# QT_PREFIX = os.path.join(PREFIX, 'qt')
# QT_DLLS = ['Qt5' + x for x in (
#     'Core', 'Gui', 'Network', 'PrintSupport', 'Positioning', 'Sensors', 'Sql',
#     'Svg', 'WebKit', 'WebKitWidgets', 'Widgets', 'Multimedia', 'OpenGL',
#     'MultimediaWidgets', 'Xml',  # 'XmlPatterns',
# )]
# QT_PLUGINS = [
#     'imageformats', 'iconengines', 'mediaservice', 'platforms',
#     'playlistformats', 'sqldrivers',
#     # 'audio', 'printsupport', 'bearer', 'position',
# ]
# PYQT_MODULES = ('Qt', 'QtCore', 'QtGui', 'QtNetwork',  # 'QtMultimedia', 'QtMultimediaWidgets',
#                 'QtPrintSupport', 'QtSensors', 'QtSvg', 'QtWebKit', 'QtWebKitWidgets', 'QtWidgets')
# CODESIGN_KEYCHAIN = '/Users/kovid/codesign.keychain'
#     class SYSTEM_INFO(ctypes.Structure):
# 
# Path: scripts/pkgs/utils.py
#     def split(x):
#     def issymlink(x):
#     def __init__(self, **kwargs):
#     def apply(self, mods):
#     def __enter__(self):
#     def __exit__(self, *args):
# def current_env(library_path=False):
# def isatty():
# def run_shell(library_path=False):
# def run(*args, **kw):
# def extract(source):
# def chdir_for_extract(name):
# def extract_source():
# def apply_patch(name, level=0, reverse=False, convert_line_endings=False):
# def simple_build(configure_args=(), make_args=(), install_args=(), library_path=None, override_prefix=None, no_parallel=False, configure_name='./configure'):
# def python_build(extra_args=()):
# def python_install():
# def replace_in_file(path, old, new, missing_ok=False):
#     def hardlink(src, dst):
#     def rmtree(x, tries=10):
# def lcopy(src, dst, no_hardlinks=False):
# def install_binaries(pattern, destdir='lib', do_symlinks=False, fname_map=os.path.basename):
# def install_tree(src, dest_parent='include', ignore=None):
# def copy_headers(pattern, destdir='include'):
# def library_symlinks(full_name, destdir='lib'):
# def ensure_dir(path):
# def create_package(module, src_dir, outpath):
#         def get_name(x):
#         def is_ok(name):
# def install_package(pkg_path, dest_dir):
# def set_title(x):
# def walk(path='.'):
# def read_lib_names(p):
# def flipwritable(fn, mode=None):
# def change_lib_names(p, changes):
# def is_macho_binary(p):
# def fix_install_names(m, output_dir):
# def timeit():
# def current_dir(path):
# def tempdir(prefix='tmp-'):
# def windows_cmake_build(headers=None, binaries=None, libraries=None, header_dest='include', nmake_target='', **kw):
# class ModifiedEnv(object):


# Path: scripts/pkgs/mozjpeg.py
import os
from .constants import build_dir, isosx, PREFIX
from .utils import simple_build, windows_cmake_build, iswindows, install_binaries

#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>

from __future__ import (unicode_literals, division, absolute_import,
                        print_function)



def main(args):
    if iswindows:
        windows_cmake_build()
        install_binaries('build/jpegtran-static.exe', 'bin', fname_map=lambda x: 'jpegtran-calibre.exe')

        install_binaries('build/cjpeg-static.exe', 'bin', fname_map=lambda x: 'cjpeg-calibre.exe')