From cfca4513e49d52b1ac3be469f42892aa7f258e74 Mon Sep 17 00:00:00 2001 From: Massimo Gengarelli Date: Tue, 1 May 2012 17:24:27 +0200 Subject: [PATCH] Major refactor Since we've decided to keep the two projects separated it's necessary that if some one wants to clone the repository he has a clear idea of what's going on here: in src/lib folder there are the three main components of the library libgrive (drive, protocol and util); while in the src/cli folder there's the command line interface tool that uses the library. The CLI is called in the same way as the library (grive). In this way, we can keep multiple clients using the same library in just one repo.. --- CMakeLists.txt | 80 ++++-------------------------- src/CMakeLists.txt | 4 ++ src/cli/CMakeLists.txt | 14 ++++++ src/{ => cli}/main.cc | 0 src/lib/CMakeLists.txt | 46 +++++++++++++++++ src/{ => lib}/drive/Collection.cc | 0 src/{ => lib}/drive/Collection.hh | 0 src/{ => lib}/drive/Drive.cc | 0 src/{ => lib}/drive/Drive.hh | 0 src/{ => lib}/protocol/Download.cc | 0 src/{ => lib}/protocol/Download.hh | 0 src/{ => lib}/protocol/HTTP.cc | 0 src/{ => lib}/protocol/HTTP.hh | 0 src/{ => lib}/protocol/Json.cc | 0 src/{ => lib}/protocol/Json.hh | 0 src/{ => lib}/protocol/OAuth2.cc | 0 src/{ => lib}/protocol/OAuth2.hh | 0 src/{ => lib}/util/Crypt.cc | 0 src/{ => lib}/util/Crypt.hh | 0 src/{ => lib}/util/DateTime.cc | 0 src/{ => lib}/util/DateTime.hh | 0 src/{ => lib}/util/Function.hh | 0 src/{ => lib}/util/OS.cc | 0 src/{ => lib}/util/OS.hh | 0 src/{ => lib}/util/Path.cc | 0 src/{ => lib}/util/Path.hh | 0 test/CMakeLists.txt | 14 ++++++ 27 files changed, 87 insertions(+), 71 deletions(-) create mode 100644 src/CMakeLists.txt create mode 100644 src/cli/CMakeLists.txt rename src/{ => cli}/main.cc (100%) create mode 100644 src/lib/CMakeLists.txt rename src/{ => lib}/drive/Collection.cc (100%) rename src/{ => lib}/drive/Collection.hh (100%) rename src/{ => lib}/drive/Drive.cc (100%) rename src/{ => lib}/drive/Drive.hh (100%) rename src/{ => lib}/protocol/Download.cc (100%) rename src/{ => lib}/protocol/Download.hh (100%) rename src/{ => lib}/protocol/HTTP.cc (100%) rename src/{ => lib}/protocol/HTTP.hh (100%) rename src/{ => lib}/protocol/Json.cc (100%) rename src/{ => lib}/protocol/Json.hh (100%) rename src/{ => lib}/protocol/OAuth2.cc (100%) rename src/{ => lib}/protocol/OAuth2.hh (100%) rename src/{ => lib}/util/Crypt.cc (100%) rename src/{ => lib}/util/Crypt.hh (100%) rename src/{ => lib}/util/DateTime.cc (100%) rename src/{ => lib}/util/DateTime.hh (100%) rename src/{ => lib}/util/Function.hh (100%) rename src/{ => lib}/util/OS.cc (100%) rename src/{ => lib}/util/OS.hh (100%) rename src/{ => lib}/util/Path.cc (100%) rename src/{ => lib}/util/Path.hh (100%) create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 09aa10b..e01806c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,78 +9,16 @@ find_package(JSONC REQUIRED) find_package(CURL REQUIRED) find_package(CppUnit) +# Common include +include_directories( ${grive_SOURCE_DIR}/src/lib + ${OPT_INCS} +) + +add_subdirectory(src) + IF ( CPPUNIT_FOUND ) + message("-- Building unitary tests along with the library and the binary") set( OPT_INCS ${CPPUNIT_INCLUDE_DIR} ) + add_subdirectory(test) ENDIF ( CPPUNIT_FOUND ) -include_directories( - ${grive_SOURCE_DIR}/src - ${OPT_INCS} -) - -file(GLOB DRIVE_HEADERS - ${grive_SOURCE_DIR}/src/drive/*.hh -) - -file (GLOB PROTOCOL_HEADERS - ${grive_SOURCE_DIR}/src/protocol/*.hh -) - -file (GLOB UTIL_HEADERS - ${grive_SOURCE_DIR}/src/util/*.hh -) - -add_library( fgrive SHARED - src/drive/Collection.cc - src/drive/Drive.cc - src/protocol/Download.cc - src/protocol/HTTP.cc - src/protocol/Json.cc - src/protocol/OAuth2.cc - src/util/Crypt.cc - src/util/DateTime.cc - src/util/OS.cc - src/util/Path.cc -) - -add_executable( grive - src/main.cc -) - -target_link_libraries( fgrive - ${CURL_LIBRARIES} - ${JSONC_LIBRARY} - ${OPENSSL_LIBRARIES} -) - -target_link_libraries( grive - fgrive -) - -set_target_properties(fgrive PROPERTIES - SOVERSION 0 VERSION 0.0.1 -) - -IF ( CPPUNIT_FOUND ) - add_executable( unittest - test/UnitTest.cc - test/util/DateTimeTest.cc - test/util/FunctionTest.cc - test/util/PathTest.cc - ) - - target_link_libraries( unittest - fgrive - ${CPPUNIT_LIBRARY} - ) - else ( CPPUNIT_FOUND ) - message( STATUS "skip building unittest" ) -endif ( CPPUNIT_FOUND ) - - -## Install targets -install(TARGETS fgrive LIBRARY DESTINATION lib) -install(TARGETS grive RUNTIME DESTINATION bin) -install(FILES ${DRIVE_HEADERS} DESTINATION include/grive/drive) -install(FILES ${PROTOCOL_HEADERS} DESTINATION include/grive/protocol) -install(FILES ${UTIL_HEADERS} DESTINATION include/grive/util) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..7b3f05d --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,4 @@ +# Keep the order right + +add_subdirectory(lib) +add_subdirectory(cli) \ No newline at end of file diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt new file mode 100644 index 0000000..1e7d682 --- /dev/null +++ b/src/cli/CMakeLists.txt @@ -0,0 +1,14 @@ + +add_executable( grive_executable + main.cc +) + +target_link_libraries( grive_executable + grive +) + +set_target_properties( grive_executable + PROPERTIES OUTPUT_NAME grive +) + +install(TARGETS grive_executable RUNTIME DESTINATION bin) \ No newline at end of file diff --git a/src/main.cc b/src/cli/main.cc similarity index 100% rename from src/main.cc rename to src/cli/main.cc diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt new file mode 100644 index 0000000..f75c64e --- /dev/null +++ b/src/lib/CMakeLists.txt @@ -0,0 +1,46 @@ +# lib subproject + +file(GLOB DRIVE_SOURCES + drive/*.cc +) + +file(GLOB PROTOCOL_SOURCES + protocol/*.cc +) + +file(GLOB UTIL_SOURCES + util/*.cc +) + +file(GLOB DRIVE_HEADERS + drive/*.hh +) + +file (GLOB PROTOCOL_HEADERS + protocol/*.hh +) + +file (GLOB UTIL_HEADERS + util/*.hh +) + +add_library( grive SHARED + ${DRIVE_SOURCES} + ${PROTOCOL_SOURCES} + ${UTIL_SOURCES} +) + +target_link_libraries( grive + ${CURL_LIBRARIES} + ${JSONC_LIBRARY} + ${OPENSSL_LIBRARIES} +) + +set_target_properties(grive PROPERTIES + SOVERSION 0 VERSION 0.0.1 +) + +install(TARGETS grive LIBRARY DESTINATION lib) +install(FILES ${DRIVE_HEADERS} DESTINATION include/grive/drive) +install(FILES ${PROTOCOL_HEADERS} DESTINATION include/grive/protocol) +install(FILES ${UTIL_HEADERS} DESTINATION include/grive/util) \ No newline at end of file diff --git a/src/drive/Collection.cc b/src/lib/drive/Collection.cc similarity index 100% rename from src/drive/Collection.cc rename to src/lib/drive/Collection.cc diff --git a/src/drive/Collection.hh b/src/lib/drive/Collection.hh similarity index 100% rename from src/drive/Collection.hh rename to src/lib/drive/Collection.hh diff --git a/src/drive/Drive.cc b/src/lib/drive/Drive.cc similarity index 100% rename from src/drive/Drive.cc rename to src/lib/drive/Drive.cc diff --git a/src/drive/Drive.hh b/src/lib/drive/Drive.hh similarity index 100% rename from src/drive/Drive.hh rename to src/lib/drive/Drive.hh diff --git a/src/protocol/Download.cc b/src/lib/protocol/Download.cc similarity index 100% rename from src/protocol/Download.cc rename to src/lib/protocol/Download.cc diff --git a/src/protocol/Download.hh b/src/lib/protocol/Download.hh similarity index 100% rename from src/protocol/Download.hh rename to src/lib/protocol/Download.hh diff --git a/src/protocol/HTTP.cc b/src/lib/protocol/HTTP.cc similarity index 100% rename from src/protocol/HTTP.cc rename to src/lib/protocol/HTTP.cc diff --git a/src/protocol/HTTP.hh b/src/lib/protocol/HTTP.hh similarity index 100% rename from src/protocol/HTTP.hh rename to src/lib/protocol/HTTP.hh diff --git a/src/protocol/Json.cc b/src/lib/protocol/Json.cc similarity index 100% rename from src/protocol/Json.cc rename to src/lib/protocol/Json.cc diff --git a/src/protocol/Json.hh b/src/lib/protocol/Json.hh similarity index 100% rename from src/protocol/Json.hh rename to src/lib/protocol/Json.hh diff --git a/src/protocol/OAuth2.cc b/src/lib/protocol/OAuth2.cc similarity index 100% rename from src/protocol/OAuth2.cc rename to src/lib/protocol/OAuth2.cc diff --git a/src/protocol/OAuth2.hh b/src/lib/protocol/OAuth2.hh similarity index 100% rename from src/protocol/OAuth2.hh rename to src/lib/protocol/OAuth2.hh diff --git a/src/util/Crypt.cc b/src/lib/util/Crypt.cc similarity index 100% rename from src/util/Crypt.cc rename to src/lib/util/Crypt.cc diff --git a/src/util/Crypt.hh b/src/lib/util/Crypt.hh similarity index 100% rename from src/util/Crypt.hh rename to src/lib/util/Crypt.hh diff --git a/src/util/DateTime.cc b/src/lib/util/DateTime.cc similarity index 100% rename from src/util/DateTime.cc rename to src/lib/util/DateTime.cc diff --git a/src/util/DateTime.hh b/src/lib/util/DateTime.hh similarity index 100% rename from src/util/DateTime.hh rename to src/lib/util/DateTime.hh diff --git a/src/util/Function.hh b/src/lib/util/Function.hh similarity index 100% rename from src/util/Function.hh rename to src/lib/util/Function.hh diff --git a/src/util/OS.cc b/src/lib/util/OS.cc similarity index 100% rename from src/util/OS.cc rename to src/lib/util/OS.cc diff --git a/src/util/OS.hh b/src/lib/util/OS.hh similarity index 100% rename from src/util/OS.hh rename to src/lib/util/OS.hh diff --git a/src/util/Path.cc b/src/lib/util/Path.cc similarity index 100% rename from src/util/Path.cc rename to src/lib/util/Path.cc diff --git a/src/util/Path.hh b/src/lib/util/Path.hh similarity index 100% rename from src/util/Path.hh rename to src/lib/util/Path.hh diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..8670329 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,14 @@ +# test subfolder + +file(GLOB UTIL_TESTS util/*.cc) + + +add_executable( unittest + UnitTest.cc + ${UTIL_TESTS} +) + +target_link_libraries(unittest + grive + ${CPPUNIT_LIBRARY} +)