Move guarded objetc allocation to a guardedalloc header
[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\t/' | sort -d`
42 headers=`find ./libmv -type f -iname '*.h' | sed -r 's/^\.\//\t\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\t/' | sort -d`
45 third_headers=`find ./third_party -type f -iname '*.h' | grep -v glog | grep -v ceres | sed -r 's/^\.\//\t\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\t/' | sort -d`
48 third_glog_headers=`find ./third_party -type f -iname '*.h' | grep glog | grep -v windows | sed -r 's/^\.\//\t\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\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\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 )
128
129 set(SRC
130         libmv-capi.h
131 )
132
133 if(WITH_LIBMV)
134         add_definitions(
135                 -DWITH_LIBMV
136                 -DWITH_LIBMV_GUARDED_ALLOC
137                 -DGOOGLE_GLOG_DLL_DECL=
138         )
139
140         list(APPEND INC
141                 third_party/ceres/include
142         )
143
144         set(INC_SYS
145                 ../Eigen3
146                 \${PNG_INCLUDE_DIR}
147                 \${ZLIB_INCLUDE_DIRS}
148         )
149
150         list(APPEND SRC
151                 libmv-capi.cc
152 ${sources}
153
154 ${third_sources}
155
156 ${headers}
157
158 ${third_headers}
159         )
160
161         if(WIN32)
162                 list(APPEND SRC
163                         third_party/glog/src/logging.cc
164                         third_party/glog/src/raw_logging.cc
165                         third_party/glog/src/utilities.cc
166                         third_party/glog/src/vlog_is_on.cc
167                         third_party/glog/src/windows/port.cc
168
169                         third_party/glog/src/utilities.h
170                         third_party/glog/src/stacktrace_generic-inl.h
171                         third_party/glog/src/stacktrace.h
172                         third_party/glog/src/stacktrace_x86_64-inl.h
173                         third_party/glog/src/base/googleinit.h
174                         third_party/glog/src/base/mutex.h
175                         third_party/glog/src/base/commandlineflags.h
176                         third_party/glog/src/stacktrace_powerpc-inl.h
177                         third_party/glog/src/stacktrace_x86-inl.h
178                         third_party/glog/src/config.h
179                         third_party/glog/src/stacktrace_libunwind-inl.h
180                         third_party/glog/src/windows/glog/raw_logging.h
181                         third_party/glog/src/windows/glog/vlog_is_on.h
182                         third_party/glog/src/windows/glog/logging.h
183                         third_party/glog/src/windows/glog/log_severity.h
184                         third_party/glog/src/windows/port.h
185                         third_party/glog/src/windows/config.h
186                 )
187
188                 list(APPEND INC
189                         third_party/glog/src/windows
190                 )
191
192                 if(NOT MINGW)
193                         list(APPEND INC
194                                 third_party/msinttypes
195                         )
196                 endif()
197         else()
198                 list(APPEND SRC
199 ${third_glog_sources}
200
201 ${third_glog_headers}
202                 )
203
204                 list(APPEND INC
205                         third_party/glog/src
206                 )
207         endif()
208 else()
209         list(APPEND SRC
210                 libmv-capi_stub.cc
211         )
212 endif()
213
214 blender_add_lib(extern_libmv "\${SRC}" "\${INC}" "\${INC_SYS}")
215
216 if(WITH_LIBMV)
217         add_subdirectory(third_party)
218 endif()
219 EOF
220
221 cat > SConscript << EOF
222 #!/usr/bin/python
223
224 # NOTE: This file is automatically generated by bundle.sh script
225 #       If you're doing changes in this file, please update template
226 #       in that script too
227
228 import sys
229 import os
230
231 Import('env')
232
233 defs = []
234 incs = '.'
235
236 if env['WITH_BF_LIBMV']:
237     defs.append('GOOGLE_GLOG_DLL_DECL=')
238     defs.append('WITH_LIBMV')
239     defs.append('WITH_LIBMV_GUARDED_ALLOC')
240
241     src = env.Glob("libmv-capi.cc")
242 $src
243
244     incs += ' ../Eigen3 third_party/ceres/include ../../intern/guardedalloc'
245     incs += ' ' + env['BF_PNG_INC']
246     incs += ' ' + env['BF_ZLIB_INC']
247
248     if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
249         incs += ' ./third_party/glog/src/windows ./third_party/glog/src/windows/glog'
250         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
251             incs += ' ./third_party/msinttypes'
252 ${win_src}
253         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']
254         src += ['./third_party/glog/src/windows/port.cc']
255     else:
256         src += env.Glob("third_party/glog/src/*.cc")
257         incs += ' ./third_party/glog/src'
258 else:
259     src = env.Glob("libmv-capi_stub.cc")
260
261 env.BlenderLib ( libname = 'extern_libmv', sources=src, includes=Split(incs), defines=defs, libtype=['extern', 'player'], priority=[20,137] )
262
263 if env['WITH_BF_LIBMV']:
264     SConscript(['third_party/SConscript'])
265 EOF