TheBrokenRail 07f5e188f7
All checks were successful
CI / Build (AMD64) (push) Successful in 19m40s
CI / Build (ARM64) (push) Successful in 22m32s
CI / Build (ARMHF) (push) Successful in 13m16s
CI / Test (AMD64, Server) (push) Successful in 1m44s
CI / Build Example Mods (push) Successful in 1m40s
CI / Test (ARM64, Client) (push) Successful in 4m0s
CI / Test (ARM64, Server) (push) Successful in 58s
CI / Test (AMD64, Client) (push) Successful in 5m57s
CI / Test (ARMHF, Client) (push) Successful in 4m12s
CI / Test (ARMHF, Server) (push) Successful in 1m9s
CI / Release (push) Has been skipped
Bug Fixes & Improvements
2024-08-23 05:18:20 -04:00

60 lines
1.7 KiB
C++

#include <libreborn/libreborn.h>
#include "bootstrap.h"
#include "util.h"
// Log
#define LOG(is_debug, ...) \
{ \
if (is_debug) { \
DEBUG(__VA_ARGS__); \
} else { \
INFO(__VA_ARGS__); \
} \
}
// Copy SDK Into ~/.minecraft-pi
#define HOME_SUBDIRECTORY_FOR_SDK (std::string(get_home_subdirectory_for_game_data()) + "/sdk")
void copy_sdk(const std::string &binary_directory, const bool log_with_debug) {
// Ensure SDK Directory
std::string sdk_path;
{
sdk_path = std::string(getenv(_MCPI_HOME_ENV)) + HOME_SUBDIRECTORY_FOR_SDK;
const char *const command[] = {"mkdir", "-p", sdk_path.c_str(), nullptr};
run_simple_command(command, "Unable To Create SDK Directory");
}
// Lock File
const std::string lock_file_path = sdk_path + "/.lock";
const int lock_file_fd = lock_file(lock_file_path.c_str());
// Output Directory
const std::string output = sdk_path + "/" MCPI_SDK_DIR;
// Source Directory
const std::string source = binary_directory + "/sdk/.";
// Clean
{
const char *const command[] = {"rm", "-rf", output.c_str(), nullptr};
run_simple_command(command, "Unable To Clean SDK Output Directory");
}
// Make Directory
{
const char *const command[] = {"mkdir", "-p", output.c_str(), nullptr};
run_simple_command(command, "Unable To Create SDK Output Directory");
}
// Copy
{
const char *const command[] = {"cp", "-ar", source.c_str(), output.c_str(), nullptr};
run_simple_command(command, "Unable To Copy SDK");
}
// Log
LOG(log_with_debug, "Copied SDK To: %s", output.c_str());
// Unlock File
unlock_file(lock_file_path.c_str(), lock_file_fd);
}