-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_bzl_cc
More file actions
executable file
·131 lines (111 loc) · 2.75 KB
/
git_bzl_cc
File metadata and controls
executable file
·131 lines (111 loc) · 2.75 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
#!/bin/bash
# $1 = Project Name
# Get variables
USER=$(git config --global user.name)
PROJECT=$1
TEMP_SOURCE="$HOME/bin/starter_kit_maker/bin/bazel/cc-temp"
# Create and enter git directory
if [ -d "$PROJECT" ]; then
echo "${PROJECT} directory already exists in this directory. Go to a different directory."
exit N
fi
mkdir $PROJECT
cd $PROJECT
# Direnv setup
echo "export PROJECT=${PROJECT}" >> .envrc
echo "export PROJPWD=${PWD}" >> .envrc
direnv allow .
# README
touch README
echo "This is the README for $PROJECT" >> README
# Create dir tree
mkdir src
mkdir src/lib
mkdir src/main
mkdir tests
# Create WORKSPACE
touch WORKSPACE
echo "# $PROJECT" > WORKSPACE
cat "$TEMP_SOURCE/WORKSPACE" >> WORKSPACE
# Create BUILDS
touch src/lib/BUILD
cat "$TEMP_SOURCE/src/lib/BUILD" > src/lib/BUILD
touch src/main/BUILD
cat "$TEMP_SOURCE/src/main/BUILD" > src/main/BUILD
touch tests/BUILD
cat "$TEMP_SOURCE/tests/BUILD" > tests/BUILD
# Create object instance
COUNT=0
for item in "$@"; do
if [ $COUNT -ne 0 ]; then
# Header
touch src/lib/$item.h
HEADER=${PROJECT^^}"_SRC_LIB_"${item^^}"_H_"
echo "#ifndef $HEADER
#define $HEADER
class $item {
public:
$item();
~$item();
private:
};
#endif" >> src/lib/$item.h
# Source
touch src/lib/$item.cc
echo "#include \"$item.h\"
$item::$item() {
}
$item::~$item() {
}" >> src/lib/$item.cc
# Test
touch tests/${item}_test.cc
echo "#include <memory>
#include \"gtest/gtest.h\"
#include \"src/lib/$item.h\"
TEST(${item}Should, ReturnSomething){
/*
std::unique_ptr<$item> ${item,,} = std::make_unique<$item>();
std::string actual = ${item,,}->DoSomething();
std::string expected = "Something";
EXPECT_EQ(expected, actual);
*/
}" >> tests/${item}_test.cc
# Object vars
echo "$item" >> $VARS
# Increase Count
let COUNT=COUNT+1
else
# Skip first item (project name)
let COUNT=COUNT+1
fi
done
# main
touch src/main/main.cc
echo "#include <iostream>
int main(int argc, char** argv) {
return 0;
}" >> src/main/main.cc
# Make first commit
git init
echo "Project initialized..."
# README
vim README
echo "README updated..."
# .gitignore
touch .gitignore
echo "bazel*" >> .gitignore
# Add and commit
git add .
git commit -m "First commit of $PROJECT: Check README"
# Branch setup
git branch -m master develop
echo "develop branch created (HEAD)..."
git branch release
echo "release branch created..."
# Remote and push
echo "First commit is set. Ready to push the develop branch..."
echo "Go to https://github.com/new and make a new repo with the project name: $PROJECT"
read -p "Press enter once done"
git remote add origin https://github.com/$USER/$PROJECT.git
git push origin develop
echo "Develop branch successfuly pushed. Release branch is ready for merge when a releaseable version of develop is ready! Happy Building!!"