From 32d7706ed6ab08b5a6095cf8fad42ac01cce3c12 Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Sun, 2 Jun 2019 21:37:18 -0700 Subject: [PATCH 01/22] works; working on object maker --- bin/object_maker | 1 + git_begin | 32 ++------------------------------ 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/bin/object_maker b/bin/object_maker index ddd0d82..253d92b 100755 --- a/bin/object_maker +++ b/bin/object_maker @@ -26,6 +26,7 @@ class $OBJECT { # Source touch $OBJECT.cc echo "#include \"$OBJECT.h\" + $OBJECT::$OBJECT() { } diff --git a/git_begin b/git_begin index d19fc5f..088da8f 100755 --- a/git_begin +++ b/git_begin @@ -40,37 +40,9 @@ clean: # Create Objects PWD=`pwd` COUNT=0 -for object in "$OBJECT"; do +for object in "$@"; do if [ $COUNT -ne 0 ]; then - # Make Object: item - touch $@.h - echo "#ifndef $@.H - #define $@.H - - class $@ { - public: - $@(); - ~$@(); - - private: - }; - - #endif" >> $@.h - - # Source - touch $@.cc - echo "#include \"$@.h\" - $@::$@() { - } - - $@::~$@() { - }" >> $@.cc - - # Add object to makefile - sed -i "/^OBJFILES/ s/$/$@.o /" Makefile - $HOME/bin/object_maker $object - # Increase Count - let COUNT=COUNT+1 + object_maker $object else # Skip first item (project name) let COUNT=COUNT+1 From ffd98925801ea7ee3a5e9b7ce3b34fa0bc12093a Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Sun, 2 Jun 2019 22:25:44 -0700 Subject: [PATCH 02/22] added more capability: creates develop and release branches and prompts the user to login to github and make the repo. then develop is pushed --- git_begin | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/git_begin b/git_begin index 54a3561..3ca7375 100755 --- a/git_begin +++ b/git_begin @@ -12,11 +12,7 @@ cd $PROJECT # Create beginning files # README touch README -echo "This is the README for $PROJECT -Template_v0: -Name: -Number: -Hi:" >> README +echo "This is the README for $PROJECT" >> README # .gitignore touch .gitignore @@ -92,7 +88,18 @@ sed -i "/^OBJFILES/ s/$/main.o /" Makefile # Make first commit git init +echo "Project initialized..." +vim README +echo "README updated..." git add . -git commit -m "First commit of $PROJECT" -git remote add origin git@github.com/$USER/$PROJECT.git - +git commit -m "First commit of $PROJECT: Check README" +git branch -m master develop +echo "develop branch created (HEAD)..." +git branch release +echo "release branch created..." +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!!" From 1c00c56fef074b8048d3bfca16c1a2c9be6b568f Mon Sep 17 00:00:00 2001 From: Maxx Tepper Date: Sat, 21 Mar 2020 16:53:47 -0700 Subject: [PATCH 03/22] bazel-test cc -- must have bin setupgit add git_bzl_cc --- git_bzl_cc | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100755 git_bzl_cc diff --git a/git_bzl_cc b/git_bzl_cc new file mode 100755 index 0000000..2bf54e2 --- /dev/null +++ b/git_bzl_cc @@ -0,0 +1,95 @@ +#!/bin/bash +# $1 = Project Name + +# Get variables +USER=$(git config --global user.name) +PROJECT=$1 +TEMP_SOURCE="$HOME/bin/bazel/cpp-template" + +# Create and enter git directory +mkdir $PROJECT +cd $PROJECT + +# 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 +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 files +COUNT=0 +for item in "$@"; do + if [ $COUNT -ne 0 ]; then + # Header + touch src/lib/$item.h + echo "#ifndef $item.H +#define $item.H + +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 + + # 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 + +int main(int argc, char** argv) { + return 0; +}" >> src/main/main.cc + +# Make first commit +git init +echo "Project initialized..." +vim README +echo "README updated..." +git add . +git commit -m "First commit of $PROJECT: Check README" +git branch -m master develop +echo "develop branch created (HEAD)..." +git branch release +echo "release branch created..." +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!!" From b19d86037d508c86353995836e2e2791410d697c Mon Sep 17 00:00:00 2001 From: Maxx Tepper Date: Sat, 21 Mar 2020 23:59:36 -0700 Subject: [PATCH 04/22] now in local bin --- git_bzl_cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git_bzl_cc b/git_bzl_cc index 2bf54e2..a73226c 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -4,7 +4,7 @@ # Get variables USER=$(git config --global user.name) PROJECT=$1 -TEMP_SOURCE="$HOME/bin/bazel/cpp-template" +TEMP_SOURCE="$PWD/bin/bazel/cpp-template" # Create and enter git directory mkdir $PROJECT From 6218677e29466891c4a07853dc69808df7b0231a Mon Sep 17 00:00:00 2001 From: Maxx Tepper Date: Sun, 22 Mar 2020 00:00:01 -0700 Subject: [PATCH 05/22] added bin --- bin/bazel/cpp-template | 1 + 1 file changed, 1 insertion(+) create mode 160000 bin/bazel/cpp-template diff --git a/bin/bazel/cpp-template b/bin/bazel/cpp-template new file mode 160000 index 0000000..07ae6a2 --- /dev/null +++ b/bin/bazel/cpp-template @@ -0,0 +1 @@ +Subproject commit 07ae6a2daeb3e99f2d252ed7a8bf0991ff5eaf0f From 7210010a1abfaed3cb2266e001dbcb5ff760ab8c Mon Sep 17 00:00:00 2001 From: Maxx Tepper Date: Sun, 22 Mar 2020 09:31:30 -0700 Subject: [PATCH 06/22] cpp-temp now included --- bin/bazel/cpp-temp/WORKSPACE | 7 +++++++ bin/bazel/cpp-temp/src/lib/BUILD | 7 +++++++ bin/bazel/cpp-temp/src/main/BUILD | 6 ++++++ bin/bazel/cpp-temp/src/main/main.cc | 10 ++++++++++ bin/bazel/cpp-temp/tests/BUILD | 8 ++++++++ bin/bazel/cpp-temp/tests/Greeting_test.cc | 9 +++++++++ bin/bazel/cpp-temp/tests/README.md | 1 + bin/bazel/cpp-temp/tests/WORKSPACE | 7 +++++++ bin/bazel/cpp-template | 1 - 9 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 bin/bazel/cpp-temp/WORKSPACE create mode 100644 bin/bazel/cpp-temp/src/lib/BUILD create mode 100644 bin/bazel/cpp-temp/src/main/BUILD create mode 100644 bin/bazel/cpp-temp/src/main/main.cc create mode 100644 bin/bazel/cpp-temp/tests/BUILD create mode 100644 bin/bazel/cpp-temp/tests/Greeting_test.cc create mode 100644 bin/bazel/cpp-temp/tests/README.md create mode 100644 bin/bazel/cpp-temp/tests/WORKSPACE delete mode 160000 bin/bazel/cpp-template diff --git a/bin/bazel/cpp-temp/WORKSPACE b/bin/bazel/cpp-temp/WORKSPACE new file mode 100644 index 0000000..b54973d --- /dev/null +++ b/bin/bazel/cpp-temp/WORKSPACE @@ -0,0 +1,7 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +git_repository( + name = "googletest", + remote = "https://github.com/google/googletest", + tag = "release-1.10.0", +) diff --git a/bin/bazel/cpp-temp/src/lib/BUILD b/bin/bazel/cpp-temp/src/lib/BUILD new file mode 100644 index 0000000..4ceeac8 --- /dev/null +++ b/bin/bazel/cpp-temp/src/lib/BUILD @@ -0,0 +1,7 @@ +# https://docs.bazel.build/versions/master/be/c-cpp.html#cc_library +cc_library( + name = "ThisLib", + srcs = glob(["**/*.cc"]), + hdrs = glob(["**/*.h"]), + visibility = ["//visibility:public"], +) diff --git a/bin/bazel/cpp-temp/src/main/BUILD b/bin/bazel/cpp-temp/src/main/BUILD new file mode 100644 index 0000000..5950289 --- /dev/null +++ b/bin/bazel/cpp-temp/src/main/BUILD @@ -0,0 +1,6 @@ +# https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary +cc_binary( + name = "main", + srcs = ["main.cc"], + deps = ["//src/lib:ThisLib"], +) diff --git a/bin/bazel/cpp-temp/src/main/main.cc b/bin/bazel/cpp-temp/src/main/main.cc new file mode 100644 index 0000000..99e4c80 --- /dev/null +++ b/bin/bazel/cpp-temp/src/main/main.cc @@ -0,0 +1,10 @@ +#include +#include "src/lib/Greeting.h" + +int main() +{ + Greeting *greet = new Greeting(); + std::cout << greet->getGreetingMessage() << std::endl; + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/bin/bazel/cpp-temp/tests/BUILD b/bin/bazel/cpp-temp/tests/BUILD new file mode 100644 index 0000000..1ddfa8f --- /dev/null +++ b/bin/bazel/cpp-temp/tests/BUILD @@ -0,0 +1,8 @@ +cc_test( + name = "tests", + srcs = glob(["**/*.cc"]), + deps = [ + "//src/lib:GreetingLib", + "@googletest//:gtest_main", + ], +) diff --git a/bin/bazel/cpp-temp/tests/Greeting_test.cc b/bin/bazel/cpp-temp/tests/Greeting_test.cc new file mode 100644 index 0000000..92e7794 --- /dev/null +++ b/bin/bazel/cpp-temp/tests/Greeting_test.cc @@ -0,0 +1,9 @@ +#include "gtest/gtest.h" +#include "src/lib/Greeting.h" + +TEST(GreetingShould, ReturnHelloWorld){ + Greeting *greet = new Greeting(); + std::string actual = greet->getGreetingMessage(); + std::string expected = "Hello World!"; + EXPECT_EQ(expected, actual); +} \ No newline at end of file diff --git a/bin/bazel/cpp-temp/tests/README.md b/bin/bazel/cpp-temp/tests/README.md new file mode 100644 index 0000000..802f947 --- /dev/null +++ b/bin/bazel/cpp-temp/tests/README.md @@ -0,0 +1 @@ +This repo contains the example file structure discussed in https://www.ratanparai.com/c++/writing-unit-tests-with-bazel/ diff --git a/bin/bazel/cpp-temp/tests/WORKSPACE b/bin/bazel/cpp-temp/tests/WORKSPACE new file mode 100644 index 0000000..b54973d --- /dev/null +++ b/bin/bazel/cpp-temp/tests/WORKSPACE @@ -0,0 +1,7 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +git_repository( + name = "googletest", + remote = "https://github.com/google/googletest", + tag = "release-1.10.0", +) diff --git a/bin/bazel/cpp-template b/bin/bazel/cpp-template deleted file mode 160000 index 07ae6a2..0000000 --- a/bin/bazel/cpp-template +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 07ae6a2daeb3e99f2d252ed7a8bf0991ff5eaf0f From f474a0b38c60d0a32f4e6164fbdc4ef065082f10 Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Sun, 22 Mar 2020 09:36:03 -0700 Subject: [PATCH 07/22] fixed cpp-template to cpp-temp --- git_bzl_cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git_bzl_cc b/git_bzl_cc index a73226c..0dd3ee2 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -4,7 +4,7 @@ # Get variables USER=$(git config --global user.name) PROJECT=$1 -TEMP_SOURCE="$PWD/bin/bazel/cpp-template" +TEMP_SOURCE="$PWD/bin/bazel/cpp-temp" # Create and enter git directory mkdir $PROJECT From b87725eaac17a1384184d591ce736ada86a7715d Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Sun, 22 Mar 2020 10:32:32 -0700 Subject: [PATCH 08/22] went back to needing /home/maxx/bin/bazel/ --- git_bzl_cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git_bzl_cc b/git_bzl_cc index 0dd3ee2..6818662 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -4,7 +4,7 @@ # Get variables USER=$(git config --global user.name) PROJECT=$1 -TEMP_SOURCE="$PWD/bin/bazel/cpp-temp" +TEMP_SOURCE="$HOME/bin/bazel/cpp-temp" # Create and enter git directory mkdir $PROJECT From 73a00f16033d63b1c13e3827172ec61bb086de2d Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Sun, 22 Mar 2020 10:40:12 -0700 Subject: [PATCH 09/22] added object maker for bazel --- bin/bazel/cpp_bzl_obj | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 bin/bazel/cpp_bzl_obj diff --git a/bin/bazel/cpp_bzl_obj b/bin/bazel/cpp_bzl_obj new file mode 100755 index 0000000..923902c --- /dev/null +++ b/bin/bazel/cpp_bzl_obj @@ -0,0 +1,35 @@ +#!/bin/bash +# $1 = Project Name + +# Get variables +OBJECT=$1 + +# Which directory? +# This one for now +# MUST be in the directory where the files are going + +# Create object files +# Header +touch $OBJECT.h +echo "#ifndef $OBJECT.H +#define $OBJECT.H + +class $OBJECT { + public: + $OBJECT(); + ~$OBJECT(); + + private: +}; + +#endif" >> $OBJECT.h + +# Source +touch $OBJECT.cc +echo "#include \"$OBJECT.h\" + +$OBJECT::$OBJECT() { +} + +$OBJECT::~$OBJECT() { +}" >> $OBJECT.cc From 99088272dc2f86e585aa8cfd9e7d65d8864b67f8 Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Sun, 22 Mar 2020 11:05:33 -0700 Subject: [PATCH 10/22] made name fixes; restructured where everything is --- README | 20 +++++++---- bin/bazel/{cpp-temp => cc-temp}/WORKSPACE | 0 bin/bazel/{cpp-temp => cc-temp}/src/lib/BUILD | 0 .../{cpp-temp => cc-temp}/src/main/BUILD | 0 .../{cpp-temp => cc-temp}/src/main/main.cc | 0 bin/bazel/{cpp-temp => cc-temp}/tests/BUILD | 0 .../tests/Greeting_test.cc | 0 .../{cpp-temp => cc-temp}/tests/README.md | 0 .../{cpp-temp => cc-temp}/tests/WORKSPACE | 0 bin/bazel/cc_bzl_obj | 35 +++++++++++++++++++ bin/object_maker | 4 +-- git_bzl_cc | 6 ++-- 12 files changed, 53 insertions(+), 12 deletions(-) rename bin/bazel/{cpp-temp => cc-temp}/WORKSPACE (100%) rename bin/bazel/{cpp-temp => cc-temp}/src/lib/BUILD (100%) rename bin/bazel/{cpp-temp => cc-temp}/src/main/BUILD (100%) rename bin/bazel/{cpp-temp => cc-temp}/src/main/main.cc (100%) rename bin/bazel/{cpp-temp => cc-temp}/tests/BUILD (100%) rename bin/bazel/{cpp-temp => cc-temp}/tests/Greeting_test.cc (100%) rename bin/bazel/{cpp-temp => cc-temp}/tests/README.md (100%) rename bin/bazel/{cpp-temp => cc-temp}/tests/WORKSPACE (100%) create mode 100755 bin/bazel/cc_bzl_obj diff --git a/README b/README index 2d76eae..5052795 100644 --- a/README +++ b/README @@ -3,16 +3,22 @@ Created By: maxxtepper This is not the only way to use this tool, it is simply an example. Instructions: -1. Establish a user bin - $ mkdir $HOME/bin -2. Create symlink of file in bin - $ ln -s /full-path/git_begin $HOME/bin/. -3. Add the following line at the end of $HOME/.bashrc +1. Establish a user bin up to the following: + $ mkdir -p $HOME/bin/starter_kit_maker/bin/bazel +2. Add the following line at the end of $HOME/.bashrc export PATH="$HOME/bin:$PATH" +3. Create symlink of files in bin + $ ln -s /full-path/git_begin $HOME/bin/. + $ ln -s /full-path/bin/object_maker $HOME/bin/. + $ ln -s /full-path/git_bzl_cc $HOME/bin/. + $ ln -s /full-path/bin/bazel/cc_bzl_obj $HOME/bin/. -Example Usage: +Example Usage (no bazel): $ git_begin project_name object0 object1 +Example Usage (with bazel): +$ git_bzl_cc project_name object0 object1 + After git_begin, the next string will be the name of the project, and every string after that will be objects named after the strings themselves -Symlink allows you to edit the git_begin file in the repo to keep the executable up-to-date +Symlink allows you to edit the scripts in the repo to keep the executable up-to-date diff --git a/bin/bazel/cpp-temp/WORKSPACE b/bin/bazel/cc-temp/WORKSPACE similarity index 100% rename from bin/bazel/cpp-temp/WORKSPACE rename to bin/bazel/cc-temp/WORKSPACE diff --git a/bin/bazel/cpp-temp/src/lib/BUILD b/bin/bazel/cc-temp/src/lib/BUILD similarity index 100% rename from bin/bazel/cpp-temp/src/lib/BUILD rename to bin/bazel/cc-temp/src/lib/BUILD diff --git a/bin/bazel/cpp-temp/src/main/BUILD b/bin/bazel/cc-temp/src/main/BUILD similarity index 100% rename from bin/bazel/cpp-temp/src/main/BUILD rename to bin/bazel/cc-temp/src/main/BUILD diff --git a/bin/bazel/cpp-temp/src/main/main.cc b/bin/bazel/cc-temp/src/main/main.cc similarity index 100% rename from bin/bazel/cpp-temp/src/main/main.cc rename to bin/bazel/cc-temp/src/main/main.cc diff --git a/bin/bazel/cpp-temp/tests/BUILD b/bin/bazel/cc-temp/tests/BUILD similarity index 100% rename from bin/bazel/cpp-temp/tests/BUILD rename to bin/bazel/cc-temp/tests/BUILD diff --git a/bin/bazel/cpp-temp/tests/Greeting_test.cc b/bin/bazel/cc-temp/tests/Greeting_test.cc similarity index 100% rename from bin/bazel/cpp-temp/tests/Greeting_test.cc rename to bin/bazel/cc-temp/tests/Greeting_test.cc diff --git a/bin/bazel/cpp-temp/tests/README.md b/bin/bazel/cc-temp/tests/README.md similarity index 100% rename from bin/bazel/cpp-temp/tests/README.md rename to bin/bazel/cc-temp/tests/README.md diff --git a/bin/bazel/cpp-temp/tests/WORKSPACE b/bin/bazel/cc-temp/tests/WORKSPACE similarity index 100% rename from bin/bazel/cpp-temp/tests/WORKSPACE rename to bin/bazel/cc-temp/tests/WORKSPACE diff --git a/bin/bazel/cc_bzl_obj b/bin/bazel/cc_bzl_obj new file mode 100755 index 0000000..4ca0988 --- /dev/null +++ b/bin/bazel/cc_bzl_obj @@ -0,0 +1,35 @@ +#!/bin/bash +# $1 = Project Name + +# Get variables +OBJECT=$1 + +# Which directory? +# This one for now +# MUST be in the directory where the files are going + +# Create object files +# Header +touch $OBJECT.h +echo "#ifndef ${OBJECT}_H +#define ${OBJECT}_H + +class $OBJECT { + public: + $OBJECT(); + ~$OBJECT(); + + private: +}; + +#endif" >> $OBJECT.h + +# Source +touch $OBJECT.cc +echo "#include \"$OBJECT.h\" + +$OBJECT::$OBJECT() { +} + +$OBJECT::~$OBJECT() { +}" >> $OBJECT.cc diff --git a/bin/object_maker b/bin/object_maker index 253d92b..836044a 100755 --- a/bin/object_maker +++ b/bin/object_maker @@ -10,8 +10,8 @@ OBJECT=$1 # Create object files # Header touch $OBJECT.h -echo "#ifndef $OBJECT.H -#define $OBJECT.H +echo "#ifndef ${OBJECT}_H +#define ${OBJECT}_H class $OBJECT { public: diff --git a/git_bzl_cc b/git_bzl_cc index 6818662..719ca9d 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -4,7 +4,7 @@ # Get variables USER=$(git config --global user.name) PROJECT=$1 -TEMP_SOURCE="$HOME/bin/bazel/cpp-temp" +TEMP_SOURCE="$HOME/bin/starter_kit_maker/bin/bazel/cc-temp" # Create and enter git directory mkdir $PROJECT @@ -38,8 +38,8 @@ for item in "$@"; do if [ $COUNT -ne 0 ]; then # Header touch src/lib/$item.h - echo "#ifndef $item.H -#define $item.H + echo "#ifndef ${item}_H +#define ${item}_H class $item { public: From be7716f574e674dcad7311238c76bec4e63599ce Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Sun, 22 Mar 2020 12:06:30 -0700 Subject: [PATCH 11/22] fixed lib name for tests --- bin/bazel/cc-temp/tests/BUILD | 2 +- bin/bazel/cpp_bzl_obj | 35 ----------------------------------- 2 files changed, 1 insertion(+), 36 deletions(-) delete mode 100755 bin/bazel/cpp_bzl_obj diff --git a/bin/bazel/cc-temp/tests/BUILD b/bin/bazel/cc-temp/tests/BUILD index 1ddfa8f..804ff70 100644 --- a/bin/bazel/cc-temp/tests/BUILD +++ b/bin/bazel/cc-temp/tests/BUILD @@ -2,7 +2,7 @@ cc_test( name = "tests", srcs = glob(["**/*.cc"]), deps = [ - "//src/lib:GreetingLib", + "//src/lib:ThisLib", "@googletest//:gtest_main", ], ) diff --git a/bin/bazel/cpp_bzl_obj b/bin/bazel/cpp_bzl_obj deleted file mode 100755 index 923902c..0000000 --- a/bin/bazel/cpp_bzl_obj +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# $1 = Project Name - -# Get variables -OBJECT=$1 - -# Which directory? -# This one for now -# MUST be in the directory where the files are going - -# Create object files -# Header -touch $OBJECT.h -echo "#ifndef $OBJECT.H -#define $OBJECT.H - -class $OBJECT { - public: - $OBJECT(); - ~$OBJECT(); - - private: -}; - -#endif" >> $OBJECT.h - -# Source -touch $OBJECT.cc -echo "#include \"$OBJECT.h\" - -$OBJECT::$OBJECT() { -} - -$OBJECT::~$OBJECT() { -}" >> $OBJECT.cc From 44792c41342f538c089988c2bc2cd7446bd866ce Mon Sep 17 00:00:00 2001 From: Maxx Tepper Date: Mon, 23 Mar 2020 19:12:18 -0700 Subject: [PATCH 12/22] google header style -- need to update obj_maker --- bin/bazel/cpp_bzl_obj | 35 ----------------------------------- git_bzl_cc | 8 +++++--- 2 files changed, 5 insertions(+), 38 deletions(-) delete mode 100755 bin/bazel/cpp_bzl_obj diff --git a/bin/bazel/cpp_bzl_obj b/bin/bazel/cpp_bzl_obj deleted file mode 100755 index 923902c..0000000 --- a/bin/bazel/cpp_bzl_obj +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# $1 = Project Name - -# Get variables -OBJECT=$1 - -# Which directory? -# This one for now -# MUST be in the directory where the files are going - -# Create object files -# Header -touch $OBJECT.h -echo "#ifndef $OBJECT.H -#define $OBJECT.H - -class $OBJECT { - public: - $OBJECT(); - ~$OBJECT(); - - private: -}; - -#endif" >> $OBJECT.h - -# Source -touch $OBJECT.cc -echo "#include \"$OBJECT.h\" - -$OBJECT::$OBJECT() { -} - -$OBJECT::~$OBJECT() { -}" >> $OBJECT.cc diff --git a/git_bzl_cc b/git_bzl_cc index 719ca9d..3b2fe51 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -22,7 +22,8 @@ mkdir tests # Create WORKSPACE touch WORKSPACE -cat "$TEMP_SOURCE/WORKSPACE" > WORKSPACE +echo "# $PROJECT" > WORKSPACE +cat "$TEMP_SOURCE/WORKSPACE" >> WORKSPACE # Create BUILDS touch src/lib/BUILD @@ -38,8 +39,9 @@ for item in "$@"; do if [ $COUNT -ne 0 ]; then # Header touch src/lib/$item.h - echo "#ifndef ${item}_H -#define ${item}_H + HEADER=${PROJECT^^}"_SRC_LIB_"${item^^}"_H_" + echo "#ifndef $HEADER +#define $HEADER class $item { public: From c46cc87a32f3e031e6c5bc35c2a96cc8f96f6735 Mon Sep 17 00:00:00 2001 From: Maxx Tepper Date: Tue, 24 Mar 2020 09:46:30 -0700 Subject: [PATCH 13/22] integrated direnv into projects -- PROJECT is now an env var and used by object maker --- README | 20 ++++++++++++-------- bin/bazel/cc_bzl_obj | 5 +++-- git_bzl_cc | 4 ++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README b/README index 5052795..193fce8 100644 --- a/README +++ b/README @@ -4,14 +4,18 @@ This is not the only way to use this tool, it is simply an example. Instructions: 1. Establish a user bin up to the following: - $ mkdir -p $HOME/bin/starter_kit_maker/bin/bazel -2. Add the following line at the end of $HOME/.bashrc - export PATH="$HOME/bin:$PATH" -3. Create symlink of files in bin - $ ln -s /full-path/git_begin $HOME/bin/. - $ ln -s /full-path/bin/object_maker $HOME/bin/. - $ ln -s /full-path/git_bzl_cc $HOME/bin/. - $ ln -s /full-path/bin/bazel/cc_bzl_obj $HOME/bin/. + $ mkdir -p $HOME/bin/starter_kit_maker/bin/bazel +2. Install packages + $ sudo apt install direnv bazel + *go to bazel getting started and follow instructions +3. Add the following lines at the end of $HOME/.bashrc (if using a different shell, direnv line will be different. Google direnv setup) + export PATH="$HOME/bin:$PATH" + eval "$(direnv hook bash)" +4. Create symlink of files in bin + $ ln -s /full-path/git_begin $HOME/bin/. + $ ln -s /full-path/bin/object_maker $HOME/bin/. + $ ln -s /full-path/git_bzl_cc $HOME/bin/. + $ ln -s /full-path/bin/bazel/cc_bzl_obj $HOME/bin/. Example Usage (no bazel): $ git_begin project_name object0 object1 diff --git a/bin/bazel/cc_bzl_obj b/bin/bazel/cc_bzl_obj index 4ca0988..aa8d36c 100755 --- a/bin/bazel/cc_bzl_obj +++ b/bin/bazel/cc_bzl_obj @@ -11,8 +11,9 @@ OBJECT=$1 # Create object files # Header touch $OBJECT.h -echo "#ifndef ${OBJECT}_H -#define ${OBJECT}_H +HEADER=${PROJECT^^}"_SRC_LIB_"${OBJECT^^}"_H_" +echo "#ifndef $HEADER +#define $HEADER class $OBJECT { public: diff --git a/git_bzl_cc b/git_bzl_cc index 3b2fe51..49cad24 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -10,6 +10,10 @@ TEMP_SOURCE="$HOME/bin/starter_kit_maker/bin/bazel/cc-temp" mkdir $PROJECT cd $PROJECT +# Direnv setup +echo "export PROJECT=${PROJECT}" >> .envrc +direnv allow . + # README touch README echo "This is the README for $PROJECT" >> README From e51466db244b2aec9972ec78260f3f5dcc635416 Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Fri, 27 Mar 2020 10:14:21 -0700 Subject: [PATCH 14/22] added test file maker for objects --- bin/bazel/cc_bzl_obj | 12 ++++++++++++ git_bzl_cc | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/bin/bazel/cc_bzl_obj b/bin/bazel/cc_bzl_obj index aa8d36c..d723cb1 100755 --- a/bin/bazel/cc_bzl_obj +++ b/bin/bazel/cc_bzl_obj @@ -34,3 +34,15 @@ $OBJECT::$OBJECT() { $OBJECT::~$OBJECT() { }" >> $OBJECT.cc + +# Test +touch ${PROJPWD}/tests/${OBJECT}_test.cc +echo "#include \"gtest/gtest.h\" +#include \"src/lib/$OBJECT.h\" + +TEST(${OBJECT}Should, ReturnSomething){ + std::unique_ptr<$OBJECT> ${OBJECT,,} = std::make_unique<$OBJECT>(); + std::string actual = ${OBJECT,,}->DoSomething(); + std::string expected = "Something"; + EXPECT_EQ(expected, actual); +}" >> ${PROJPWD}/tests/${OBJECT}_test.cc diff --git a/git_bzl_cc b/git_bzl_cc index 49cad24..8c006b9 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -12,6 +12,7 @@ cd $PROJECT # Direnv setup echo "export PROJECT=${PROJECT}" >> .envrc +echo "export PROJPWD=${PWD}" >> .envrc direnv allow . # README @@ -37,7 +38,7 @@ cat "$TEMP_SOURCE/src/main/BUILD" > src/main/BUILD touch tests/BUILD cat "$TEMP_SOURCE/tests/BUILD" > tests/BUILD -# Create object files +# Create object instance COUNT=0 for item in "$@"; do if [ $COUNT -ne 0 ]; then @@ -66,6 +67,18 @@ $item::$item() { $item::~$item() { }" >> src/lib/$item.cc + # Test + touch tests/${item}_test.cc + echo "#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 + # Increase Count let COUNT=COUNT+1 else From 0be4b472919209f21896f2f96ebff14424309d15 Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Fri, 27 Mar 2020 10:48:35 -0700 Subject: [PATCH 15/22] added to tests --- bin/bazel/cc_bzl_obj | 3 ++- git_bzl_cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/bazel/cc_bzl_obj b/bin/bazel/cc_bzl_obj index d723cb1..bf518bb 100755 --- a/bin/bazel/cc_bzl_obj +++ b/bin/bazel/cc_bzl_obj @@ -37,7 +37,8 @@ $OBJECT::~$OBJECT() { # Test touch ${PROJPWD}/tests/${OBJECT}_test.cc -echo "#include \"gtest/gtest.h\" +echo "#include +#include \"gtest/gtest.h\" #include \"src/lib/$OBJECT.h\" TEST(${OBJECT}Should, ReturnSomething){ diff --git a/git_bzl_cc b/git_bzl_cc index 8c006b9..c87aaaa 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -69,7 +69,8 @@ $item::~$item() { # Test touch tests/${item}_test.cc - echo "#include \"gtest/gtest.h\" + echo "#include +#include \"gtest/gtest.h\" #include \"src/lib/$item.h\" TEST(${item}Should, ReturnSomething){ From ab932be63850af71a1796ca8cdec79cac0b14650 Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Fri, 27 Mar 2020 11:18:23 -0700 Subject: [PATCH 16/22] .gitignore for bazel* --- git_bzl_cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/git_bzl_cc b/git_bzl_cc index c87aaaa..fdd761b 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -99,14 +99,21 @@ int main(int argc, char** argv) { # 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" From 6b309e035f4cb7725b0ebf1a54f942275f717446 Mon Sep 17 00:00:00 2001 From: Maxx Tepper Date: Fri, 27 Mar 2020 18:02:43 -0700 Subject: [PATCH 17/22] commented out test conditions --- bin/bazel/cc_bzl_obj | 2 ++ git_bzl_cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bin/bazel/cc_bzl_obj b/bin/bazel/cc_bzl_obj index bf518bb..1ac72ec 100755 --- a/bin/bazel/cc_bzl_obj +++ b/bin/bazel/cc_bzl_obj @@ -42,8 +42,10 @@ echo "#include #include \"src/lib/$OBJECT.h\" TEST(${OBJECT}Should, ReturnSomething){ +/* std::unique_ptr<$OBJECT> ${OBJECT,,} = std::make_unique<$OBJECT>(); std::string actual = ${OBJECT,,}->DoSomething(); std::string expected = "Something"; EXPECT_EQ(expected, actual); +*/ }" >> ${PROJPWD}/tests/${OBJECT}_test.cc diff --git a/git_bzl_cc b/git_bzl_cc index fdd761b..d74649c 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -74,10 +74,12 @@ $item::~$item() { #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 # Increase Count From 150c27c787d7bbd1cdd7b6322c2db798bd4429f8 Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Thu, 2 Apr 2020 21:09:49 -0700 Subject: [PATCH 18/22] trying obj chng --- bin/bazel/bzl_obj_chng | 9 +++++++++ bin/bazel/cc_bzl_obj | 5 ++++- git_bzl_cc | 7 +++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 bin/bazel/bzl_obj_chng diff --git a/bin/bazel/bzl_obj_chng b/bin/bazel/bzl_obj_chng new file mode 100644 index 0000000..0f3b23b --- /dev/null +++ b/bin/bazel/bzl_obj_chng @@ -0,0 +1,9 @@ +#!/bin/bash + +# Get variables +OBJECT=$1 +VARS=".vars" + +# Go into VARS, find the input +# And change all instances of +# the input, in all files, and in all directories. diff --git a/bin/bazel/cc_bzl_obj b/bin/bazel/cc_bzl_obj index 1ac72ec..727c6ee 100755 --- a/bin/bazel/cc_bzl_obj +++ b/bin/bazel/cc_bzl_obj @@ -1,8 +1,8 @@ #!/bin/bash -# $1 = Project Name # Get variables OBJECT=$1 +VARS=".vars" # Which directory? # This one for now @@ -49,3 +49,6 @@ TEST(${OBJECT}Should, ReturnSomething){ EXPECT_EQ(expected, actual); */ }" >> ${PROJPWD}/tests/${OBJECT}_test.cc + +# Object vars +echo "$OBJECT" >> $VARS diff --git a/git_bzl_cc b/git_bzl_cc index d74649c..36423f0 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -5,6 +5,7 @@ USER=$(git config --global user.name) PROJECT=$1 TEMP_SOURCE="$HOME/bin/starter_kit_maker/bin/bazel/cc-temp" +VARS=".vars" # Create and enter git directory mkdir $PROJECT @@ -38,6 +39,9 @@ cat "$TEMP_SOURCE/src/main/BUILD" > src/main/BUILD touch tests/BUILD cat "$TEMP_SOURCE/tests/BUILD" > tests/BUILD +# Create vars hidden file +touch .vars + # Create object instance COUNT=0 for item in "$@"; do @@ -82,6 +86,9 @@ TEST(${item}Should, ReturnSomething){ */ }" >> tests/${item}_test.cc + # Object vars + echo "$item" >> $VARS + # Increase Count let COUNT=COUNT+1 else From 6afaac0b041e1bb43ffc29b3cb11f2661568e5db Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Tue, 7 Apr 2020 21:58:38 -0700 Subject: [PATCH 19/22] README updated --- README | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README b/README index 193fce8..c5b4f87 100644 --- a/README +++ b/README @@ -1,16 +1,16 @@ +Starter Kit Maker Created By: maxxtepper -This is not the only way to use this tool, it is simply an example. - Instructions: 1. Establish a user bin up to the following: $ mkdir -p $HOME/bin/starter_kit_maker/bin/bazel -2. Install packages - $ sudo apt install direnv bazel +2. Install direnv + $ sudo apt install direnv + $ echo "eval \"\$(direnv hook bash)\"" >> $HOME/.bashrc +3. Install bazel *go to bazel getting started and follow instructions -3. Add the following lines at the end of $HOME/.bashrc (if using a different shell, direnv line will be different. Google direnv setup) - export PATH="$HOME/bin:$PATH" - eval "$(direnv hook bash)" + $ sudo apt install bazel + $ echo "export PATH=\"\$HOME/bin:\$PATH\"" >> $HOME/.bashrc 4. Create symlink of files in bin $ ln -s /full-path/git_begin $HOME/bin/. $ ln -s /full-path/bin/object_maker $HOME/bin/. From b56c7236ca1b64f160883a20027ea3abdcd062ec Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Tue, 7 Apr 2020 22:02:54 -0700 Subject: [PATCH 20/22] README updated --- README | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README b/README index c5b4f87..144bb41 100644 --- a/README +++ b/README @@ -11,7 +11,10 @@ Instructions: *go to bazel getting started and follow instructions $ sudo apt install bazel $ echo "export PATH=\"\$HOME/bin:\$PATH\"" >> $HOME/.bashrc -4. Create symlink of files in bin +4. Git clone the repo + $ git clone https://github.com/maxxtepper/starter_kit_maker.git + $ cd starter_kit_maker +5. Create symlink of files in bin $ ln -s /full-path/git_begin $HOME/bin/. $ ln -s /full-path/bin/object_maker $HOME/bin/. $ ln -s /full-path/git_bzl_cc $HOME/bin/. From db088d461b98bce4185a7160790fa28c3c91e038 Mon Sep 17 00:00:00 2001 From: maxxtepper Date: Tue, 7 Apr 2020 22:17:36 -0700 Subject: [PATCH 21/22] README updated --- README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README b/README index 144bb41..549ed2e 100644 --- a/README +++ b/README @@ -19,6 +19,10 @@ Instructions: $ ln -s /full-path/bin/object_maker $HOME/bin/. $ ln -s /full-path/git_bzl_cc $HOME/bin/. $ ln -s /full-path/bin/bazel/cc_bzl_obj $HOME/bin/. +6. Create $HOME/.bazelrc + $ Add the following: + build --cxxopt='-std=c++17' + test --cxxopt='-std=c++17' --test_output=all Example Usage (no bazel): $ git_begin project_name object0 object1 From b43f137fbcda7318bc1e34089fc6cdb893294c3c Mon Sep 17 00:00:00 2001 From: Maxx Tepper Date: Tue, 27 Apr 2021 17:49:46 -0700 Subject: [PATCH 22/22] added bin copy step to install -- block same name dir making --- README | 19 +++++++++++-------- git_bzl_cc | 8 ++++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README b/README index 549ed2e..37e9211 100644 --- a/README +++ b/README @@ -2,24 +2,26 @@ Starter Kit Maker Created By: maxxtepper Instructions: -1. Establish a user bin up to the following: - $ mkdir -p $HOME/bin/starter_kit_maker/bin/bazel -2. Install direnv +1. Install direnv $ sudo apt install direnv $ echo "eval \"\$(direnv hook bash)\"" >> $HOME/.bashrc -3. Install bazel +2. Install bazel *go to bazel getting started and follow instructions $ sudo apt install bazel $ echo "export PATH=\"\$HOME/bin:\$PATH\"" >> $HOME/.bashrc -4. Git clone the repo +3. Git clone the repo $ git clone https://github.com/maxxtepper/starter_kit_maker.git $ cd starter_kit_maker -5. Create symlink of files in bin +4. Establish a user bin up to the following: + $ mkdir -p $HOME/bin/starter_kit_maker/bin/bazel/cc-temp +5. Install the contents of the local repo cc-temp into the user bin cc-temp + $ cp -r ./bin/bazel/cc_temp/* $HOME/bin/starter_kit_maker/bin/bazel/cc-temp +6. Create symlink of scripts in bin $ ln -s /full-path/git_begin $HOME/bin/. $ ln -s /full-path/bin/object_maker $HOME/bin/. $ ln -s /full-path/git_bzl_cc $HOME/bin/. $ ln -s /full-path/bin/bazel/cc_bzl_obj $HOME/bin/. -6. Create $HOME/.bazelrc +7. Create $HOME/.bazelrc $ Add the following: build --cxxopt='-std=c++17' test --cxxopt='-std=c++17' --test_output=all @@ -32,4 +34,5 @@ $ git_bzl_cc project_name object0 object1 After git_begin, the next string will be the name of the project, and every string after that will be objects named after the strings themselves -Symlink allows you to edit the scripts in the repo to keep the executable up-to-date +*Symlink allows you to edit/update the scripts in the repo while keeping the executable pointing to it +*Template files in local bin can be edited as needed diff --git a/git_bzl_cc b/git_bzl_cc index 36423f0..362c28f 100755 --- a/git_bzl_cc +++ b/git_bzl_cc @@ -5,9 +5,12 @@ USER=$(git config --global user.name) PROJECT=$1 TEMP_SOURCE="$HOME/bin/starter_kit_maker/bin/bazel/cc-temp" -VARS=".vars" # 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 @@ -39,9 +42,6 @@ cat "$TEMP_SOURCE/src/main/BUILD" > src/main/BUILD touch tests/BUILD cat "$TEMP_SOURCE/tests/BUILD" > tests/BUILD -# Create vars hidden file -touch .vars - # Create object instance COUNT=0 for item in "$@"; do