summaryrefslogtreecommitdiffstats
path: root/gendocs.sh
blob: 0052748d4bcbd5da59cb6f457cb2d1f1d28481e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash

OUTFILENAME="Application-Framework-Binder-Guide"

SCRIPT=$(basename $BASH_SOURCE)

VERSION=$(grep '"version":' $(dirname $BASH_SOURCE)/book.json | cut -d'"' -f 4)
[ "$VERSION" != "" ] && OUTFILENAME="${OUTFILENAME}_${VERSION}"


function usage() {
	cat <<EOF >&2
Usage: $SCRIPT [options] [pdf|serve|doxygen]

Options:
   --debug
      enable debug when generating pdf or html documentation
   -d|--dry
      dry run
   -h|--help
      get this help

Example:
	$SCRIPT pdf

EOF
	exit 1
}

function info() {
	echo "$@" >&2
}

#default values
DEBUG_FLAG=""
DRY=""
DO_ACTION=""
OUT_DIR=./build

[[ $? != 0 ]] && usage
while [ $# -gt 0 ]; do
	case "$1" in
		--debug) DEBUG_FLAG="--log=debug --debug";;
		-d|--dry) DRY=echo;;
		-h|--help) usage;;
        pdf | serve | doxygen) DO_ACTION=$1;;
		--) break;;
	esac
    shift
done

cd $(dirname $0)
ROOTDIR=`pwd -P`

# Create out dir if needed
[ -d $OUT_DIR ] || mkdir -p $OUT_DIR

if [ "$DO_ACTION" = "pdf" -o "$DO_ACTION" = "serve" ]; then
    GITBOOK=`which gitbook`
    [ "$?" = "1" ] && { echo "You must install gitbook first, using: sudo npm install -g gitbook-cli"; exit 1; }

    EBCONV=`which ebook-convert`
    [ "$?" = "1" ] && { echo "You must install calibre first, using: 'sudo apt install calibre' or refer to https://calibre-ebook.com/download"; exit 1; }

    if [ "$DO_ACTION" = "pdf" ]; then

        # Update cover when book.json has been changed
        [[ $ROOTDIR/book.json -nt $ROOTDIR/docs/cover.jpg ]] && { echo "Update cover files"; $ROOTDIR/docs/resources/make_cover.sh || exit 1; }

	    OUTFILE=$OUT_DIR/$OUTFILENAME.pdf
        $DRY $GITBOOK pdf $ROOTDIR $OUTFILE $DEBUG_FLAG
        [ "$?" = "0" ] && echo "PDF has been successfully generated in $OUTFILE"
    else
        $DRY $GITBOOK serve $DEBUG_FLAG
    fi

elif [ "$DO_ACTION" = "doxygen" ]; then
    $DRY cd $OUT_DIR && cmake .. && make doxygen $ROOTDIR/Doxyfile

else
    echo "Unknown action !"
    usage
fi
n class="n">ConsolePrintf( PRIO_ERROR, RED"-i parameter requires string fragment which shall be ignored"RESETCOLOR"\n" ); return -1; } mainClass->SetCdevIgnorePattern(argv[i + 1]); i++; } else if( strstr( argv[i], "-m" ) ) { disableMenu = false; } else if( strstr( argv[i], "-vv" ) ) { prio = PRIO_LOW; } else if( strstr( argv[i], "-v" ) ) { prio = PRIO_MEDIUM; } else if( strstr( argv[i], "--help" ) ) { ConsolePrintfStart( PRIO_HIGH, "Usage: %s [OPTION] ... [FILE] ... \n", argv[0] ); ConsolePrintfContinue( "Example MOST VideoOnDemand streaming service.\n" ); ConsolePrintfContinue( "\t-p\t\t path to search the media files."\ " If not set, the callee path will be searched\n" ); ConsolePrintfContinue( "\t-m\t\t enable user menu\n" ); ConsolePrintfContinue( "\t-i\t\t ignore all cdev with the given string fragments\n" ); ConsolePrintfContinue( "\t-v\t\t verbose mode - print debug info\n" ); ConsolePrintfContinue( "\t-vv\t\t super verbose mode - print even more debug info\n" ); ConsolePrintfContinue( "Example: %s -p /root\n", argv[0] ); return 0; } else { ConsolePrintf( PRIO_ERROR, RED "Ignoring command line parameter at pos %d: %s, type '%s --help'"\ " to see the correct parameter syntax"RESETCOLOR\ "\n", i, argv[i], argv[0] ); } } ConsoleSetPrio( prio ); if( NULL != searchPath ) mainClass->SetSearchPath( searchPath ); else mainClass->SetSearchPath( "." ); mainClass->ConnectToNetworkManager(); mainClass->GetConnectionListFromNetworkManager(); if( disableMenu || !isatty( fileno( stdin ) ) ) { while( true ) sleep( 1 ); } else { PrintMenu(); while( true ) { int c = getchar(); fflush( stdin ); switch( c ) { case 'M': case 'm': PrintMenu(); break; case 'R': case 'r': mainClass->ToggleStatisticsPrint(); break; case 'S': case 's': mainClass->CreateSampleStreams( 4 ); break; case 'X': case 'x': CVodHandler::DestroyInstance(); ConsolePrintf( PRIO_HIGH, BLUE"========== Video On Demand Server End =========="RESETCOLOR"\n" ); ConsoleDeinit(); return 0; default: break; } usleep( 10000 ); //Avoid high CPU load, if terminal is disconnected (running as daemon) } } }