From 457c619fda70e65084dd4d6817d91f44e6346b88 Mon Sep 17 00:00:00 2001 From: Wolfywolfy Date: Fri, 28 Jun 2024 14:22:37 -0300 Subject: [PATCH 1/4] Add iop cmake. --- Makefile | 4 ++++ samples/Makefile | 1 + samples/ps2dev_iop.cmake | 29 +++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 samples/ps2dev_iop.cmake diff --git a/Makefile b/Makefile index 6d30f17d3a0..e3013b2bdf0 100644 --- a/Makefile +++ b/Makefile @@ -69,6 +69,9 @@ $(PS2SDK)/common/include: $(PS2SDK)/ports: $(MKDIR) -p $(PS2SDK)/ports +$(PS2SDK)/ports_iop: + $(MKDIR) -p $(PS2SDK)/ports_iop + install: | release release: | build @@ -76,6 +79,7 @@ release: | build $(MAKE) release-clean $(MAKE) $(PS2SDK)/common/include $(MAKE) $(PS2SDK)/ports + $(MAKE) $(PS2SDK)/ports_iop $(MAKE) $(subdir_release) release_base: | env_release_check diff --git a/samples/Makefile b/samples/Makefile index 7a3523d79fe..22fbb39b990 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -27,6 +27,7 @@ release-samples: cp -f Makefile.eeglobal_cpp_sample $(SAMPLES_TARGET)/Makefile.eeglobal_cpp cp -f Makefile.iopglobal_sample $(SAMPLES_TARGET)/Makefile.iopglobal cp -f ps2dev.cmake $(SHARE_TARGET)/ps2dev.cmake + cp -f ps2dev_iop.cmake $(SHARE_TARGET)/ps2dev_iop.cmake release-clean: rm -f -r $(SAMPLES_TARGET) diff --git a/samples/ps2dev_iop.cmake b/samples/ps2dev_iop.cmake new file mode 100644 index 00000000000..0513876fe9c --- /dev/null +++ b/samples/ps2dev_iop.cmake @@ -0,0 +1,29 @@ +if(DEFINED ENV{PS2DEV}) + SET(PS2DEV $ENV{PS2DEV}) +else() + message(FATAL_ERROR "The environment variable PS2DEV needs to be defined.") +endif() + +SET(CMAKE_SYSTEM_NAME Generic) +SET(CMAKE_SYSTEM_VERSION 1) +SET(CMAKE_SYSTEM_PROCESSOR mips) +SET(CMAKE_C_COMPILER mipsel-ps2-irx-gcc) +SET(CMAKE_CXX_COMPILER mipsel-ps2-irx-g++) +ADD_DEFINITIONS(-D_IOP -DPS2 -D__PS2__) +INCLUDE_DIRECTORIES($ENV{PS2SDK}/iop/include $ENV{PS2SDK}/common/include $ENV{PS2SDK}/ports_iop/include) +SET(CMAKE_C_FLAGS_INIT "-O2 -G0 -fno-builtin") +SET(CMAKE_CXX_FLAGS_INIT "-O2 -G0 -fno-builtin") +SET(CMAKE_EXE_LINKER_FLAGS_INIT "-T$ENV{PS2SDK}/iop/startup/linkfile -L$ENV{PS2SDK}/iop/lib -L$ENV{PS2DEV}/gsKit/lib -L$ENV{PS2SDK}/ports_iop/lib -Wl,-zmax-page-size=128 -nostdlib -Os -Wall") +#SET(CMAKE_SHARED_LINKER_FLAGS_INIT "...") +#SET(CMAKE_STATIC_LINKER_FLAGS_CONFIG_INIT "...") +#SET(CMAKE_STATIC_LINKER_FLAGS_INIT "...") +SET(CMAKE_TARGET_INSTALL_PREFIX $ENV{PS2DEV}/ports_iop) +SET(CMAKE_C_COMPILER_WORKS 1) #Hack by f0bes + +SET(CMAKE_FIND_ROOT_PATH $ENV{PS2DEV} $ENV{PS2DEV}/iop $ENV{PS2DEV}/iop/iop $ENV{PS2SDK} $ENV{PS2SDK}/ports_iop) +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(PLATFORM_PS2 TRUE) +SET(PS2IOP TRUE) From 3c35d584cce22468730c544e4edfa3c842e02492 Mon Sep 17 00:00:00 2001 From: Wolfywolfy Date: Sat, 29 Jun 2024 20:27:03 -0300 Subject: [PATCH 2/4] =?UTF-8?q?Add=20new=20cmake=20system=20with=20support?= =?UTF-8?q?=20to=20iop=20building=20with=20Tweaks=20to=20make=20cmake?= =?UTF-8?q?=C2=B4s=20smaller,=20RemoveD=20ancient=20gcc=20code,=20Removed?= =?UTF-8?q?=20-nostartfiles=20and=20Added=20ports=5Fiop.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/ps2dev.cmake | 40 ++++++++++++++++++---- samples/ps2dev_iop.cmake | 67 ++++++++++++++++++++++++++++++++----- skeleton/iop/CMakeLists.txt | 19 +++++++++++ 3 files changed, 110 insertions(+), 16 deletions(-) create mode 100644 skeleton/iop/CMakeLists.txt diff --git a/samples/ps2dev.cmake b/samples/ps2dev.cmake index 1265583dc45..13166aa9986 100644 --- a/samples/ps2dev.cmake +++ b/samples/ps2dev.cmake @@ -1,3 +1,20 @@ +# +# CMake platform file for PS2 EE processor +# +# Copyright (C) 2009-2010 Mathias Lafeldt +# Copyright (C) 2023 Francisco Javier Trujillo Mata +# Copyright (C) 2024 André Guilherme +# Copyright (C) 2024-Present PS2DEV Team +# + + +INCLUDE(CMakeForceCompiler) +if(DEFINED ENV{PS2SDK}) + SET(PS2SDK $ENV{PS2SDK}) +else() + message(FATAL_ERROR "The environment variable PS2SDK needs to be defined.") +endif() + if(DEFINED ENV{PS2DEV}) SET(PS2DEV $ENV{PS2DEV}) else() @@ -7,14 +24,14 @@ endif() SET(CMAKE_SYSTEM_NAME Generic) SET(CMAKE_SYSTEM_VERSION 1) SET(CMAKE_SYSTEM_PROCESSOR mips) + SET(CMAKE_C_COMPILER mips64r5900el-ps2-elf-gcc) SET(CMAKE_CXX_COMPILER mips64r5900el-ps2-elf-g++) -SET(CMAKE_C_FLAGS_INIT "-I$ENV{PS2SDK}/ee/include -I$ENV{PS2SDK}/common/include -I$ENV{PS2SDK}/ports/include -D_EE -DPS2 -D__PS2__ -O2 -G0") -SET(CMAKE_CXX_FLAGS_INIT "-I$ENV{PS2SDK}/ee/include -I$ENV{PS2SDK}/common/include -I$ENV{PS2SDK}/ports/include -D_EE -DPS2 -D__PS2__ -O2 -G0") -SET(CMAKE_EXE_LINKER_FLAGS_INIT "-T$ENV{PS2SDK}/ee/startup/linkfile -L$ENV{PS2SDK}/ee/lib -L$ENV{PS2DEV}/gsKit/lib -L$ENV{PS2SDK}/ports/lib -Wl,-zmax-page-size=128") -#SET(CMAKE_SHARED_LINKER_FLAGS_INIT "...") -#SET(CMAKE_STATIC_LINKER_FLAGS_CONFIG_INIT "...") -#SET(CMAKE_STATIC_LINKER_FLAGS_INIT "...") + +SET(EE_CFLAGS "-I$ENV{PS2SDK}/ee/include -I$ENV{PS2SDK}/common/include -I$ENV{PS2SDK}/ports/include -D_EE -DPS2 -D__PS2__ -O2 -G0" CACHE STRING "EE C compiler flags" FORCE) +SET(EE_LDFLAGS "-L$ENV{PS2SDK}/ee/lib -L$ENV{PS2DEV}/gsKit/lib -L$ENV{PS2SDK}/ports/lib -Wl,-zmax-page-size=128 -T$ENV{PS2SDK}/ee/startup/linkfile" CACHE STRING "EE linker flags" FORCE) +SET(EE_ASFLAGS "-G0" CACHE STRING "EE assembler flags" FORCE) + SET(CMAKE_TARGET_INSTALL_PREFIX $ENV{PS2DEV}/ports) SET(CMAKE_FIND_ROOT_PATH $ENV{PS2DEV} $ENV{PS2DEV}/ee $ENV{PS2DEV}/ee/ee $ENV{PS2SDK} $ENV{PS2SDK}/ports) @@ -22,5 +39,14 @@ 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_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) + +SET(CMAKE_C_FLAGS_INIT ${EE_CFLAGS}) +SET(CMAKE_CXX_FLAGS_INIT ${EE_CFLAGS}) +SET(CMAKE_EXE_LINKER_FLAGS_INIT ${EE_LDFLAGS}) + +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostartfiles -Wl,-r -Wl,-d") + +SET(PS2 TRUE) SET(PLATFORM_PS2 TRUE) -SET(PS2 TRUE) \ No newline at end of file +SET(EE TRUE) diff --git a/samples/ps2dev_iop.cmake b/samples/ps2dev_iop.cmake index 0513876fe9c..2fa1d7fa8ce 100644 --- a/samples/ps2dev_iop.cmake +++ b/samples/ps2dev_iop.cmake @@ -1,3 +1,19 @@ +# +# CMake platform file for PS2 IOP processor +# +# Copyright (C) 2009-2010 Mathias Lafeldt +# Copyright (C) 2023 Francisco Javier Trujillo Mata +# Copyright (C) 2024 André Guilherme +# Copyright (C) 2024-Present PS2DEV Team +# + +INCLUDE(CMakeForceCompiler) +if(DEFINED ENV{PS2SDK}) + SET(PS2SDK $ENV{PS2SDK}) +else() + message(FATAL_ERROR "The environment variable PS2SDK needs to be defined.") +endif() + if(DEFINED ENV{PS2DEV}) SET(PS2DEV $ENV{PS2DEV}) else() @@ -9,21 +25,54 @@ SET(CMAKE_SYSTEM_VERSION 1) SET(CMAKE_SYSTEM_PROCESSOR mips) SET(CMAKE_C_COMPILER mipsel-ps2-irx-gcc) SET(CMAKE_CXX_COMPILER mipsel-ps2-irx-g++) -ADD_DEFINITIONS(-D_IOP -DPS2 -D__PS2__) +SET(CMAKE_C_COMPILER_WORKS 1) #Hack by f0bes +SET(CMAKE_CXX_COMPILER_WORKS 1) #Hack by f0bes + +# +# set arch flags depending on gcc version +# +EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -dumpversion + OUTPUT_VARIABLE IOP_CC_VERSION) + +SET(IOP_ASFLAGS_TARGET "-mcpu=r3000") INCLUDE_DIRECTORIES($ENV{PS2SDK}/iop/include $ENV{PS2SDK}/common/include $ENV{PS2SDK}/ports_iop/include) -SET(CMAKE_C_FLAGS_INIT "-O2 -G0 -fno-builtin") -SET(CMAKE_CXX_FLAGS_INIT "-O2 -G0 -fno-builtin") -SET(CMAKE_EXE_LINKER_FLAGS_INIT "-T$ENV{PS2SDK}/iop/startup/linkfile -L$ENV{PS2SDK}/iop/lib -L$ENV{PS2DEV}/gsKit/lib -L$ENV{PS2SDK}/ports_iop/lib -Wl,-zmax-page-size=128 -nostdlib -Os -Wall") -#SET(CMAKE_SHARED_LINKER_FLAGS_INIT "...") -#SET(CMAKE_STATIC_LINKER_FLAGS_CONFIG_INIT "...") -#SET(CMAKE_STATIC_LINKER_FLAGS_INIT "...") +ADD_DEFINITIONS(-D_IOP -DPS2 -D__PS2__) + +SET(IOP_CFLAGS "${IOP_CFLAGS_TARGET} -O2 -G0 -fno-builtin" CACHE STRING "IOP C compiler flags" FORCE) +SET(IOP_LDFLAGS "${IOP_LDFLAGS_TARGET} -T$ENV{PS2SDK}/iop/startup/linkfile -L$ENV{PS2SDK}/iop/lib -L$ENV{PS2SDK}/ports_iop/lib -Wl,-zmax-page-size=128 -nostdlib -Os -Wall" CACHE STRING "IOP linker flags" FORCE) +SET(IOP_ASFLAGS "${IOP_ASFLAGS_TARGET} -EL -G0" CACHE STRING "IOP assembler flags" FORCE) + +SET(CMAKE_C_FLAGS_INIT ${IOP_CFLAGS}) +SET(CMAKE_CXX_FLAGS_INIT ${IOP_CFLAGS}) +SET(CMAKE_EXE_LINKER_FLAGS_INIT ${IOP_LDFLAGS}) + SET(CMAKE_TARGET_INSTALL_PREFIX $ENV{PS2DEV}/ports_iop) -SET(CMAKE_C_COMPILER_WORKS 1) #Hack by f0bes SET(CMAKE_FIND_ROOT_PATH $ENV{PS2DEV} $ENV{PS2DEV}/iop $ENV{PS2DEV}/iop/iop $ENV{PS2SDK} $ENV{PS2SDK}/ports_iop) 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_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) + +FUNCTION(BUILD_IOP_IMPORTS out_f in_f) + ADD_CUSTOM_COMMAND(OUTPUT ${out_f} + COMMAND echo "#include \"irx_imports.h\"" > ${out_f} + COMMAND cat ${in_f} >> ${out_f} + DEPENDS ${in_f} + COMMENT "Creating ${out_f}" VERBATIM + ) +ENDFUNCTION() + +FUNCTION(BUILD_IOP_EXPORTS out_f in_f) + ADD_CUSTOM_COMMAND(OUTPUT ${out_f} + COMMAND echo "#include \"irx.h\"" > ${out_f} + COMMAND cat ${in_f} >> ${out_f} + DEPENDS ${in_f} + COMMENT "Creating ${out_f}" VERBATIM + ) +ENDFUNCTION() + SET(PLATFORM_PS2 TRUE) -SET(PS2IOP TRUE) +SET(IOP TRUE) +SET(PS2 TRUE) diff --git a/skeleton/iop/CMakeLists.txt b/skeleton/iop/CMakeLists.txt new file mode 100644 index 00000000000..933b17006f0 --- /dev/null +++ b/skeleton/iop/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.10) + +project(hello) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +SET(IOP_BIN hello.irx) +SET(IOP_SRCS hello_exports.c hello_main.c exports.c imports.c) +SET(IOP_LIBS) + +BUILD_IOP_EXPORTS(exports.c ${CMAKE_CURRENT_SOURCE_DIR}/exports.tab) +BUILD_IOP_IMPORTS(imports.c ${CMAKE_CURRENT_SOURCE_DIR}/imports.lst) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fno-builtin") +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s") + +ADD_EXECUTABLE(${IOP_BIN} ${IOP_SRCS}) + +ADD_CUSTOM_COMMAND(TARGET ${IOP_BIN} POST_BUILD COMMAND md5sum ARGS ${IOP_BIN}) \ No newline at end of file From d997d760968c22620a2c13c18a05241265349869 Mon Sep 17 00:00:00 2001 From: Wolfywolfy Date: Mon, 1 Jul 2024 08:45:12 -0300 Subject: [PATCH 3/4] Add initial ASM_COMPILER. --- samples/ps2dev.cmake | 3 +++ samples/ps2dev_iop.cmake | 2 ++ 2 files changed, 5 insertions(+) diff --git a/samples/ps2dev.cmake b/samples/ps2dev.cmake index 13166aa9986..c7e583bddd3 100644 --- a/samples/ps2dev.cmake +++ b/samples/ps2dev.cmake @@ -27,6 +27,7 @@ SET(CMAKE_SYSTEM_PROCESSOR mips) SET(CMAKE_C_COMPILER mips64r5900el-ps2-elf-gcc) SET(CMAKE_CXX_COMPILER mips64r5900el-ps2-elf-g++) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) SET(EE_CFLAGS "-I$ENV{PS2SDK}/ee/include -I$ENV{PS2SDK}/common/include -I$ENV{PS2SDK}/ports/include -D_EE -DPS2 -D__PS2__ -O2 -G0" CACHE STRING "EE C compiler flags" FORCE) SET(EE_LDFLAGS "-L$ENV{PS2SDK}/ee/lib -L$ENV{PS2DEV}/gsKit/lib -L$ENV{PS2SDK}/ports/lib -Wl,-zmax-page-size=128 -T$ENV{PS2SDK}/ee/startup/linkfile" CACHE STRING "EE linker flags" FORCE) @@ -44,6 +45,8 @@ SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) SET(CMAKE_C_FLAGS_INIT ${EE_CFLAGS}) SET(CMAKE_CXX_FLAGS_INIT ${EE_CFLAGS}) SET(CMAKE_EXE_LINKER_FLAGS_INIT ${EE_LDFLAGS}) +SET(CMAKE_ASM_FLAGS_INIT ${EE_ASFLAGS}) + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostartfiles -Wl,-r -Wl,-d") diff --git a/samples/ps2dev_iop.cmake b/samples/ps2dev_iop.cmake index 2fa1d7fa8ce..9464f4597a4 100644 --- a/samples/ps2dev_iop.cmake +++ b/samples/ps2dev_iop.cmake @@ -25,6 +25,7 @@ SET(CMAKE_SYSTEM_VERSION 1) SET(CMAKE_SYSTEM_PROCESSOR mips) SET(CMAKE_C_COMPILER mipsel-ps2-irx-gcc) SET(CMAKE_CXX_COMPILER mipsel-ps2-irx-g++) +SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) SET(CMAKE_C_COMPILER_WORKS 1) #Hack by f0bes SET(CMAKE_CXX_COMPILER_WORKS 1) #Hack by f0bes @@ -45,6 +46,7 @@ SET(IOP_ASFLAGS "${IOP_ASFLAGS_TARGET} -EL -G0" CACHE STRING "IOP assembler flag SET(CMAKE_C_FLAGS_INIT ${IOP_CFLAGS}) SET(CMAKE_CXX_FLAGS_INIT ${IOP_CFLAGS}) SET(CMAKE_EXE_LINKER_FLAGS_INIT ${IOP_LDFLAGS}) +SET(CMAKE_ASM_FLAGS_INIT ${EE_ASFLAGS}) SET(CMAKE_TARGET_INSTALL_PREFIX $ENV{PS2DEV}/ports_iop) From dcaaf722b2947a586d000fb997f286fc1e322e77 Mon Sep 17 00:00:00 2001 From: Wolfywolfy Date: Mon, 1 Jul 2024 14:10:32 -0300 Subject: [PATCH 4/4] Change gcc compiler to mipsel-ps2-as --- samples/ps2dev.cmake | 2 +- samples/ps2dev_iop.cmake | 4 +++- skeleton/iop/CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/samples/ps2dev.cmake b/samples/ps2dev.cmake index c7e583bddd3..00f3e6e1cfc 100644 --- a/samples/ps2dev.cmake +++ b/samples/ps2dev.cmake @@ -27,7 +27,7 @@ SET(CMAKE_SYSTEM_PROCESSOR mips) SET(CMAKE_C_COMPILER mips64r5900el-ps2-elf-gcc) SET(CMAKE_CXX_COMPILER mips64r5900el-ps2-elf-g++) -SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_ASM_COMPILER mips64r5900el-ps2-elf-as) SET(EE_CFLAGS "-I$ENV{PS2SDK}/ee/include -I$ENV{PS2SDK}/common/include -I$ENV{PS2SDK}/ports/include -D_EE -DPS2 -D__PS2__ -O2 -G0" CACHE STRING "EE C compiler flags" FORCE) SET(EE_LDFLAGS "-L$ENV{PS2SDK}/ee/lib -L$ENV{PS2DEV}/gsKit/lib -L$ENV{PS2SDK}/ports/lib -Wl,-zmax-page-size=128 -T$ENV{PS2SDK}/ee/startup/linkfile" CACHE STRING "EE linker flags" FORCE) diff --git a/samples/ps2dev_iop.cmake b/samples/ps2dev_iop.cmake index 9464f4597a4..31558d8f3c8 100644 --- a/samples/ps2dev_iop.cmake +++ b/samples/ps2dev_iop.cmake @@ -25,9 +25,11 @@ SET(CMAKE_SYSTEM_VERSION 1) SET(CMAKE_SYSTEM_PROCESSOR mips) SET(CMAKE_C_COMPILER mipsel-ps2-irx-gcc) SET(CMAKE_CXX_COMPILER mipsel-ps2-irx-g++) -SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +SET(CMAKE_ASM_COMPILER mipsel-ps2-irx-as) SET(CMAKE_C_COMPILER_WORKS 1) #Hack by f0bes SET(CMAKE_CXX_COMPILER_WORKS 1) #Hack by f0bes +SET(CMAKE_ASM_COMPILER_WORKS 1) #Hack by f0bes + # # set arch flags depending on gcc version diff --git a/skeleton/iop/CMakeLists.txt b/skeleton/iop/CMakeLists.txt index 933b17006f0..c1b068e8ac9 100644 --- a/skeleton/iop/CMakeLists.txt +++ b/skeleton/iop/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10) -project(hello) +project(hello LANGUAGES C) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})