From 8139b85ecab74ea61cef9a383f270c856309b52d Mon Sep 17 00:00:00 2001 From: gretacb Date: Thu, 16 Nov 2017 13:38:05 -0600 Subject: [PATCH 1/7] fix directory move --- scripts/liftoff.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/liftoff.sh b/scripts/liftoff.sh index d899492..ebff04c 100755 --- a/scripts/liftoff.sh +++ b/scripts/liftoff.sh @@ -4,13 +4,14 @@ set -eu # First create new repo on GitHub # Then run "./scripts/liftoff.sh" from within your local hpp-skel root directory +# and will create your new local project repo side by side with node-cpp-skel directory echo "What is the name of your new project? " read name echo "What is the remote repo url for your new project? " read url -mv ../hpp-skel $name +mv ../hpp-skel ../$name rm -rf .git git init From eb6df56cbd99f13a6b095f3176748ba65ed9b80a Mon Sep 17 00:00:00 2001 From: gretacb Date: Thu, 16 Nov 2017 14:00:09 -0600 Subject: [PATCH 2/7] ok this works for real --- scripts/liftoff.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/liftoff.sh b/scripts/liftoff.sh index ebff04c..6cb4d12 100755 --- a/scripts/liftoff.sh +++ b/scripts/liftoff.sh @@ -2,16 +2,18 @@ set -eu -# First create new repo on GitHub +# First create new repo on GitHub and copy the SSH repo url # Then run "./scripts/liftoff.sh" from within your local hpp-skel root directory -# and will create your new local project repo side by side with node-cpp-skel directory +# and will create your new local project repo side by side with hpp-skel directory echo "What is the name of your new project? " read name echo "What is the remote repo url for your new project? " read url -mv ../hpp-skel ../$name +mkdir ../$name +cp -R ../hpp-skel/. ../$name/ +cd ../$name/ rm -rf .git git init From 8b03073ce16f98d05df6cce4871cdc5cb7550a3e Mon Sep 17 00:00:00 2001 From: gretacb Date: Thu, 16 Nov 2017 14:16:21 -0600 Subject: [PATCH 3/7] update docs --- README.md | 10 ++++++---- scripts/liftoff.sh | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 40f6f23..26858aa 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,11 @@ make ``` ## Customize -Easily use this skeleton as a starting off point for your own custom project: +Easily use this skeleton as a starting off point for a _new_ custom project: ``` # Clone hpp-skel locally + git clone git@github.com:mapbox/hpp-skel.git cd hpp-skel/ @@ -60,9 +61,10 @@ cd hpp-skel/ # # This will: # - prompt you for the new name of your project and the new remote repo url -# - automatically rename your local hpp-skel directory to the name of your project -# - create a new branch called "hpp-skel-port" -# - add, commit, and push +# - automatically create a new directory for your new project repo +# - create a new branch called "hpp-skel-port" within your new repo directory +# - add, commit, and push that branch to your new repo + ./scripts/liftoff.sh ``` diff --git a/scripts/liftoff.sh b/scripts/liftoff.sh index 6cb4d12..1a4fa40 100755 --- a/scripts/liftoff.sh +++ b/scripts/liftoff.sh @@ -4,7 +4,7 @@ set -eu # First create new repo on GitHub and copy the SSH repo url # Then run "./scripts/liftoff.sh" from within your local hpp-skel root directory -# and will create your new local project repo side by side with hpp-skel directory +# and it will create your new local project repo side by side with hpp-skel directory echo "What is the name of your new project? " read name From b988e5cf9c8256c63d0c1306d16f6eb13c6e1df0 Mon Sep 17 00:00:00 2001 From: gretacb Date: Thu, 16 Nov 2017 15:19:20 -0600 Subject: [PATCH 4/7] add more customize docs --- README.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/README.md b/README.md index 26858aa..3003573 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ make ## Customize Easily use this skeleton as a starting off point for a _new_ custom project: +### Start new project ``` # Clone hpp-skel locally @@ -69,6 +70,38 @@ cd hpp-skel/ ``` +### Add custom code +Once your project has ported hpp-skel, follow these steps to integrate your own code: + +- Create a dir in `./include` to hold your custom code. See the example code within `/include` for reference. +- Create a module header file (see [hello_world.hpp](https://github.com/mapbox/hpp-skel/blob/master/include/hello_world.hpp)), and `#include` your new method or class. Make sure this file matches the name of the directory you created in the bullet point above. +- Run `make` and see what surprises await on your new journey :boat: +- If it compiles succesfully, congrats :tada: If not, dont fret. Take a breath and read the error message. +- To start putting your header lib to work, setup a test to make sure it is working as expected. + +### Setup tests +Since header-only libraries are _not_ compiled, they require a compiled parent. This is done by using the [`#include`](https://github.com/mapbox/cpp/blob/master/glossary.md#include) keyword. We can use a compiled test file to use your new header, using [Catch](https://github.com/catchorg/Catch2). + +- Create a file in `/test` directory, and add the following. Be sure to update relevant lines with the name of the header you created above: +``` +#include +#define CATCH_CONFIG_MAIN +#include + +TEST_CASE("test_my_header") +{ + // Your test logic here +} +``` +- Fill in the TEST_CASE with relevant [Catch](https://github.com/catchorg/Catch2) logic (see [test.cpp](https://github.com/mapbox/hpp-skel/blob/master/test/test.cpp) for examples). +- Tip: When calling your header method/class, make sure the namespace matches your header. For example +``` +# "hello_world" is the namespace +# "exclaim" is the method +std::string value = hello_world::exclaim("hello"); +``` +- Run `make test` to compile and run your test + ## Benchmarks This skeleton uses [Google Benchmark](https://github.com/google/benchmark) to measure performance, and includes a [couple benchmark tests](https://github.com/mapbox/hpp-skel/blob/master/bench/run.cpp) to get you up and running quickly: - `BM_exlaim()`: Pretty barebone, simply testing string creation From 4ea835f904266327a4fe969ab8588547c2b4c633 Mon Sep 17 00:00:00 2001 From: gretacb Date: Thu, 16 Nov 2017 15:30:17 -0600 Subject: [PATCH 5/7] cleanup a bit --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 3003573..5c91e6a 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ make ``` ## Customize -Easily use this skeleton as a starting off point for a _new_ custom project: +Easily use this skeleton as a starting off point. ### Start new project ``` @@ -73,17 +73,18 @@ cd hpp-skel/ ### Add custom code Once your project has ported hpp-skel, follow these steps to integrate your own code: -- Create a dir in `./include` to hold your custom code. See the example code within `/include` for reference. -- Create a module header file (see [hello_world.hpp](https://github.com/mapbox/hpp-skel/blob/master/include/hello_world.hpp)), and `#include` your new method or class. Make sure this file matches the name of the directory you created in the bullet point above. +- Create a dir in `./include` to hold your custom code. See the example code within [`./include`](https://github.com/mapbox/hpp-skel/tree/master/include) for reference. +- Create a new file within your new directory, and add your custom method or class. +- Create a module header file (see [hello_world.hpp](https://github.com/mapbox/hpp-skel/blob/master/include/hello_world.hpp)), and `#include` your new method or class. Make sure this file matches the name of the directory you created in the first step above. - Run `make` and see what surprises await on your new journey :boat: - If it compiles succesfully, congrats :tada: If not, dont fret. Take a breath and read the error message. - To start putting your header lib to work, setup a test to make sure it is working as expected. ### Setup tests -Since header-only libraries are _not_ compiled, they require a compiled parent. This is done by using the [`#include`](https://github.com/mapbox/cpp/blob/master/glossary.md#include) keyword. We can use a compiled test file to use your new header, using [Catch](https://github.com/catchorg/Catch2). +Since header-only libraries are _not_ compiled, they require a compiled parent. This is done by using the [`#include`](https://github.com/mapbox/cpp/blob/master/glossary.md#include) keyword. We can use a compiled test file to use your new header, using [Catch](https://github.com/catchorg/Catch2) for assertions. -- Create a file in `/test` directory, and add the following. Be sure to update relevant lines with the name of the header you created above: -``` +- Create a file in `/test` directory, and add the following (be sure to update relevant lines with the name of the header you created above): +``` cpp #include #define CATCH_CONFIG_MAIN #include @@ -95,7 +96,7 @@ TEST_CASE("test_my_header") ``` - Fill in the TEST_CASE with relevant [Catch](https://github.com/catchorg/Catch2) logic (see [test.cpp](https://github.com/mapbox/hpp-skel/blob/master/test/test.cpp) for examples). - Tip: When calling your header method/class, make sure the namespace matches your header. For example -``` +``` cpp # "hello_world" is the namespace # "exclaim" is the method std::string value = hello_world::exclaim("hello"); From d31677f4924be4c40420ea2aa9d2e714c7f8af43 Mon Sep 17 00:00:00 2001 From: gretacb Date: Thu, 16 Nov 2017 15:32:57 -0600 Subject: [PATCH 6/7] random cleanup --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5c91e6a..9ef68e7 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,9 @@ TEST_CASE("test_my_header") - Fill in the TEST_CASE with relevant [Catch](https://github.com/catchorg/Catch2) logic (see [test.cpp](https://github.com/mapbox/hpp-skel/blob/master/test/test.cpp) for examples). - Tip: When calling your header method/class, make sure the namespace matches your header. For example ``` cpp -# "hello_world" is the namespace -# "exclaim" is the method +// "hello_world" is the namespace +// "exclaim" is the method + std::string value = hello_world::exclaim("hello"); ``` - Run `make test` to compile and run your test From 6d36dafa51208d7a2e7eb0f3dc362cb460a8d6b0 Mon Sep 17 00:00:00 2001 From: gretacb Date: Thu, 16 Nov 2017 16:37:47 -0600 Subject: [PATCH 7/7] add edit from Dane --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ef68e7..fca043c 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Once your project has ported hpp-skel, follow these steps to integrate your own - To start putting your header lib to work, setup a test to make sure it is working as expected. ### Setup tests -Since header-only libraries are _not_ compiled, they require a compiled parent. This is done by using the [`#include`](https://github.com/mapbox/cpp/blob/master/glossary.md#include) keyword. We can use a compiled test file to use your new header, using [Catch](https://github.com/catchorg/Catch2) for assertions. +Since header-only libraries are _not_ normally compiled themselves, to test them you need to [#include](https://github.com/mapbox/cpp/blob/master/glossary.md#include) them in a `.cpp` file (aka a [translation unit](https://github.com/mapbox/cpp/blob/master/glossary.md#translation-unit)) to compile and run their code. We recommend using [Catch](https://github.com/catchorg/Catch2) to make writing this `.cpp` file easy. - Create a file in `/test` directory, and add the following (be sure to update relevant lines with the name of the header you created above): ``` cpp