-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetenv
More file actions
142 lines (120 loc) · 4.04 KB
/
setenv
File metadata and controls
142 lines (120 loc) · 4.04 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#! /bin/bash
export WORKSPACE=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
export ENV="$WORKSPACE/env"
export IS_SETENV=1
export OLD_PATH=$PATH
export OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
export OLD_LC_ALL=$LC_ALL
export OLD_LDFLAGS=$LDFLAGS
export OLD_PS1=$PS1
export OLD_CC=$CC
export OLD_CXX=$CXX
export OLD_VCPKG_ROOT=$VCPKG_ROOT
unsetenv() {
# reset old environment variables
if [[ -n "$OLD_PATH" ]]; then
export PATH="$OLD_PATH"
fi
unset OLD_PATH
if [[ -n "$OLD_LD_LIBRARY_PATH" ]]; then
export LD_LIBRARY_PATH=$OLD_LD_LIBRARY_PATH
else
unset LD_LIBRARY_PATH
fi
unset OLD_LD_LIBRARY_PATH
if [[ -n "$OLD_LC_ALL" ]]; then
export LC_ALL="$OLD_LC_ALL"
else
unset LC_ALL
fi
unset OLD_LC_ALL
if [[ -n "$OLD_CC" ]]; then
export CC=$OLD_CC
else
unset CC
fi
unset OLD_CC
if [[ -n "$OLD_CXX" ]]; then
export CXX=$OLD_CXX
else
unset CXX
fi
unset OLD_CXX
if [[ -n "$OLD_LDFLAGS" ]]; then
export LDFLAGS=$OLD_LDFLAGS
else
unset LDFLAGS
fi
unset OLD_LDFLAGS
if [[ -n "$OLD_VCPKG_ROOT" ]]; then
export VCPKG_ROOT=$OLD_VCPKG_ROOT
fi
unset OLD_VCPKG_ROOT
# Call hash to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
hash -r 2> /dev/null
if [[ -n "$OLD_PS1" ]]; then
export PS1=$OLD_PS1
fi
unset OLD_PS1
unset IS_SETENV
}
# point to workspace GCC if it exists in workspace
if [[ ! -z $(ls -A "${WORKSPACE}/env/gcc") ]]; then
export PATH="$WORKSPACE/env/gcc/bin:$PATH"
if [[ ! -z $LD_LIBRARY_PATH ]]; then
export LD_LIBRARY_PATH="$WORKSPACE/env/gcc/lib:$WORKSPACE/env/gcc/lib64:$LD_LIBRARY_PATH"
else
export LD_LIBRARY_PATH="$WORKSPACE/env/gcc/lib:$WORKSPACE/env/gcc/lib64"
fi
# set default path C/C++ compiler to point to new gcc compiler
export CC="$WORKSPACE/env/gcc/bin/gcc"
export CXX="$WORKSPACE/env/gcc/bin/g++"
else
echo "Warning. No gcc detected in current workspace. No environment variable will be modified"
fi
# set environment variables for
export VCPKG_ROOT="$WORKSPACE/vcpkg"
export PATH="$VCPKG_ROOT:$PATH"
if [[ ! -z $(ls -A "${WORKSPACE}/env/cmake") ]]; then
# point to workspace CMake
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
export PATH="$WORKSPACE/env/cmake/bin:$PATH"
elif [[ "$OSTYPE" == "darwin"* ]]; then
export PATH="$WORKSPACE/env/cmake/CMake.app/Contents/bin:$PATH"
fi
else
echo "Warning. No cmake detected in current workspace. No environment variable will be modified"
fi
if [[ ! -z $(ls -A "${WORKSPACE}/env/openssl") ]]; then
# point to workspace openssl
export PATH="$WORKSPACE/env/openssl/bin:$PATH"
if [[ ! -z $LD_LIBRARY_PATH ]]; then
export LD_LIBRARY_PATH="$WORKSPACE/env/openssl/lib:$WORKSPACE/env/openssl/lib64:$LD_LIBRARY_PATH"
else
export LD_LIBRARY_PATH="$WORKSPACE/env/openssl/lib:$WORKSPACE/env/openssl/lib64"
fi
export LC_ALL="en_US.UTF-8"
export LDFLAGS="-L $WORKSPACE/env/openssl/lib -Wl,-rpath,$WORKSPACE/env/openssl/lib"
fi
if [[ ! -z $(ls -A "${WORKSPACE}/env/python") ]]; then
# point to workspace Python3
export PATH="$WORKSPACE/env/python/bin:$PATH"
export LD_LIBRARY_PATH="$WORKSPACE/env/python/lib:$LD_LIBRARY_PATH"
else
echo "Warning. No python detected in current workspace. No environment variable will be modified"
fi
if [[ ! -z $(ls -A "${WORKSPACE}/env/ninja") ]]; then
# point to workspace ninja
export PATH="$WORKSPACE/env/ninja/bin:$PATH"
else
echo "Warning. No ninja detected in current workspace. No environment variable will be modified"
fi
if [[ -z $(ls -A "${WORKSPACE}/.venv/") ]]; then
echo "WARNING: No python virtual environment has been detected."
echo "A virtual environment will be created by executing `pythonenv.sh`"
/bin/bash $WORKSPACE/pythonenv.sh
fi
echo "Activating virtual python environment"
source "${WORKSPACE}/.venv/bin/activate"
pip3 install -r ${WORKSPACE}/requirements.txt