Skip to content

Commit

Permalink
Added all-cultures command to build localization binaries. Fixed the …
Browse files Browse the repository at this point in the history
…problem with zero error code when error occurs
  • Loading branch information
evpo committed Aug 7, 2016
1 parent d75dfef commit 89615d7
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
all:: back_end cli
$(MAKE) -f Makefile.qt_ui RELEASE=$(RELEASE) USE_SYSTEM_LIBS=$(USE_SYSTEM_LIBS)
$(MAKE) -f Makefile.qt_ui RELEASE=$(RELEASE) USE_SYSTEM_LIBS=$(USE_SYSTEM_LIBS) LOCALIZATION=$(LOCALIZATION)
back_end::
$(MAKE) -f Makefile.back_end RELEASE=$(RELEASE) USE_SYSTEM_LIBS=$(USE_SYSTEM_LIBS)
cli:
Expand Down
4 changes: 4 additions & 0 deletions build/Makefile.qt_ui
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ ifeq ($(USE_SYSTEM_LIBS),on)
QMAKE_CONFIG += USE_SYSTEM_LIBS
endif

ifeq ($(LOCALIZATION),on)
QMAKE_CONFIG += LOCALIZATION
endif

all:: x_make

x_qmake::
Expand Down
27 changes: 24 additions & 3 deletions configure.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
set -e
set -o pipefail

USAGE="USAGE:\n\
configure.sh <command> [option]\n\n\
Expand All @@ -13,6 +15,7 @@ COMMANDS:\n\
-t, --run-tests run the unit tests\n\
-f, --run-func-tests run functional tests\n\
-n, --clean-tests clean the unit tests\n\
--all-cultures the same as all but builds binaries for all cultures\n\
-h, --help help\n\n\
OPTIONS:\n\
--debug debug configuration. If not specified, the release configuration is used. The unit tests\n\
Expand Down Expand Up @@ -70,17 +73,35 @@ then
CONFIG_DIR=debug
fi

case $COMMAND in
-a|--all)
function build_all {
if [[ ! "$USE_SYSTEM_LIBS" == "on" ]]
then
$MAKE -f Makefile.botan
fi
$MAKE -f Makefile RELEASE=$RELEASE USE_SYSTEM_LIBS=$USE_SYSTEM_LIBS
$MAKE -f Makefile RELEASE=$RELEASE USE_SYSTEM_LIBS=$USE_SYSTEM_LIBS LOCALIZATION=$LOCALIZATION
if [[ $SUBDIR == *MACOS* ]]
then
cd ../macos_deployment && ./prepare_bundle.sh ../bin/${CONFIG_DIR}/${TARGET}.app
fi
}

case $COMMAND in
-a|--all)
build_all
;;
--all-cultures)
LOCALIZATION=on
mkdir -p qt_build
for TSFILE in ../qt_ui/*.ts
do
CULTUREFILE=$(echo -n "$TSFILE" | sed -n -e "s/..\/qt_ui\///" -e "s/\.ts$//p")
lrelease $TSFILE -qm ./qt_build/${CULTUREFILE}.qm
echo "const char *kCultureFile=\"${CULTUREFILE}.qm\";" > ./qt_build/culture_name.h
cp ../qt_ui/${CULTUREFILE}.qrc ./qt_build/culture.qrc
build_all
mkdir -p ../bin/${CONFIG_DIR}/${CULTUREFILE}/
mv ../bin/${CONFIG_DIR}/${TARGET} ../bin/${CONFIG_DIR}/${CULTUREFILE}/
done
;;
-c|--clean)
$MAKE -f Makefile.qt_ui clean RELEASE=$RELEASE
Expand Down
8 changes: 8 additions & 0 deletions qt_ui/EncryptPad.pro
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ HEADERS += \
RESOURCES += \
EncryptPad.qrc

LOCALIZATION {
RESOURCES += \
culture.qrc
HEADERS += \
culture_name.h
QMAKE_CXXFLAGS += -DLOCALIZATION
}

TRANSLATIONS = \
encryptpad_en_gb.ts \
encryptpad_ru_ru.ts \
Expand Down
1 change: 0 additions & 1 deletion qt_ui/EncryptPad.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@
<file>../images/famfamfam/user_suit.png</file>
<file>../images/famfamfam/page_white_text.png</file>
<file>../images/famfamfam/page_white_key.png</file>
<file>encryptpad_ru_ru.qm</file>
</qresource>
</RCC>
5 changes: 5 additions & 0 deletions qt_ui/encryptpad_en_gb.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="cultures/">
<file>encryptpad_en_gb.qm</file>
</qresource>
</RCC>
5 changes: 5 additions & 0 deletions qt_ui/encryptpad_fr_fr.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="cultures/">
<file>encryptpad_fr_fr.qm</file>
</qresource>
</RCC>
5 changes: 5 additions & 0 deletions qt_ui/encryptpad_ru_ru.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="cultures/">
<file>encryptpad_ru_ru.qm</file>
</qresource>
</RCC>
2 changes: 1 addition & 1 deletion qt_ui/encryptpad_ru_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ Do you want to disable it?</oldsource>
<message>
<location filename="mainwindow.cpp" line="690"/>
<source>&amp;Close and Reset</source>
<translation type="unfinished">&amp;Закрыть и сбросить</translation>
<translation type="unfinished">&amp;Закрыть и Сбросить</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="692"/>
Expand Down
12 changes: 9 additions & 3 deletions qt_ui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@
#include "mainwindow.h"
#include "application.h"


#ifdef LOCALIZATION
#include "culture_name.h"
#endif

int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(EncryptPad);

Application app(argc, argv);
//QTextCodec::setCodecForTr(QTextCodec::codecForName("Unicode"));
QResource translator_res(":/encryptpad_ru_ru.qm");

#ifdef LOCALIZATION
QString culture(":/cultures/");
culture += kCultureFile;
QResource translator_res(culture);

QTranslator translator;
translator.load(translator_res.data(), translator_res.size());

app.installTranslator(&translator);
#endif

app.setOrganizationName("Evpo"); //
app.setApplicationName("EncryptPad");
Expand Down

0 comments on commit 89615d7

Please sign in to comment.