Restructure project to allow factoring out a library

This commit is contained in:
Sebastian Messmer 2016-02-23 21:07:23 +01:00
parent f92c4a4f71
commit e48188f470
41 changed files with 159 additions and 90 deletions

View File

@ -41,5 +41,6 @@ script:
- ./test/blobstore/blobstore-test
# TODO Also run on osx once fixed
- if [ "${TRAVIS_OS_NAME}" == "linux"]; then ./test/cryfs/cryfs-test ; fi
- if [ "${TRAVIS_OS_NAME}" == "linux"]; then ./test/cryfs/cryfs-cli-test ; fi
after_script:
- rm run_with_fuse.sh

View File

@ -5,4 +5,5 @@ add_subdirectory(fspp)
add_subdirectory(parallelaccessstore)
add_subdirectory(blockstore)
add_subdirectory(blobstore)
add_subdirectory(cryfs)
add_subdirectory(cryfs)
add_subdirectory(cryfs-cli)

View File

@ -0,0 +1,29 @@
project (cryfs-cli)
set(SOURCES
Cli.cpp
VersionChecker.cpp
VersionCompare.cpp
CallAfterTimeout.cpp
Environment.cpp
program_options/utils.cpp
program_options/ProgramOptions.cpp
program_options/Parser.cpp
)
add_library(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} PUBLIC cryfs cpp-utils)
target_enable_style_warnings(${PROJECT_NAME})
target_activate_cpp14(${PROJECT_NAME})
target_git_version_init(${PROJECT_NAME})
add_executable(${PROJECT_NAME}_bin main.cpp)
set_target_properties(${PROJECT_NAME}_bin PROPERTIES OUTPUT_NAME cryfs)
target_link_libraries(${PROJECT_NAME}_bin PUBLIC ${PROJECT_NAME})
target_enable_style_warnings(${PROJECT_NAME}_bin)
target_activate_cpp14(${PROJECT_NAME}_bin)
install(TARGETS ${PROJECT_NAME}_bin
DESTINATION bin
CONFIGURATIONS Release
)

View File

@ -12,8 +12,8 @@
#include <fspp/impl/FilesystemImpl.h>
#include <cpp-utils/process/subprocess.h>
#include <cpp-utils/io/DontEchoStdinToStdoutRAII.h>
#include "../filesystem/CryDevice.h"
#include "../config/CryConfigLoader.h"
#include <cryfs/filesystem/CryDevice.h>
#include <cryfs/config/CryConfigLoader.h>
#include "program_options/Parser.h"
#include <boost/filesystem.hpp>

View File

@ -3,7 +3,7 @@
#define MESSMER_CRYFS_CLI_H
#include "program_options/ProgramOptions.h"
#include "../config/CryConfigFile.h"
#include <cryfs/config/CryConfigFile.h>
#include <boost/filesystem/path.hpp>
#include <cpp-utils/tempfile/TempFile.h>
#include <cpp-utils/io/Console.h>

View File

@ -1,4 +1,4 @@
#include "cli/Cli.h"
#include "Cli.h"
#include <cpp-utils/random/Random.h>
#include <cpp-utils/crypto/kdf/Scrypt.h>
#include <cpp-utils/network/CurlHttpClient.h>

View File

@ -2,7 +2,7 @@
#include "utils.h"
#include <iostream>
#include <boost/optional.hpp>
#include <cryfs/cli/Environment.h>
#include <cryfs-cli/Environment.h>
namespace po = boost::program_options;
namespace bf = boost::filesystem;

View File

@ -1,67 +1,56 @@
project (cryfs)
set(SOURCES
cli/Cli.cpp
cli/VersionChecker.cpp
cli/VersionCompare.cpp
cli/CallAfterTimeout.cpp
cli/Environment.cpp
cli/program_options/utils.cpp
cli/program_options/ProgramOptions.cpp
cli/program_options/Parser.cpp
config/crypto/outer/OuterConfig.cpp
config/crypto/outer/OuterEncryptor.cpp
config/crypto/CryConfigEncryptorFactory.cpp
config/crypto/inner/ConcreteInnerEncryptor.cpp
config/crypto/inner/InnerConfig.cpp
config/crypto/inner/InnerEncryptor.cpp
config/crypto/CryConfigEncryptor.cpp
config/CryConfigConsole.cpp
config/CryConfigLoader.cpp
config/CryConfig.cpp
config/CryConfigFile.cpp
config/CryCipher.cpp
config/CryConfigCreator.cpp
filesystem/CryOpenFile.cpp
filesystem/fsblobstore/utils/DirEntry.cpp
filesystem/fsblobstore/utils/DirEntryList.cpp
filesystem/fsblobstore/FsBlobStore.cpp
filesystem/fsblobstore/FsBlobView.cpp
filesystem/fsblobstore/FileBlob.cpp
filesystem/fsblobstore/FsBlob.cpp
filesystem/fsblobstore/SymlinkBlob.cpp
filesystem/fsblobstore/DirBlob.cpp
filesystem/CryNode.cpp
filesystem/parallelaccessfsblobstore/DirBlobRef.cpp
filesystem/parallelaccessfsblobstore/ParallelAccessFsBlobStore.cpp
filesystem/parallelaccessfsblobstore/ParallelAccessFsBlobStoreAdapter.cpp
filesystem/parallelaccessfsblobstore/FsBlobRef.cpp
filesystem/parallelaccessfsblobstore/FileBlobRef.cpp
filesystem/parallelaccessfsblobstore/SymlinkBlobRef.cpp
filesystem/CrySymlink.cpp
filesystem/CryDir.cpp
filesystem/cachingfsblobstore/DirBlobRef.cpp
filesystem/cachingfsblobstore/CachingFsBlobStore.cpp
filesystem/cachingfsblobstore/FsBlobRef.cpp
filesystem/cachingfsblobstore/FileBlobRef.cpp
filesystem/cachingfsblobstore/SymlinkBlobRef.cpp
filesystem/CryFile.cpp
filesystem/CryDevice.cpp
set(LIB_SOURCES
# cryfs.cpp
config/crypto/outer/OuterConfig.cpp
config/crypto/outer/OuterEncryptor.cpp
config/crypto/CryConfigEncryptorFactory.cpp
config/crypto/inner/ConcreteInnerEncryptor.cpp
config/crypto/inner/InnerConfig.cpp
config/crypto/inner/InnerEncryptor.cpp
config/crypto/CryConfigEncryptor.cpp
config/CryConfigConsole.cpp
config/CryConfigLoader.cpp
config/CryConfig.cpp
config/CryConfigFile.cpp
config/CryCipher.cpp
config/CryConfigCreator.cpp
filesystem/CryOpenFile.cpp
filesystem/fsblobstore/utils/DirEntry.cpp
filesystem/fsblobstore/utils/DirEntryList.cpp
filesystem/fsblobstore/FsBlobStore.cpp
filesystem/fsblobstore/FsBlobView.cpp
filesystem/fsblobstore/FileBlob.cpp
filesystem/fsblobstore/FsBlob.cpp
filesystem/fsblobstore/SymlinkBlob.cpp
filesystem/fsblobstore/DirBlob.cpp
filesystem/CryNode.cpp
filesystem/parallelaccessfsblobstore/DirBlobRef.cpp
filesystem/parallelaccessfsblobstore/ParallelAccessFsBlobStore.cpp
filesystem/parallelaccessfsblobstore/ParallelAccessFsBlobStoreAdapter.cpp
filesystem/parallelaccessfsblobstore/FsBlobRef.cpp
filesystem/parallelaccessfsblobstore/FileBlobRef.cpp
filesystem/parallelaccessfsblobstore/SymlinkBlobRef.cpp
filesystem/CrySymlink.cpp
filesystem/CryDir.cpp
filesystem/cachingfsblobstore/DirBlobRef.cpp
filesystem/cachingfsblobstore/CachingFsBlobStore.cpp
filesystem/cachingfsblobstore/FsBlobRef.cpp
filesystem/cachingfsblobstore/FileBlobRef.cpp
filesystem/cachingfsblobstore/SymlinkBlobRef.cpp
filesystem/CryFile.cpp
filesystem/CryDevice.cpp
)
add_library(${PROJECT_NAME}_lib STATIC ${SOURCES})
target_link_libraries(${PROJECT_NAME}_lib PUBLIC cpp-utils blockstore blobstore fspp)
target_add_boost(${PROJECT_NAME}_lib program_options chrono)
target_enable_style_warnings(${PROJECT_NAME}_lib)
target_activate_cpp14(${PROJECT_NAME}_lib)
target_git_version_init(${PROJECT_NAME}_lib)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}_lib)
add_library(${PROJECT_NAME} STATIC ${LIB_SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME cryfs)
target_link_libraries(${PROJECT_NAME} PRIVATE cpp-utils blockstore blobstore fspp) # TODO Check that dependent projects don't get this linked in
target_add_boost(${PROJECT_NAME} program_options chrono) # TODO Check that dependent projects don't get boost added (use PRIVATE here)
target_enable_style_warnings(${PROJECT_NAME})
target_activate_cpp14(${PROJECT_NAME})
target_git_version_init(${PROJECT_NAME})
install(TARGETS cryfs
COMPONENT cryfs-cli
DESTINATION bin
CONFIGURATIONS Release)
#install(TARGETS ${PROJECT_NAME}
# DESTINATION lib
# CONFIGURATIONS Release
#)

20
src/cryfs/cryfs.cpp Normal file
View File

@ -0,0 +1,20 @@
#include "cryfs.h"
class cryfs_load_handle {
public:
cryfs_load_handle(const char *value_): value(value_) {}
const char *value;
};
cryfs_load_handle *cryfs_load_init() {
return new cryfs_load_handle("Hello Library World!");
}
void cryfs_load_free(cryfs_load_handle *handle) {
delete handle;
}
const char *cryfs_test(cryfs_load_handle *handle) {
return handle->value;
}

19
src/cryfs/cryfs.h Normal file
View File

@ -0,0 +1,19 @@
#pragma once
#ifndef MESSMER_CRYFS_CRYFS_H
#define MESSMER_CRYFS_CRYFS_H
#ifdef __cplusplus
extern "C" {
#endif
struct cryfs_load_handle;
cryfs_load_handle *cryfs_load_init();
void cryfs_load_free(cryfs_load_handle *handle);
const char *cryfs_test(cryfs_load_handle *handle);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -7,4 +7,5 @@ if (BUILD_TESTING)
add_subdirectory(blockstore)
add_subdirectory(blobstore)
add_subdirectory(cryfs)
add_subdirectory(cryfs-cli)
endif(BUILD_TESTING)

View File

@ -0,0 +1,22 @@
project (cryfs-cli-test)
set(SOURCES
CallAfterTimeoutTest.cpp
testutils/CliTest.cpp
CliTest_Setup.cpp
CliTest_WrongEnvironment.cpp
program_options/UtilsTest.cpp
program_options/ProgramOptionsTest.cpp
program_options/ParserTest.cpp
CliTest_ShowingHelp.cpp
EnvironmentTest.cpp
VersionCheckerTest.cpp
VersionCompareTest.cpp
)
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} googletest cryfs-cli)
add_test(${PROJECT_NAME} ${PROJECT_NAME})
target_enable_style_warnings(${PROJECT_NAME})
target_activate_cpp14(${PROJECT_NAME})

View File

@ -1,6 +1,6 @@
#include <gtest/gtest.h>
#include <cpp-utils/pointer/unique_ref.h>
#include <cryfs/cli/CallAfterTimeout.h>
#include <cryfs-cli/CallAfterTimeout.h>
using cpputils::unique_ref;
using cpputils::make_unique_ref;

View File

@ -1,5 +1,5 @@
#include <gtest/gtest.h>
#include <cryfs/cli/Environment.h>
#include <cryfs-cli/Environment.h>
#include <boost/optional.hpp>
using namespace cryfs;

View File

@ -1,5 +1,5 @@
#include <gtest/gtest.h>
#include <cryfs/cli/VersionChecker.h>
#include <cryfs-cli/VersionChecker.h>
#include <cpp-utils/network/FakeHttpClient.h>
#include <cpp-utils/pointer/unique_ref.h>

View File

@ -1,5 +1,5 @@
#include <gtest/gtest.h>
#include <cryfs/cli/VersionCompare.h>
#include <cryfs-cli/VersionCompare.h>
using namespace cryfs;
using std::string;

View File

@ -1,5 +1,5 @@
#include "testutils/ProgramOptionsTestBase.h"
#include <cryfs/cli/program_options/Parser.h>
#include <cryfs-cli/program_options/Parser.h>
#include <cryfs/config/CryCipher.h>
using namespace cryfs;

View File

@ -1,5 +1,5 @@
#include "testutils/ProgramOptionsTestBase.h"
#include <cryfs/cli/program_options/ProgramOptions.h>
#include <cryfs-cli/program_options/ProgramOptions.h>
#include <cpp-utils/pointer/unique_ref_boost_optional_gtest_workaround.h>
using namespace cryfs::program_options;

View File

@ -1,5 +1,5 @@
#include "testutils/ProgramOptionsTestBase.h"
#include <cryfs/cli/program_options/utils.h>
#include <cryfs-cli/program_options/utils.h>
using namespace cryfs::program_options;
using std::pair;

View File

@ -6,12 +6,12 @@
#include <gmock/gmock.h>
#include <cpp-utils/tempfile/TempDir.h>
#include <cpp-utils/tempfile/TempFile.h>
#include <cryfs/cli/Cli.h>
#include <cryfs/cli/VersionChecker.h>
#include <cryfs-cli/Cli.h>
#include <cryfs-cli/VersionChecker.h>
#include <cpp-utils/logging/logging.h>
#include <cpp-utils/process/subprocess.h>
#include <cpp-utils/network/FakeHttpClient.h>
#include "../../testutils/MockConsole.h"
#include "../../cryfs/testutils/MockConsole.h"
class CliTest : public ::testing::Test {
public:

View File

@ -1,17 +1,6 @@
project (cryfs-test)
set(SOURCES
cli/CallAfterTimeoutTest.cpp
cli/testutils/CliTest.cpp
cli/CliTest_Setup.cpp
cli/CliTest_WrongEnvironment.cpp
cli/program_options/UtilsTest.cpp
cli/program_options/ProgramOptionsTest.cpp
cli/program_options/ParserTest.cpp
cli/CliTest_ShowingHelp.cpp
cli/EnvironmentTest.cpp
cli/VersionCheckerTest.cpp
cli/VersionCompareTest.cpp
config/crypto/CryConfigEncryptorFactoryTest.cpp
config/crypto/outer/OuterConfigTest.cpp
config/crypto/outer/OuterEncryptorTest.cpp
@ -30,7 +19,7 @@ set(SOURCES
)
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} googletest cryfs_lib)
target_link_libraries(${PROJECT_NAME} googletest cryfs)
add_test(${PROJECT_NAME} ${PROJECT_NAME})
target_enable_style_warnings(${PROJECT_NAME})

View File

@ -1,5 +1,4 @@
#include <gtest/gtest.h>
#include <cryfs/config/CryConfigFile.h>
#include <cpp-utils/tempfile/TempFile.h>

View File

@ -1,5 +1,4 @@
#include <gtest/gtest.h>
#include <cryfs/config/CryConfig.h>
using namespace cryfs;