From afdc14776b6d84198aefa41e223d9283fc982c20 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Tue, 22 Jun 2021 21:14:22 +0200 Subject: [PATCH] cmake: move ps2 cmake toolchain to subdirectory of ps2 --- .github/workflows/build-cmake-conan.yml | 4 +- CMakeLists.txt | 2 +- cmake/{nxtoolchain => nx}/FindNXGL.cmake | 0 cmake/{nxtoolchain => nx}/NXFunctions.cmake | 0 .../cmaketoolchain}/CMakeDSMCompiler.cmake.in | 0 .../cmaketoolchain}/CMakeDSMInformation.cmake | 0 .../CMakeDetermineDSMCompiler.cmake | 0 .../CMakeTestDSMCompiler.cmake | 0 .../Platform/PlayStation2.cmake | 0 .../cmaketoolchain}/conanfile.py | 5 +- .../cmaketoolchain/toolchain_ps2_ee.cmake} | 23 +++++-- cmake/ps2toolchain/toolchain_ps2_ee.cmake | 60 ------------------- 12 files changed, 25 insertions(+), 69 deletions(-) rename cmake/{nxtoolchain => nx}/FindNXGL.cmake (100%) rename cmake/{nxtoolchain => nx}/NXFunctions.cmake (100%) rename cmake/{ps2toolchain => ps2/cmaketoolchain}/CMakeDSMCompiler.cmake.in (100%) rename cmake/{ps2toolchain => ps2/cmaketoolchain}/CMakeDSMInformation.cmake (100%) rename cmake/{ps2toolchain => ps2/cmaketoolchain}/CMakeDetermineDSMCompiler.cmake (100%) rename cmake/{ps2toolchain => ps2/cmaketoolchain}/CMakeTestDSMCompiler.cmake (100%) rename cmake/{ps2toolchain => ps2/cmaketoolchain}/Platform/PlayStation2.cmake (100%) rename cmake/{ps2toolchain => ps2/cmaketoolchain}/conanfile.py (71%) rename cmake/{ps2toolchain/cmaketoolchain.cmake => ps2/cmaketoolchain/toolchain_ps2_ee.cmake} (80%) delete mode 100644 cmake/ps2toolchain/toolchain_ps2_ee.cmake diff --git a/.github/workflows/build-cmake-conan.yml b/.github/workflows/build-cmake-conan.yml index 78bed1d..d30f2c2 100644 --- a/.github/workflows/build-cmake-conan.yml +++ b/.github/workflows/build-cmake-conan.yml @@ -59,10 +59,10 @@ jobs: fi - name: "Export Playstation 2 CMake toolchain conan recipe" run: | - conan export cmake/ps2toolchain ps2dev-cmaketoolchain/master@ + conan export cmake/ps2/cmaketoolchain ps2dev-cmaketoolchain/master@ - name: "Download/build dependencies (conan install)" run: | - conan install ${{ github.workspace }} librw/master@ -if build -o librw:platform=${{ matrix.platform }} -o librw:gl3_gfxlib=${{ matrix.gl3_gfxlib}} --build missing -pr:h ./host_profile -pr:b default + conan install ${{ github.workspace }} librw/master@ -if build -o librw:platform=${{ matrix.platform }} -o librw:gl3_gfxlib=${{ matrix.gl3_gfxlib }} --build missing -pr:h ./host_profile -pr:b default env: CONAN_SYSREQUIRES_MODE: enabled - name: "Build librw (conan build)" diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a663bc..dbc9e00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,7 +84,7 @@ if(LIBRW_INSTALL) endif() if(NINTENDO_SWITCH) install( - FILES "${CMAKE_CURRENT_LIST_DIR}/cmake/nxtoolchain/FindNXGL.cmake" + FILES "${CMAKE_CURRENT_LIST_DIR}/cmake/nx/FindNXGL.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake" ) endif() diff --git a/cmake/nxtoolchain/FindNXGL.cmake b/cmake/nx/FindNXGL.cmake similarity index 100% rename from cmake/nxtoolchain/FindNXGL.cmake rename to cmake/nx/FindNXGL.cmake diff --git a/cmake/nxtoolchain/NXFunctions.cmake b/cmake/nx/NXFunctions.cmake similarity index 100% rename from cmake/nxtoolchain/NXFunctions.cmake rename to cmake/nx/NXFunctions.cmake diff --git a/cmake/ps2toolchain/CMakeDSMCompiler.cmake.in b/cmake/ps2/cmaketoolchain/CMakeDSMCompiler.cmake.in similarity index 100% rename from cmake/ps2toolchain/CMakeDSMCompiler.cmake.in rename to cmake/ps2/cmaketoolchain/CMakeDSMCompiler.cmake.in diff --git a/cmake/ps2toolchain/CMakeDSMInformation.cmake b/cmake/ps2/cmaketoolchain/CMakeDSMInformation.cmake similarity index 100% rename from cmake/ps2toolchain/CMakeDSMInformation.cmake rename to cmake/ps2/cmaketoolchain/CMakeDSMInformation.cmake diff --git a/cmake/ps2toolchain/CMakeDetermineDSMCompiler.cmake b/cmake/ps2/cmaketoolchain/CMakeDetermineDSMCompiler.cmake similarity index 100% rename from cmake/ps2toolchain/CMakeDetermineDSMCompiler.cmake rename to cmake/ps2/cmaketoolchain/CMakeDetermineDSMCompiler.cmake diff --git a/cmake/ps2toolchain/CMakeTestDSMCompiler.cmake b/cmake/ps2/cmaketoolchain/CMakeTestDSMCompiler.cmake similarity index 100% rename from cmake/ps2toolchain/CMakeTestDSMCompiler.cmake rename to cmake/ps2/cmaketoolchain/CMakeTestDSMCompiler.cmake diff --git a/cmake/ps2toolchain/Platform/PlayStation2.cmake b/cmake/ps2/cmaketoolchain/Platform/PlayStation2.cmake similarity index 100% rename from cmake/ps2toolchain/Platform/PlayStation2.cmake rename to cmake/ps2/cmaketoolchain/Platform/PlayStation2.cmake diff --git a/cmake/ps2toolchain/conanfile.py b/cmake/ps2/cmaketoolchain/conanfile.py similarity index 71% rename from cmake/ps2toolchain/conanfile.py rename to cmake/ps2/cmaketoolchain/conanfile.py index 11c8628..4cc9d3c 100644 --- a/cmake/ps2toolchain/conanfile.py +++ b/cmake/ps2/cmaketoolchain/conanfile.py @@ -18,4 +18,7 @@ class Ps2devCMakeToolchainConan(ConanFile): def package_info(self): self.user_info.cmake_dir = os.path.join(self.package_folder, "cmake").replace("\\", "/") - self.user_info.cmake_toolchain_file = os.path.join(self.package_folder, "cmake", "cmaketoolchain.cmake").replace("\\", "/") + + cmake_toolchain_file = os.path.join(self.package_folder, "cmake", "toolchain_ps2_ee.cmake").replace("\\", "/") + self.user_info.cmake_toolchain_file = cmake_toolchain_file + self.cpp_info.CONAN_CMAKE_TOOLCHAIN_FILE = cmake_toolchain_file diff --git a/cmake/ps2toolchain/cmaketoolchain.cmake b/cmake/ps2/cmaketoolchain/toolchain_ps2_ee.cmake similarity index 80% rename from cmake/ps2toolchain/cmaketoolchain.cmake rename to cmake/ps2/cmaketoolchain/toolchain_ps2_ee.cmake index 6f83c96..9f3c24a 100644 --- a/cmake/ps2toolchain/cmaketoolchain.cmake +++ b/cmake/ps2/cmaketoolchain/toolchain_ps2_ee.cmake @@ -45,7 +45,7 @@ set(CMAKE_C_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK} set(CMAKE_CXX_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"") set(CMAKE_EXE_LINKER_FLAGS_INIT "-G0 -L\"${PS2SDK}/ee/lib\" -Wl,-r -Wl,-d") -set(CMAKE_FIND_ROOT_PATH "${PS2DEV}/ee;${PS2SDK}/ee") +set(CMAKE_FIND_ROOT_PATH "${PS2DEV}/ee" "${PS2SDK}/ee") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) @@ -53,9 +53,19 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(PS2 1) set(EE 1) -function(add_erl_executable OUTFILE TARGET) - get_property(output_dir TARGET ${TARGET} PROPERTY RUNTIME_OUTPUT_DIRECTORY) - set(outfile "${output_dir}/${TARGET}.erl") +set(CMAKE_EXECUTABLE_SUFFIX ".elf") + +function(add_erl_executable TARGET) + cmake_parse_arguments("AEE" "" "OUTPUT_VAR" "" ${ARGN}) + + get_target_property(output_dir ${TARGET} RUNTIME_OUTPUT_DIRECTORY) + + get_target_property(output_name ${TARGET} OUTPUT_NAME) + if(NOT output_name) + set(output_name ${TARGET}) + endif() + set(outfile "${output_dir}/${output_name}.erl") + add_custom_command(OUTPUT "${outfile}" COMMAND "${CMAKE_COMMAND}" -E copy "$" "${outfile}" COMMAND "${CMAKE_STRIP}" --strip-unneeded -R .mdebug.eabi64 -R .reginfo -R .comment "${outfile}" @@ -64,5 +74,8 @@ function(add_erl_executable OUTFILE TARGET) add_custom_target("${TARGET}_erl" ALL DEPENDS "${outfile}" ) - set("${OUTFILE}" "${outfile}" PARENT_SCOPE) + + if(AEE_OUTPUT_VAR) + set("${AEE_OUTPUT_VAR}" "${outfile}" PARENT_SCOPE) + endif() endfunction() diff --git a/cmake/ps2toolchain/toolchain_ps2_ee.cmake b/cmake/ps2toolchain/toolchain_ps2_ee.cmake deleted file mode 100644 index 95517d0..0000000 --- a/cmake/ps2toolchain/toolchain_ps2_ee.cmake +++ /dev/null @@ -1,60 +0,0 @@ -cmake_minimum_required(VERSION 3.7) - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") - -set(CMAKE_SYSTEM_NAME "PlayStation2") -set(CMAKE_SYSTEM_PROCESSOR "mipsel") -set(CMAKE_SYSTEM_VERSION 1) - -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) - -set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) - -if(NOT DEFINED ENV{PS2DEV}) - message(FATAL_ERROR "Need environment variable PS2DEV set") -endif() -if(NOT DEFINED ENV{PS2SDK}) - message(FATAL_ERROR "Need environment variable PS2SDK set") -endif() -set(PS2DEV "$ENV{PS2DEV}") -set(PS2SDK "$ENV{PS2SDK}") - -set(CMAKE_DSM_SOURCE_FILE_EXTENSIONS "dsm") - -set(CMAKE_C_COMPILER "${PS2DEV}/ee/bin/ee-gcc") -set(CMAKE_CXX_COMPILER "${PS2DEV}/ee/bin/ee-g++") -set(CMAKE_ASM_COMPILER "${PS2DEV}/ee/bin/ee-g++") -set(CMAKE_DSM_COMPILER "${PS2DEV}/dvp/bin/dvp-as") -set(CMAKE_AR "${PS2DEV}/ee/bin/ee-ar" CACHE FILEPATH "archiver") -set(CMAKE_LINKER "${PS2DEV}/ee/bin/ee-ld") -set(CMAKE_RANLIB "${PS2DEV}/ee/bin/ee-ranlib" CACHE FILEPATH "ranlib") -set(CMAKE_STRIP "${PS2DEV}/ee/bin/ee-strip" CACHE FILEPATH "strip") - -set(CMAKE_ASM_FLAGS_INIT "-G0 -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"") -set(CMAKE_C_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"") -set(CMAKE_CXX_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"") -set(CMAKE_EXE_LINKER_FLAGS_INIT "-G0 -L\"${PS2SDK}/ee/lib\" -Wl,-r -Wl,-d") - -set(CMAKE_FIND_ROOT_PATH "${PS2DEV}/ee;${PS2SDK}/ee") -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - -set(PS2 1) -set(EE 1) - -function(add_erl_executable OUTFILE TARGET) - get_property(output_dir TARGET ${TARGET} PROPERTY RUNTIME_OUTPUT_DIRECTORY) - set(outfile "${output_dir}/${TARGET}.erl") - add_custom_command(OUTPUT "${outfile}" - COMMAND "${CMAKE_COMMAND}" -E copy "$" "${outfile}" - COMMAND "${CMAKE_STRIP}" --strip-unneeded -R .mdebug.eabi64 -R .reginfo -R .comment "${outfile}" - DEPENDS ${TARGET} - ) - add_custom_target("${TARGET}_erl" ALL - DEPENDS "${outfile}" - ) - set("${OUTFILE}" "${outfile}" PARENT_SCOPE) -endfunction()