AllwmakeParseArguments 3.67 KB
Newer Older
1
2
3
4
#----------------------------------*-sh-*--------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     |
5
#   \\  /    A nd           | Copyright (C) 2014-2017 OpenFOAM Foundation
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
#    \\/     M anipulation  |
#------------------------------------------------------------------------------
# License
#     This file is part of OpenFOAM.
#
#     OpenFOAM is free software: you can redistribute it and/or modify it
#     under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
#
#     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
#     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
#     for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
#
# File
#     wmake/scripts/AllwmakeParseArguments
#
# Description
#     Allwmake argument parser
#
# Usage
#     # Parse the arguments by sourcing this script
#     . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
#
#------------------------------------------------------------------------------
Script=${0##*/}

37
38
39
40
41
42
43
44
45
if [ -z "$WM_PROJECT_DIR" ]
then
    echo "$Script error: The OpenFOAM environment is not set."
    echo "    Check the OpenFOAM entries in your dot-files and source them."
    echo "    If in doubt, please read:"
    echo "       http://openfoam.org/download/source/setting-environment"
    exit 1
fi

46
47
48
49
50
51
52
53
54
usage() {
    exec 1>&2
    while [ "$#" -ge 1 ]; do echo "$1"; shift; done

    # Print normal usage options
    cat<<USAGE

Usage: $Script [OPTIONS]

55
Executing $Script is equivalent to
56

57
58
   wmake -all [OPTIONS]
USAGE
59

60
    wmake -help
61
62
63
64
65
66
67
68
    exit 1
}


#------------------------------------------------------------------------------
# Parse the arguments and options
#------------------------------------------------------------------------------

69
fromWmake=
70
qOpt=
71
72

for arg in "$@"
73
do
74
75
76
    # Remove arg
    shift

77
    case "$arg" in
78
79
        -h | -help)
            usage
80
            exit 0
81
            ;;
82
83
84
        # Check if called from wmake to avoid recusion
        -fromWmake)
            fromWmake="fromWmake"
85
            ;;
86
87
88
89
90
        -q)
            qOpt="-q"
            # Permanently remove arg
            continue
            ;;
91
        # Target type
92
        lib | libo | libso | dep | objects)
93
            targetType=$arg
94
95
            ;;
    esac
96
97
98

    # Re-insert arg
    set -- "$@" "$arg"
99
100
101
done


102
103
104
105
106
107
#------------------------------------------------------------------------------
# Execute wmake -all if not called from wmake
#------------------------------------------------------------------------------

if [ -z "$fromWmake" ]
then
108
    exec wmake -all $qOpt $*
109
110
111
112
else
    # Print command
    [ -z "$targetType" ] || targetSpace=" "
    echo "$Script $targetType$targetSpace$(echo $PWD | sed s%$WM_PROJECT_DIR/%% )"
113
114
115
fi


116
117
118
119
120
121
122
123
124
125
#------------------------------------------------------------------------------
# If WM_CONTINUE_ON_ERROR not set activate the shell option "stop on error"
#------------------------------------------------------------------------------

if [ -z "${WM_CONTINUE_ON_ERROR}" ]
then
    set -e
fi


126
127
128
129
#------------------------------------------------------------------------------
# Cleanup local variables and functions
#------------------------------------------------------------------------------

130
unset Script usage fromWmake
131
132


133
#------------------------------------------------------------------------------