mirror of
https://github.com/Mibew/i18n.git
synced 2025-01-22 13:30:29 +03:00
Update build system.
Add ability to use complex directory structure of Handlebars templates in dialog styles.
This commit is contained in:
parent
4b7614caec
commit
97ca21d295
@ -29,16 +29,39 @@
|
||||
|
||||
<!-- Compile Handlebars templates for dialogs styles -->
|
||||
<target name="styles_handlebars">
|
||||
<echo>Compile Handlebars templates for dialogs styles</echo>
|
||||
<echo>Flatten templates directory structure</echo>
|
||||
|
||||
<!-- Use system 'mkdir' instead of ant 'mkdir' task because it do not
|
||||
work with dirsets -->
|
||||
<apply executable="mkdir" addsourcefile="false">
|
||||
<targetfile />
|
||||
<dirset dir=".">
|
||||
<include name="${dialogs_styles_path}/*/handlebars_templates" />
|
||||
</dirset>
|
||||
<mapper type="glob" from="*/handlebars_templates" to="*/handlebars_templates_tmp" />
|
||||
</apply>
|
||||
|
||||
<!-- Flatten templates directory structure -->
|
||||
<apply executable="build_scripts/flat_cp" force="true">
|
||||
<srcfile />
|
||||
<targetfile />
|
||||
<arg value="handlebars_templates" />
|
||||
<fileset dir=".">
|
||||
<include name="${dialogs_styles_path}/*/handlebars_templates/**/*.handlebars" />
|
||||
</fileset>
|
||||
<mapper type="regexp" from="^(.*)/handlebars_templates/(.*)$$" to="\1/handlebars_templates_tmp" />
|
||||
</apply>
|
||||
|
||||
<echo>Compile templates</echo>
|
||||
|
||||
<!-- Compile templates -->
|
||||
<apply executable="${handlebars}">
|
||||
<arg value="-f"/>
|
||||
<targetfile />
|
||||
<dirset dir=".">
|
||||
<include name="${dialogs_styles_path}/*/handlebars_templates" />
|
||||
<include name="${dialogs_styles_path}/*/handlebars_templates_tmp" />
|
||||
</dirset>
|
||||
<mapper type="glob" from="*/handlebars_templates" to="*/js/compiled/templates_tmp.js" />
|
||||
<mapper type="glob" from="*/handlebars_templates_tmp" to="*/js/compiled/templates_tmp.js" />
|
||||
</apply>
|
||||
|
||||
<!-- Use closule compiler instead of handlebars minifyer (-m flag)
|
||||
@ -74,6 +97,17 @@
|
||||
</move>
|
||||
|
||||
<!-- Remove all temporary files -->
|
||||
<!-- Use system 'rm' instead of ant
|
||||
'delete' task because it do not work with dirsets -->
|
||||
<echo>Remove temporary files</echo>
|
||||
<apply executable="rm">
|
||||
<arg value="-r" />
|
||||
<arg value="-f" />
|
||||
<dirset dir=".">
|
||||
<include name="${dialogs_styles_path}/*/handlebars_templates_tmp" />
|
||||
</dirset>
|
||||
</apply>
|
||||
|
||||
<delete>
|
||||
<fileset dir=".">
|
||||
<include name="${dialogs_styles_path}/*/js/compiled/templates_tmp.js" />
|
||||
|
39
src/messenger/build_scripts/flat_cp
Executable file
39
src/messenger/build_scripts/flat_cp
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copy file and flatten its name by replace '/' by '_'. For more
|
||||
# details see examples below.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# flat_cp [from] [to_dir] [cut_from]
|
||||
# from - source file
|
||||
# to_dir - target file
|
||||
# cut_from - part of source file path. Only part after
|
||||
# cut_from will be used for target file name.
|
||||
#
|
||||
# Examples:
|
||||
# If execute the command:
|
||||
#
|
||||
# $ flat cp /home/user/application/templates/controls/radio \
|
||||
# /home/user/application/compiled_templates "templates"
|
||||
#
|
||||
# the file from '/home/user/application/templates/controls/radio'
|
||||
# will be copied to '/home/user/application/compiled_templates/controls_radio'
|
||||
#
|
||||
|
||||
source_file=$1
|
||||
cut_from=$(sed -r "s/\/+$//" <<< "$3")
|
||||
|
||||
if [ $cut_from ]
|
||||
then
|
||||
cut_from=$(sed -r "s/\//\\\\\//g" <<< "$cut_from")
|
||||
target_file_name=$(sed -r "s/^(.*)$cut_from\/(.*)$/\2/" <<< "$source_file")
|
||||
else
|
||||
target_file_name=$source_file
|
||||
fi
|
||||
|
||||
target_file_name=$(sed -r "s/\//_/g" <<< "$target_file_name")
|
||||
target_file=$(sed -r "s/\/?$//" <<< "$2")"/"$target_file_name
|
||||
|
||||
cp $source_file $target_file
|
Loading…
Reference in New Issue
Block a user