Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
properly install powerloader and namespace fs (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv authored Feb 16, 2022
1 parent b37d372 commit e04b85b
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 21 deletions.
37 changes: 37 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ set(LIBPOWERLOADER_SRCS
src/uploader/oci_upload.cpp
)

set(LIBPOWERLOADER_HEADERS
include/context.hpp
include/curl.hpp
include/download_target.hpp
include/downloader.hpp
include/enums.hpp
include/errors.hpp
include/fastest_mirror.hpp
include/fileio.hpp
include/mirror.hpp
include/url.hpp
include/result.hpp
include/target.hpp
include/utils.hpp
include/zck.hpp
)



add_executable(powerloader src/cli/main.cpp)

Expand All @@ -46,12 +64,18 @@ endif()
add_library(libpowerloader
${LIBPOWERLOADER_SRCS}
)
set_target_properties(libpowerloader
PROPERTIES PREFIX ""
)

target_include_directories(powerloader PUBLIC
include
${CURL_INCLUDE_DIRS}
${ZCK_INCLUDE_DIRS}
)

set_target_properties(powerloader PROPERTIES PUBLIC_HEADER "${LIBPOWERLOADER_HEADERS}")

if (DEV)
add_executable(dpowerloader src/main.cpp)
target_link_libraries(dpowerloader libpowerloader)
Expand Down Expand Up @@ -82,6 +106,19 @@ target_link_libraries(libpowerloader
${YAML_CPP_LIBRARIES})
target_link_libraries(powerloader libpowerloader CLI11::CLI11)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

set(LIBMAMBA_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for libmambaConfig.cmake")

install(TARGETS powerloader libpowerloader
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/powerloader
)

option(ENABLE_TESTS "Enable tests" ON)

option(ENABLE_PYTHON "Enable python bindings" ON)
Expand Down
3 changes: 2 additions & 1 deletion include/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <chrono>
#include <map>
#include <filesystem>
namespace fs = std::filesystem;
#include <spdlog/spdlog.h>

#ifdef WITH_ZCHUNK
Expand All @@ -18,6 +17,8 @@ extern "C"

namespace powerloader
{
namespace fs = std::filesystem;

struct Mirror;

class Context
Expand Down
10 changes: 10 additions & 0 deletions include/download_target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ extern "C"

namespace powerloader
{
/** Called when a transfer is done (use transfer status to check
* if successful or failed).
* @param clientp Pointer to user data.
* @param status Transfer status
* @param msg Error message or NULL.
* @return See LrCbReturnCode codes
*/
typedef CbReturnCode (*EndCb)(TransferStatus status, const std::string& msg, void* clientp);

class DownloadTarget
{
public:
Expand Down Expand Up @@ -123,6 +132,7 @@ namespace powerloader

std::function<int(curl_off_t, curl_off_t)> progress_callback;


EndCb endcb = nullptr;
void* cbdata = nullptr;

Expand Down
3 changes: 2 additions & 1 deletion include/downloader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ extern "C"
#include <fcntl.h>
}

namespace fs = std::filesystem;

#include "context.hpp"
#include "curl.hpp"
Expand All @@ -32,6 +31,8 @@ namespace fs = std::filesystem;

namespace powerloader
{
namespace fs = std::filesystem;

class Downloader
{
public:
Expand Down
9 changes: 0 additions & 9 deletions include/enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,4 @@ namespace powerloader
ChecksumType type;
std::string checksum;
};

/** Called when a transfer is done (use transfer status to check
* if successful or failed).
* @param clientp Pointer to user data.
* @param status Transfer status
* @param msg Error message or NULL.
* @return See LrCbReturnCode codes
*/
typedef CbReturnCode (*EndCb)(TransferStatus status, const std::string& msg, void* clientp);
}
5 changes: 4 additions & 1 deletion include/fileio.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include <filesystem>
#include <spdlog/spdlog.h>

Expand All @@ -10,10 +12,11 @@
#include <windows.h>
#endif

namespace fs = std::filesystem;

namespace powerloader
{
namespace fs = std::filesystem;

class FileIO
{
private:
Expand Down
4 changes: 2 additions & 2 deletions include/target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <fstream>
#include <set>

namespace fs = std::filesystem;

#include "curl.hpp"
#include "download_target.hpp"
#include "enums.hpp"
Expand All @@ -15,6 +13,8 @@ namespace fs = std::filesystem;

namespace powerloader
{
namespace fs = std::filesystem;

class Target
{
public:
Expand Down
4 changes: 2 additions & 2 deletions include/url.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//
// The full license is in the file LICENSE, distributed with this software.

#ifndef MAMBA_CORE_URL_HPP
#define MAMBA_CORE_URL_HPP
#ifndef POWERLOADER_URL_HPP
#define POWERLOADER_URL_HPP

extern "C"
{
Expand Down
4 changes: 2 additions & 2 deletions include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
#include <string_view>
#include <cctype>

namespace fs = std::filesystem;

extern "C"
{
#include <openssl/evp.h>
}

namespace powerloader
{
namespace fs = std::filesystem;

inline bool is_sig_interrupted()
{
return false;
Expand Down
5 changes: 2 additions & 3 deletions src/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ namespace powerloader

CbReturnCode Target::call_endcallback(TransferStatus status)
{
reset_file(status);

EndCb end_cb = override_endcb ? override_endcb : target->endcb;
void* cb_data = override_endcb ? override_endcb_data : target->cbdata;
CbReturnCode rc = CbReturnCode::kOK;
Expand All @@ -66,9 +68,6 @@ namespace powerloader
spdlog::error("End-Callback returned an error");
}
}

reset_file(status);

return rc;
}

Expand Down

0 comments on commit e04b85b

Please sign in to comment.