mirror of https://github.com/aap/librw.git
Merge branch 'master' of github.com:aap/librw
This commit is contained in:
commit
78d540fce0
|
@ -1,4 +1,4 @@
|
|||
name: Build using conan
|
||||
name: Build using conan+cmake
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
|
@ -10,18 +10,22 @@ jobs:
|
|||
matrix:
|
||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
||||
platform: ['null', 'gl3', 'd3d9', 'ps2']
|
||||
gl3_gfxlib: ['glfw', 'sdl2']
|
||||
exclude:
|
||||
- os: windows-latest
|
||||
platform: ps2
|
||||
- os: ubuntu-latest
|
||||
platform: d3d9
|
||||
- os: ubuntu-latest
|
||||
platform: ps2 # FIXME: add ps2toolchain conan package + ps2 profile
|
||||
- os: macos-latest
|
||||
platform: d3d9
|
||||
- os: macos-latest
|
||||
platform: ps2
|
||||
- platform: 'null'
|
||||
gl3_gfxlib: sdl2
|
||||
- platform: d3d9
|
||||
gl3_gfxlib: sdl2
|
||||
- platform: ps2
|
||||
gl3_gfxlib: sdl2
|
||||
runs-on: ${{ matrix.os }}
|
||||
continue-on-error: ${{ matrix.platform == 'ps2' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
|
@ -30,17 +34,50 @@ jobs:
|
|||
- name: "Setup conan"
|
||||
run: |
|
||||
python -m pip install conan
|
||||
conan user
|
||||
conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
|
||||
conan config init
|
||||
conan config set log.print_run_commands=True
|
||||
- name: "conan install (download/build dependencies)"
|
||||
conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
|
||||
conan remote add madebr_ps2dev https://api.bintray.com/conan/madebr/ps2dev
|
||||
- name: "Add os=Playstation2 + gcc.version=3.2 to .conan/settings.yml"
|
||||
if: ${{ matrix.platform == 'ps2' }}
|
||||
shell: python
|
||||
run: |
|
||||
conan install ${{ github.workspace }} -if build -o platform=${{ matrix.platform }} --build missing
|
||||
import os, yaml
|
||||
settings_path = os.path.expanduser("~/.conan/settings.yml")
|
||||
yml = yaml.safe_load(open(settings_path))
|
||||
yml["os"]["Playstation2"] = None
|
||||
yml["compiler"]["gcc"]["version"].append("3.2")
|
||||
yml["compiler"]["gcc"]["version"].sort()
|
||||
yaml.safe_dump(yml, open(settings_path, "w"))
|
||||
- name: "Create host profile"
|
||||
shell: bash
|
||||
run: |
|
||||
if test "${{ matrix.platform }}" = "ps2"; then
|
||||
cp conan/playstation2 host_profile
|
||||
else
|
||||
cp ~/.conan/profiles/default host_profile
|
||||
fi
|
||||
- name: "Export Playstation 2 CMake toolchain conan recipe"
|
||||
run: |
|
||||
conan export cmake/ps2toolchain ps2dev-cmaketoolchain/master@
|
||||
- name: "Download/build dependencies (conan install)"
|
||||
run: |
|
||||
conan install ${{ github.workspace }} librw/master@ -if build -o platform=${{ matrix.platform }} -o gl3_gfxlib=${{ matrix.gl3_gfxlib}} --build missing -pr:h ./host_profile -pr:b default
|
||||
env:
|
||||
CONAN_SYSREQUIRES_MODE: enabled
|
||||
- name: "conan build (build librw)"
|
||||
- name: "Build librw (conan build)"
|
||||
run: |
|
||||
conan build ${{ github.workspace }} -if build -bf build -pf package
|
||||
- name: "conan package (package librw)"
|
||||
- name: "Package librw (conan package)"
|
||||
run: |
|
||||
conan package ${{ github.workspace }} -if build -bf build -pf package
|
||||
- name: "Create binary package (cpack)"
|
||||
working-directory: ./build
|
||||
run: |
|
||||
cpack
|
||||
- name: "Archive binary package (github artifacts)"
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: "${{ matrix.os }}-${{ matrix.platform }}"
|
||||
path: build/*.tar.xz
|
||||
if-no-files-found: error
|
||||
|
|
|
@ -3,10 +3,6 @@ project(librw C CXX)
|
|||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
if(PS2DEV AND EE)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/cmake/ee.cmake")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(LIBRW_PLATFORMS "NULL" "GL3" "D3D9")
|
||||
else()
|
||||
|
@ -63,7 +59,54 @@ if(LIBRW_INSTALL)
|
|||
EXPORT librw-targets NAMESPACE librw::
|
||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
|
||||
)
|
||||
set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
|
||||
|
||||
string(REPLACE "." ";" cmake_c_compiler_version_list "${CMAKE_C_COMPILER_VERSION}")
|
||||
list(GET cmake_c_compiler_version_list 0 cmake_c_compiler_version_major)
|
||||
|
||||
string(TOLOWER "${LIBRW_PLATFORM}" librw_platform)
|
||||
set(compiler)
|
||||
set(os)
|
||||
if(NOT LIBRW_PLATFORM STREQUAL "PS2")
|
||||
if(MSVC)
|
||||
set(compiler "-msvc${MSVC_VERSION}")
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
set(compiler "-gcc${cmake_c_compiler_version_major}")
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set(compiler "-clang${cmake_c_compiler_version_major}")
|
||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
|
||||
set(compiler "-appleclang${cmake_c_compiler_version_major}")
|
||||
else()
|
||||
set(compiler "-UNK")
|
||||
message(WARNING "Unknown compiler. Created cpack package will be wrong. (override using cpack -P)")
|
||||
endif()
|
||||
endif()
|
||||
if(LIBRW_PLATFORM_NULL)
|
||||
set(platform "-null")
|
||||
elseif(LIBRW_PLATFORM_PS2)
|
||||
set(platform "-ps2")
|
||||
elseif(LIBRW_PLATFORM_GL3)
|
||||
if(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
|
||||
set(platform "-gl3-glfw")
|
||||
else()
|
||||
set(platform "-gl3-sdl2")
|
||||
endif()
|
||||
elseif(LIBRW_PLATFORM_D3D9)
|
||||
set(platform "-d3d9")
|
||||
endif()
|
||||
if(NOT LIBRW_PLATFORM_PS2)
|
||||
if(WIN32)
|
||||
set(os "-win")
|
||||
elseif(APPLE)
|
||||
set(os "-apple")
|
||||
elseif(UNIX)
|
||||
set(os "-linux")
|
||||
else()
|
||||
set(compiler "-UNK")
|
||||
message(WARNING "Unknown os. Created cpack package will be wrong. (override using cpack -P)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}${platform}${os}${compiler}")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A (partial) re-implementation of RenderWare Graphics")
|
||||
set(CPACK_PACKAGE_VENDOR "aap")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/LICENSE")
|
||||
|
@ -71,5 +114,6 @@ if(LIBRW_INSTALL)
|
|||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
|
||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
|
||||
set(CPACK_GENERATOR "TXZ")
|
||||
include(CPack)
|
||||
endif()
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
find_package(PkgConfig QUIET)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(SDL2 IMPORTED_TARGET "sdl2")
|
||||
if(TARGET PkgConfig::SDL2 AND NOT TARGET sdl2::sdl2)
|
||||
add_library(_sdl2 INTERFACE)
|
||||
target_link_libraries(_sdl2 INTERFACE PkgConfig::SDL2)
|
||||
add_library(SDL2::SDL2 ALIAS _sdl2)
|
||||
if(TARGET PkgConfig::SDL2 AND NOT TARGET SDL2::SDL2)
|
||||
add_library(SDL2::SDL2 INTERFACE IMPORTED)
|
||||
set_property(TARGET SDL2::SDL2 PROPERTY INTERFACE_LINK_LIBRARIES PkgConfig::SDL2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_library(SDL2main_LIBRARY SDL2main)
|
||||
|
||||
if(NOT SDL2_FOUND)
|
||||
find_path(SDL2_INCLUDE_DIR sdl2.h)
|
||||
find_library(SDL2_LIBRARY sdl2)
|
||||
find_library(SDL2_LIBRARY SDL2 SDL2d)
|
||||
|
||||
find_library(SDL2main_LIBRARY SDL2main)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(libuv
|
||||
|
@ -25,3 +28,11 @@ if(NOT SDL2_FOUND)
|
|||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SDL2main_LIBRARY AND NOT TARGET SDL2::SDL2main)
|
||||
add_library(SDL2::SDL2main UNKNOWN IMPORTED)
|
||||
set_target_properties(SDL2::SDL2main PROPERTIES
|
||||
IMPORTED_LOCATION "${SDL2main_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
include_directories(SYSTEM "${PS2SDK}/common/include")
|
||||
include_directories(SYSTEM "${PS2SDK}/ee/include")
|
|
@ -10,10 +10,10 @@ if(LIBRW_PLATFORM_GL3)
|
|||
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
find_package(OpenGL REQUIRED)
|
||||
if(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
|
||||
find_package(GLEW REQUIRED)
|
||||
if(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
|
||||
find_package(glfw3 REQUIRED)
|
||||
elseif(LIBRW_GL3_GFXLIB STREQUAL "GLFW")
|
||||
elseif(LIBRW_GL3_GFXLIB STREQUAL "SDL2")
|
||||
find_package(SDL2 REQUIRED)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
|
|
@ -0,0 +1,68 @@
|
|||
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}")
|
||||
|
||||
if(NOT IS_DIRECTORY "${PS2DEV}")
|
||||
message(FATAL_ERROR "PS2DEV must contain a folder path (${PS2DEV})")
|
||||
endif()
|
||||
|
||||
if(NOT IS_DIRECTORY "${PS2SDK}")
|
||||
message(FATAL_ERROR "PS2SDK must contain a folder path (${PS2SDK})")
|
||||
endif()
|
||||
|
||||
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 "$<TARGET_FILE:${TARGET}>" "${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()
|
|
@ -0,0 +1,21 @@
|
|||
from conans import ConanFile
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
class Ps2devCMakeToolchainConan(ConanFile):
|
||||
name = "ps2dev-cmaketoolchain"
|
||||
description = "CMake toolchain script for ps2dev"
|
||||
topics = "ps2", "sdk", "library", "sony", "playstation", "ps2"
|
||||
|
||||
def export_sources(self):
|
||||
self.copy("*.cmake*", dst="cmake")
|
||||
self.copy("Platform", dst="cmake")
|
||||
|
||||
def package(self):
|
||||
shutil.copytree(os.path.join(self.source_folder, "cmake"),
|
||||
os.path.join(self.package_folder, "cmake"))
|
||||
|
||||
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("\\", "/")
|
|
@ -1,7 +1,9 @@
|
|||
cmake_minimum_required(VERSION 3.7)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(CMAKE_SYSTEM_NAME "Generic")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "ee")
|
||||
set(CMAKE_SYSTEM_NAME "PlayStation2")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "mipsel")
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
@ -19,13 +21,8 @@ endif()
|
|||
set(PS2DEV "$ENV{PS2DEV}")
|
||||
set(PS2SDK "$ENV{PS2SDK}")
|
||||
|
||||
#set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS "asm;dsm")
|
||||
|
||||
set(CMAKE_DSM_SOURCE_FILE_EXTENSIONS "dsm")
|
||||
|
||||
set(CMAKE_SHARED_LIBRARY_SUFFIX ".erl")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
|
||||
|
||||
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++")
|
||||
|
@ -35,25 +32,10 @@ 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(EE_LDFLAGS "" CACHE STRING "EE linker flags")
|
||||
set(EE_ASFLAGS "-G0" CACHE STRING "EE assembler flags")
|
||||
|
||||
set(EE_CRT0 "${PS2SDK}/ee/startup/crt0.o" CACHE FILEPATH "EE crt0 file")
|
||||
set_source_files_properties("${EE_CRT0}" PROPERTIES EXTERNAL_OBJECT ON)
|
||||
|
||||
set(EE_LINKSCRIPT "${PS2SDK}/ee/startup/linkfile" CACHE FILEPATH "EE link script")
|
||||
|
||||
#set(EE_CFLAGS " -nostdlib -fno-common -D_EE" CACHE STRING "EE C/CXX compiler flags")
|
||||
set(EE_CFLAGS "-D_EE")
|
||||
set(CMAKE_C_FLAGS_INIT "${EE_CFLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_INIT "${EE_CFLAGS}")
|
||||
#set(CMAKE_ASM_FLAGS_INIT "${EE_CFLAGS}")
|
||||
|
||||
set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> cru <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
set(CMAKE_CXX_CREATE_STATIC_LIBRARY "${CMAKE_C_CREATE_STATIC_LIBRARY}")
|
||||
set(CMAKE_ASM_CREATE_STATIC_LIBRARY "${CMAKE_C_CREATE_STATIC_LIBRARY}")
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-mno-crt0 -T\"${PS2SDK}/ee/startup/linkfile\" \"${EE_CRT0}\" -L\"${PS2SDK}/ee/lib\"")
|
||||
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)
|
||||
|
@ -62,3 +44,17 @@ 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 "$<TARGET_FILE:${TARGET}>" "${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()
|
|
@ -0,0 +1,12 @@
|
|||
[settings]
|
||||
os=Playstation2
|
||||
arch=mips
|
||||
compiler=gcc
|
||||
compiler.version=3.2
|
||||
compiler.libcxx=libstdc++
|
||||
build_type=Release
|
||||
[options]
|
||||
librw:platform=ps2
|
||||
[build_requires]
|
||||
ps2dev-ps2toolchain/unknown@madebr/testing
|
||||
[env]
|
37
conanfile.py
37
conanfile.py
|
@ -1,5 +1,5 @@
|
|||
from conans import ConanFile, CMake, tools
|
||||
from conans.errors import ConanInvalidConfiguration
|
||||
from conans.errors import ConanException, ConanInvalidConfiguration
|
||||
import os
|
||||
import shutil
|
||||
import textwrap
|
||||
|
@ -18,21 +18,39 @@ class LibrwConan(ConanFile):
|
|||
default_options = {
|
||||
"platform": "gl3",
|
||||
"gl3_gfxlib": "glfw",
|
||||
"openal:with_external_libs": False,
|
||||
"sdl2:vulkan": False,
|
||||
"sdl2:opengl": True,
|
||||
"sdl2:sdl2main": False,
|
||||
"sdl2:sdl2main": True,
|
||||
}
|
||||
no_copy_source = True
|
||||
|
||||
@property
|
||||
def _os_is_playstation2(self):
|
||||
try:
|
||||
return self.settings.os == "Playstation2"
|
||||
except ConanException:
|
||||
return False
|
||||
|
||||
def config_options(self):
|
||||
if self._os_is_playstation2:
|
||||
self.options.platform = "ps2"
|
||||
if self.settings.os == "Windows":
|
||||
self.options["sdl2"].directx = False
|
||||
|
||||
def configure(self):
|
||||
if self.options.platform != "gl3":
|
||||
del self.options.gl3_gfxlib
|
||||
|
||||
def validate(self):
|
||||
if self.options.platform == "d3d9" and self.settings.os != "Windows":
|
||||
raise ConanInvalidConfiguration("d3d9 can only be built for Windows")
|
||||
if self.options.platform == "ps2":
|
||||
if not self._os_is_playstation2:
|
||||
raise ConanInvalidConfiguration("platform=ps2 is only valid for os=Playstation2")
|
||||
else:
|
||||
if self._os_is_playstation2:
|
||||
raise ConanInvalidConfiguration("os=Playstation2 only supports platform=ps2")
|
||||
|
||||
def requirements(self):
|
||||
if self.options.platform == "gl3":
|
||||
|
@ -41,6 +59,10 @@ class LibrwConan(ConanFile):
|
|||
self.requires("glfw/3.3.2")
|
||||
elif self.options.gl3_gfxlib == "sdl2":
|
||||
self.requires("sdl2/2.0.12@bincrafters/stable")
|
||||
elif self.options.platform == "ps2":
|
||||
self.requires("ps2dev-ps2sdk/unknown@madebr/testing")
|
||||
if self._os_is_playstation2:
|
||||
self.requires("ps2dev-cmaketoolchain/{}".format(self.version))
|
||||
|
||||
def export_sources(self):
|
||||
for d in ("cmake", "skeleton", "src", "tools"):
|
||||
|
@ -62,6 +84,7 @@ class LibrwConan(ConanFile):
|
|||
def build(self):
|
||||
if self.source_folder == self.build_folder:
|
||||
raise Exception("cannot build with source_folder == build_folder")
|
||||
if self.options.platform == "gl3" and self.options.gl3_gfxlib == "glfw":
|
||||
tools.save("Findglfw3.cmake",
|
||||
textwrap.dedent(
|
||||
"""
|
||||
|
@ -69,7 +92,7 @@ class LibrwConan(ConanFile):
|
|||
message(STATUS "Creating glfw TARGET")
|
||||
add_library(glfw INTERFACE IMPORTED)
|
||||
set_target_properties(glfw PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES CONAN_PKG::glfw) #$<BUILD_INTERFACE:CONAN_PKG::glfw>)
|
||||
INTERFACE_LINK_LIBRARIES CONAN_PKG::glfw)
|
||||
endif()
|
||||
"""), append=True)
|
||||
tools.save("CMakeLists.txt",
|
||||
|
@ -85,10 +108,16 @@ class LibrwConan(ConanFile):
|
|||
""").format(self.install_folder.replace("\\", "/"),
|
||||
self.source_folder.replace("\\", "/")))
|
||||
cmake = CMake(self)
|
||||
env = {}
|
||||
cmake.definitions["LIBRW_PLATFORM"] = self._librw_platform
|
||||
cmake.definitions["LIBRW_INSTALL"] = True
|
||||
cmake.definitions["LIBRW_TOOLS"] = True
|
||||
if self.options.platform == "gl3":
|
||||
cmake.definitions["LIBRW_GL3_GFXLIB"] = str(self.options.gl3_gfxlib).upper()
|
||||
if self._os_is_playstation2:
|
||||
cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = self.deps_user_info["ps2dev-cmaketoolchain"].cmake_toolchain_file
|
||||
env["PS2SDK"] = self.deps_cpp_info["ps2dev-ps2sdk"].rootpath
|
||||
with tools.environment_append(env):
|
||||
cmake.configure(source_folder=self.build_folder)
|
||||
cmake.build()
|
||||
|
||||
|
@ -98,7 +127,7 @@ class LibrwConan(ConanFile):
|
|||
|
||||
def package_info(self):
|
||||
self.cpp_info.includedirs.append(os.path.join("include", "librw"))
|
||||
self.cpp_info.libs = ["librw"]
|
||||
self.cpp_info.libs = ["librw" if self.settings.compiler == "Visual Studio" else "rw"]
|
||||
if self.options.platform == "null":
|
||||
self.cpp_info.defines.append("RW_NULL")
|
||||
elif self.options.platform == "gl3":
|
||||
|
|
|
@ -4,22 +4,22 @@ add_library(librw_skeleton
|
|||
skeleton.cpp
|
||||
skeleton.h
|
||||
win.cpp
|
||||
)
|
||||
)
|
||||
|
||||
set_target_properties(librw_skeleton
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
)
|
||||
)
|
||||
|
||||
target_link_libraries(librw_skeleton
|
||||
PUBLIC
|
||||
librw
|
||||
)
|
||||
)
|
||||
|
||||
target_include_directories(librw_skeleton
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
)
|
||||
)
|
||||
|
||||
if(NOT LIBRW_PLATFORM_PS2 AND NOT LIBRW_PLATFORM_NULL)
|
||||
add_subdirectory(imgui)
|
||||
|
|
|
@ -12,17 +12,17 @@ add_library(librw_skeleton_imgui
|
|||
stb_rect_pack.h
|
||||
stb_textedit.h
|
||||
stb_truetype.h
|
||||
)
|
||||
)
|
||||
|
||||
set_target_properties(librw_skeleton_imgui
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
)
|
||||
)
|
||||
|
||||
target_link_libraries(librw_skeleton_imgui
|
||||
PUBLIC
|
||||
librw_skeleton
|
||||
)
|
||||
)
|
||||
|
||||
if(LIBRW_INSTALL)
|
||||
install(
|
||||
|
|
|
@ -91,21 +91,28 @@ add_library(librw
|
|||
ps2/rwps2.h
|
||||
ps2/rwps2impl.h
|
||||
ps2/rwps2plg.h
|
||||
)
|
||||
)
|
||||
add_library(librw::librw ALIAS librw)
|
||||
|
||||
target_include_directories(librw
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
||||
)
|
||||
)
|
||||
|
||||
target_compile_definitions(librw
|
||||
PRIVATE
|
||||
LODEPNG_NO_COMPILE_CPP
|
||||
"$<IF:$<CONFIG:DEBUG>,DEBUG,NDEBUG>"
|
||||
PUBLIC
|
||||
"RW_${LIBRW_PLATFORM}"
|
||||
)
|
||||
)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_libraries(librw
|
||||
PRIVATE
|
||||
m
|
||||
)
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
target_compile_options(librw
|
||||
PRIVATE
|
||||
|
@ -135,10 +142,7 @@ set_target_properties(librw
|
|||
CXX_EXTENSIONS OFF
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
PREFIX ""
|
||||
)
|
||||
|
||||
if(LIBRW_PLATFORM_GL3)
|
||||
|
||||
)
|
||||
|
||||
if(LIBRW_PLATFORM_GL3)
|
||||
set(OpenGL_GL_PREFERENCE GLVND)
|
||||
|
@ -163,8 +167,13 @@ if(LIBRW_PLATFORM_GL3)
|
|||
PUBLIC
|
||||
SDL2::SDL2
|
||||
)
|
||||
if(TARGET SDL2::SDL2main)
|
||||
target_link_libraries(librw
|
||||
PUBLIC
|
||||
SDL2::SDL2main
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
elseif(LIBRW_PLATFORM_D3D9)
|
||||
target_link_libraries(librw
|
||||
PUBLIC
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
add_executable(dumprwtree
|
||||
dumprwtree.cpp
|
||||
)
|
||||
)
|
||||
|
||||
target_link_libraries(dumprwtree
|
||||
PUBLIC
|
||||
librw
|
||||
)
|
||||
)
|
||||
|
||||
if(LIBRW_INSTALL)
|
||||
install(TARGETS dumprwtree
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
add_executable(imguitest WIN32
|
||||
main.cpp
|
||||
)
|
||||
)
|
||||
|
||||
target_link_libraries(imguitest
|
||||
PUBLIC
|
||||
librw
|
||||
librw_skeleton_imgui
|
||||
)
|
||||
)
|
||||
|
||||
if(LIBRW_INSTALL)
|
||||
install(TARGETS imguitest
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
add_executable(ps2test
|
||||
gs.h
|
||||
main.cpp
|
||||
mem.h
|
||||
ps2.h
|
||||
vu/defaultpipe.dsm
|
||||
vu/skinpipe.dsm
|
||||
)
|
||||
|
||||
target_link_libraries(ps2test
|
||||
PUBLIC
|
||||
librw
|
||||
kernel
|
||||
)
|
||||
|
||||
add_erl_executable(PS2TEST_ERL ps2test)
|
||||
|
||||
if(LIBRW_INSTALL)
|
||||
install(TARGETS ps2test
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
)
|
||||
install(FILES "${PS2TEST_ERL}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
)
|
||||
endif()
|
Loading…
Reference in New Issue