deploy.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/sh
  2. # NOTE: Use pimpl to hide the implementation details (headers from dependencies)
  3. set -e
  4. deploy_dir=build/deploy
  5. # Clean the project
  6. rm -rf test_package/build/**
  7. # Use conan to build the project
  8. conan create . --build=missing $@
  9. # conan install . --deployer=full_deploy --build=missing
  10. # cmake --build build
  11. # Find the test_package artifacts folder
  12. test_package_build_dir=$(find test_package/build/ -mindepth 1 -maxdepth 1 -type d | head -n 1)
  13. echo Reading build directory: $test_package_build_dir
  14. # Find the link.txt file and extract the library path
  15. link_file=$(find $test_package_build_dir/CMakeFiles/example.dir -name link.txt)
  16. echo Reading link file: $link_file
  17. # Deploy the project
  18. if [ -z "$deploy_dir" ]; then
  19. # FAILSAFE guard
  20. echo ❌ Deployment directory is not set. Please set the variable \`deploy_dir\` to the desired deployment directory.
  21. exit 1
  22. fi
  23. merged_lib_file=$deploy_dir/lib/libtsdb-merged.a
  24. mkdir -p $deploy_dir
  25. rm -rf $deploy_dir/**
  26. mkdir $deploy_dir/include
  27. mkdir $deploy_dir/lib
  28. cp -r include/* $deploy_dir/include
  29. echo Creating merged library: $merged_lib_file
  30. # grep -o '/[^ ]*/.conan2/p/b/[^ ]*\.a' $link_file
  31. # libtool -static -o $deploy_dir/lib/libtsdb-merged.a $(grep -o '/[^ ]*/.conan2/p/b/[^ ]*\.a' $link_file)
  32. ar cqT $merged_lib_file $(grep -o '/[^ ]*/.conan2/p/b/[^ ]*\.a' $link_file)
  33. printf 'create %s\naddlib %s\nsave\nend' "$merged_lib_file" "$merged_lib_file" | ar -M
  34. # Done!
  35. echo ✅ Project has been successfully deployed to \`$deploy_dir\`.
  36. echo
  37. echo To consume the library, run the following commands:
  38. echo
  39. echo " $ g++ -std=c++17 -I$deploy_dir/include -L$deploy_dir/lib main.cpp -o main -ltsdb-merged"