| 
									
										
										
										
											2019-05-31 15:48:51 +08:00
										 |  |  | #!/bin/bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-12 12:23:40 +08:00
										 |  |  | # common tasks before either build or test | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  | function configure() | 
					
						
							| 
									
										
										
										
											2019-06-12 12:23:40 +08:00
										 |  |  | { | 
					
						
							|  |  |  |   set -e   # Make sure any error makes the script to return an error code | 
					
						
							|  |  |  |   set -x   # echo | 
					
						
							| 
									
										
										
										
											2019-05-31 15:48:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-12 12:23:40 +08:00
										 |  |  |   SOURCE_DIR=`pwd` | 
					
						
							|  |  |  |   BUILD_DIR=build | 
					
						
							| 
									
										
										
										
											2019-05-31 15:48:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   #env | 
					
						
							|  |  |  |   git clean -fd || true | 
					
						
							|  |  |  |   rm -fr $BUILD_DIR || true | 
					
						
							|  |  |  |   mkdir $BUILD_DIR && cd $BUILD_DIR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if [ ! -z "$GCC_VERSION" ]; then | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  |     export CC=gcc-$GCC_VERSION | 
					
						
							|  |  |  |     export CXX=g++-$GCC_VERSION | 
					
						
							| 
									
										
										
										
											2019-05-31 15:48:51 +08:00
										 |  |  |   fi | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # GTSAM_BUILD_WITH_MARCH_NATIVE=OFF: to avoid crashes in builder VMs | 
					
						
							|  |  |  |   cmake $SOURCE_DIR \
 | 
					
						
							|  |  |  |       -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \
 | 
					
						
							|  |  |  |       -DGTSAM_BUILD_TESTS=${GTSAM_BUILD_TESTS:-OFF} \
 | 
					
						
							|  |  |  |       -DGTSAM_BUILD_UNSTABLE=${GTSAM_BUILD_UNSTABLE:-ON} \
 | 
					
						
							| 
									
										
										
										
											2019-12-24 01:21:34 +08:00
										 |  |  |       -DGTSAM_USE_QUATERNIONS=${GTSAM_USE_QUATERNIONS:-OFF} \
 | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  |       -DGTSAM_BUILD_EXAMPLES_ALWAYS=${GTSAM_BUILD_EXAMPLES_ALWAYS:-ON} \
 | 
					
						
							|  |  |  |       -DGTSAM_ALLOW_DEPRECATED_SINCE_V4=${GTSAM_ALLOW_DEPRECATED_SINCE_V4:-OFF} \
 | 
					
						
							|  |  |  |       -DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF \
 | 
					
						
							|  |  |  |       -DCMAKE_VERBOSE_MAKEFILE=ON | 
					
						
							| 
									
										
										
										
											2019-06-12 12:23:40 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-12 12:23:40 +08:00
										 |  |  | # common tasks after either build or test | 
					
						
							|  |  |  | function finish () | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   # Print ccache stats | 
					
						
							|  |  |  |   ccache -s | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   cd $SOURCE_DIR | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # compile the code with the intent of populating the cache | 
					
						
							|  |  |  | function build () | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  |   export GTSAM_BUILD_EXAMPLES_ALWAYS=ON | 
					
						
							|  |  |  |   export GTSAM_BUILD_TESTS=OFF | 
					
						
							| 
									
										
										
										
											2019-05-31 15:48:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  |   configure | 
					
						
							| 
									
										
										
										
											2019-05-31 15:48:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  |   make -j2 | 
					
						
							| 
									
										
										
										
											2019-05-31 15:48:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-12 12:23:40 +08:00
										 |  |  |   finish | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-05-31 15:48:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-12 12:23:40 +08:00
										 |  |  | # run the tests | 
					
						
							|  |  |  | function test () | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  |   export GTSAM_BUILD_EXAMPLES_ALWAYS=OFF | 
					
						
							|  |  |  |   export GTSAM_BUILD_TESTS=ON | 
					
						
							| 
									
										
										
										
											2019-06-03 06:12:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  |   configure | 
					
						
							| 
									
										
										
										
											2019-06-12 12:23:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   # Actual build: | 
					
						
							|  |  |  |   make -j2 check | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   finish | 
					
						
							| 
									
										
										
										
											2019-05-31 15:48:51 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-12 12:23:40 +08:00
										 |  |  | # select between build or test | 
					
						
							|  |  |  | case $1 in | 
					
						
							|  |  |  |   -b) | 
					
						
							|  |  |  |     build | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2019-12-11 23:31:43 +08:00
										 |  |  |   -t) | 
					
						
							| 
									
										
										
										
											2019-06-12 12:23:40 +08:00
										 |  |  |     test | 
					
						
							|  |  |  |     ;; | 
					
						
							|  |  |  | esac |