diff --git a/CMakeLists.txt b/CMakeLists.txt index a1f785db..183c782f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ option(WITH_UPNP "Include support for UPnP client" OFF) option(WITH_TESTS "Build unit tests" OFF) option(WITH_BENCHMARK "Build benchmarking code" OFF) option(WITH_OPTIMIZE "Optimization flags" OFF) +option(I2PD_DATA_PATH "The path to the i2pd data folder") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake_modules") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -153,6 +154,18 @@ include_directories( "core/" ) +if(I2PD_DATA_PATH) + set(I2PD_DATA_DIR ${I2PD_DATA_PATH}) + # Using custom path, make sure the code knows about this + add_definitions(-DI2PD_CUSTOM_DATA_PATH="${I2PD_DATA_PATH}") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + set(I2PD_DATA_DIR "$ENV{APPDATA}\i2pd") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(I2PD_DATA_DIR "$ENV{HOME}/Library/Application Support/i2pd") +else() + set(I2PD_DATA_DIR "$ENV{HOME}/.i2pd") +endif() + # Show summary message(STATUS "---------------------------------------") message(STATUS "Build type : ${CMAKE_BUILD_TYPE}") @@ -160,6 +173,7 @@ message(STATUS "Compiler vendor : ${CMAKE_CXX_COMPILER_ID}") message(STATUS "Compiler version : ${CMAKE_CXX_COMPILER_VERSION}") message(STATUS "Compiler path : ${CMAKE_CXX_COMPILER}") message(STATUS "Install prefix: : ${CMAKE_INSTALL_PREFIX}") +message(STATUS "I2PD data directory: ${I2PD_DATA_DIR}") message(STATUS "Options:") message(STATUS " AESNI : ${WITH_AESNI}") message(STATUS " HARDENING : ${WITH_HARDENING}") @@ -183,3 +197,8 @@ add_subdirectory(core) add_subdirectory(client) add_subdirectory(tests) add_subdirectory(benchmark) + +if(WITH_BINARY) + file(MAKE_DIRECTORY "${I2PD_DATA_DIR}/webui") + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/webui" DESTINATION "${I2PD_DATA_DIR}") +endif() diff --git a/README.md b/README.md index a50fe65d..46e82d99 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ Build Statuses - Microsoft VC13 - To be added -Testing -------- +Building from source +-------------------- First, build it. @@ -58,6 +58,10 @@ By default, the web console is located at http://localhost:7070/. For a list of cmake options, see build/BUILD_NOTES.md +Note that cmake will automatically create a directory for storing configuration files. +To change the location of this directory, you must set the I2PD_DATA_DIR flag. +This does not apply to core-only builds. + Building Unit Tests ------------------- diff --git a/build/BUILD_NOTES.md b/build/BUILD_NOTES.md index 0ddcd4f7..d4d289dd 100644 --- a/build/BUILD_NOTES.md +++ b/build/BUILD_NOTES.md @@ -9,6 +9,7 @@ Available cmake options: * WITH_TESTS -- build tests (ON/OFF) * WITH_BENCHMARK -- build bechmarking code (ON/OFF) * WITH_OPTIMIZE -- enable optimization flags (ON/OFF) (not for MSVC) +* I2PD_DATA_DIR -- directory where i2pd will store data Debian ------ diff --git a/core/util/util.cpp b/core/util/util.cpp index d55f380b..cb53e786 100644 --- a/core/util/util.cpp +++ b/core/util/util.cpp @@ -195,23 +195,24 @@ namespace filesystem boost::filesystem::path GetDefaultDataDir() { + // Custom path, or default path: // Windows < Vista: C:\Documents and Settings\Username\Application Data\i2pd // Windows >= Vista: C:\Users\Username\AppData\Roaming\i2pd // Mac: ~/Library/Application Support/i2pd - // Unix: ~/.i2pd or /var/lib/i2pd is system=1 - + // Unix: ~/.i2pd +#ifdef I2PD_CUSTOM_DATA_PATH + return boost::filesystem::path(std::string(I2PD_CUSTOM_DATA_PATH)); +#else #ifdef WIN32 // Windows char localAppData[MAX_PATH]; SHGetFolderPath(NULL, CSIDL_APPDATA, 0, NULL, localAppData); return boost::filesystem::path(std::string(localAppData) + "\\" + appName); #else - if(i2p::util::config::GetArg("-service", 0)) // use system folder - return boost::filesystem::path(std::string ("/var/lib/") + appName); boost::filesystem::path pathRet; char* pszHome = getenv("HOME"); if(pszHome == NULL || strlen(pszHome) == 0) - pathRet = boost::filesystem::path("/"); + pathRet = boost::filesystem::path("/"); else pathRet = boost::filesystem::path(pszHome); #ifdef MAC_OSX @@ -223,6 +224,7 @@ namespace filesystem // Unix return pathRet / (std::string (".") + appName); #endif +#endif #endif } diff --git a/webui/index.html b/webui/index.html new file mode 100644 index 00000000..3d98ba3d --- /dev/null +++ b/webui/index.html @@ -0,0 +1 @@ +Nothing here yet.