Libmv: Re-bundle from upstream to ensure code base is perfectly in sync
[blender.git] / intern / libmv / bundle.sh
1 #!/bin/sh
2
3 if [ "x$1" = "x--i-really-know-what-im-doing" ] ; then
4   echo Proceeding as requested by command line ...
5 else
6   echo "*** Please run again with --i-really-know-what-im-doing ..."
7   exit 1
8 fi
9
10 BRANCH="master"
11
12 repo="git://git.blender.org/libmv.git"
13 tmp=`mktemp -d`
14
15 git clone -b $BRANCH $repo $tmp/libmv
16
17 git --git-dir $tmp/libmv/.git --work-tree $tmp/libmv log -n 50 > ChangeLog
18
19 find libmv -type f -exec rm -rf {} \;
20 find third_party -type f -exec rm -rf {} \;
21
22 cat "files.txt" | while read f; do
23   mkdir -p `dirname $f`
24   cp $tmp/libmv/src/$f $f
25 done
26
27 rm -rf $tmp
28
29 sources=`find ./libmv -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | grep -v _test.cc | grep -v test_data_sets | sed -r 's/^\.\//\t\t/' | sort -d`
30 headers=`find ./libmv -type f -iname '*.h' | grep -v test_data_sets | sed -r 's/^\.\//\t\t/' | sort -d`
31
32 third_sources=`find ./third_party -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | sed -r 's/^\.\//\t\t/' | sort -d`
33 third_headers=`find ./third_party -type f -iname '*.h' | sed -r 's/^\.\//\t\t/' | sort -d`
34
35 tests=`find ./libmv -type f -iname '*_test.cc' | sort -d | awk ' { name=gensub(".*/([A-Za-z_]+)_test.cc", "\\\\1", $1); printf("\t\tBLENDER_SRC_GTEST(\"libmv_%s\" \"%s\" \"libmv_test_dataset;bf_intern_libmv;extern_ceres\")\n", name, $1) } '`
36
37 src_dir=`find ./libmv -type f -iname '*.cc' -exec dirname {} \; -or -iname '*.cpp' -exec dirname {} \; -or -iname '*.c' -exec dirname {} \; | sed -r 's/^\.\//\t\t/' | sort -d | uniq`
38 src_third_dir=`find ./third_party -type f -iname '*.cc' -exec dirname {} \; -or -iname '*.cpp' -exec dirname {} \; -or -iname '*.c' -exec dirname {} \;  | sed -r 's/^\.\//\t\t/'  | sort -d | uniq`
39 src=""
40 win_src=""
41 for x in $src_dir $src_third_dir; do
42   t=""
43
44   if stat $x/*.cpp > /dev/null 2>&1; then
45     t="    src += env.Glob('`echo $x'/*.cpp'`')"
46   fi
47
48   if stat $x/*.c > /dev/null 2>&1; then
49     if [ -z "$t" ]; then
50       t="    src += env.Glob('`echo $x'/*.c'`')"
51     else
52       t="$t + env.Glob('`echo $x'/*.c'`')"
53     fi
54   fi
55
56   if stat $x/*.cc > /dev/null 2>&1; then
57     if [ -z "$t" ]; then
58       t="    src += env.Glob('`echo $x'/*.cc'`')"
59     else
60       t="$t + env.Glob('`echo $x'/*.cc'`')"
61     fi
62   fi
63
64   if test `echo $x | grep -c "windows\|gflags" ` -eq 0; then
65     if [ -z "$src" ]; then
66       src=$t
67     else
68       src=`echo "$src\n$t"`
69     fi
70   else
71     if [ -z "$win_src" ]; then
72       win_src=`echo "    $t"`
73     else
74       win_src=`echo "$win_src\n    $t"`
75     fi
76   fi
77 done
78
79 cat > CMakeLists.txt << EOF
80 # ***** BEGIN GPL LICENSE BLOCK *****
81 #
82 # This program is free software; you can redistribute it and/or
83 # modify it under the terms of the GNU General Public License
84 # as published by the Free Software Foundation; either version 2
85 # of the License, or (at your option) any later version.
86 #
87 # This program is distributed in the hope that it will be useful,
88 # but WITHOUT ANY WARRANTY; without even the implied warranty of
89 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
90 # GNU General Public License for more details.
91 #
92 # You should have received a copy of the GNU General Public License
93 # along with this program; if not, write to the Free Software Foundation,
94 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
95 #
96 # The Original Code is Copyright (C) 2011, Blender Foundation
97 # All rights reserved.
98 #
99 # Contributor(s): Blender Foundation,
100 #                 Sergey Sharybin
101 #
102 # ***** END GPL LICENSE BLOCK *****
103
104 # NOTE: This file is automatically generated by bundle.sh script
105 #       If you're doing changes in this file, please update template
106 #       in that script too
107
108 set(INC
109         .
110 )
111
112 set(INC_SYS
113 )
114
115 set(SRC
116         libmv-capi.h
117 )
118
119 if(WITH_LIBMV)
120         add_definitions(\${GFLAGS_DEFINES})
121         add_definitions(\${GLOG_DEFINES})
122         add_definitions(\${CERES_DEFINES})
123         add_definitions(-DLIBMV_GFLAGS_NAMESPACE=\${GFLAGS_NAMESPACE})
124
125         list(APPEND INC
126                 \${GFLAGS_INCLUDE_DIRS}
127                 ../../extern/glog/src
128                 ../../extern/ceres/include
129                 ../../extern/ceres/config
130                 ../guardedalloc
131         )
132
133         list(APPEND INC_SYS
134                 \${EIGEN3_INCLUDE_DIRS}
135                 \${PNG_INCLUDE_DIRS}
136                 \${ZLIB_INCLUDE_DIRS}
137         )
138
139         add_definitions(
140                 -DWITH_LIBMV_GUARDED_ALLOC
141                 -DLIBMV_NO_FAST_DETECTOR=
142         )
143
144         list(APPEND SRC
145                 intern/autotrack.cc
146                 intern/camera_intrinsics.cc
147                 intern/detector.cc
148                 intern/frame_accessor.cc
149                 intern/homography.cc
150                 intern/image.cc
151                 intern/logging.cc
152                 intern/reconstruction.cc
153                 intern/track_region.cc
154                 intern/tracks.cc
155                 intern/tracksN.cc
156 ${sources}
157 ${third_sources}
158
159                 intern/autotrack.h
160                 intern/camera_intrinsics.h
161                 intern/detector.h
162                 intern/frame_accessor.h
163                 intern/homography.h
164                 intern/image.h
165                 intern/logging.h
166                 intern/reconstruction.h
167                 intern/track_region.h
168                 intern/tracks.h
169                 intern/tracksN.h
170 ${headers}
171
172 ${third_headers}
173         )
174
175
176         if(WITH_GTESTS)
177                 blender_add_lib(libmv_test_dataset "./libmv/multiview/test_data_sets.cc" "${INC}" "${INC_SYS}")
178
179 ${tests}
180         endif()
181 else()
182         list(APPEND SRC
183                 intern/stub.cc
184         )
185 endif()
186
187 blender_add_lib(bf_intern_libmv "\${SRC}" "\${INC}" "\${INC_SYS}")
188 EOF