mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Updated build system to incorporate libgit2.
Also, VCS picking is done by looking to see if ".git" is in the remote URL or not.
This commit is contained in:
+2
-2
@@ -16,7 +16,7 @@ set (BOSS_SRC "${CMAKE_SOURCE_DIR}/src/backend/metadata.cpp" "${CMAKE_SOURCE_DIR
|
||||
set (BOSS_SRC ${BOSS_SRC} "${PROJECT_LIBS_DIR}/boost/libs/iostreams/src/file_descriptor.cpp")
|
||||
|
||||
# Include source and library directories.
|
||||
include_directories ("${PROJECT_LIBS_DIR}/alphanum" "${PROJECT_LIBS_DIR}/boost" "${PROJECT_LIBS_DIR}/yaml-cpp/include" "${CMAKE_SOURCE_DIR}/src" "${PROJECT_LIBS_DIR}/libloadorder/src" "${PROJECT_LIBS_DIR}/libespm" "${PROJECT_LIBS_DIR}/zlib" "${PROJECT_LIBS_DIR}/pugixml/src" "${PROJECT_LIBS_DIR}/wxWidgets/include")
|
||||
include_directories ("${PROJECT_LIBS_DIR}/alphanum" "${PROJECT_LIBS_DIR}/boost" "${PROJECT_LIBS_DIR}/yaml-cpp/include" "${CMAKE_SOURCE_DIR}/src" "${PROJECT_LIBS_DIR}/libloadorder/src" "${PROJECT_LIBS_DIR}/libespm" "${PROJECT_LIBS_DIR}/zlib" "${PROJECT_LIBS_DIR}/pugixml/src" "${PROJECT_LIBS_DIR}/wxWidgets/include" "${PROJECT_LIBS_DIR}/libgit2/include")
|
||||
|
||||
|
||||
##############################
|
||||
@@ -61,7 +61,7 @@ IF (CMAKE_HOST_SYSTEM_NAME MATCHES "Linux")
|
||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--subsystem,windows")
|
||||
ENDIF ()
|
||||
|
||||
set (BOSS_LIBS ${BOSS_LIBS} zlibstatic loadorder${PROJECT_ARCH} yaml-cpp boost_log_setup boost_log boost_locale boost_thread_win32 boost_chrono boost_date_time boost_filesystem boost_system boost_regex)
|
||||
set (BOSS_LIBS ${BOSS_LIBS} git2 zlibstatic loadorder${PROJECT_ARCH} yaml-cpp boost_log_setup boost_log boost_locale boost_thread_win32 boost_chrono boost_date_time boost_filesystem boost_system boost_regex)
|
||||
ENDIF ()
|
||||
|
||||
# Settings when compiling on Windows.
|
||||
|
||||
@@ -85,8 +85,7 @@ echo "using gcc : 4.6.3 : i686-w64-mingw32-g++ : <rc>i686-w64-mingw32-windres <a
|
||||
### zlib
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
mkdir build && cd build
|
||||
cmake .. -DCMAKE_C_FLAGS=-m32 -DPROJECT_ARCH=32 -DCMAKE_TOOLCHAIN_FILE=../BOSSv3/mingw-toolchain.cmake
|
||||
make
|
||||
cp zconf.h ../zconf.h
|
||||
@@ -100,13 +99,20 @@ cmake . -DCMAKE_C_FLAGS=-m32 -DPROJECT_ARCH=32 -DCMAKE_TOOLCHAIN_FILE=../BOSSv3/
|
||||
|
||||
### Libloadorder
|
||||
|
||||
Follow the instructions in libloadorder's README to build it as a static library.
|
||||
Follow the instructions in libloadorder's README.md to build it as a static library.
|
||||
|
||||
### Libgit2
|
||||
|
||||
```
|
||||
mkdir build && cd build
|
||||
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-m32 -DPROJECT_ARCH=32 -DCMAKE_TOOLCHAIN_FILE=../BOSSv3/mingw-toolchain.cmake
|
||||
|
||||
```
|
||||
|
||||
### BOSS
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
mkdir build && cd build
|
||||
cmake .. -DPROJECT_LIBS_DIR=.. -DPROJECT_ARCH=32 -DPROJECT_LINK=STATIC -DCMAKE_TOOLCHAIN_FILE=mingw-toolchain.cmake
|
||||
make
|
||||
```
|
||||
|
||||
+60
-50
@@ -27,6 +27,8 @@
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include <git2.h>
|
||||
|
||||
#if _WIN32 || _WIN64
|
||||
# ifndef UNICODE
|
||||
# define UNICODE
|
||||
@@ -143,69 +145,77 @@ namespace boss {
|
||||
|
||||
std::string UpdateMasterlist(const Game& game, std::vector<std::string>& parsingErrors) {
|
||||
|
||||
string command, output, revision;
|
||||
//First check if the working copy is set up or not.
|
||||
command = g_path_svn.string() + " info \"" + game.MasterlistPath().string() + "\"";
|
||||
//First need to decide how the masterlist is updated: using Git or Subversion?
|
||||
//Look at the update URL to decide.
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "Checking to see if the working copy is set up or not for the masterlist at \"" + game.MasterlistPath().string() + "\"";
|
||||
bool success = RunCommand(command, output);
|
||||
if (game.URL().find(".git") == string::npos) { //Subversion
|
||||
|
||||
revision = GetRevision(output);
|
||||
string command, output, revision;
|
||||
//First check if the working copy is set up or not.
|
||||
command = g_path_svn.string() + " info \"" + game.MasterlistPath().string() + "\"";
|
||||
|
||||
if (game.URL().empty()) {
|
||||
if (!revision.empty())
|
||||
return revision;
|
||||
else
|
||||
return "N/A";
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(trace) << "Checking to see if the working copy is set up or not for the masterlist at \"" + game.MasterlistPath().string() + "\"";
|
||||
bool success = RunCommand(command, output);
|
||||
|
||||
if (!success) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Working copy is not set up, checking out repository.";
|
||||
//Working copy not set up, perform a checkout.
|
||||
command = g_path_svn.string() + " co --depth empty " + game.URL().substr(0, game.URL().rfind('/')) + " \"" + game.MasterlistPath().parent_path().string() + "\\.\"";
|
||||
revision = GetRevision(output);
|
||||
|
||||
if (game.URL().empty()) {
|
||||
if (!revision.empty())
|
||||
return revision;
|
||||
else
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Working copy is not set up, checking out repository.";
|
||||
//Working copy not set up, perform a checkout.
|
||||
command = g_path_svn.string() + " co --depth empty " + game.URL().substr(0, game.URL().rfind('/')) + " \"" + game.MasterlistPath().parent_path().string() + "\\.\"";
|
||||
if (!RunCommand(command, output)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Subversion could not perform a checkout. Details: " << output;
|
||||
throw error(error::subversion_error, "Subversion could not perform a checkout. Details: " + output);
|
||||
}
|
||||
}
|
||||
|
||||
//Now update masterlist.
|
||||
BOOST_LOG_TRIVIAL(trace) << "Performing Subversion update of masterlist.";
|
||||
command = g_path_svn.string() + " update \"" + game.MasterlistPath().string() + "\"";
|
||||
if (!RunCommand(command, output)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Subversion could not perform a checkout. Details: " << output;
|
||||
throw error(error::subversion_error, "Subversion could not perform a checkout. Details: " + output);
|
||||
BOOST_LOG_TRIVIAL(error) << "Subversion could not update the masterlist. Details: " << output;
|
||||
throw error(error::subversion_error, "Subversion could not update the masterlist. Details: " + output);
|
||||
}
|
||||
}
|
||||
|
||||
//Now update masterlist.
|
||||
BOOST_LOG_TRIVIAL(trace) << "Performing Subversion update of masterlist.";
|
||||
command = g_path_svn.string() + " update \"" + game.MasterlistPath().string() + "\"";
|
||||
if (!RunCommand(command, output)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Subversion could not update the masterlist. Details: " << output;
|
||||
throw error(error::subversion_error, "Subversion could not update the masterlist. Details: " + output);
|
||||
}
|
||||
while (true) {
|
||||
try {
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
//Now get the masterlist revision.
|
||||
BOOST_LOG_TRIVIAL(trace) << "Getting the new masterlist version.";
|
||||
command = g_path_svn.string() + " info \"" + game.MasterlistPath().string() + "\"";
|
||||
if (!RunCommand(command, output)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Subversion could not read the masterlist revision number. Details: " << output;
|
||||
throw error(error::subversion_error, "Subversion could not read the masterlist revision number. Details: " + output);
|
||||
}
|
||||
|
||||
//Now get the masterlist revision.
|
||||
BOOST_LOG_TRIVIAL(trace) << "Getting the new masterlist version.";
|
||||
command = g_path_svn.string() + " info \"" + game.MasterlistPath().string() + "\"";
|
||||
if (!RunCommand(command, output)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Subversion could not read the masterlist revision number. Details: " << output;
|
||||
throw error(error::subversion_error, "Subversion could not read the masterlist revision number. Details: " + output);
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(trace) << "Reading the masterlist version from the svn info output.";
|
||||
revision = GetRevision(output);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "Reading the masterlist version from the svn info output.";
|
||||
revision = GetRevision(output);
|
||||
//Now test masterlist to see if it parses OK.
|
||||
BOOST_LOG_TRIVIAL(trace) << "Testing the new masterlist to see if it parses OK.";
|
||||
YAML::Node mlist = YAML::LoadFile(game.MasterlistPath().string());
|
||||
|
||||
//Now test masterlist to see if it parses OK.
|
||||
BOOST_LOG_TRIVIAL(trace) << "Testing the new masterlist to see if it parses OK.";
|
||||
YAML::Node mlist = YAML::LoadFile(game.MasterlistPath().string());
|
||||
|
||||
return revision;
|
||||
} catch (YAML::Exception& e) {
|
||||
//Roll back one revision if there's an error.
|
||||
BOOST_LOG_TRIVIAL(error) << "Masterlist parsing failed. Masterlist revision " + revision + ": " + e.what();
|
||||
parsingErrors.push_back("Masterlist revision " + revision + ": " + e.what());
|
||||
command = g_path_svn.string() + " update --revision PREV \"" + game.MasterlistPath().string() + "\"";
|
||||
if (!RunCommand(command, output)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Subversion could not update the masterlist. Details: " << output;
|
||||
throw error(error::subversion_error, "Subversion could not update the masterlist. Details: " + output);
|
||||
return revision;
|
||||
} catch (YAML::Exception& e) {
|
||||
//Roll back one revision if there's an error.
|
||||
BOOST_LOG_TRIVIAL(error) << "Masterlist parsing failed. Masterlist revision " + revision + ": " + e.what();
|
||||
parsingErrors.push_back("Masterlist revision " + revision + ": " + e.what());
|
||||
command = g_path_svn.string() + " update --revision PREV \"" + game.MasterlistPath().string() + "\"";
|
||||
if (!RunCommand(command, output)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "Subversion could not update the masterlist. Details: " << output;
|
||||
throw error(error::subversion_error, "Subversion could not update the masterlist. Details: " + output);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { //Git.
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user