Fix for BA possible move bundles behind the camera
[blender.git] / extern / 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="keir"
11 #BRANCH="Matthias-Fauconneau"
12 BRANCH="Nazg-Gul"
13
14 repo="git://github.com/${BRANCH}/libmv.git"
15 tmp=`mktemp -d`
16
17 git clone $repo $tmp/libmv
18
19 #git --git-dir $tmp/libmv/.git --work-tree $tmp/libmv log --since="1 month ago" > ChangeLog
20 git --git-dir $tmp/libmv/.git --work-tree $tmp/libmv log -n 50 > ChangeLog
21
22 for p in `cat ./patches/series`; do
23   echo "Applying patch $p..."
24   cat ./patches/$p | patch -d $tmp/libmv -p1
25 done
26
27 find libmv -type f -not -iwholename '*.svn*' -exec rm -rf {} \;
28 find third_party -type f -not -iwholename '*.svn*' -not -iwholename '*third_party/ceres*' \
29     -not -iwholename '*third_party/SConscript*' -not -iwholename '*third_party/CMakeLists.txt*' \
30     -exec rm -rf {} \;
31
32 cat "files.txt" | while read f; do
33   mkdir -p `dirname $f`
34   cp $tmp/libmv/src/$f $f
35 done
36
37 rm -rf $tmp
38
39 chmod 664 ./third_party/glog/src/windows/*.cc ./third_party/glog/src/windows/*.h ./third_party/glog/src/windows/glog/*.h
40
41 sources=`find ./libmv -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | sed -r 's/^\.\//\t/' | sort -d`
42 headers=`find ./libmv -type f -iname '*.h' | sed -r 's/^\.\//\t/' | sort -d`
43
44 third_sources=`find ./third_party -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | grep -v glog | grep -v ceres | sed -r 's/^\.\//\t/' | sort -d`
45 third_headers=`find ./third_party -type f -iname '*.h' | grep -v glog | grep -v ceres | sed -r 's/^\.\//\t/' | sort -d`
46
47 third_glog_sources=`find ./third_party -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | grep glog | grep -v windows | sed -r 's/^\.\//\t\t/' | sort -d`
48 third_glog_headers=`find ./third_party -type f -iname '*.h' | grep glog | grep -v windows | sed -r 's/^\.\//\t\t/' | sort -d`
49
50 src_dir=`find ./libmv -type f -iname '*.cc' -exec dirname {} \; -or -iname '*.cpp' -exec dirname {} \; -or -iname '*.c' -exec dirname {} \; | sed -r 's/^\.\//\t/' | sort -d | uniq`
51 src_third_dir=`find ./third_party -type f -iname '*.cc' -exec dirname {} \; -or -iname '*.cpp' -exec dirname {} \; -or -iname '*.c' -exec dirname {} \;  | grep -v ceres | sed -r 's/^\.\//\t/'  | sort -d | uniq`
52 src=""
53 win_src=""
54 for x in $src_dir $src_third_dir; do
55   t=""
56
57   if test  `echo "$x" | grep -c glog ` -eq 1; then
58     continue;
59   fi
60
61   if stat $x/*.cpp > /dev/null 2>&1; then
62     t="src += env.Glob('`echo $x'/*.cpp'`')"
63   fi
64
65   if stat $x/*.c > /dev/null 2>&1; then
66     if [ -z "$t" ]; then
67       t="src += env.Glob('`echo $x'/*.c'`')"
68     else
69       t="$t + env.Glob('`echo $x'/*.c'`')"
70     fi
71   fi
72
73   if stat $x/*.cc > /dev/null 2>&1; then
74     if [ -z "$t" ]; then
75       t="src += env.Glob('`echo $x'/*.cc'`')"
76     else
77       t="$t + env.Glob('`echo $x'/*.cc'`')"
78     fi
79   fi
80
81   if test `echo $x | grep -c windows ` -eq 0; then
82     if [ -z "$src" ]; then
83       src=$t
84     else
85       src=`echo "$src\n$t"`
86     fi
87   else
88     if [ -z "$win_src" ]; then
89       win_src=`echo "    $t"`
90     else
91       win_src=`echo "$win_src\n    $t"`
92     fi
93   fi
94 done
95
96 cat > CMakeLists.txt << EOF
97 # ***** BEGIN GPL LICENSE BLOCK *****
98 #
99 # This program is free software; you can redistribute it and/or
100 # modify it under the terms of the GNU General Public License
101 # as published by the Free Software Foundation; either version 2
102 # of the License, or (at your option) any later version.
103 #
104 # This program is distributed in the hope that it will be useful,
105 # but WITHOUT ANY WARRANTY; without even the implied warranty of
106 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
107 # GNU General Public License for more details.
108 #
109 # You should have received a copy of the GNU General Public License
110 # along with this program; if not, write to the Free Software Foundation,
111 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
112 #
113 # The Original Code is Copyright (C) 2011, Blender Foundation
114 # All rights reserved.
115 #
116 # Contributor(s): Blender Foundation,
117 #                 Sergey Sharybin
118 #
119 # ***** END GPL LICENSE BLOCK *****
120
121 # NOTE: This file is automatically generated by bundle.sh script
122 #       If you're doing changes in this file, please update template
123 #       in that script too
124
125 set(INC
126         .
127         third_party/ceres/include
128 )
129
130 set(INC_SYS
131         ../Eigen3
132         \${PNG_INCLUDE_DIR}
133         \${ZLIB_INCLUDE_DIRS}
134 )
135
136 set(SRC
137         libmv-capi.cpp
138 ${sources}
139
140 ${third_sources}
141
142         libmv-capi.h
143 ${headers}
144
145 ${third_headers}
146 )
147
148 if(WIN32)
149         list(APPEND SRC
150                 third_party/glog/src/logging.cc
151                 third_party/glog/src/raw_logging.cc
152                 third_party/glog/src/utilities.cc
153                 third_party/glog/src/vlog_is_on.cc
154                 third_party/glog/src/windows/port.cc
155
156                 third_party/glog/src/utilities.h
157                 third_party/glog/src/stacktrace_generic-inl.h
158                 third_party/glog/src/stacktrace.h
159                 third_party/glog/src/stacktrace_x86_64-inl.h
160                 third_party/glog/src/base/googleinit.h
161                 third_party/glog/src/base/mutex.h
162                 third_party/glog/src/base/commandlineflags.h
163                 third_party/glog/src/stacktrace_powerpc-inl.h
164                 third_party/glog/src/stacktrace_x86-inl.h
165                 third_party/glog/src/config.h
166                 third_party/glog/src/stacktrace_libunwind-inl.h
167                 third_party/glog/src/windows/glog/raw_logging.h
168                 third_party/glog/src/windows/glog/vlog_is_on.h
169                 third_party/glog/src/windows/glog/logging.h
170                 third_party/glog/src/windows/glog/log_severity.h
171                 third_party/glog/src/windows/port.h
172                 third_party/glog/src/windows/config.h
173         )
174
175         list(APPEND INC
176                 third_party/glog/src/windows
177         )
178
179         if(NOT MINGW)
180                 list(APPEND INC
181                         third_party/msinttypes
182                 )
183         endif()
184 else()
185         list(APPEND SRC
186 ${third_glog_sources}
187
188 ${third_glog_headers}
189         )
190
191         list(APPEND INC
192                 third_party/glog/src
193         )
194 endif()
195
196 add_definitions(
197         -DGOOGLE_GLOG_DLL_DECL=
198 )
199
200 blender_add_lib(extern_libmv "\${SRC}" "\${INC}" "\${INC_SYS}")
201
202 add_subdirectory(third_party)
203 EOF
204
205 cat > SConscript << EOF
206 #!/usr/bin/python
207
208 # NOTE: This file is automatically generated by bundle.sh script
209 #       If you're doing changes in this file, please update template
210 #       in that script too
211
212 import sys
213 import os
214
215 Import('env')
216
217 defs = []
218
219 defs.append('GOOGLE_GLOG_DLL_DECL=')
220
221 src = env.Glob("*.cpp")
222 $src
223
224 incs = '. ../Eigen3 third_party/ceres/include'
225 incs += ' ' + env['BF_PNG_INC']
226 incs += ' ' + env['BF_ZLIB_INC']
227
228 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
229     incs += ' ./third_party/glog/src/windows ./third_party/glog/src/windows/glog'
230     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
231         incs += ' ./third_party/msinttypes'
232 ${win_src}
233     src += ['./third_party/glog/src/logging.cc', './third_party/glog/src/raw_logging.cc', './third_party/glog/src/utilities.cc', './third_party/glog/src/vlog_is_on.cc']
234     src += ['./third_party/glog/src/windows/port.cc']
235 else:
236     src += env.Glob("third_party/glog/src/*.cc")
237     incs += ' ./third_party/glog/src'
238
239 env.BlenderLib ( libname = 'extern_libmv', sources=src, includes=Split(incs), defines=defs, libtype=['extern', 'player'], priority=[20,137] )
240
241 SConscript(['third_party/SConscript'])
242 EOF