Skip to content

Commit 2bcff73

Browse files
authored
allow for multiple examples (#33)
* allow for multiple examples * remove old items from .gitignore * remove singular form of "example"
1 parent 9ac719c commit 2bcff73

File tree

14 files changed

+16
-27
lines changed

14 files changed

+16
-27
lines changed

.gitignore

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
/boosty/boost_1_80_0/
2-
/boosty/cmake-bcp/
3-
/boosty/boost_1_80_0.tar.gz
4-
/boosty/example/main
5-
/boosty/extracted/doc/
6-
/boosty/extracted/libs/
7-
/boosty/extracted/boost.png
8-
9-
/example/example
10-
/example/hasher
11-
/example/scratch
12-
131
/bazel-*
142
/.build/
153
/.coverage/

CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.24)
55
project(dd-trace-cpp)
66

77
option(BUILD_COVERAGE "Build code with code coverage profiling instrumentation" OFF)
8-
option(BUILD_EXAMPLE "Build the example program (example/)" OFF)
8+
option(BUILD_HASHER_EXAMPLE "Build the example program examples/hasher" OFF)
99
option(BUILD_TESTING "Build the unit tests (test/)" OFF)
1010
option(SANITIZE "Build with address sanitizer and undefined behavior sanitizer" OFF)
1111
option(FUZZ_W3C_PROPAGATION "Build a fuzzer for W3C propagation" OFF)
@@ -226,6 +226,5 @@ if(BUILD_TESTING)
226226
add_subdirectory(test)
227227
endif()
228228

229-
if(BUILD_EXAMPLE)
230-
add_subdirectory(example)
231-
endif()
229+
# Each example has its own build flag.
230+
add_subdirectory(examples)

bin/check-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22

3-
find src/ example/ test/ -type f \( -name '*.h' -o -name '*.cpp' \) -print0 | \
3+
find src/ examples/ test/ -type f \( -name '*.h' -o -name '*.cpp' \) -print0 | \
44
xargs -0 clang-format-14 --style=file --dry-run -Werror

bin/format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ formatter=clang-format-$version
1414
formatter_options="--style=file -i"
1515

1616
find_sources() {
17-
find src/ example/ test/ fuzz/ -type f \( -name '*.h' -o -name '*.cpp' \) "$@"
17+
find src/ examples/ test/ fuzz/ -type f \( -name '*.h' -o -name '*.cpp' \) "$@"
1818
}
1919

2020
# If the correct version of clang-format is installed, then use it and quit.

bin/example renamed to bin/hasher-example

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,22 @@ cd "$(dirname "$0")"/..
1919

2020
mkdir -p .build
2121
cd .build
22-
cmake .. -DBUILD_EXAMPLE=1
22+
cmake .. -DBUILD_HASHER_EXAMPLE=1
2323
# shellcheck disable=SC2086
2424
make -j "$(nproc)" $verbosity_flags
25+
cd ../
2526

2627
if [ "$build_only" -eq 1 ]; then
2728
exit
2829
fi
2930

30-
trap 'docker compose --project-directory ../example down' INT
31+
trap 'docker compose --project-directory examples/hasher down' INT
3132

32-
echo 'Running example...'
33+
echo 'Running hasher example...'
3334
if [ "$DD_API_KEY" = '' ]; then
3435
>&2 echo "The DD_API_KEY environment variable must be set to a Datadog API key."
3536
exit 1
3637
fi
37-
docker compose --project-directory ../example up --detach --remove-orphans
38-
# docker compose --project-directory ../example logs --follow &
39-
./example/example "$@"
40-
docker compose --project-directory ../example down
41-
# wait
38+
docker compose --project-directory examples/hasher up --detach --remove-orphans
39+
.build/examples/hasher/example "$@"
40+
docker compose --project-directory examples/hasher down

example/console.png

-127 KB
Binary file not shown.

examples/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if (BUILD_HASHER_EXAMPLE)
2+
add_subdirectory(hasher)
3+
endif()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ file or directory encountered.
1010
The program produces a trace of this calculation, where each file encountered
1111
is a span whose duration is the time it took to hash the file.
1212

13-
[../bin/example](../bin/example) builds and runs the example.
13+
[../bin/hasher-example](../bin/hasher-example) builds and runs this example.
1414

1515
![example console usage](console.png)
1616

examples/hasher/console.png

439 KB
Loading

0 commit comments

Comments
 (0)