More CMake Tweaks
This commit is contained in:
parent
9a521ebca2
commit
513628d91f
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,4 +12,3 @@
|
||||
/*.AppImage
|
||||
/core*
|
||||
/qemu_*
|
||||
/cmake/.prebuilt-armhf-toolchain
|
||||
|
@ -99,10 +99,14 @@ project(minecraft-pi-reborn)
|
||||
include(cmake/util.cmake)
|
||||
|
||||
# Sanity Checks
|
||||
if(BUILD_NATIVE_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND NOT MCPI_IS_MIXED_BUILD)
|
||||
set(IS_ARM_TARGETING FALSE)
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
|
||||
set(IS_ARM_TARGETING TRUE)
|
||||
endif()
|
||||
if(BUILD_NATIVE_COMPONENTS AND NOT IS_ARM_TARGETING AND NOT MCPI_IS_MIXED_BUILD)
|
||||
message(FATAL_ERROR "Project is configured as a mixed-buld, but MCPI_IS_MIXED_BUILD is disabled.")
|
||||
endif()
|
||||
if(BUILD_ARM_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
|
||||
if(BUILD_ARM_COMPONENTS AND NOT IS_ARM_TARGETING)
|
||||
message(FATAL_ERROR "ARM-Targeting Compiler Required")
|
||||
endif()
|
||||
|
||||
|
12
cmake/embed-resource.cmake
Normal file
12
cmake/embed-resource.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
# Read Hex Data
|
||||
file(READ "${EMBED_IN}" data HEX)
|
||||
|
||||
# Convert Hex Data For C Compatibility
|
||||
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," data "${data}")
|
||||
|
||||
# Get C Name
|
||||
get_filename_component(name "${EMBED_IN}" NAME)
|
||||
string(MAKE_C_IDENTIFIER "${name}" name)
|
||||
|
||||
# Write Data
|
||||
file(WRITE "${EMBED_OUT}" "#include <stddef.h>\nconst unsigned char ${name}[] = {${data}};\nconst size_t ${name}_len = sizeof (${name});\n")
|
@ -9,8 +9,6 @@ set(CMAKE_SYSTEM_NAME "Linux")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "arm")
|
||||
unset(CMAKE_TOOLCHAIN_FILE CACHE)
|
||||
|
||||
# Download If Needed
|
||||
if(NOT EXISTS "${CMAKE_C_COMPILER}")
|
||||
# Pick URL
|
||||
execute_process(COMMAND uname -m OUTPUT_VARIABLE arch OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(arch STREQUAL "x86_64")
|
||||
@ -23,6 +21,20 @@ if(NOT EXISTS "${CMAKE_C_COMPILER}")
|
||||
message(FATAL_ERROR "Unable To Download Prebuilt ARMHF Toolchain")
|
||||
endif()
|
||||
|
||||
# Check Toolchain
|
||||
set(toolchain_valid FALSE)
|
||||
if(EXISTS "${toolchain_dir}/.last_sha256")
|
||||
file(STRINGS "${toolchain_dir}/.last_sha256" toolchain_last_sha256)
|
||||
if(toolchain_last_sha256 STREQUAL toolchain_sha256)
|
||||
set(toolchain_valid TRUE)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT toolchain_valid)
|
||||
file(REMOVE_RECURSE "${toolchain_dir}")
|
||||
endif()
|
||||
|
||||
# Download If Needed
|
||||
if(NOT EXISTS "${CMAKE_C_COMPILER}")
|
||||
# Download
|
||||
message(STATUS "Downloading Prebuilt ARMHF Toolchain...")
|
||||
file(REMOVE_RECURSE "${toolchain_dir}")
|
||||
@ -36,6 +48,12 @@ if(NOT EXISTS "${CMAKE_C_COMPILER}")
|
||||
)
|
||||
FetchContent_Populate(prebuilt-armhf-toolchain)
|
||||
|
||||
# Write Last SHA256
|
||||
file(WRITE "${toolchain_dir}/.last_sha256" "${toolchain_sha256}")
|
||||
|
||||
# Write .gitignore
|
||||
file(WRITE "${toolchain_dir}/.gitignore" "/*\n")
|
||||
|
||||
# Force Sysroot Rebuild
|
||||
file(REMOVE_RECURSE "${sysroot_dir}")
|
||||
endif()
|
||||
|
@ -10,22 +10,17 @@ function(install_symlink target link)
|
||||
endfunction()
|
||||
|
||||
# Embed Resources
|
||||
set(util_list_dir "${CMAKE_CURRENT_LIST_DIR}")
|
||||
function(embed_resource target file)
|
||||
# Read Hex Data
|
||||
file(READ "${file}" data HEX)
|
||||
# Convert Hex Data For C Compatibility
|
||||
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," data "${data}")
|
||||
# Get C Name
|
||||
get_filename_component(name "${file}" NAME)
|
||||
string(MAKE_C_IDENTIFIER "${name}" name)
|
||||
# Write Data
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${name}.c" "#include <stddef.h>\nconst unsigned char ${name}[] = {${data}};\nconst size_t ${name}_len = sizeof (${name});\n")
|
||||
# Add Command
|
||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
ARGS "-DEMBED_IN=${CMAKE_CURRENT_SOURCE_DIR}/${file}" "-DEMBED_OUT=${CMAKE_CURRENT_BINARY_DIR}/${name}.c" "-P" "${util_list_dir}/embed-resource.cmake"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${file}" "${util_list_dir}/embed-resource.cmake"
|
||||
)
|
||||
# Add To Target
|
||||
target_sources("${target}" PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
|
||||
# Mark Dependency
|
||||
set_property(
|
||||
DIRECTORY
|
||||
APPEND
|
||||
PROPERTY CMAKE_CONFIGURE_DEPENDS "${file}"
|
||||
)
|
||||
endfunction()
|
||||
|
2
dependencies/zenity/src
vendored
2
dependencies/zenity/src
vendored
@ -1 +1 @@
|
||||
Subproject commit d673e9aab842d7151d92eb9164872dc05e748db2
|
||||
Subproject commit 7dc886e7d217bb2ecaa2d771e08443b92c36fe28
|
@ -1,5 +1,5 @@
|
||||
# Example Mods
|
||||
This is an example of a mod that cane be built using the modding SDK.
|
||||
This is an example of a mod that can be built using the modding SDK.
|
||||
|
||||
* **Expanded Creative Mod**: This specific mod adds even more items and blocks to the Creative Inventory. It was originally by [@Bigjango13](https://github.com/bigjango13).
|
||||
* **Chat Commands Mod**: This specific mod makes an chat message starting with a ``/`` handled by the MCPI API.
|
||||
|
@ -16,8 +16,8 @@ if(NOT MCPI_HEADLESS_MODE)
|
||||
target_link_libraries(GLESv1_CM PRIVATE glfw PUBLIC reborn-util PRIVATE dl PRIVATE m)
|
||||
# Shaders
|
||||
if(MCPI_USE_GLES1_COMPATIBILITY_LAYER)
|
||||
embed_resource(GLESv1_CM src/compatibility-layer/shaders/main.vert)
|
||||
embed_resource(GLESv1_CM src/compatibility-layer/shaders/main.frag)
|
||||
embed_resource(GLESv1_CM src/compatibility-layer/shaders/main.vsh)
|
||||
embed_resource(GLESv1_CM src/compatibility-layer/shaders/main.fsh)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -78,14 +78,14 @@ static GLuint compile_shader(const char *vertex_shader_text, const int vertex_sh
|
||||
}
|
||||
|
||||
// Shader
|
||||
extern unsigned char main_vert[];
|
||||
extern size_t main_vert_len;
|
||||
extern unsigned char main_frag[];
|
||||
extern size_t main_frag_len;
|
||||
extern unsigned char main_vsh[];
|
||||
extern size_t main_vsh_len;
|
||||
extern unsigned char main_fsh[];
|
||||
extern size_t main_fsh_len;
|
||||
static GLuint get_shader() {
|
||||
static GLuint program = 0;
|
||||
if (program == 0) {
|
||||
program = compile_shader((const char *) main_vert, main_vert_len, (const char *) main_frag, main_frag_len);
|
||||
program = compile_shader((const char *) main_vsh, main_vsh_len, (const char *) main_fsh, main_fsh_len);
|
||||
}
|
||||
return program;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user