Embed Feature Flag Data

This commit is contained in:
TheBrokenRail 2022-07-13 23:35:05 -04:00
parent 0e32fd36c8
commit 010aaa89e3
6 changed files with 43 additions and 42 deletions

View File

@ -8,7 +8,14 @@ add_executable(launcher src/bootstrap.c src/patchelf.c src/crash-report.c)
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)
target_sources(launcher PRIVATE src/server/launcher.c) target_sources(launcher PRIVATE src/server/launcher.c)
else() else()
target_sources(launcher PRIVATE src/client/launcher.cpp) add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/available-feature-flags.c"
COMMAND xxd -i available-feature-flags "${CMAKE_CURRENT_BINARY_DIR}/available-feature-flags.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/client/available-feature-flags"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/client"
VERBATIM
)
target_sources(launcher PRIVATE src/client/launcher.cpp "${CMAKE_CURRENT_BINARY_DIR}/available-feature-flags.c")
endif() endif()
target_link_libraries(launcher reborn-util) target_link_libraries(launcher reborn-util)
# RPath # RPath
@ -18,11 +25,6 @@ set_target_properties(launcher PROPERTIES INSTALL_RPATH "$ORIGIN/lib/native")
install(TARGETS launcher DESTINATION "${MCPI_INSTALL_DIR}") install(TARGETS launcher DESTINATION "${MCPI_INSTALL_DIR}")
install_symlink("../${MCPI_INSTALL_DIR}/launcher" "bin/${MCPI_VARIANT_NAME}") install_symlink("../${MCPI_INSTALL_DIR}/launcher" "bin/${MCPI_VARIANT_NAME}")
# Install Available Feature Flags List
if(NOT MCPI_SERVER_MODE)
install(FILES "src/client/available-feature-flags" DESTINATION "${MCPI_INSTALL_DIR}")
endif()
# Install Desktop Entry # Install Desktop Entry
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/launcher.desktop" file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/launcher.desktop"
"[Desktop Entry]\n" "[Desktop Entry]\n"

View File

@ -1,4 +1,4 @@
#include <fstream> #include <sstream>
#include <cstring> #include <cstring>
#include <cerrno> #include <cerrno>
#include <sys/wait.h> #include <sys/wait.h>
@ -36,14 +36,17 @@ static std::string strip_feature_flag_default(std::string flag, bool *default_re
} }
// Load Available Feature Flags // Load Available Feature Flags
extern unsigned char available_feature_flags[];
extern unsigned int available_feature_flags_len;
static void load_available_feature_flags(std::function<void(std::string)> callback) { static void load_available_feature_flags(std::function<void(std::string)> callback) {
// Get Path // Get Path
char *binary_directory = get_binary_directory(); char *binary_directory = get_binary_directory();
std::string path = std::string(binary_directory) + "/available-feature-flags"; std::string path = std::string(binary_directory) + "/available-feature-flags";
free(binary_directory); free(binary_directory);
// Load File // Load File
std::ifstream stream(path); std::string data(available_feature_flags, available_feature_flags + available_feature_flags_len);
if (stream && stream.good()) { std::stringstream stream(data);
// Store Lines
std::vector<std::string> lines; std::vector<std::string> lines;
// Read File // Read File
{ {
@ -69,14 +72,9 @@ static void load_available_feature_flags(std::function<void(std::string)> callba
return stripped_a < stripped_b; return stripped_a < stripped_b;
}); });
// Run Callbacks // Run Callbacks
for (std::string line : lines) { for (std::string &line : lines) {
callback(line); callback(line);
} }
// Close File
stream.close();
} else {
ERR("Unable To Load Available Feature Flags");
}
} }
// Run Command And Set Environmental Variable // Run Command And Set Environmental Variable

View File

@ -229,7 +229,7 @@ ALuint _media_audio_get_buffer(const char *source, const char *name) {
// Delete Buffers // Delete Buffers
void _media_audio_delete_buffers() { void _media_audio_delete_buffers() {
if (_media_audio_is_loaded()) { if (_media_audio_is_loaded()) {
for (auto it : buffers) { for (auto &it : buffers) {
if (it.second && alIsBuffer(it.second)) { if (it.second && alIsBuffer(it.second)) {
alDeleteBuffers(1, &it.second); alDeleteBuffers(1, &it.second);
} }

View File

@ -415,7 +415,7 @@ static bool is_ip_in_blacklist(const char *ip) {
return false; return false;
} else { } else {
// Check List // Check List
for (std::string x : ips) { for (std::string &x : ips) {
if (x.compare(ip) == 0) { if (x.compare(ip) == 0) {
return true; return true;
} }

View File

@ -370,8 +370,8 @@ std::string _sound_pick(std::string sound) {
void _sound_resolve_all() { void _sound_resolve_all() {
std::string source = _sound_get_source_file(); std::string source = _sound_get_source_file();
if (source.size() > 0) { if (source.size() > 0) {
for (auto it : repository) { for (auto &it : repository) {
for (std::string name : it.second) { for (std::string &name : it.second) {
// Zero Volume Prevents An OpenAL Source From Being Allocated While Still Resolving The Sound // Zero Volume Prevents An OpenAL Source From Being Allocated While Still Resolving The Sound
media_audio_play(source.c_str(), name.c_str(), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f); media_audio_play(source.c_str(), name.c_str(), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f);
} }

View File

@ -30,7 +30,8 @@ run() {
# Host Dependencies Needed For Compile # Host Dependencies Needed For Compile
queue_pkg \ queue_pkg \
libwayland-bin libwayland-bin \
xxd
# Host Dependencies Needed For Running # Host Dependencies Needed For Running
queue_pkg \ queue_pkg \