-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_project_impl.sh
executable file
·64 lines (51 loc) · 1.19 KB
/
make_project_impl.sh
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
#!/bin/bash
set -euo pipefail
CPP=${CPP:-}
PY=${PY:-}
say() {
echo -e "\033[36;1m[ make_project ] $*\033[0m"
}
make_repo() {
say "Setting up the git repo..."
git init
if [[ -f ~/.gitconfig ]]; then
cp ~/.gitconfig .git/config
else
cat <<EOF > .git/config
[user]
name = "Skynet"
email = "[email protected]"
EOF
fi
git add .
git commit -m "Initial commit"
say "Done."
rm .git/config
}
if [[ $# -lt 1 ]]; then
say "Usage: $0 <path>"
exit 1
fi
here=$(dirname "$0")
# the output directory will be $project_name (so either relative to
# cwd or absolute path)
project_name=$1
if [[ $(stat "$project_name") ]]; then
say "$project_name" already exists
exit 1
fi
if [[ -n "$CPP" ]]; then
templates="$here/templates/cpp"
say "Creating Bazel C++ project in <$project_name>..."
elif [[ -n "$PY" ]]; then
templates="$here/templates/py"
say "Creating Python project in <$project_name>..."
fi
# copy templates to particular folder
# replace instances of project name if necessary
cp -r "$templates" "$project_name"
# cd into the project and build / test
cd "$project_name"
say "Testing project..."
./build.sh
make_repo