-
Notifications
You must be signed in to change notification settings - Fork 0
/
make
executable file
·58 lines (46 loc) · 1.73 KB
/
make
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
#! /usr/bin/env bash
# This script dynamically inserts the assignment repository path into
# ROS_PACKAGE_PATH so that the dotfiles on each machine don't need to
# be manually updated.
function fix-ros-path() {
# This function inserts the current working directory into the
# ROS_PACKAGE_PATH environment variable.
CWD=$(pwd)
# Split ROS_PACKAGE_PATH by colons, and store the resulting tokens in
# an array named RPP.
if [[ "$ZSH_NAME" != "" ]]; then
# `read` in zsh uses capital -A for some reason
# it also numbers arrays starting with 1
IFS=':' read -rA RPP <<< "${ROS_PACKAGE_PATH}"
else
IFS=':' read -ra RPP <<< "${ROS_PACKAGE_PATH}"
fi
# Iterate through RPP and check if the current working directory
# is already present in ROS_PACKAGE_PATH. Return from the function
# if the current working directory is already present in
# ROS_PACKAGE_PATH.
for p in "${RPP[@]}"; do
# `-ef` compares device and inode numbers for equality
if [[ "$p" -ef "$CWD" ]]; then
return
fi
done
export ROS_PACKAGE_PATH="${ROS_PACKAGE_PATH}:${CWD}"
}
function use-clang() {
# clang tends to compile the project in less time and using less
# memory than gcc. This function tries to set the environment
# variables used by the Makefile to the latest version of clang,
# if it exists on the system.
# On Ubuntu 20.04, the latest version of clang is 12.
for VERSION in {12..10}; do
if [[ -x /usr/bin/clang-$VERSION ]]; then
export C_compiler="/usr/bin/clang-$VERSION"
export CXX_compiler="/usr/bin/clang++-$VERSION"
break
fi
done
}
use-clang
fix-ros-path
make -j $(nproc)