3 # check if there is 'realpath' tool installed
4 if [ "$(which realpath)" == "" ] ; then
5 echo "You need 'realpath' to run this script."
6 echo "to install: apt-get install realpath"
10 # test whether script is running in the right directory
11 if [[ $(realpath $(pwd)) != $(realpath $(dirname $0)) ]] ; then
12 echo "Error! You must launch this script from tizen-cmake directory!"
16 function find_file_lists_dirs()
18 for f in $(find ../../ -name 'file.list') ; do
19 dirname $(realpath $f);
23 # now prepare file-lists
25 # 1. line with '=' defines variable name
26 # 2. line with '#' defines comment
27 function write_cmake_file_lists()
31 function update_list()
33 if [[ "$2" != "" ]] ; then
34 # update sources, headers, doxy
35 echo " *** Updating $1 list..." >&2
45 for file_list_dir in ${file_cmake_lists} ; do
50 outfile=$file_list_dir/file-list.cmake
51 echo " * Writing $(realpath --relative-base=../../ $file_list_dir)/file-list.cmake..."
52 echo "# This file is auto-generated!" > $outfile
55 # look for *_src_dir variables ( should be just one ) and
56 # substitute it with current path
57 for dirpath in $(grep -oE '\(.*_src_dir\)' $file_list_dir/file.list | sort -u) ; do
58 src_dir=${dirpath:1:-1}
59 new_path=$(realpath --relative-base=../../ $file_list_dir)
60 echo -e "\n# Set the source directory\n" >> $outfile
61 echo "SET( $src_dir \${ROOT_SRC_DIR}/$new_path )" >> $outfile
66 lines=$(cat $file_list_dir/file.list | sed -e 's/ /|/g;')
68 is_var=$(echo $l | grep '=')
69 is_comment=$(echo $l | grep '#')
70 if [ "$is_comment" ] ; then
71 comment="$(echo "$l" | sed -e 's/|/ /g;')"
72 elif [ "$is_var" ] ; then
73 if [ "$variable" ] ; then
77 echo $comment >> $outfile
79 variable=$(echo $is_var | sed -e 's/|//g;' | awk -F '=' '{print $1}')
80 echo "SET( $variable " >> $outfile
82 # collect sources, headers and doxy to compile final
83 # set of vars to be included
84 if [[ ${variable:${#variable}-9:9} = src_files ]] ; then
85 sources="${sources} $variable"
86 elif [[ ${variable:${#variable}-12:12} = header_files ]] ; then
87 if [[ ${variable} = devel_api* ]] ; then
88 devel_headers="${devel_headers} $variable"
89 elif [[ ${variable} = public_api* ]] ; then
90 public_headers="${public_headers} $variable"
91 elif [[ ${variable} = platform_abstraction_* ]] ; then
92 integration_headers="${integration_headers} $variable"
94 echo "ERROR! Variable $variable in $file_list_dir unrecoginzed!"
97 elif [[ ${variable:${#variable}-10:10} = doxy_files ]] ; then
98 doxy="${doxy} $variable"
101 echo "$(echo "$l" | sed -e 's/(/{/g;s/)/}/g;s/|/ /g;s/\\//g;')" >> $outfile
104 if [ "$variable" ] ; then
109 update_list SOURCES "$sources" >> $outfile
111 update_list PUBLIC_API_HEADERS "$public_headers" >>$outfile
113 update_list DEVEL_API_HEADERS "$devel_headers" >>$outfile
115 update_list INTEGRATION_API_HEADERS "$integration_headers" >>$outfile
117 # Remove trailing whitespaces
118 cat $outfile | sed -e 's/[[:space:]]*$//' > /tmp/file-list.cmake
119 mv /tmp/file-list.cmake $outfile
125 export file_cmake_lists=$(find_file_lists_dirs)
127 write_cmake_file_lists