aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-09-27 07:30:41 +0200
committerSven Gothel <[email protected]>2021-09-27 07:30:41 +0200
commit21a350f106375962c05ee984161edc88e18a195d (patch)
treef399feae6cf0caa697defbb4fd746152c7af9471
parent0ca9b5b4f9716907c72e9c5b8dab6d7a372822df (diff)
Examples: Build using a set of idiomatic names, one recipe for each examples; Add jar install for example/java!
-rw-r--r--examples/CMakeLists.txt29
-rw-r--r--examples/dbt_peripheral00.cpp (renamed from examples/direct_bt_peripheral00/dbt_peripheral00.cpp)0
-rw-r--r--examples/dbt_scanner00.cpp (renamed from examples/direct_bt_scanner00/dbt_scanner00.cpp)0
-rw-r--r--examples/dbt_scanner01.cpp (renamed from examples/direct_bt_scanner01/dbt_scanner01.cpp)0
-rw-r--r--examples/dbt_scanner10.cpp (renamed from examples/direct_bt_scanner10/dbt_scanner10.cpp)0
-rw-r--r--examples/java/CMakeLists.txt30
-rw-r--r--scripts/build.sh1
-rw-r--r--scripts/rebuild.sh1
8 files changed, 34 insertions, 27 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 58d12184..9be670d4 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -3,21 +3,22 @@ include_directories(
${PROJECT_SOURCE_DIR}/api
)
-add_executable (dbt_scanner00 direct_bt_scanner00/dbt_scanner00.cpp)
-target_link_libraries (dbt_scanner00 direct_bt)
-add_dependencies(dbt_scanner00 direct_bt)
-
-add_executable (dbt_scanner01 direct_bt_scanner01/dbt_scanner01.cpp)
-target_link_libraries (dbt_scanner01 direct_bt)
-add_dependencies(dbt_scanner01 direct_bt)
+# These examples use the standard separate compilation
+set( SOURCES_IDIOMATIC_EXAMPLES
+ dbt_scanner00.cpp
+ dbt_scanner01.cpp
+ dbt_scanner10.cpp
+ dbt_peripheral00.cpp
+)
-add_executable (dbt_scanner10 direct_bt_scanner10/dbt_scanner10.cpp)
-target_link_libraries (dbt_scanner10 direct_bt)
-add_dependencies(dbt_scanner10 direct_bt)
+string( REPLACE ".cpp" "" BASENAMES_IDIOMATIC_EXAMPLES "${SOURCES_IDIOMATIC_EXAMPLES}" )
+set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} )
-add_executable (dbt_peripheral00 direct_bt_peripheral00/dbt_peripheral00.cpp)
-target_link_libraries (dbt_peripheral00 direct_bt)
-add_dependencies(dbt_peripheral00 direct_bt)
+foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} )
+ add_executable(${name} ${name}.cpp)
+ target_link_libraries(${name} direct_bt)
+ add_dependencies(${name} direct_bt)
+endforeach()
-install(TARGETS dbt_scanner00 dbt_scanner01 dbt_scanner10 dbt_peripheral00 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+install(TARGETS ${TARGETS_IDIOMATIC_EXAMPLES} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/examples/direct_bt_peripheral00/dbt_peripheral00.cpp b/examples/dbt_peripheral00.cpp
index a722df4e..a722df4e 100644
--- a/examples/direct_bt_peripheral00/dbt_peripheral00.cpp
+++ b/examples/dbt_peripheral00.cpp
diff --git a/examples/direct_bt_scanner00/dbt_scanner00.cpp b/examples/dbt_scanner00.cpp
index 2f340a05..2f340a05 100644
--- a/examples/direct_bt_scanner00/dbt_scanner00.cpp
+++ b/examples/dbt_scanner00.cpp
diff --git a/examples/direct_bt_scanner01/dbt_scanner01.cpp b/examples/dbt_scanner01.cpp
index a719f672..a719f672 100644
--- a/examples/direct_bt_scanner01/dbt_scanner01.cpp
+++ b/examples/dbt_scanner01.cpp
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/dbt_scanner10.cpp
index 857263df..857263df 100644
--- a/examples/direct_bt_scanner10/dbt_scanner10.cpp
+++ b/examples/dbt_scanner10.cpp
diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt
index d35e1c0a..1d1f3786 100644
--- a/examples/java/CMakeLists.txt
+++ b/examples/java/CMakeLists.txt
@@ -2,17 +2,25 @@
find_package(Java REQUIRED)
include(UseJava)
-add_jar(DBTScanner10 SOURCES DBTScanner10.java INCLUDE_JARS direct_bt_jar ENTRY_POINT Notification)
-add_custom_command(TARGET DBTScanner10
- POST_BUILD
- COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/DBTScanner10.dir/DBTScanner10.class" "${CMAKE_CURRENT_BINARY_DIR}"
+# These examples use the standard separate compilation
+set( SOURCES_IDIOMATIC_EXAMPLES
+ DBTScanner10.java
+ DBTPeripheral00.java
)
-add_dependencies(DBTScanner10 direct_bt_jar)
-add_jar(DBTPeripheral00 SOURCES DBTPeripheral00.java INCLUDE_JARS direct_bt_jar ENTRY_POINT Notification)
-add_custom_command(TARGET DBTPeripheral00
- POST_BUILD
- COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/DBTPeripheral00.dir/DBTPeripheral00.class" "${CMAKE_CURRENT_BINARY_DIR}"
-)
-add_dependencies(DBTPeripheral00 direct_bt_jar)
+string( REPLACE ".java" "" BASENAMES_IDIOMATIC_EXAMPLES "${SOURCES_IDIOMATIC_EXAMPLES}" )
+set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} )
+
+string( REPLACE ".java" ".jar" BASENAMES_IDIOMATIC_EXAMPLE_JARS "${SOURCES_IDIOMATIC_EXAMPLES}" )
+set( TARGETS_IDIOMATIC_EXAMPLE_JARS ${BASENAMES_IDIOMATIC_EXAMPLE_JARS} )
+
+foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} )
+ add_jar(${name} SOURCES ${name}.java INCLUDE_JARS direct_bt_jar ENTRY_POINT Notification)
+ add_custom_command(TARGET ${name}
+ POST_BUILD
+ COMMAND cp "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${name}.dir/${name}.class" "${CMAKE_CURRENT_BINARY_DIR}"
+ )
+ add_dependencies(${name} direct_bt_jar)
+ install_jar(${name} DESTINATION ${CMAKE_INSTALL_BINDIR}/java)
+endforeach()
diff --git a/scripts/build.sh b/scripts/build.sh
index 6468ffe1..71c5a49d 100644
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -46,7 +46,6 @@ buildit() {
make -j $CPU_COUNT install test
if [ $? -eq 0 ] ; then
echo "BUILD SUCCESS $bname $archabi"
- cp -a examples/* $rootdir/dist-$archabi/bin
cd $rootdir
return 0
else
diff --git a/scripts/rebuild.sh b/scripts/rebuild.sh
index 06538b16..64c5d682 100644
--- a/scripts/rebuild.sh
+++ b/scripts/rebuild.sh
@@ -29,7 +29,6 @@ buildit() {
make -j $CPU_COUNT install
if [ $? -eq 0 ] ; then
echo "REBUILD SUCCESS $bname $archabi"
- cp -a examples/* $rootdir/dist-$archabi/bin
cd $rootdir
return 0
else