mirror of https://github.com/GNOME/gimp.git
build/windows: Port list-installer-langs.sh to Python
This commit is contained in:
parent
dea5e2414a
commit
b95c78fdbd
|
@ -0,0 +1,77 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import os
|
||||||
|
import glob
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
MESON_BUILD_ROOT = Path(os.environ.get("MESON_BUILD_ROOT",".")).as_posix()
|
||||||
|
MESON_SOURCE_ROOT = Path(os.environ.get("MESON_SOURCE_ROOT",sys.argv[2])).as_posix()
|
||||||
|
|
||||||
|
## Get list of Inno and GIMP supported languages
|
||||||
|
po_inno_files = sorted(glob.glob(os.path.join(MESON_SOURCE_ROOT,'po-windows-installer/*.po')))
|
||||||
|
po_inno_array = [re.sub(r'^po-windows-installer/|\.po$', '', f) for f in po_inno_files]
|
||||||
|
po_files = sorted(glob.glob(os.path.join(MESON_SOURCE_ROOT,'po/*.po')))
|
||||||
|
po_array = [re.sub(r'^po/|\.po$', '', f) for f in po_files]
|
||||||
|
|
||||||
|
## Get strings for GIMP and Inno supported languages
|
||||||
|
xml_file = os.path.join(MESON_SOURCE_ROOT, 'build/windows/installer/lang/iso_639_custom.xml')
|
||||||
|
tree = ET.parse(xml_file)
|
||||||
|
root = tree.getroot()
|
||||||
|
|
||||||
|
|
||||||
|
## Create list of lang [Languages]
|
||||||
|
if sys.argv[1] == 'msg':
|
||||||
|
msg_list = []
|
||||||
|
for po in po_inno_array:
|
||||||
|
# Change po
|
||||||
|
po = po.replace('\\', '').replace('//', '').replace('..', '').replace('po-windows-installer', '')
|
||||||
|
# Change isl
|
||||||
|
inno_code = None
|
||||||
|
for entry in root.findall('.//iso_639_entry'):
|
||||||
|
if entry.get('dl_code') == po:
|
||||||
|
inno_code = entry.get('inno_code').replace('\\\\', '\\')
|
||||||
|
break
|
||||||
|
# Create line
|
||||||
|
if inno_code is not None:
|
||||||
|
msg_line = f'Name: "{po}"; MessagesFile: "compiler:{inno_code},{{#ASSETS_DIR}}\\lang\\{po}.setup.isl"'
|
||||||
|
msg_list.append(msg_line)
|
||||||
|
output_file = os.path.join(MESON_BUILD_ROOT, 'build/windows/installer/base_po-msg.list')
|
||||||
|
with open(output_file, 'w', encoding='utf-8') as f:
|
||||||
|
f.write('\n'.join(msg_list))
|
||||||
|
|
||||||
|
## Create list of lang [Components]
|
||||||
|
elif sys.argv[1] == 'cmp':
|
||||||
|
cmp_list = []
|
||||||
|
for po in po_array:
|
||||||
|
# Change po
|
||||||
|
po = po.replace('\\', '').replace('//', '').replace('..', '').replace('po', '')
|
||||||
|
po_clean = po.replace('@', '_')
|
||||||
|
# Change desc
|
||||||
|
desc = None
|
||||||
|
for entry in root.findall('.//iso_639_entry'):
|
||||||
|
if entry.get('dl_code') == po:
|
||||||
|
desc = entry.get('name')
|
||||||
|
break
|
||||||
|
# Create line
|
||||||
|
if desc is not None:
|
||||||
|
cmp_line = f'Name: loc\\{po_clean}; Description: "{desc}"; Types: full custom'
|
||||||
|
cmp_list.append(cmp_line)
|
||||||
|
output_file = os.path.join(MESON_BUILD_ROOT, 'build/windows/installer/base_po-cmp.list')
|
||||||
|
with open(output_file, 'w', encoding='utf-8') as f:
|
||||||
|
f.write('\n'.join(cmp_list))
|
||||||
|
|
||||||
|
## Create list of lang [Files]
|
||||||
|
elif sys.argv[1] == 'files':
|
||||||
|
files_list = []
|
||||||
|
for po in po_array:
|
||||||
|
# Change po
|
||||||
|
po = po.replace('\\', '').replace('//', '').replace('..', '').replace('po', '')
|
||||||
|
po_clean = po.replace('@', '_')
|
||||||
|
# Create line
|
||||||
|
files_line = f'Source: "{{#GIMP_DIR32}}\\share\\locale\\{po}\\*"; DestDir: "{{app}}\\share\\locale\\{po}"; Components: loc\\{po_clean}; Flags: recursesubdirs restartreplace uninsrestartdelete ignoreversion'
|
||||||
|
files_list.append(files_line)
|
||||||
|
output_file = os.path.join(MESON_BUILD_ROOT, 'build/windows/installer/base_po-files.list')
|
||||||
|
with open(output_file, 'w') as f:
|
||||||
|
f.write('\n'.join(files_list))
|
|
@ -1,85 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
BUILD_ROOT="`pwd`"
|
|
||||||
SOURCE_ROOT="$2"
|
|
||||||
|
|
||||||
if [ "$1" = 'cmp' ]; then
|
|
||||||
cd "$SOURCE_ROOT"
|
|
||||||
## Get list of GIMP supported languages
|
|
||||||
PO_ARRAY=($(echo $(ls po/*.po |
|
|
||||||
sed -e 's|po/||g' -e 's|.po||g' | sort) |
|
|
||||||
tr '\n\r' ' '))
|
|
||||||
|
|
||||||
## Create list of lang [Components]
|
|
||||||
for PO in "${PO_ARRAY[@]}"; do
|
|
||||||
CMP_LINE='Name: loc\PO_CLEAN; Description: "DESC"; Types: full custom'
|
|
||||||
# Change po
|
|
||||||
PO_CLEAN=$(echo $PO | sed "s/@/_/g")
|
|
||||||
CMP_LINE=$(sed "s/PO_CLEAN/$PO_CLEAN/g" <<< $CMP_LINE)
|
|
||||||
# Change desc
|
|
||||||
DESC=$(echo "cat //iso_639_entries/iso_639_entry[@dl_code=\"$PO\"]/@name" |
|
|
||||||
xmllint --shell build/windows/installer/lang/iso_639_custom.xml |
|
|
||||||
awk -F'[="]' '!/>/{print $(NF-1)}')
|
|
||||||
CMP_LINE=$(sed "s/DESC/$DESC/g" <<< $CMP_LINE)
|
|
||||||
# Create line
|
|
||||||
NL=$'\n'
|
|
||||||
CMP_LIST+="${CMP_LINE}${NL}"
|
|
||||||
done
|
|
||||||
cd "$BUILD_ROOT"
|
|
||||||
echo "$CMP_LIST" > build/windows/installer/base_po-cmp.list
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$1" = 'files' ]; then
|
|
||||||
cd "$SOURCE_ROOT"
|
|
||||||
## Get list of GIMP supported languages
|
|
||||||
PO_ARRAY=($(echo $(ls po/*.po |
|
|
||||||
sed -e 's|po/||g' -e 's|.po||g' | sort) |
|
|
||||||
tr '\n\r' ' '))
|
|
||||||
|
|
||||||
## Create list of lang [Files]
|
|
||||||
for PO in "${PO_ARRAY[@]}"; do
|
|
||||||
FILES_LINE='Source: "{#GIMP_DIR32}\share\locale\PO\*"; DestDir: "{app}\share\locale\PO"; Components: loc\PO_CLEAN; Flags: recursesubdirs restartreplace uninsrestartdelete ignoreversion'
|
|
||||||
# Change po
|
|
||||||
PO_CLEAN=$(echo $PO | sed "s/@/_/g")
|
|
||||||
FILES_LINE=$(sed "s/PO_CLEAN/$PO_CLEAN/g" <<< $FILES_LINE)
|
|
||||||
FILES_LINE=$(sed "s/PO/$PO/g" <<< $FILES_LINE)
|
|
||||||
# Create line
|
|
||||||
NL=$'\n'
|
|
||||||
FILES_LIST+="${FILES_LINE}${NL}"
|
|
||||||
done
|
|
||||||
cd "$BUILD_ROOT"
|
|
||||||
echo "$FILES_LIST" > build/windows/installer/base_po-files.list
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$1" = 'msg' ]; then
|
|
||||||
## Get list of Inno supported languages
|
|
||||||
cd "$SOURCE_ROOT"
|
|
||||||
PO_INNO_ARRAY=($(echo $(ls po-windows-installer/*.po |
|
|
||||||
sed -e 's|po-windows-installer/||g' -e 's|.po||g' | sort) |
|
|
||||||
tr '\n\r' ' '))
|
|
||||||
cd "$BUILD_ROOT"
|
|
||||||
|
|
||||||
## Create list of lang [Languages]
|
|
||||||
if [ "$1" = 'msg' ]; then
|
|
||||||
cd "$SOURCE_ROOT"
|
|
||||||
for PO in "${PO_INNO_ARRAY[@]}"; do
|
|
||||||
MSG_LINE='Name: "PO"; MessagesFile: "compiler:INNO_CODE,{#ASSETS_DIR}\lang\PO.setup.isl"'
|
|
||||||
# Change po
|
|
||||||
MSG_LINE=$(sed "s/PO/$PO/g" <<< $MSG_LINE)
|
|
||||||
# Change isl
|
|
||||||
INNO_CODE=$(echo "cat //iso_639_entries/iso_639_entry[@dl_code=\"$PO\"]/@inno_code" |
|
|
||||||
xmllint --shell build/windows/installer/lang/iso_639_custom.xml |
|
|
||||||
awk -F'[="]' '!/>/{print $(NF-1)}')
|
|
||||||
MSG_LINE=$(sed "s/INNO_CODE/$INNO_CODE/g" <<< $MSG_LINE)
|
|
||||||
# Create line
|
|
||||||
if [ "$INNO_CODE" != '' ]; then
|
|
||||||
NL=$'\n'
|
|
||||||
MSG_LIST+="${MSG_LINE}${NL}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
cd "$BUILD_ROOT"
|
|
||||||
echo "$MSG_LIST" > build/windows/installer/base_po-msg.list
|
|
||||||
fi
|
|
||||||
fi
|
|
|
@ -105,7 +105,16 @@ foreach language : languages
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
# Generate lang lists for Inno
|
# Generate lang lists for Inno
|
||||||
gen_list = find_program('list-installer-langs.sh')
|
gen_list = find_program('list-installer-langs.py')
|
||||||
|
|
||||||
|
custom_target('base_po-msg',
|
||||||
|
input : [ 'iso_639_custom.xml' ],
|
||||||
|
output: [ 'base_po-msg.list', ],
|
||||||
|
command: [
|
||||||
|
gen_list, 'msg', '@SOURCE_ROOT@'
|
||||||
|
],
|
||||||
|
build_by_default: true,
|
||||||
|
)
|
||||||
|
|
||||||
custom_target('base_po-cmp',
|
custom_target('base_po-cmp',
|
||||||
input : [ 'iso_639_custom.xml' ],
|
input : [ 'iso_639_custom.xml' ],
|
||||||
|
@ -125,15 +134,6 @@ custom_target('base_po-files',
|
||||||
build_by_default: true,
|
build_by_default: true,
|
||||||
)
|
)
|
||||||
|
|
||||||
custom_target('base_po-msg',
|
|
||||||
input : [ 'iso_639_custom.xml' ],
|
|
||||||
output: [ 'base_po-msg.list', ],
|
|
||||||
command: [
|
|
||||||
gen_list, 'msg', '@SOURCE_ROOT@'
|
|
||||||
],
|
|
||||||
build_by_default: true,
|
|
||||||
)
|
|
||||||
|
|
||||||
test('windows-installer-langs',
|
test('windows-installer-langs',
|
||||||
find_program('test-installer-langs.sh'),
|
find_program('test-installer-langs.sh'),
|
||||||
env: [
|
env: [
|
||||||
|
|
Loading…
Reference in New Issue