2017-03-12 19:00:57 +00:00
|
|
|
# Copyright 2017 Virgil Dupras
|
2014-10-05 20:31:16 +00:00
|
|
|
#
|
2015-01-03 21:33:16 +00:00
|
|
|
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
2014-10-05 20:31:16 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2015-01-03 21:33:16 +00:00
|
|
|
# http://www.gnu.org/licenses/gpl-3.0.html
|
2009-12-30 16:34:41 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import os.path as op
|
2011-01-21 13:39:33 +00:00
|
|
|
from optparse import OptionParser
|
2010-01-01 20:42:52 +00:00
|
|
|
import shutil
|
2009-12-30 16:34:41 +00:00
|
|
|
|
2011-12-28 19:51:33 +00:00
|
|
|
from setuptools import setup, Extension
|
2009-12-30 16:34:41 +00:00
|
|
|
|
2011-01-12 16:30:57 +00:00
|
|
|
from hscommon import sphinxgen
|
2014-10-13 19:08:59 +00:00
|
|
|
from hscommon.build import (
|
2017-03-12 19:00:57 +00:00
|
|
|
add_to_pythonpath, print_and_do, move_all, fix_qt_resource_file,
|
2014-10-13 19:08:59 +00:00
|
|
|
)
|
2011-11-01 19:44:18 +00:00
|
|
|
from hscommon import loc
|
2009-12-30 16:34:41 +00:00
|
|
|
|
2011-01-21 13:39:33 +00:00
|
|
|
def parse_args():
|
|
|
|
usage = "usage: %prog [options]"
|
|
|
|
parser = OptionParser(usage=usage)
|
2014-10-13 19:08:59 +00:00
|
|
|
parser.add_option(
|
|
|
|
'--clean', action='store_true', dest='clean',
|
|
|
|
help="Clean build folder before building"
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
'--doc', action='store_true', dest='doc',
|
|
|
|
help="Build only the help file"
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
'--loc', action='store_true', dest='loc',
|
|
|
|
help="Build only localization"
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
'--updatepot', action='store_true', dest='updatepot',
|
|
|
|
help="Generate .pot files from source code."
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
'--mergepot', action='store_true', dest='mergepot',
|
|
|
|
help="Update all .po files based on .pot files."
|
|
|
|
)
|
|
|
|
parser.add_option(
|
|
|
|
'--normpo', action='store_true', dest='normpo',
|
|
|
|
help="Normalize all PO files (do this before commit)."
|
|
|
|
)
|
2011-01-21 13:39:33 +00:00
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
return options
|
|
|
|
|
2016-06-01 00:21:07 +00:00
|
|
|
def build_help():
|
2011-01-11 16:58:28 +00:00
|
|
|
print("Generating Help")
|
2011-01-12 16:30:57 +00:00
|
|
|
current_path = op.abspath('.')
|
|
|
|
help_basepath = op.join(current_path, 'help', 'en')
|
2016-06-01 00:21:07 +00:00
|
|
|
help_destpath = op.join(current_path, 'build', 'help')
|
2016-06-07 00:48:26 +00:00
|
|
|
changelog_path = op.join(current_path, 'help', 'changelog')
|
2013-07-28 19:11:39 +00:00
|
|
|
tixurl = "https://github.com/hsoft/dupeguru/issues/{}"
|
2016-06-07 00:48:26 +00:00
|
|
|
confrepl = {'language': 'en'}
|
2012-01-24 13:28:23 +00:00
|
|
|
changelogtmpl = op.join(current_path, 'help', 'changelog.tmpl')
|
|
|
|
conftmpl = op.join(current_path, 'help', 'conf.tmpl')
|
|
|
|
sphinxgen.gen(help_basepath, help_destpath, changelog_path, tixurl, confrepl, conftmpl, changelogtmpl)
|
2011-01-11 16:58:28 +00:00
|
|
|
|
2012-08-02 16:49:49 +00:00
|
|
|
def build_qt_localizations():
|
|
|
|
loc.compile_all_po(op.join('qtlib', 'locale'))
|
|
|
|
loc.merge_locale_dir(op.join('qtlib', 'locale'), 'locale')
|
|
|
|
|
2017-03-12 19:00:57 +00:00
|
|
|
def build_localizations():
|
2013-11-30 23:23:42 +00:00
|
|
|
loc.compile_all_po('locale')
|
2017-03-12 19:00:57 +00:00
|
|
|
build_qt_localizations()
|
|
|
|
locale_dest = op.join('build', 'locale')
|
2012-08-02 16:49:49 +00:00
|
|
|
if op.exists(locale_dest):
|
|
|
|
shutil.rmtree(locale_dest)
|
|
|
|
shutil.copytree('locale', locale_dest, ignore=shutil.ignore_patterns('*.po', '*.pot'))
|
2011-11-01 19:44:18 +00:00
|
|
|
|
2011-11-02 19:55:20 +00:00
|
|
|
def build_updatepot():
|
2011-11-01 19:44:18 +00:00
|
|
|
print("Building .pot files from source files")
|
|
|
|
print("Building core.pot")
|
2016-06-01 02:32:37 +00:00
|
|
|
loc.generate_pot(['core'], op.join('locale', 'core.pot'), ['tr'])
|
2011-11-01 19:44:18 +00:00
|
|
|
print("Building columns.pot")
|
2016-06-01 02:32:37 +00:00
|
|
|
loc.generate_pot(['core'], op.join('locale', 'columns.pot'), ['coltr'])
|
2011-11-01 19:44:18 +00:00
|
|
|
print("Building ui.pot")
|
2013-03-24 14:59:41 +00:00
|
|
|
# When we're not under OS X, we don't want to overwrite ui.pot because it contains Cocoa locs
|
|
|
|
# We want to merge the generated pot with the old pot in the most preserving way possible.
|
2011-11-04 15:23:17 +00:00
|
|
|
ui_packages = ['qt', op.join('cocoa', 'inter')]
|
2017-03-12 19:00:57 +00:00
|
|
|
loc.generate_pot(ui_packages, op.join('locale', 'ui.pot'), ['tr'], merge=True)
|
2011-11-01 19:44:18 +00:00
|
|
|
print("Building qtlib.pot")
|
|
|
|
loc.generate_pot(['qtlib'], op.join('qtlib', 'locale', 'qtlib.pot'), ['tr'])
|
2011-11-02 19:55:20 +00:00
|
|
|
|
|
|
|
def build_mergepot():
|
|
|
|
print("Updating .po files using .pot files")
|
|
|
|
loc.merge_pots_into_pos('locale')
|
2012-01-03 22:03:53 +00:00
|
|
|
loc.merge_pots_into_pos(op.join('qtlib', 'locale'))
|
2012-02-01 14:45:33 +00:00
|
|
|
loc.merge_pots_into_pos(op.join('cocoalib', 'locale'))
|
2011-06-14 17:43:29 +00:00
|
|
|
|
2013-08-03 21:13:24 +00:00
|
|
|
def build_normpo():
|
|
|
|
loc.normalize_all_pos('locale')
|
|
|
|
loc.normalize_all_pos(op.join('qtlib', 'locale'))
|
|
|
|
loc.normalize_all_pos(op.join('cocoalib', 'locale'))
|
|
|
|
|
2017-03-12 19:00:57 +00:00
|
|
|
def build_pe_modules():
|
2010-08-17 07:30:25 +00:00
|
|
|
print("Building PE Modules")
|
|
|
|
exts = [
|
2016-06-01 02:32:37 +00:00
|
|
|
Extension(
|
|
|
|
"_block",
|
|
|
|
[op.join('core', 'pe', 'modules', 'block.c'), op.join('core', 'pe', 'modules', 'common.c')]
|
|
|
|
),
|
|
|
|
Extension(
|
|
|
|
"_cache",
|
|
|
|
[op.join('core', 'pe', 'modules', 'cache.c'), op.join('core', 'pe', 'modules', 'common.c')]
|
|
|
|
),
|
2010-08-17 07:30:25 +00:00
|
|
|
]
|
2017-03-12 19:00:57 +00:00
|
|
|
exts.append(Extension("_block_qt", [op.join('qt', 'pe', 'modules', 'block.c')]))
|
2010-08-17 07:30:25 +00:00
|
|
|
setup(
|
2014-10-13 19:08:59 +00:00
|
|
|
script_args=['build_ext', '--inplace'],
|
|
|
|
ext_modules=exts,
|
2010-08-17 07:30:25 +00:00
|
|
|
)
|
2011-10-04 13:45:55 +00:00
|
|
|
move_all('_block_qt*', op.join('qt', 'pe'))
|
2016-06-01 02:32:37 +00:00
|
|
|
move_all('_block*', op.join('core', 'pe'))
|
|
|
|
move_all('_cache*', op.join('core', 'pe'))
|
2010-02-09 14:32:52 +00:00
|
|
|
|
2017-03-12 19:00:57 +00:00
|
|
|
def build_normal():
|
|
|
|
print("Building dupeGuru with UI qt")
|
2010-01-01 20:42:52 +00:00
|
|
|
add_to_pythonpath('.')
|
2010-08-11 14:39:06 +00:00
|
|
|
print("Building dupeGuru")
|
2017-03-12 19:00:57 +00:00
|
|
|
build_pe_modules()
|
|
|
|
print("Building localizations")
|
|
|
|
build_localizations()
|
|
|
|
print("Building Qt stuff")
|
|
|
|
print_and_do("pyrcc5 {0} > {1}".format(op.join('qt', 'dg.qrc'), op.join('qt', 'dg_rc.py')))
|
|
|
|
fix_qt_resource_file(op.join('qt', 'dg_rc.py'))
|
|
|
|
build_help()
|
2009-12-30 16:34:41 +00:00
|
|
|
|
2011-01-21 13:39:33 +00:00
|
|
|
def main():
|
|
|
|
options = parse_args()
|
2011-01-22 16:06:04 +00:00
|
|
|
if not op.exists('build'):
|
|
|
|
os.mkdir('build')
|
2011-06-14 17:43:29 +00:00
|
|
|
if options.doc:
|
2016-06-01 00:21:07 +00:00
|
|
|
build_help()
|
2011-06-14 17:43:29 +00:00
|
|
|
elif options.loc:
|
2017-03-12 19:00:57 +00:00
|
|
|
build_localizations()
|
2011-11-02 19:55:20 +00:00
|
|
|
elif options.updatepot:
|
|
|
|
build_updatepot()
|
|
|
|
elif options.mergepot:
|
|
|
|
build_mergepot()
|
2013-08-03 21:13:24 +00:00
|
|
|
elif options.normpo:
|
|
|
|
build_normpo()
|
2011-01-21 13:39:33 +00:00
|
|
|
else:
|
2017-03-12 19:00:57 +00:00
|
|
|
build_normal()
|
2011-01-21 13:39:33 +00:00
|
|
|
|
2009-12-30 16:34:41 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|