From 97ca21d295edc6951cb46d3a09d5b7b117e9e188 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Fri, 1 Mar 2013 12:52:01 +0000 Subject: [PATCH] Update build system. Add ability to use complex directory structure of Handlebars templates in dialog styles. --- src/messenger/build.xml | 40 ++++++++++++++++++++++++++--- src/messenger/build_scripts/flat_cp | 39 ++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 3 deletions(-) create mode 100755 src/messenger/build_scripts/flat_cp diff --git a/src/messenger/build.xml b/src/messenger/build.xml index bd7a48ab..5c9ba8bc 100644 --- a/src/messenger/build.xml +++ b/src/messenger/build.xml @@ -29,16 +29,39 @@ - Compile Handlebars templates for dialogs styles + Flatten templates directory structure + + + + + + + + + + + + + + + + + + + + + + Compile templates - + - + + + Remove temporary files + + + + + + + + diff --git a/src/messenger/build_scripts/flat_cp b/src/messenger/build_scripts/flat_cp new file mode 100755 index 00000000..2e61b97f --- /dev/null +++ b/src/messenger/build_scripts/flat_cp @@ -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 \ No newline at end of file