CMake: Added 'DROPOUT_DL_BUILD_ALL' Option

This option will build four executables:
- dropout-dl-minimal (with curl without sqlite or gcrypt)
- dropout-dl-sqlite (with curl and sqlite without gcrypt)
- dropout-dl-full (with curl, sqlite and gcrypt)
- tests
This commit is contained in:
Moss 2022-10-01 15:07:40 -04:00
parent a55b90491e
commit 35b4c181b3
4 changed files with 34 additions and 4 deletions

View File

@ -3,6 +3,30 @@ project(dropout-dl)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
IF(DROPOUT_DL_BUILD_ALL)
add_executable(dropout-dl-minimal src/episode.cpp src/season.cpp src/series.cpp src/main.cpp)
target_link_libraries(dropout-dl-minimal curl)
add_executable(dropout-dl-sqlite src/episode.cpp src/season.cpp src/series.cpp src/main.cpp)
target_link_libraries(dropout-dl-sqlite curl sqlite3)
target_compile_definitions(dropout-dl-sqlite PUBLIC DROPOUT_DL_SQLITE)
add_executable(dropout-dl-full src/episode.cpp src/season.cpp src/series.cpp src/main.cpp)
target_link_libraries(dropout-dl-full curl gcrypt sqlite3)
target_compile_definitions(dropout-dl-full PUBLIC DROPOUT_DL_SQLITE DROPOUT_DL_GCRYPT)
add_subdirectory(tests)
ELSE()
add_executable(dropout-dl src/episode.cpp src/season.cpp src/series.cpp src/main.cpp) add_executable(dropout-dl src/episode.cpp src/season.cpp src/series.cpp src/main.cpp)
target_link_libraries(dropout-dl curl) target_link_libraries(dropout-dl curl)
@ -22,3 +46,5 @@ ENDIF()
IF(DROPOUT_DL_TESTS) IF(DROPOUT_DL_TESTS)
add_subdirectory(tests) add_subdirectory(tests)
ENDIF() ENDIF()
ENDIF()

View File

@ -52,7 +52,6 @@ By default, dropout-dl will download the episode in the format `<series>/S<seaso
## TODO ## TODO
- [x] Create tests - [x] Create tests
- [x] Handle non-alphanumeric characters - [x] Handle non-alphanumeric characters
- [ ] Create static executables
- [ ] Test build process on other setups with other OSs. - [ ] Test build process on other setups with other OSs.

View File

@ -516,6 +516,7 @@ namespace dropout_dl {
// Cookie functions // Cookie functions
void cookie::get_value_from_db(sqlite3 *db, const std::string &sql_query_base, const std::string& value, bool verbose, int (*callback)(void*,int,char**,char**)) { void cookie::get_value_from_db(sqlite3 *db, const std::string &sql_query_base, const std::string& value, bool verbose, int (*callback)(void*,int,char**,char**)) {
#ifdef DROPOUT_DL_SQLITE
std::string sql_mod_base = sql_query_base; std::string sql_mod_base = sql_query_base;
if (sql_mod_base.find("WHERE") == std::string::npos) { if (sql_mod_base.find("WHERE") == std::string::npos) {
@ -566,6 +567,10 @@ namespace dropout_dl {
} }
this->value = tmp; this->value = tmp;
#else
std::cerr << "COOKIE ERROR: Attempted to get cookies from sqlite without having sqlite installed\n";
exit(12);
#endif
} }
void cookie::format_from_chrome() { void cookie::format_from_chrome() {
@ -617,7 +622,7 @@ namespace dropout_dl {
this->value = this->value.substr(0, this->len - 7); this->value = this->value.substr(0, this->len - 7);
this->len -= 7; this->len -= 7;
#else #else
std::cerr << "CHROME COOKIE ERROR: Attempted to Decrypt Chrome Cookie With libgcrypt\n"; std::cerr << "CHROME COOKIE ERROR: Attempted to Decrypt Chrome Cookie Without libgcrypt\n";
exit(12); exit(12);
#endif #endif
} }

View File

@ -297,14 +297,14 @@ std::vector<dropout_dl::cookie> get_cookies(bool verbose = false) {
#ifdef DROPOUT_DL_SQLITE #ifdef DROPOUT_DL_SQLITE
return get_cookies_from_firefox(firefox_profile, verbose); return get_cookies_from_firefox(firefox_profile, verbose);
#else #else
std::cout << "WARNING: Firefox profile file exists but sqlite3-dev is not installed" << std::endl; std::cout << "WARNING: Firefox profile file exists but sqlite is not installed" << std::endl;
#endif #endif
} }
if (std::filesystem::exists(chrome_profile)) { if (std::filesystem::exists(chrome_profile)) {
#if defined(DROPOUT_DL_GCRYPT) & defined(DROPOUT_DL_SQLITE) #if defined(DROPOUT_DL_GCRYPT) & defined(DROPOUT_DL_SQLITE)
return get_cookies_from_chrome(chrome_profile, verbose); return get_cookies_from_chrome(chrome_profile, verbose);
#else #else
std::cout << "WARNING: Chrome profile file exists but libgcrypt or sqlite3-dev is not installed" << std::endl; std::cout << "WARNING: Chrome profile file exists but libgcrypt or sqlite is not installed" << std::endl;
#endif #endif
} }