Embed Feature Flag Data
This commit is contained in:
parent
0e32fd36c8
commit
010aaa89e3
@ -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"
|
||||||
|
@ -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,46 +36,44 @@ 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);
|
||||||
std::vector<std::string> lines;
|
// Store Lines
|
||||||
// Read File
|
std::vector<std::string> lines;
|
||||||
{
|
// Read File
|
||||||
std::string line;
|
{
|
||||||
while (std::getline(stream, line)) {
|
std::string line;
|
||||||
if (line.length() > 0) {
|
while (std::getline(stream, line)) {
|
||||||
// Verify Line
|
if (line.length() > 0) {
|
||||||
if (line.find('|') == std::string::npos) {
|
// Verify Line
|
||||||
lines.push_back(line);
|
if (line.find('|') == std::string::npos) {
|
||||||
} else {
|
lines.push_back(line);
|
||||||
// Invalid Line
|
} else {
|
||||||
ERR("Feature Flag Contains Invalid '|'");
|
// Invalid Line
|
||||||
}
|
ERR("Feature Flag Contains Invalid '|'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Sort
|
||||||
|
std::sort(lines.begin(), lines.end(), [](std::string a, std::string b) {
|
||||||
|
// Strip Defaults
|
||||||
|
std::string stripped_a = strip_feature_flag_default(a, NULL);
|
||||||
|
std::string stripped_b = strip_feature_flag_default(b, NULL);
|
||||||
// Sort
|
// Sort
|
||||||
std::sort(lines.begin(), lines.end(), [](std::string a, std::string b) {
|
return stripped_a < stripped_b;
|
||||||
// Strip Defaults
|
});
|
||||||
std::string stripped_a = strip_feature_flag_default(a, NULL);
|
// Run Callbacks
|
||||||
std::string stripped_b = strip_feature_flag_default(b, NULL);
|
for (std::string &line : lines) {
|
||||||
// Sort
|
callback(line);
|
||||||
return stripped_a < stripped_b;
|
|
||||||
});
|
|
||||||
// Run Callbacks
|
|
||||||
for (std::string line : lines) {
|
|
||||||
callback(line);
|
|
||||||
}
|
|
||||||
// Close File
|
|
||||||
stream.close();
|
|
||||||
} else {
|
|
||||||
ERR("Unable To Load Available Feature Flags");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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 \
|
||||||
|
Loading…
Reference in New Issue
Block a user