Stop Fighting CMake
This commit is contained in:
parent
0d9f498aa7
commit
edd346dd66
@ -200,7 +200,7 @@ endif()
|
||||
# Install SDK
|
||||
if(BUILD_ARM_COMPONENTS)
|
||||
install(EXPORT sdk DESTINATION "${MCPI_SDK_DIR}" FILE "sdk-targets.cmake" EXPORT_LINK_INTERFACE_LIBRARIES)
|
||||
string(CONCAT SDK_SETUP
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sdk.cmake"
|
||||
# Compile Flags
|
||||
"${COMPILE_FLAGS_SETUP}\n"
|
||||
# Log
|
||||
@ -208,6 +208,5 @@ if(BUILD_ARM_COMPONENTS)
|
||||
# Include Targets
|
||||
"include(\"\${CMAKE_CURRENT_LIST_DIR}/sdk-targets.cmake\")\n"
|
||||
)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sdk.cmake" "${SDK_SETUP}")
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sdk.cmake" DESTINATION "${MCPI_SDK_DIR}")
|
||||
endif()
|
||||
|
@ -1,43 +1,20 @@
|
||||
# Locations
|
||||
set(toolchain_dir "${CMAKE_CURRENT_LIST_DIR}/.prebuilt-armhf-toolchain")
|
||||
set(toolchain_dir "${CMAKE_CURRENT_BINARY_DIR}/prebuilt-armhf-toolchain")
|
||||
set(sysroot_dir "${CMAKE_CURRENT_BINARY_DIR}/bundled-armhf-sysroot")
|
||||
|
||||
# Force Toolchain
|
||||
set(CMAKE_C_COMPILER "${toolchain_dir}/bin/arm-none-linux-gnueabihf-gcc")
|
||||
set(CMAKE_CXX_COMPILER "${toolchain_dir}/bin/arm-none-linux-gnueabihf-g++")
|
||||
set(CMAKE_SYSTEM_NAME "Linux")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "arm")
|
||||
unset(CMAKE_TOOLCHAIN_FILE CACHE)
|
||||
|
||||
# Pick URL
|
||||
execute_process(COMMAND uname -m OUTPUT_VARIABLE arch OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(arch STREQUAL "x86_64")
|
||||
set(toolchain_url "https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf.tar.xz")
|
||||
set(toolchain_sha256 "aa074fa8371a4f73fecbd16bd62c8b1945f23289e26414794f130d6ccdf8e39c")
|
||||
set(toolchain_url "https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz")
|
||||
set(toolchain_sha256 "3f76650b1d048036473b16b647b8fd005ffccd1a2869c10994967e0e49f26ac2")
|
||||
elseif(arch STREQUAL "aarch64" OR arch STREQUAL "armv8b" OR arch STREQUAL "armv8l")
|
||||
set(toolchain_url "https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-aarch64-arm-none-linux-gnueabihf.tar.xz")
|
||||
set(toolchain_sha256 "fccd7af76988da2b077f939eb2a78baa9935810918d2bf3f837bc74f52efa825")
|
||||
set(toolchain_url "https://developer.arm.com/-/media/Files/downloads/gnu/11.3.rel1/binrel/arm-gnu-toolchain-11.3.rel1-aarch64-arm-none-linux-gnueabihf.tar.xz")
|
||||
set(toolchain_sha256 "2a12d92fcb7aadb059f42b9f18396c5d22ef76624225a855f4c28fa7fd888654")
|
||||
else()
|
||||
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}")
|
||||
include(FetchContent)
|
||||
set(FETCHCONTENT_QUIET FALSE)
|
||||
FetchContent_Declare(
|
||||
@ -46,21 +23,22 @@ if(NOT EXISTS "${CMAKE_C_COMPILER}")
|
||||
URL_HASH "SHA256=${toolchain_sha256}"
|
||||
SOURCE_DIR "${toolchain_dir}"
|
||||
)
|
||||
FetchContent_Populate(prebuilt-armhf-toolchain)
|
||||
FetchContent_MakeAvailable(prebuilt-armhf-toolchain)
|
||||
set(FETCHCONTENT_QUIET TRUE)
|
||||
|
||||
# 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()
|
||||
# Force Toolchain
|
||||
file(WRITE "${toolchain_dir}/toolchain.cmake"
|
||||
"set(CMAKE_C_COMPILER \"\${CMAKE_CURRENT_LIST_DIR}/bin/arm-none-linux-gnueabihf-gcc\")\n"
|
||||
"set(CMAKE_CXX_COMPILER \"\${CMAKE_CURRENT_LIST_DIR}/bin/arm-none-linux-gnueabihf-g++\")\n"
|
||||
"set(CMAKE_SYSTEM_NAME \"Linux\")\n"
|
||||
"set(CMAKE_SYSTEM_PROCESSOR \"arm\")\n"
|
||||
)
|
||||
set(CMAKE_TOOLCHAIN_FILE "${toolchain_dir}/toolchain.cmake" CACHE STRING "" FORCE)
|
||||
|
||||
# Build Sysroot
|
||||
if(NOT EXISTS "${sysroot_dir}")
|
||||
if("${toolchain_dir}/bin/arm-none-linux-gnueabihf-gcc" IS_NEWER_THAN "${sysroot_dir}")
|
||||
# Create Directory
|
||||
file(REMOVE_RECURSE "${sysroot_dir}")
|
||||
file(MAKE_DIRECTORY "${sysroot_dir}")
|
||||
|
||||
# Copy Files From Toolchain
|
||||
|
@ -32,8 +32,7 @@ static int32_t BucketItem_getIcon(__attribute__((unused)) unsigned char *item, i
|
||||
static int32_t BucketItem_useOn(__attribute__((unused)) unsigned char *item, ItemInstance *item_instance, unsigned char *player, unsigned char *level, int32_t x, int32_t y, int32_t z, int32_t hit_side, __attribute__((unused)) float hit_x, __attribute__((unused)) float hit_y, __attribute__((unused)) float hit_z) {
|
||||
if (item_instance->count < 1) {
|
||||
return 0;
|
||||
}
|
||||
if (item_instance->auxiliary == 0) {
|
||||
} else if (item_instance->auxiliary == 0) {
|
||||
// Empty Bucket
|
||||
int32_t new_auxiliary = 0;
|
||||
int32_t tile = (*Level_getTile)(level, x, y, z);
|
||||
|
Loading…
Reference in New Issue
Block a user