diff options
author | Sven Göthel <[email protected]> | 2024-08-09 02:17:26 +0200 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-08-09 02:17:26 +0200 |
commit | 6cecefc62cba98fe81a98d62fa471be39c75c269 (patch) | |
tree | 03a67a6a6ec2762541b21aae27614fd1a356add7 | |
parent | f1a3a29ecdcde3b8bc2a89814ca51dc1e9fe4a33 (diff) |
Align to jaulib 1.3.3: Full cmake-presets usage w/ vscode support update; also use cmake target_{link|compile}_options instead of globalsv3.3.3
Example run scripts were also adopted.
Unit and trial tests passed on amd64 machine.
VSCode(ium) IDE integration manually tested.
30 files changed, 363 insertions, 377 deletions
diff --git a/.vscode/direct_bt.code-workspace_example b/.vscode/direct_bt.code-workspace_example index 4654f998..18a3a640 100644 --- a/.vscode/direct_bt.code-workspace_example +++ b/.vscode/direct_bt.code-workspace_example @@ -29,16 +29,17 @@ // "java.format.settings.profile": "GoogleStyle", "java.codeGeneration.useBlocks": true, "java.inlayHints.parameterNames.enabled": "literals", - "java.configuration.runtimes": [ - { - "name": "JavaSE-11", - "path": "/usr/lib/jvm/java-11-openjdk-amd64", - }, + "java.configuration.runtimes": [ { "name": "JavaSE-17", "path": "/usr/lib/jvm/java-17-openjdk-amd64", "default": true }, + { + "name": "JavaSE-21", + "path": "/opt-linux-x86_64/jdk21", + "default": true + } ], "[cpp]": { "breadcrumbs.showKeys": true, @@ -66,7 +67,8 @@ "ShortcutMenuBar.userButton02Command": "clangd.memoryUsage", "ShortcutMenuBar.userButton03Command": "workbench.action.reloadWindow", "ShortcutMenuBar.userButton04Command": "clangd.restart", - "clang-tidy.buildPath": "${workspaceFolder}/build-vscode", + // "clang-tidy.buildPath": "${workspaceFolder}/build/default", + // "C_Cpp.default.cppStandard": "c++20", }, "extensions": { "recommendations": [ diff --git a/.vscode/settings.json b/.vscode/settings.json index b67bcc69..b726dcfc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,26 +1,26 @@ { - "java.settings.url": "${workspaceFolder}/.settings/org.eclipse.jdt.core.prefs", "files.associations": { "*.hpp": "cpp", "*.cpp": "cpp", "*.cxx": "cpp" }, + "cmake.useCMakePresets": "always", "cmake.configureOnOpen": true, "cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json", "cmake.sourceDirectory": "${workspaceFolder}", - "cmake.buildDirectory": "${workspaceFolder}/build-vscode", "cmake.configureArgs": [ - "-DCMAKE_INSTALL_PREFIX=${workspaceFolder}/dist-vscode", - "-DCMAKE_C_COMPILER=/usr/bin/clang", - "-DCMAKE_CXX_COMPILER=/usr/bin/clang++", - "-DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy;-p;${workspaceFolder}/build-vscode", - "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", - "-DBUILD_TRIAL=ON", - "-DBUILDJAVA=ON" + ], + // "cmake.parallelJobs": 16, + "cmake.buildEnvironment": { + // "CMAKE_BUILD_PARALLEL_LEVEL": "16" + }, + "cmake.buildArgs": [ + "--parallel" ], "clangd.arguments": [ "--background-index", "--project-root=${workspaceFolder}" ], "workbench.editor.labelFormat": "medium", + "C_Cpp.errorSquiggles": "disabled" } diff --git a/CMakeLists.txt b/CMakeLists.txt index 57187dca..f4e62710 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,14 +28,13 @@ endif() JaulibSetup() -if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.clangd) # Fixup clangd w/ absolute path set (direct_bt_clangd_source_args "-isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/include, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/src, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/java_jni/jni, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/java_jni/jni/jau") set (direct_bt_clangd_source_args "${direct_bt_clangd_source_args}, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/include/catch2_jau, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/jaulib/test") set (direct_bt_clangd_source_args "${direct_bt_clangd_source_args}, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/api/include, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/src/direct_bt, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/src/direct_bt/ieee11073, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/java/jni, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/java/jni/direct_bt, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/test/direct_bt, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/test/ieee11073, -isystem, ${CMAKE_CURRENT_SOURCE_DIR}/trial/direct_bt") configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/clangd.in - ${CMAKE_CURRENT_SOURCE_DIR}/.clangd) -endif() + ${CMAKE_CURRENT_BINARY_DIR}/.clangd) +file(COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/.clangd ${CMAKE_CURRENT_SOURCE_DIR}/.clangd) # this is the library version, derived from git tag and revision set (direct_bt_VERSION_MAJOR ${VERSION_MAJOR}) diff --git a/CMakePresets.json b/CMakePresets.json index ed600149..a1d4fea6 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -9,11 +9,11 @@ { "name": "debug", "displayName": "Debug (cc, C++20, java)", - "binaryDir": "${sourceDir}/build/preset-debug", + "binaryDir": "${sourceDir}/build/debug", "cacheVariables": { "CMAKE_CXX_STANDARD": "20", "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_INSTALL_PREFIX": "dist/preset-debug", + "CMAKE_INSTALL_PREFIX": "dist/debug", "JAU_CMAKE_FIX_INSTALL_PREFIX": "ON", "TRY_JAVA": "ON", "USE_LIBCURL": "OFF", @@ -28,19 +28,21 @@ "name": "debug-clang", "inherits": "debug", "displayName": "Debug (clang, clang-tidy, C++20, java)", - "binaryDir": "${sourceDir}/build/preset-debug-clang", + "binaryDir": "${sourceDir}/build/debug-clang", "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "dist/debug-clang", "CMAKE_C_COMPILER": "clang", "CMAKE_CXX_COMPILER": "clang++", - "CMAKE_CXX_CLANG_TIDY": "clang-tidy;-p;${sourceDir}/build/preset-debug-clang" + "CMAKE_CXX_CLANG_TIDY": "clang-tidy;-p;${sourceDir}/build/debug-clang" } }, { "name": "debug-gcc", "inherits": "debug", "displayName": "Debug (gcc, C++20, java)", - "binaryDir": "${sourceDir}/build/preset-debug-gcc", + "binaryDir": "${sourceDir}/build/debug-gcc", "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "dist/debug-gcc", "CMAKE_C_COMPILER": "gcc", "CMAKE_CXX_COMPILER": "g++" } @@ -49,10 +51,10 @@ "name": "release", "inherits": "debug", "displayName": "Release (cc, C++20, java)", - "binaryDir": "${sourceDir}/build/preset-release", + "binaryDir": "${sourceDir}/build/release", "cacheVariables": { "CMAKE_BUILD_TYPE": "Release", - "CMAKE_INSTALL_PREFIX": "dist/preset-release", + "CMAKE_INSTALL_PREFIX": "dist/release", "JAU_CMAKE_FIX_INSTALL_PREFIX": "ON", "USE_LIBUNWIND": "OFF" } @@ -61,22 +63,34 @@ "name": "release-clang", "inherits": "release", "displayName": "Release (clang, clang-tidy, C++20, java)", - "binaryDir": "${sourceDir}/build/preset-release-clang", + "binaryDir": "${sourceDir}/build/release-clang", "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "dist/release-clang", "CMAKE_C_COMPILER": "clang", "CMAKE_CXX_COMPILER": "clang++", - "CMAKE_CXX_CLANG_TIDY": "clang-tidy;-p;${sourceDir}/build/preset-release-clang" + "CMAKE_CXX_CLANG_TIDY": "clang-tidy;-p;${sourceDir}/build/release-clang" } }, { "name": "release-gcc", "inherits": "release", "displayName": "Release (gcc, C++20, java)", - "binaryDir": "${sourceDir}/build/preset-release-gcc", + "binaryDir": "${sourceDir}/build/release-gcc", "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "dist/release-gcc", "CMAKE_C_COMPILER": "gcc", "CMAKE_CXX_COMPILER": "g++" } + }, + { + "name": "default", + "inherits": "debug-clang", + "displayName": "Default (debug-clang)", + "binaryDir": "${sourceDir}/build/default", + "cacheVariables": { + "CMAKE_INSTALL_PREFIX": "dist/default", + "CMAKE_CXX_CLANG_TIDY": "clang-tidy;-p;${sourceDir}/build/default" + } } ], "buildPresets": [ @@ -85,24 +99,28 @@ "configurePreset": "debug" }, { - "name": "debug-gcc", - "configurePreset": "debug-gcc" - }, - { "name": "debug-clang", "configurePreset": "debug-clang" }, { + "name": "debug-gcc", + "configurePreset": "debug-gcc" + }, + { "name": "release", "configurePreset": "release" }, { + "name": "release-clang", + "configurePreset": "release-clang" + }, + { "name": "release-gcc", "configurePreset": "release-gcc" }, { - "name": "release-clang", - "configurePreset": "release-clang" + "name": "default", + "configurePreset": "default" } ], "testPresets": [ @@ -113,14 +131,14 @@ "execution": {"noTestsAction": "error", "stopOnFailure": true} }, { - "name": "debug-gcc", - "configurePreset": "debug-gcc", + "name": "debug-clang", + "configurePreset": "debug-clang", "output": {"outputOnFailure": true}, "execution": {"noTestsAction": "error", "stopOnFailure": true} }, { - "name": "debug-clang", - "configurePreset": "debug-clang", + "name": "debug-gcc", + "configurePreset": "debug-gcc", "output": {"outputOnFailure": true}, "execution": {"noTestsAction": "error", "stopOnFailure": true} }, @@ -131,14 +149,20 @@ "execution": {"noTestsAction": "error", "stopOnFailure": true} }, { + "name": "release-clang", + "configurePreset": "release-clang", + "output": {"outputOnFailure": true}, + "execution": {"noTestsAction": "error", "stopOnFailure": true} + }, + { "name": "release-gcc", "configurePreset": "release-gcc", "output": {"outputOnFailure": true}, "execution": {"noTestsAction": "error", "stopOnFailure": true} }, { - "name": "release-clang", - "configurePreset": "release-clang", + "name": "default", + "configurePreset": "default", "output": {"outputOnFailure": true}, "execution": {"noTestsAction": "error", "stopOnFailure": true} } @@ -316,30 +316,48 @@ Following debug presets are defined in `CMakePresets.json` - default compiler - C++20 - debug enabled + - disabled `clang-tidy` - java (if available) - libunwind enabled - no: libcurl - testing on - testing with 2 bluetooth trial on - testing with sudo off -- `debug-gcc` - - inherits from `debug` - - compiler: `gcc` - - disabled `clang-tidy` + - binary-dir `build/debug` + - install-dir `dist/debug` - `debug-clang` - inherits from `debug` - compiler: `clang` - enabled `clang-tidy` + - binary-dir `build/debug-clang` + - install-dir `dist/debug-clang` +- `debug-gcc` + - inherits from `debug` + - compiler: `gcc` + - disabled `clang-tidy` + - binary-dir `build/debug-gcc` + - install-dir `dist/debug-gcc` - `release` - inherits from `debug` - debug disabled - - libunwind disabled -- `release-gcc` - - compiler: `gcc` - disabled `clang-tidy` + - libunwind disabled + - binary-dir `build/release` + - install-dir `dist/release` - `release-clang` - compiler: `clang` - enabled `clang-tidy` + - binary-dir `build/release-clang` + - install-dir `dist/release-clang` +- `release-gcc` + - compiler: `gcc` + - disabled `clang-tidy` + - binary-dir `build/release-gcc` + - install-dir `dist/release-gcc` +- **`default`** + - inherits from `debug-clang` + - binary-dir `build/default` + - install-dir `dist/default` All presets enable [full unit testing](README.md#unit_testing) including actual Bluetooth trials, i.e. require two adapter to pass. @@ -352,6 +370,8 @@ cmake --build --preset release-gcc --parallel cmake --build --preset release-gcc --target test install doc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +You may utilize `scripts/build-preset.sh` for an initial build, install and test workflow. + <a name="cmake_presets_hardcoded"></a> #### CMake Build via Hardcoded Presets @@ -422,8 +442,19 @@ The following issues are known and are under investigation: - *BlueZ* is not sending us all new key information under legacy security (SC 0) using at least one BT5 adapter - This is mitigated by *BTAdapter*'s *smp_watchdog*, leading to a retrial visible as *SMP Timeout* +#### Build Scripts +Build scripts use the recommended [cmake presets](README.md#cmake_presets_optional), +supported via e.g. `scripts/build-preset.sh`. + +- `scripts/build-preset.sh` .. initial build incl. install and unit testing using [presets](README.md#cmake_presets_optional) +- `scripts/rebuild-preset.sh` .. rebuild using [presets](README.md#cmake_presets_optional) +- `scripts/build-preset-cross.sh` .. [cross-build](#cross-build) using [presets](README.md#cmake_presets_optional) +- `scripts/rebuild-preset-cross.sh` .. [cross-build](#cross-build) using [presets](README.md#cmake_presets_optional) +- `scripts/test_java.sh` .. invoke a java unit test +- `scripts/test_exe_template.sh` .. invoke the symlink'ed files to invoke native unit tests + ### Cross Build -Also provided is a [cross-build script](https://jausoft.com/cgit/direct_bt.git/tree/scripts/build-cross.sh) +Also provided is a [cross-build script](https://jausoft.com/cgit/direct_bt.git/tree/scripts/build-preset-cross.sh) using chroot into a target system using [QEMU User space emulation](https://qemu-project.gitlab.io/qemu/user/main.html) and [Linux kernel binfmt_misc](https://wiki.debian.org/QemuUserEmulation) to run on other architectures than the host. @@ -492,10 +523,10 @@ vi ../direct_bt.code-workspace ~~~~~~~~~~~~~ Then you can open it via `File . Open Workspace from File...` menu item. - All listed extensions are referenced in this workspace file to be installed via the IDE -- The [local settings.json](.vscode/settings.json) has `clang-tidy` enabled - - If using `clang-tidy` is too slow, just remove it from the settings file. - - `clangd` will still contain a good portion of `clang-tidy` checks - +- Select one of the [CMake Presets](README.md#cmake_presets_optional) for + - Configuration + - Build + - Test ## Support & Sponsorship diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9fb8478c..a75dbee3 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,6 +11,8 @@ set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} ) foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} ) add_executable(${name} ${name}.cpp) + target_compile_options(${name} PUBLIC ${direct_bt_CXX_FLAGS}) + target_link_options(${name} PUBLIC ${direct_bt_EXE_LINKER_FLAGS}) target_link_libraries(${name} direct_bt) add_dependencies(${name} direct_bt) endforeach() diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt index 2b882345..8c4c775d 100644 --- a/examples/java/CMakeLists.txt +++ b/examples/java/CMakeLists.txt @@ -16,6 +16,7 @@ string( REPLACE ".java" ".jar" BASENAMES_IDIOMATIC_EXAMPLE_JARS "${SOURCES_IDIOM set( TARGETS_IDIOMATIC_EXAMPLE_JARS ${BASENAMES_IDIOMATIC_EXAMPLE_JARS} ) foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} ) + set(CMAKE_JAVA_COMPILE_FLAGS ${direct_bt_JAVA_COMPILE_FLAGS}) add_jar(${name} SOURCES ${name}.java INCLUDE_JARS direct_bt_jar ENTRY_POINT Notification) add_custom_command(TARGET ${name} POST_BUILD diff --git a/jaulib b/jaulib -Subproject bc2c32ecb086c76c4544b2a7c080cdf49cece4a +Subproject 3ff5c4f596ce110a1e472ba1c2b1e72d07d2cd1 diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 1d6783d6..c64f630e 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -1,11 +1,10 @@ # java/CMakeLists.txt -set(CMAKE_JNI_TARGET TRUE) - set(direct_bt_jar_file ${CMAKE_CURRENT_BINARY_DIR}/direct_bt.jar CACHE FILEPATH "direct_bt jar file" FORCE) +set(CMAKE_JNI_TARGET TRUE) file(GLOB_RECURSE JAVA_SOURCES "*.java") - +set(CMAKE_JAVA_COMPILE_FLAGS ${direct_bt_JAVA_COMPILE_FLAGS}) add_jar(direct_bt_jar ${JAVA_SOURCES} ${PROJECT_SOURCE_DIR}/jaulib/java_base/org/jau/util/BasicTypes.java diff --git a/java/jni/direct_bt/CMakeLists.txt b/java/jni/direct_bt/CMakeLists.txt index 3f4e3d4a..04c99ad2 100644 --- a/java/jni/direct_bt/CMakeLists.txt +++ b/java/jni/direct_bt/CMakeLists.txt @@ -43,6 +43,8 @@ set (direct_bt_JNI_SRCS set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed") add_library (javadirect_bt SHARED ${direct_bt_JNI_SRCS}) +target_compile_options(javadirect_bt PUBLIC ${direct_bt_CXX_FLAGS}) +target_link_options(javadirect_bt PUBLIC ${direct_bt_SHARED_LINKER_FLAGS}) target_link_libraries(javadirect_bt ${JNI_LIBRARIES} direct_bt) if(USE_STRIP) diff --git a/scripts/build-clang.sh b/scripts/build-clang.sh deleted file mode 100644 index d0a77395..00000000 --- a/scripts/build-clang.sh +++ /dev/null @@ -1,80 +0,0 @@ -#! /bin/sh - -sdir=`dirname $(readlink -f $0)` -rootdir=`dirname $sdir` -bname=`basename $0 .sh` - -. $rootdir/jaulib/scripts/setup-machine-arch.sh - -tripleid="$os_name-$archabi-clang" - -logfile=$rootdir/$bname-$tripleid.log -rm -f $logfile - -CPU_COUNT=`getconf _NPROCESSORS_ONLN` - -# run as root 'dpkg-reconfigure locales' enable 'en_US.UTF-8' -# perhaps run as root 'update-locale LC_MEASUREMENT=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8' -export LC_MEASUREMENT=en_US.UTF-8 -export LC_ALL=en_US.UTF-8 -export LANG=en_US.UTF-8 - -buildit() { - if [ -z "$JAVA_HOME" -o ! -e "$JAVA_HOME" ] ; then - echo "WARNING: JAVA_HOME $JAVA_HOME does not exist" - else - echo JAVA_HOME $JAVA_HOME - fi - echo rootdir $rootdir - echo logfile $logfile - echo CPU_COUNT $CPU_COUNT - - dist_dir="dist-$tripleid" - build_dir="build-$tripleid" - echo dist_dir $dist_dir - echo build_dir $build_dir - - if [ -x /usr/bin/time ] ; then - time_cmd="time" - echo "time command available: ${time_cmd}" - else - time_cmd="" - echo "time command not available" - fi - - cd $rootdir - rm -rf $dist_dir - mkdir -p $dist_dir - rm -rf $build_dir - mkdir -p $build_dir - cd $build_dir - # CLANG_ARGS="-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++" - CLANG_ARGS="-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy;-p;$rootdir/$build_dir" - CXX_ARGS="-DCMAKE_CXX_STANDARD=20" - - cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DUSE_LIBUNWIND=ON .. - - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON -DUSE_LIBUNWIND=ON .. - - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DUSE_STRIP=OFF .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DUSE_STRIP=ON -DJAVAC_DEBUG_ARGS="none" .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DGPROF=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DPERF_ANALYSIS=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON -DINSTRUMENTATION=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON -DINSTRUMENTATION_UNDEFINED=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON -DINSTRUMENTATION_THREAD=ON .. - ${time_cmd} make -j $CPU_COUNT install - if [ $? -eq 0 ] ; then - echo "BUILD SUCCESS $bname $tripleid" - cd $rootdir - return 0 - else - echo "BUILD FAILURE $bname $tripleid" - cd $rootdir - return 1 - fi -} - -buildit 2>&1 | tee $logfile diff --git a/scripts/build-doc.sh b/scripts/build-doc.sh deleted file mode 100755 index 4d4201ae..00000000 --- a/scripts/build-doc.sh +++ /dev/null @@ -1,57 +0,0 @@ -#! /bin/sh - -sdir=`dirname $(readlink -f $0)` -rootdir=`dirname $sdir` -bname=`basename $0 .sh` -logfile=$bname.log -rm -f $logfile - -. $rootdir/jaulib/scripts/setup-machine-arch.sh - -if [ -e /usr/lib/jvm/java-17-openjdk-$archabi ] ; then - export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-$archabi -elif [ -e /usr/lib/jvm/java-11-openjdk-$archabi ] ; then - export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-$archabi -fi -if [ ! -e $JAVA_HOME ] ; then - echo $JAVA_HOME does not exist - exit 1 -fi - -CPU_COUNT=`getconf _NPROCESSORS_ONLN` - -# run as root 'dpkg-reconfigure locales' enable 'en_US.UTF-8' -# perhaps run as root 'update-locale LC_MEASUREMENT=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8' -export LC_MEASUREMENT=en_US.UTF-8 -export LC_ALL=en_US.UTF-8 -export LANG=en_US.UTF-8 - -buildit() { - echo rootdir $rootdir - echo logfile $logfile - echo CPU_COUNT $CPU_COUNT - - cd $rootdir - rm -rf dist-$archabi - mkdir -p dist-$archabi/bin - rm -rf build-$archabi - mkdir -p build-$archabi - cd build-$archabi - # CLANG_ARGS="-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++" - cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON .. - # cmake $CLANG_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/dist-$archabi -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON .. - make -j $CPU_COUNT doc - if [ $? -eq 0 ] ; then - echo "BUILD SUCCESS $bname $archabi" - rm -f $rootdir/documentation.tar.xz - tar caf $rootdir/documentation.tar.xz documentation - cd $rootdir - return 0 - else - echo "BUILD FAILURE $bname $archabi" - cd $rootdir - return 1 - fi -} - -buildit 2>&1 | tee $logfile diff --git a/scripts/build-cross.sh b/scripts/build-preset-cross.sh index efae547e..2ec2dfa6 100755 --- a/scripts/build-cross.sh +++ b/scripts/build-preset-cross.sh @@ -3,11 +3,11 @@ # # sudo mkdir -p /mnt/arm64 # sudo mount /data/diskimages/RaspiArm64LightDev-1.3-rw-deb11-arm64-litexdev.root-ext4.img /mnt/arm64 -# scripts/build-cross.sh /mnt/arm64 +# scripts/build-preset-cross.sh /mnt/arm64 debug-clang # # sudo mkdir -p /mnt/arm32 # sudo mount /data/diskimages/RaspiArm32LightDev-1.2-rw-deb10-armhf-litexdev.root-ext4.img /mnt/arm32 -# scripts/build-cross.sh /mnt/arm32 +# scripts/build-preset-cross.sh /mnt/arm32 debug-clang # sdir=`dirname $(readlink -f $0)` @@ -20,12 +20,14 @@ echo parentdir ${parentdir} export ROOTFS_DIR=$1 shift 1 +export preset_name=$1 +shift 1 -if [ -z "${ROOTFS_DIR}" ]; then - echo Usage "$0 <rootfs-dir>" +if [ -z "${ROOTFS_DIR}" -o -z "${preset_name}" ]; then + echo Usage "$0 <rootfs-dir> <preset_name-name>" exit 1 fi ${sdir}/on_chroot.sh ${ROOTFS_DIR} << EOF - sh ${sdir}/build.sh + sh ${sdir}/build-preset.sh ${preset_name} EOF diff --git a/scripts/build-preset.sh b/scripts/build-preset.sh new file mode 100755 index 00000000..c4b3f8de --- /dev/null +++ b/scripts/build-preset.sh @@ -0,0 +1,73 @@ +#! /bin/sh + +sdir=`dirname $(readlink -f $0)` +rootdir=`dirname $sdir` +bname=`basename $0 .sh` + +. $rootdir/jaulib/scripts/setup-machine-arch.sh + +tripleid="$os_name-$archabi" + +if [ ! -z "$1" ] ; then + preset_name=$1 + shift 1 +else + echo "ERROR: No preset passed as 1st argument, use one of:" + cmake --list-presets + return 1 +fi + +logfile=$rootdir/${bname}-${preset_name}-${tripleid}.log +rm -f $logfile + +CPU_COUNT=`getconf _NPROCESSORS_ONLN` + +# run as root 'dpkg-reconfigure locales' enable 'en_US.UTF-8' +# perhaps run as root 'update-locale LC_MEASUREMENT=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8' +export LC_MEASUREMENT=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 + +buildit() { + if [ -z "$JAVA_HOME" -o ! -e "$JAVA_HOME" ] ; then + echo "WARNING: JAVA_HOME $JAVA_HOME does not exist" + else + echo JAVA_HOME $JAVA_HOME + fi + echo rootdir $rootdir + echo logfile $logfile + echo CPU_COUNT $CPU_COUNT + + dist_dir="dist/${preset_name}-${tripleid}" + build_dir="build/${preset_name}" + echo dist_dir $dist_dir + echo build_dir $build_dir + + if [ -x /usr/bin/time ] ; then + time_cmd="time" + echo "time command available: ${time_cmd}" + else + time_cmd="" + echo "time command not available" + fi + + cd $rootdir + rm -rf $dist_dir dist/${preset_name} + rm -rf $build_dir + mkdir -p $build_dir + + cmake --preset ${preset_name} + + # ${time_cmd} cmake --build --preset ${preset_name} --target test install doc_jau --parallel + # ${time_cmd} cmake --build --preset ${preset_name} --parallel + ${time_cmd} cmake --build --preset ${preset_name} --target install --parallel + if [ $? -eq 0 ] ; then + echo "BUILD SUCCESS $bname $tripleid" + return 0 + else + echo "BUILD FAILURE $bname $tripleid" + return 1 + fi +} + +buildit 2>&1 | tee $logfile diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100644 index 86e3dc33..00000000 --- a/scripts/build.sh +++ /dev/null @@ -1,80 +0,0 @@ -#! /bin/sh - -sdir=`dirname $(readlink -f $0)` -rootdir=`dirname $sdir` -bname=`basename $0 .sh` - -. $rootdir/jaulib/scripts/setup-machine-arch.sh - -tripleid="$os_name-$archabi-gcc" - -logfile=$rootdir/$bname-$tripleid.log -rm -f $logfile - -CPU_COUNT=`getconf _NPROCESSORS_ONLN` - -# run as root 'dpkg-reconfigure locales' enable 'en_US.UTF-8' -# perhaps run as root 'update-locale LC_MEASUREMENT=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8' -export LC_MEASUREMENT=en_US.UTF-8 -export LC_ALL=en_US.UTF-8 -export LANG=en_US.UTF-8 - -buildit() { - if [ -z "$JAVA_HOME" -o ! -e "$JAVA_HOME" ] ; then - echo "WARNING: JAVA_HOME $JAVA_HOME does not exist" - else - echo JAVA_HOME $JAVA_HOME - fi - echo rootdir $rootdir - echo logfile $logfile - echo CPU_COUNT $CPU_COUNT - - dist_dir="dist-$tripleid" - build_dir="build-$tripleid" - echo dist_dir $dist_dir - echo build_dir $build_dir - - if [ -x /usr/bin/time ] ; then - time_cmd="time" - echo "time command available: ${time_cmd}" - else - time_cmd="" - echo "time command not available" - fi - - cd $rootdir - rm -rf $dist_dir - mkdir -p $dist_dir - rm -rf $build_dir - mkdir -p $build_dir - cd $build_dir - # CLANG_ARGS="-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++" - # CLANG_ARGS="-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy;-p;$rootdir/$build_dir" - CXX_ARGS="-DCMAKE_CXX_STANDARD=20" - - cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DUSE_LIBUNWIND=ON .. - - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON -DUSE_LIBUNWIND=ON .. - - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DUSE_STRIP=OFF .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DUSE_STRIP=ON -DJAVAC_DEBUG_ARGS="none" .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DGPROF=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DPERF_ANALYSIS=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON -DINSTRUMENTATION=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON -DINSTRUMENTATION_UNDEFINED=ON .. - # cmake $CLANG_ARGS $CXX_ARGS -DCMAKE_INSTALL_PREFIX=$rootdir/$dist_dir -DBUILDJAVA=ON -DBUILDEXAMPLES=ON -DBUILD_TRIAL=ON -DDEBUG=ON -DINSTRUMENTATION_THREAD=ON .. - ${time_cmd} make -j $CPU_COUNT install - if [ $? -eq 0 ] ; then - echo "BUILD SUCCESS $bname $tripleid" - cd $rootdir - return 0 - else - echo "BUILD FAILURE $bname $tripleid" - cd $rootdir - return 1 - fi -} - -buildit 2>&1 | tee $logfile diff --git a/scripts/rebuild-doc.sh b/scripts/rebuild-doc.sh deleted file mode 100755 index fe0399a8..00000000 --- a/scripts/rebuild-doc.sh +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/sh - -sdir=`dirname $(readlink -f $0)` -rootdir=`dirname $sdir` -bname=`basename $0 .sh` - -build_dir=$1 - -if [ -z "$build_dir" ] ; then - echo "Pass build directory as first argument" - exit 1 -fi - -logfile=$rootdir/$bname.log -rm -f $logfile - -# run 'dpkg-reconfigure locales' enable 'en_US.UTF-8' -export LANG=en_US.UTF-8 -export LC_MEASUREMENT=en_US.UTF-8 - -buildit() { - echo rootdir $rootdir - echo logfile $logfile - - echo build_dir $build_dir - - cd $rootdir/$build_dir - rm -rf documentation - cmake --build . --target doc --parallel - if [ $? -eq 0 ] ; then - echo "REBUILD SUCCESS $bname" - rm -f $rootdir/documentation.tar.xz - tar caf $rootdir/documentation.tar.xz documentation - cd $rootdir - return 0 - else - echo "REBUILD FAILURE $bname" - cd $rootdir - return 1 - fi -} - -buildit 2>&1 | tee $logfile - diff --git a/scripts/rebuild-cross.sh b/scripts/rebuild-preset-cross.sh index a28dbaab..fa6b6a5a 100755 --- a/scripts/rebuild-cross.sh +++ b/scripts/rebuild-preset-cross.sh @@ -3,11 +3,11 @@ # # sudo mkdir -p /mnt/arm64 # sudo mount /data/diskimages/RaspiArm64LightDev-1.2-rw-deb11-arm64-litexdev.root-ext4.img /mnt/arm64 -# scripts/build-cross.sh /mnt/arm64 +# scripts/build-preset-cross.sh /mnt/arm64 debug-clang # # sudo mkdir -p /mnt/arm32 # sudo mount /data/diskimages/RaspiArm32LightDev-1.2-rw-deb10-armhf-litexdev.root-ext4.img /mnt/arm32 -# scripts/build-cross.sh /mnt/arm32 +# scripts/build-preset-cross.sh /mnt/arm32 debug-clang # sdir=`dirname $(readlink -f $0)` @@ -20,12 +20,15 @@ echo parentdir ${parentdir} export ROOTFS_DIR=$1 shift 1 +export preset_name=$1 +shift 1 -if [ -z "${ROOTFS_DIR}" ]; then - echo Usage "$0 <rootfs-dir>" +if [ -z "${ROOTFS_DIR}" -o -z "${preset_name}" ]; then + echo Usage "$0 <rootfs-dir> <preset_name-name>" exit 1 fi ${sdir}/on_chroot.sh ${ROOTFS_DIR} << EOF - sh ${sdir}/rebuild.sh + sh ${sdir}/rebuild-preset.sh ${preset_name} EOF + diff --git a/scripts/rebuild.sh b/scripts/rebuild-preset-doc.sh index 316ae733..7c7193ca 100644..100755 --- a/scripts/rebuild.sh +++ b/scripts/rebuild-preset-doc.sh @@ -6,16 +6,27 @@ bname=`basename $0 .sh` . $rootdir/jaulib/scripts/setup-machine-arch.sh -tripleid="$os_name-$archabi-gcc" +tripleid="$os_name-$archabi" -logfile=$rootdir/$bname-$tripleid.log +if [ ! -z "$1" ] ; then + preset_name=$1 + shift 1 +else + echo "ERROR: No preset passed as 1st argument, use one of:" + cmake --list-presets + return 1 +fi + +logfile=$rootdir/${bname}-${preset_name}-${tripleid}.log rm -f $logfile CPU_COUNT=`getconf _NPROCESSORS_ONLN` -# run 'dpkg-reconfigure locales' enable 'en_US.UTF-8' -export LANG=en_US.UTF-8 +# run as root 'dpkg-reconfigure locales' enable 'en_US.UTF-8' +# perhaps run as root 'update-locale LC_MEASUREMENT=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8' export LC_MEASUREMENT=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 buildit() { if [ -z "$JAVA_HOME" -o ! -e "$JAVA_HOME" ] ; then @@ -27,8 +38,8 @@ buildit() { echo logfile $logfile echo CPU_COUNT $CPU_COUNT - dist_dir="dist-$tripleid" - build_dir="build-$tripleid" + dist_dir="dist/${preset_name}-${tripleid}" + build_dir="build/${preset_name}" echo dist_dir $dist_dir echo build_dir $build_dir @@ -40,18 +51,20 @@ buildit() { echo "time command not available" fi - cd $rootdir/$build_dir - ${time_cmd} make -j $CPU_COUNT install + cd $rootdir + + ${time_cmd} cmake --build --preset ${preset_name} --target doc --parallel if [ $? -eq 0 ] ; then - echo "REBUILD SUCCESS $bname $os_name $archabi" + echo "REBUILD SUCCESS $bname $tripleid" + cd ${build_dir} + rm -f $rootdir/documentation.tar.xz + tar caf $rootdir/documentation.tar.xz documentation cd $rootdir return 0 else - echo "REBUILD FAILURE $bname $os_name $archabi" - cd $rootdir + echo "REBUILD FAILURE $bname $tripleid" return 1 fi } buildit 2>&1 | tee $logfile - diff --git a/scripts/rebuild-clang.sh b/scripts/rebuild-preset.sh index 40704647..b2503670 100644..100755 --- a/scripts/rebuild-clang.sh +++ b/scripts/rebuild-preset.sh @@ -6,16 +6,27 @@ bname=`basename $0 .sh` . $rootdir/jaulib/scripts/setup-machine-arch.sh -tripleid="$os_name-$archabi-clang" +tripleid="$os_name-$archabi" -logfile=$rootdir/$bname-$tripleid.log +if [ ! -z "$1" ] ; then + preset_name=$1 + shift 1 +else + echo "ERROR: No preset passed as 1st argument, use one of:" + cmake --list-presets + return 1 +fi + +logfile=$rootdir/${bname}-${preset_name}-${tripleid}.log rm -f $logfile CPU_COUNT=`getconf _NPROCESSORS_ONLN` -# run 'dpkg-reconfigure locales' enable 'en_US.UTF-8' -export LANG=en_US.UTF-8 +# run as root 'dpkg-reconfigure locales' enable 'en_US.UTF-8' +# perhaps run as root 'update-locale LC_MEASUREMENT=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8' export LC_MEASUREMENT=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 +export LANG=en_US.UTF-8 buildit() { if [ -z "$JAVA_HOME" -o ! -e "$JAVA_HOME" ] ; then @@ -27,8 +38,8 @@ buildit() { echo logfile $logfile echo CPU_COUNT $CPU_COUNT - dist_dir="dist-$tripleid" - build_dir="build-$tripleid" + dist_dir="dist/${preset_name}-${tripleid}" + build_dir="build/${preset_name}" echo dist_dir $dist_dir echo build_dir $build_dir @@ -40,18 +51,16 @@ buildit() { echo "time command not available" fi - cd $rootdir/$build_dir - ${time_cmd} make -j $CPU_COUNT install + cd $rootdir + + ${time_cmd} cmake --build --preset ${preset_name} --target install --parallel if [ $? -eq 0 ] ; then - echo "REBUILD SUCCESS $bname $os_name $archabi" - cd $rootdir + echo "REBUILD SUCCESS $bname $tripleid" return 0 else - echo "REBUILD FAILURE $bname $os_name $archabi" - cd $rootdir + echo "REBUILD FAILURE $bname $tripleid" return 1 fi } buildit 2>&1 | tee $logfile - diff --git a/scripts/run-java-example-simple.sh b/scripts/run-java-example-simple.sh index 35acec51..382a209b 100755 --- a/scripts/run-java-example-simple.sh +++ b/scripts/run-java-example-simple.sh @@ -8,14 +8,32 @@ sdir=`dirname $(readlink -f $0)` rootdir=`dirname $sdir` bname=`basename $0 .sh` +. $rootdir/jaulib/scripts/setup-machine-arch.sh "-quiet" + +tripleid="$os_name-$archabi" + +if [ ! -z "$1" ] ; then + preset_name=$1 + shift 1 +else + echo "ERROR: No preset passed as 1st argument, use one of:" + cmake --list-presets + exit 1 +fi + +dist_dir="$rootdir/dist/${preset_name}-${tripleid}" +build_dir="$rootdir/build/${preset_name}" +echo dist_dir $dist_dir +echo build_dir $build_dir + exename=`echo $bname | sed 's/^run-//g'` -if [ ! -e lib/java/direct_bt.jar -o ! -e bin/java/${exename}.jar -o ! -e lib/libdirect_bt.so ] ; then - echo run from dist directory +if [ ! -e $dist_dir/lib/java/direct_bt.jar -o ! -e $dist_dir/bin/java/${exename}.jar -o ! -e $dist_dir/lib/libdirect_bt.so ] ; then + echo "dist-dir incomplete: $dist_dir" exit 1 fi -logbasename=~/$bname +logbasename=~/${bname}-${preset_name}-${tripleid} logfile=$logbasename.log rm -f $logfile diff --git a/scripts/run-java-example.sh b/scripts/run-java-example.sh index 2a002600..01ca64cb 100755 --- a/scripts/run-java-example.sh +++ b/scripts/run-java-example.sh @@ -2,6 +2,7 @@ # Script arguments in order: # +# <preset-name> One of CMakePresets.txt, see `cmake --list-presets` # [-setcap] Optional 1st argument to use setcap, see below # [-root] Optional 1st argument to use sudo, see below # [-log <filename>] Optional argument to define logfile @@ -31,13 +32,24 @@ bname=`basename $0 .sh` . $rootdir/jaulib/scripts/setup-machine-arch.sh "-quiet" -dist_dir=$rootdir/"dist-$os_name-$archabi" -build_dir=$rootdir/"build-$os_name-$archabi" +tripleid="$os_name-$archabi" + +if [ ! -z "$1" ] ; then + preset_name=$1 + shift 1 +else + echo "ERROR: No preset passed as 1st argument, use one of:" + cmake --list-presets + exit 1 +fi + +dist_dir="$rootdir/dist/${preset_name}-${tripleid}" +build_dir="$rootdir/build/${preset_name}" echo dist_dir $dist_dir echo build_dir $build_dir -if [ ! -e $dist_dir/lib/java/direct_bt-test.jar ] ; then - echo "test exe $dist_dir/lib/java/direct_bt-test.jar not existing" +if [ ! -e $dist_dir/lib/java/direct_bt.jar -o ! -e $dist_dir/lib/libdirect_bt.so -o ! -e $dist_dir/lib/java/direct_bt-test.jar ] ; then + echo "dist-dir incomplete: $dist_dir" exit 1 fi @@ -61,7 +73,7 @@ if [ "$1" = "-log" ] ; then shift 2 else mkdir -p $rootdir/doc/test - logfile=$rootdir/doc/test/${bname}-${os_name}-${archabi}.log + logfile=$rootdir/doc/test/${bname}-${preset_name}-${tripleid}.log fi rm -f $logfile logbasename=`basename ${logfile} .log` diff --git a/scripts/run-native-example-simple.sh b/scripts/run-native-example-simple.sh index 3fa51ff2..3c636d83 100755 --- a/scripts/run-native-example-simple.sh +++ b/scripts/run-native-example-simple.sh @@ -2,6 +2,7 @@ # Script arguments in order: # +# <preset-name> One of CMakePresets.txt, see `cmake --list-presets` # ... All subsequent arguments are passed to the Direct-BT example # # Assuming executing dbt_scanner10: @@ -17,8 +18,19 @@ bname=`basename $0 .sh` . $rootdir/jaulib/scripts/setup-machine-arch.sh "-quiet" -dist_dir=$rootdir/"dist-$os_name-$archabi" -build_dir=$rootdir/"build-$os_name-$archabi" +tripleid="$os_name-$archabi" + +if [ ! -z "$1" ] ; then + preset_name=$1 + shift 1 +else + echo "ERROR: No preset passed as 1st argument, use one of:" + cmake --list-presets + exit 1 +fi + +dist_dir="$rootdir/dist/${preset_name}-${tripleid}" +build_dir="$rootdir/build/${preset_name}" echo dist_dir $dist_dir echo build_dir $build_dir @@ -36,7 +48,7 @@ if [ "$1" = "-log" ] ; then logbasename=$2 shift 2 else - logbasename=$bname-$os_name-$archabi + logbasename=${bname}-${preset_name}-${tripleid} fi mkdir -p $rootdir/doc/test diff --git a/scripts/run-native-example.sh b/scripts/run-native-example.sh index 3ffe53a0..652f5a97 100755 --- a/scripts/run-native-example.sh +++ b/scripts/run-native-example.sh @@ -2,6 +2,7 @@ # Script arguments in order: # +# <preset-name> One of CMakePresets.txt, see `cmake --list-presets` # [-setcap] Optional 1st argument to use setcap, see below # [-root] Optional 1st argument to use sudo, see below # [-log <filename>] Optional argument to define logfile @@ -19,25 +20,25 @@ # Default logfile in ~/run-dbt_scanner10.log # # Scan and read all devices (using default auto-sec w/ keyboard iocap) -# ../scripts/run-dbt_scanner10.sh +# ../scripts/run-dbt_scanner10.sh debug-clang # # Read device C0:26:DA:01:DA:B1 (using default auto-sec w/ keyboard iocap) -# ../scripts/run-dbt_scanner10.sh -dev C0:26:DA:01:DA:B1 +# ../scripts/run-dbt_scanner10.sh debug-clang -dev C0:26:DA:01:DA:B1 # # Read device C0:26:DA:01:DA:B1 (enforcing no security) -# ../scripts/run-dbt_scanner10.sh -dev C0:26:DA:01:DA:B1 -seclevel C0:26:DA:01:DA:B1 1 +# ../scripts/run-dbt_scanner10.sh debug-clang -dev C0:26:DA:01:DA:B1 -seclevel C0:26:DA:01:DA:B1 1 # # Read any device containing C0:26:DA (enforcing no security) -# ../scripts/run-dbt_scanner10.sh -dev C0:26:DA -seclevel C0:26:DA 1 +# ../scripts/run-dbt_scanner10.sh debug-clang -dev C0:26:DA -seclevel C0:26:DA 1 # # Read any device containing name 'TAIDOC' (enforcing no security) -# ../scripts/run-dbt_scanner10.sh -dev 'TAIDOC' -seclevel 'TAIDOC' 1 +# ../scripts/run-dbt_scanner10.sh debug-clang -dev 'TAIDOC' -seclevel 'TAIDOC' 1 # # Read device C0:26:DA:01:DA:B1, basic debug flags enabled (using default auto-sec w/ keyboard iocap) -# ../scripts/run-dbt_scanner10.sh -dev C0:26:DA:01:DA:B1 -dbt_debug true +# ../scripts/run-dbt_scanner10.sh debug-clang -dev C0:26:DA:01:DA:B1 -dbt_debug true # # Read device C0:26:DA:01:DA:B1, all debug flags enabled (using default auto-sec w/ keyboard iocap) -# ../scripts/run-dbt_scanner10.sh -dev C0:26:DA:01:DA:B1 -dbt_debug adapter.event,gatt.data,hci.event,hci.scan_ad_eir,mgmt.event +# ../scripts/run-dbt_scanner10.sh debug-clang -dev C0:26:DA:01:DA:B1 -dbt_debug adapter.event,gatt.data,hci.event,hci.scan_ad_eir,mgmt.event # # To do a BT adapter removal/add via software, assuming the device is '1-4' (Bus 1.Port 4): # echo '1-4' > /sys/bus/usb/drivers/usb/unbind @@ -76,8 +77,19 @@ bname=`basename $0 .sh` . $rootdir/jaulib/scripts/setup-machine-arch.sh "-quiet" -dist_dir=$rootdir/"dist-$os_name-$archabi" -build_dir=$rootdir/"build-$os_name-$archabi" +tripleid="$os_name-$archabi" + +if [ ! -z "$1" ] ; then + preset_name=$1 + shift 1 +else + echo "ERROR: No preset passed as 1st argument, use one of:" + cmake --list-presets + exit 1 +fi + +dist_dir="$rootdir/dist/${preset_name}-${tripleid}" +build_dir="$rootdir/build/${preset_name}" echo dist_dir $dist_dir echo build_dir $build_dir @@ -105,7 +117,7 @@ if [ "$1" = "-log" ] ; then logbasename=$2 shift 2 else - logbasename=$bname-$os_name-$archabi + logbasename=${bname}-${preset_name}-${tripleid} fi mkdir -p $rootdir/doc/test diff --git a/scripts/test_exe_template.sh b/scripts/test_exe_template.sh index 0d8942c3..652a8d4c 100755 --- a/scripts/test_exe_template.sh +++ b/scripts/test_exe_template.sh @@ -1,6 +1,7 @@ #!/bin/bash # Arguments: +# <preset-name> One of CMakePresets.txt, see `cmake --list-presets` # --perf_analysis special performance analysis using 3rd party tools # -v normal dummy for full benchmarking # <none> auto_run, no benchmarking @@ -14,8 +15,19 @@ bname=`basename $0 .sh` . $rootdir/jaulib/scripts/setup-machine-arch.sh "-quiet" -dist_dir=$rootdir/"dist-$os_name-$archabi" -build_dir=$rootdir/"build-$os_name-$archabi" +tripleid="$os_name-$archabi" + +if [ ! -z "$1" ] ; then + preset_name=$1 + shift 1 +else + echo "ERROR: No preset passed as 1st argument, use one of:" + cmake --list-presets + exit 1 +fi + +dist_dir="$rootdir/dist/${preset_name}-${tripleid}" +build_dir="$rootdir/build/${preset_name}" echo dist_dir $dist_dir echo build_dir $build_dir @@ -28,7 +40,7 @@ if [ "$1" = "-log" ] ; then logbasename=$2 shift 2 else - logbasename=$bname-$os_name-$archabi + logbasename=${bname}-${preset_name}-${tripleid} fi mkdir -p $rootdir/doc/test diff --git a/src/direct_bt/CMakeLists.txt b/src/direct_bt/CMakeLists.txt index 4e69d8be..b1f89012 100644 --- a/src/direct_bt/CMakeLists.txt +++ b/src/direct_bt/CMakeLists.txt @@ -12,9 +12,11 @@ include_directories( ${SYS_INCLUDE_DIRS} ) -set (direct_bt_LIB_SRCS +set (tinycrypt_LIB_SRCS ${PROJECT_SOURCE_DIR}/tinycrypt/lib/source/aes_encrypt.c ${PROJECT_SOURCE_DIR}/tinycrypt/lib/source/utils.c +) +set (direct_bt_LIB_SRCS ${PROJECT_SOURCE_DIR}/jaulib/src/basic_types.cpp ${PROJECT_SOURCE_DIR}/jaulib/src/base_codec.cpp ${PROJECT_SOURCE_DIR}/jaulib/src/cpuid.cpp @@ -58,9 +60,16 @@ set (direct_bt_LIB_SRCS ${CMAKE_CURRENT_BINARY_DIR}/../version.cpp ) +add_library (tinycrypt STATIC ${tinycrypt_LIB_SRCS}) +target_compile_options(tinycrypt PRIVATE ${direct_bt_C_FLAGS}) +target_link_options(tinycrypt PRIVATE ${direct_bt_STATIC_LINKER_FLAGS}) + add_library (direct_bt SHARED ${direct_bt_LIB_SRCS}) +target_compile_options(direct_bt PUBLIC ${direct_bt_CXX_FLAGS}) +target_link_options(direct_bt PUBLIC ${direct_bt_SHARED_LINKER_FLAGS}) target_link_libraries ( - direct_bt + direct_bt + tinycrypt ${LIBUNWIND_LIBNAME} ${CMAKE_THREAD_LIBS_INIT} ) diff --git a/test/direct_bt/CMakeLists.txt b/test/direct_bt/CMakeLists.txt index a96a41cd..c030615b 100644 --- a/test/direct_bt/CMakeLists.txt +++ b/test/direct_bt/CMakeLists.txt @@ -12,6 +12,8 @@ set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} ) foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} ) add_executable(${name} ${name}.cpp) + target_compile_options(${name} PUBLIC ${direct_bt_CXX_FLAGS}) + target_link_options(${name} PUBLIC ${direct_bt_EXE_LINKER_FLAGS}) target_link_libraries(${name} direct_bt catch2) add_dependencies(${name} direct_bt catch2) add_test (NAME ${name} COMMAND ${name}) diff --git a/test/ieee11073/CMakeLists.txt b/test/ieee11073/CMakeLists.txt index 1227b68e..d1019365 100644 --- a/test/ieee11073/CMakeLists.txt +++ b/test/ieee11073/CMakeLists.txt @@ -14,6 +14,8 @@ set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} ) foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} ) add_executable(${name} ${name}.cpp) + target_compile_options(${name} PUBLIC ${direct_bt_CXX_FLAGS}) + target_link_options(${name} PUBLIC ${direct_bt_EXE_LINKER_FLAGS}) target_link_libraries(${name} direct_bt catch2) add_dependencies(${name} direct_bt catch2) add_test (NAME ${name} COMMAND ${name}) diff --git a/test/java/CMakeLists.txt b/test/java/CMakeLists.txt index 7edbd35c..3b7e0afc 100644 --- a/test/java/CMakeLists.txt +++ b/test/java/CMakeLists.txt @@ -14,6 +14,8 @@ file(GLOB_RECURSE TEST_JAVA_SOURCES "*.java") file(GLOB_RECURSE TEST_JAVA_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "Test*.java") +set(CMAKE_JAVA_COMPILE_FLAGS ${direct_bt_JAVA_COMPILE_FLAGS}) + add_jar(direct_bt_test ${TEST_JAVA_SOURCES} INCLUDE_JARS ${jaulib_fat_jar_file} ${direct_bt_fat_jar_file} ${jaulib_test_jar_file} ${JUNIT_JAR} ${HAMCREST_JAR} diff --git a/trial/direct_bt/CMakeLists.txt b/trial/direct_bt/CMakeLists.txt index 97338efc..fbed8c0f 100644 --- a/trial/direct_bt/CMakeLists.txt +++ b/trial/direct_bt/CMakeLists.txt @@ -10,6 +10,8 @@ string( REPLACE ".cpp" "" TARGETS_IDIOMATIC_TRIALS "${SOURCES_IDIOMATIC_TRIALS}" foreach( name ${TARGETS_IDIOMATIC_TRIALS} ) add_executable(${name} ${name}.cpp) + target_compile_options(${name} PUBLIC ${direct_bt_CXX_FLAGS}) + target_link_options(${name} PUBLIC ${direct_bt_EXE_LINKER_FLAGS}) target_link_libraries(${name} direct_bt catch2) add_dependencies(${name} direct_bt catch2) add_test (NAME ${name} COMMAND sudo -E /sbin/capsh --caps=cap_net_raw,cap_net_admin+eip\ cap_setpcap,cap_setuid,cap_setgid+ep @@ -25,6 +27,8 @@ string( REPLACE ".cpp" "" TARGETS_IDIOMATIC_PROVOCATIONS "${SOURCES_IDIOMATIC_PR foreach( name ${TARGETS_IDIOMATIC_PROVOCATIONS} ) add_executable(${name} ${name}.cpp) + target_compile_options(${name} PUBLIC ${direct_bt_CXX_FLAGS}) + target_link_options(${name} PUBLIC ${direct_bt_EXE_LINKER_FLAGS}) target_link_libraries(${name} direct_bt catch2) add_dependencies(${name} direct_bt catch2) endforeach() diff --git a/trial/java/CMakeLists.txt b/trial/java/CMakeLists.txt index 105b6b90..df1a41c3 100644 --- a/trial/java/CMakeLists.txt +++ b/trial/java/CMakeLists.txt @@ -10,6 +10,8 @@ file(GLOB_RECURSE TEST_JAVA_SOURCES "*.java") file(GLOB_RECURSE TEST_JAVA_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "Test*.java") +set(CMAKE_JAVA_COMPILE_FLAGS ${direct_bt_JAVA_COMPILE_FLAGS}) + add_jar(direct_bt_trial ${TEST_JAVA_SOURCES} INCLUDE_JARS ${direct_bt_fat_jar_file} ${jaulib_base_jar_file} ${jaulib_test_jar_file} ${JUNIT_JAR} |