Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update build script (fixing a couple of issues)
  • Loading branch information
martinruenz committed Mar 7, 2019
1 parent 209ec6f commit 1815d97
Show file tree
Hide file tree
Showing 5 changed files with 319 additions and 6 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Expand Up @@ -18,7 +18,6 @@ cmake_policy(SET CMP0009 NEW)

project(MaskFusion)

set(CUDA_HOST_COMPILER "/usr/bin/g++-4.9")
set(BUILD_TESTS OFF CACHE BOOL "Build unit tests")

# OpenMP
Expand Down
21 changes: 16 additions & 5 deletions build.sh
Expand Up @@ -37,6 +37,11 @@ function highlight(){
clr_magentab clr_bold clr_white "$1"
}

highlight "Starting MaskFusion build script ..."
echo "Available parameters:
--install-packages
--install-cuda
--build-dependencies"

if [[ $* == *--install-packages* ]] ; then
highlight "Installing system packages..."
Expand All @@ -46,6 +51,9 @@ if [[ $* == *--install-packages* ]] ; then
if [[ $DISTRIB_CODENAME == *"trusty"* ]] ; then
# g++ 4.9.4
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get install \
g++-4.9 \
gcc-4.9
# cmake 3.2.2
sudo add-apt-repository -y ppa:george-edison55/cmake-3.x
# openjdk 8
Expand All @@ -57,9 +65,9 @@ if [[ $* == *--install-packages* ]] ; then
build-essential \
cmake \
freeglut3-dev \
g++-4.9 \
gcc-4.9 \
git \
g++ \
gcc \
libeigen3-dev \
libglew-dev \
libjpeg-dev \
Expand All @@ -69,7 +77,9 @@ if [[ $* == *--install-packages* ]] ; then
openjdk-8-jdk \
unzip \
zlib1g-dev \
cython3
cython3 \
libboost-all-dev \
libfreetype6-dev

sudo -H pip3 install virtualenv

Expand Down Expand Up @@ -128,7 +138,7 @@ pip3 install h5py
pip3 install cython
pip3 install imgaug
pip3 install opencv-python
ln -s python-environment/lib/python3.5/site-packages/numpy/core/include/numpy Core/Segmentation/MaskRCNN
ln -s `python -c "import numpy as np; print(np.__path__[0])"`/core/include/numpy Core/Segmentation/MaskRCNN || true # Provide numpy headers to C++



Expand Down Expand Up @@ -256,7 +266,7 @@ if [[ $* == *--build-dependencies* ]] ; then
cmake \
-DOpenCV_DIR="${OpenCV_DIR}" \
-DCMAKE_BUILD_TYPE=Release \
-DCUDA_HOST_COMPILER=/usr/bin/gcc-4.9 \
-DCUDA_HOST_COMPILER=/usr/bin/gcc \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -D_FORCE_INLINES" \
..
make -j8
Expand Down Expand Up @@ -293,6 +303,7 @@ cmake \
-DOpenCV_DIR="$(pwd)/../deps/opencv/build" \
-DPangolin_DIR="$(pwd)/../deps/Pangolin/build/src" \
-DMASKFUSION_PYTHON_VE_PATH="$(pwd)/../python-environment" \
-DCUDA_HOST_COMPILER=/usr/bin/gcc \
-DWITH_FREENECT2=OFF \
..
make -j8
Expand Down
21 changes: 21 additions & 0 deletions deps/bashcolors/LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Max Tsepkov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
105 changes: 105 additions & 0 deletions deps/bashcolors/README.md
@@ -0,0 +1,105 @@
Bash colors
===========

The library defines verbal constants for ANSII color codes.
Now you can use words to tell bash what color you want to use for output.

Also, it defines functions to quickly output colored text.
As well as a function to display nice table of all colors.

Updated to allow for iterative output of colors by sequencing the color functions


Examples
--------

Print "foobar" with red foreground:
```sh
$ clr_red "foobar"
```

Print "foobar" with green background:
```sh
$ clr_greenb "foobar"
```

Print "foobar" with cyan foreground and bold font:
```sh
$ clr_bold clr_cyan "foobar"
```

Stack functions on a single output to produce complex color configurations:
```sh
$ clr_red clr_blueb clr_reverse clr_underscore "foobar"
```

Using the -n switch, the output can remain on a single line, allowing for changing colors across a line of text:
```sh
$ clr_redb clr_black "RED" -n; clr_blueb clr_black "BLUE" -n; clr_greenb clr_black "GREEN";
```

or Print "foobar" manually, using variables:
```sh
$ clr_escape "foobar" $CLR_BOLD $CLR_CYAN
```

or any other code:
```sh
$ clr_escape "foobar" 1 36
```


Quick start
------------

1. Download source
```sh
$ curl https://raw.githubusercontent.com/mercuriev/bash_colors/master/bash_colors.sh > .bash_colors
```

2. Load into your script
```sh
$ source .bash_colors
```


Variables
---------

**$CLR_***

Variables for each supported color code. E.g. $CLR_WHITE, $CLR_BLACK
Call **clr_dump** for full list.

**$CLR_ESC**
is a special variable for escape code (\033) followed by [ character.


Functions
---------

**clr_dump**
Output table of available colors, functions and variables.

**clr_*** _string_
Functions for each supported color. E.g. clr_white, clr_black
See **clr_dump** for list.

**fn_exists**
General bash function to check if string is a valid function

**clr_layer**
Recursive function allowing for muliple color functions in a sequence

**clr_escape** _string_ _$CLR_ ...
escape _string_ with given colors. Latest colors overwrites previous.

**clr_reset**
Reset formatting. Useful for custom usage of $CLR_* variable series.


See also
--------

console_codes(4)
[Advanced Bash Scripting Guide](http://tldp.org/LDP/abs/html/colorizing.html)
177 changes: 177 additions & 0 deletions deps/bashcolors/bash_colors.sh
@@ -0,0 +1,177 @@
#!/bin/bash
#
# Constants and functions for terminal colors.
# Author: Max Tsepkov <max@yogi.pw>

CLR_ESC="\033["

# All these variables has a function with the same name, but in lower case.
#
CLR_RESET=0 # reset all attributes to their defaults
CLR_RESET_UNDERLINE=24 # underline off
CLR_RESET_REVERSE=27 # reverse off
CLR_DEFAULT=39 # set underscore off, set default foreground color
CLR_DEFAULTB=49 # set default background color

CLR_BOLD=1 # set bold
CLR_BRIGHT=2 # set half-bright (simulated with color on a color display)
CLR_UNDERSCORE=4 # set underscore (simulated with color on a color display)
CLR_REVERSE=7 # set reverse video

CLR_BLACK=30 # set black foreground
CLR_RED=31 # set red foreground
CLR_GREEN=32 # set green foreground
CLR_BROWN=33 # set brown foreground
CLR_BLUE=34 # set blue foreground
CLR_MAGENTA=35 # set magenta foreground
CLR_CYAN=36 # set cyan foreground
CLR_WHITE=37 # set white foreground

CLR_BLACKB=40 # set black background
CLR_REDB=41 # set red background
CLR_GREENB=42 # set green background
CLR_BROWNB=43 # set brown background
CLR_BLUEB=44 # set blue background
CLR_MAGENTAB=45 # set magenta background
CLR_CYANB=46 # set cyan background
CLR_WHITEB=47 # set white background


# check if string exists as function
# usage: if fn_exists "sometext"; then ... fi
function fn_exists
{
type -t "$1" | grep -q 'function'
}

# iterate through command arguments, o allow for iterative color application
function clr_layer
{
# default echo setting
CLR_ECHOSWITCHES="-e"
CLR_STACK=""
CLR_SWITCHES=""
ARGS=("$@")

# iterate over arguments in reverse
for ((i=$#; i>=0; i--)); do
ARG=${ARGS[$i]}
# echo $ARG
# set CLR_VAR as last argtype
firstletter=${ARG:0:1}

# check if argument is a switch
if [ "$firstletter" = "-" ] ; then
# if -n is passed, set switch for echo in clr_escape
if [[ $ARG == *"n"* ]]; then
CLR_ECHOSWITCHES="-en"
CLR_SWITCHES=$ARG
fi
else
# last arg is the incoming string
if [ -z "$CLR_STACK" ]; then
CLR_STACK=$ARG
else
# if the argument is function, apply it
if [ -n "$ARG" ] && fn_exists $ARG; then
#continue to pass switches through recursion
CLR_STACK=$($ARG "$CLR_STACK" $CLR_SWITCHES)
fi
fi
fi
done

# pass stack and color var to escape function
clr_escape "$CLR_STACK" $1;
}

# General function to wrap string with escape sequence(s).
# Ex: clr_escape foobar $CLR_RED $CLR_BOLD
function clr_escape
{
local result="$1"
until [ -z "${2:-}" ]; do
if ! [ $2 -ge 0 -a $2 -le 47 ] 2>/dev/null; then
echo "clr_escape: argument \"$2\" is out of range" >&2 && return 1
fi
result="${CLR_ESC}${2}m${result}${CLR_ESC}${CLR_RESET}m"
shift || break
done

echo "$CLR_ECHOSWITCHES" "$result"
}

function clr_reset { clr_layer $CLR_RESET "$@"; }
function clr_reset_underline { clr_layer $CLR_RESET_UNDERLINE "$@"; }
function clr_reset_reverse { clr_layer $CLR_RESET_REVERSE "$@"; }
function clr_default { clr_layer $CLR_DEFAULT "$@"; }
function clr_defaultb { clr_layer $CLR_DEFAULTB "$@"; }
function clr_bold { clr_layer $CLR_BOLD "$@"; }
function clr_bright { clr_layer $CLR_BRIGHT "$@"; }
function clr_underscore { clr_layer $CLR_UNDERSCORE "$@"; }
function clr_reverse { clr_layer $CLR_REVERSE "$@"; }
function clr_black { clr_layer $CLR_BLACK "$@"; }
function clr_red { clr_layer $CLR_RED "$@"; }
function clr_green { clr_layer $CLR_GREEN "$@"; }
function clr_brown { clr_layer $CLR_BROWN "$@"; }
function clr_blue { clr_layer $CLR_BLUE "$@"; }
function clr_magenta { clr_layer $CLR_MAGENTA "$@"; }
function clr_cyan { clr_layer $CLR_CYAN "$@"; }
function clr_white { clr_layer $CLR_WHITE "$@"; }
function clr_blackb { clr_layer $CLR_BLACKB "$@"; }
function clr_redb { clr_layer $CLR_REDB "$@"; }
function clr_greenb { clr_layer $CLR_GREENB "$@"; }
function clr_brownb { clr_layer $CLR_BROWNB "$@"; }
function clr_blueb { clr_layer $CLR_BLUEB "$@"; }
function clr_magentab { clr_layer $CLR_MAGENTAB "$@"; }
function clr_cyanb { clr_layer $CLR_CYANB "$@"; }
function clr_whiteb { clr_layer $CLR_WHITEB "$@"; }

# Outputs colors table
function clr_dump
{
local T='gYw'

echo -e "\n 40m 41m 42m 43m 44m 45m 46m 47m";

for FGs in ' 0m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' \
' 32m' '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' \
' 35m' '1;35m' ' 36m' '1;36m' ' 37m' '1;37m';
do
FG=${FGs// /}
echo -en " $FGs \033[$FG $T "
for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do
echo -en " \033[$FG\033[$BG $T \033[0m";
done
echo;
done

echo
clr_bold " Code Function Variable"
echo \
' 0 clr_reset $CLR_RESET
1 clr_bold $CLR_BOLD
2 clr_bright $CLR_BRIGHT
4 clr_underscore $CLR_UNDERSCORE
7 clr_reverse $CLR_REVERSE
30 clr_black $CLR_BLACK
31 clr_red $CLR_RED
32 clr_green $CLR_GREEN
33 clr_brown $CLR_BROWN
34 clr_blue $CLR_BLUE
35 clr_magenta $CLR_MAGENTA
36 clr_cyan $CLR_CYAN
37 clr_white $CLR_WHITE
40 clr_blackb $CLR_BLACKB
41 clr_redb $CLR_REDB
42 clr_greenb $CLR_GREENB
43 clr_brownb $CLR_BROWNB
44 clr_blueb $CLR_BLUEB
45 clr_magentab $CLR_MAGENTAB
46 clr_cyanb $CLR_CYANB
47 clr_whiteb $CLR_WHITEB
'
}

0 comments on commit 1815d97

Please sign in to comment.