diff options
author | Filip Gawin <filip.gawin@zoho.com> | 2021-01-14 15:03:54 +0100 |
---|---|---|
committer | Filip Gawin <filip.gawin@zoho.com> | 2021-01-14 15:03:54 +0100 |
commit | 7c8933f8c4fd3ca23dcafc6c510e439f5fabb294 (patch) | |
tree | 0fd67173aa5d8ffdeb28906f73bbbc6020499f7c | |
parent | fix (diff) | |
download | re3-7c8933f8c4fd3ca23dcafc6c510e439f5fabb294.tar re3-7c8933f8c4fd3ca23dcafc6c510e439f5fabb294.tar.gz re3-7c8933f8c4fd3ca23dcafc6c510e439f5fabb294.tar.bz2 re3-7c8933f8c4fd3ca23dcafc6c510e439f5fabb294.tar.lz re3-7c8933f8c4fd3ca23dcafc6c510e439f5fabb294.tar.xz re3-7c8933f8c4fd3ca23dcafc6c510e439f5fabb294.tar.zst re3-7c8933f8c4fd3ca23dcafc6c510e439f5fabb294.zip |
Diffstat (limited to '')
-rw-r--r-- | .github/workflows/build-cmake-conan.yml | 116 | ||||
-rw-r--r-- | .github/workflows/reVC_msvc_amd64.yml | 2 | ||||
-rw-r--r-- | .github/workflows/reVC_msvc_x86.yml | 2 | ||||
-rw-r--r-- | conanfile.py | 135 |
4 files changed, 253 insertions, 2 deletions
diff --git a/.github/workflows/build-cmake-conan.yml b/.github/workflows/build-cmake-conan.yml new file mode 100644 index 00000000..1f520677 --- /dev/null +++ b/.github/workflows/build-cmake-conan.yml @@ -0,0 +1,116 @@ +name: reVC conan+cmake +on: + pull_request: + push: + release: + types: published +jobs: + build-cmake: + strategy: + matrix: + include: + - os: 'windows-latest' + platform: 'gl3' + gl3_gfxlib: 'glfw' + audio: 'openal' +# - os: 'windows-latest' +# platform: 'gl3' +# gl3_gfxlib: 'sdl2' +# audio: 'openal' + - os: 'windows-latest' + platform: 'd3d9' + audio: 'openal' +# - os: 'windows-latest' +# platform: 'd3d9' +# audio: 'miles' + - os: 'ubuntu-latest' + platform: 'gl3' + gl3_gfxlib: 'glfw' + audio: 'openal' +# - os: 'ubuntu-latest' +# platform: 'gl3' +# gl3_gfxlib: 'sdl2' +# audio: 'openal' + - os: 'macos-latest' + platform: 'gl3' + gl3_gfxlib: 'glfw' + audio: 'openal' +# - os: 'macos-latest' +# platform: 'gl3' +# gl3_gfxlib: 'sdl2' +# audio: 'openal' + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.platform == 'ps2' || matrix.gl3_gfxlib == 'sdl2' || matrix.audio == 'miles' }} + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: "Checkout Miles SDK Import Library project" + uses: actions/checkout@v2 + if: ${{ matrix.audio == 'miles' }} + with: + repository: 'withmorten/re3mss' + path: 're3mss' + - uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: "Use XCode 11 as default (conan-center-index does not provide XCode 12 binaries at the moment)" + if: startsWith(matrix.os, 'macos') + run: | + sudo xcode-select --switch /Applications/Xcode_11.7.app + - name: "Setup conan" + run: | + python -m pip install conan + conan config init + conan config set log.print_run_commands=True + 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" + shell: python + run: | + 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 vendor/librw/conan/playstation2 host_profile + else + cp ~/.conan/profiles/default host_profile + fi + - name: "Export Playstation 2 CMake toolchain conan recipe" + run: | + conan export vendor/librw/cmake/ps2toolchain ps2dev-cmaketoolchain/master@ + - name: "Export librw conan recipe" + run: | + conan export vendor/librw librw/master@ + - name: "Export Miles SDK conan recipe" + if: ${{ matrix.audio == 'miles' }} + run: | + conan export re3mss miles-sdk/master@ + - name: "Download/build dependencies (conan install)" + run: | + conan install ${{ github.workspace }} reVC/master -if build -o reVC:audio=${{ matrix.audio }} -o librw:platform=${{ matrix.platform }} -o librw:gl3_gfxlib=${{ matrix.gl3_gfxlib || 'glfw' }} --build missing -pr:h ./host_profile -pr:b default -s reVC:build_type=RelWithDebInfo -s librw:build_type=RelWithDebInfo + env: + CONAN_SYSREQUIRES_MODE: enabled + - name: "Build reVC (conan build)" + run: | + conan build ${{ github.workspace }} -if build -bf build -pf package + - name: "Package reVC (conan package)" + run: | + conan package ${{ github.workspace }} -if build -bf build -pf package + - name: "Create binary package (cpack)" + working-directory: ./build + run: | + cpack -C RelWithDebInfo + - 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 diff --git a/.github/workflows/reVC_msvc_amd64.yml b/.github/workflows/reVC_msvc_amd64.yml index 2053a770..78b8bc9d 100644 --- a/.github/workflows/reVC_msvc_amd64.yml +++ b/.github/workflows/reVC_msvc_amd64.yml @@ -1,4 +1,4 @@ -name: reVC_msvc_amd64 +name: re3 premake amd64 on: pull_request: diff --git a/.github/workflows/reVC_msvc_x86.yml b/.github/workflows/reVC_msvc_x86.yml index 99079608..b9e83dba 100644 --- a/.github/workflows/reVC_msvc_x86.yml +++ b/.github/workflows/reVC_msvc_x86.yml @@ -1,4 +1,4 @@ -name: reVC_msvc_x86 +name: reVC premake x86 on: pull_request: diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 00000000..c5b74802 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,135 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanException, ConanInvalidConfiguration +import os +import shutil +import textwrap + + +class ReVCConan(ConanFile): + name = "reVC" + version = "master" + license = "???" # FIXME: https://github.com/GTAmodding/re3/issues/794 + settings = "os", "arch", "compiler", "build_type" + generators = "cmake", "cmake_find_package" + options = { + "audio": ["openal", "miles"], + "with_libsndfile": [True, False], + "with_opus": [True, False], + } + default_options = { + "audio": "openal", + "with_libsndfile": False, + "with_opus": False, + # "libsndfile:with_external_libs": False, + # "mpg123:flexible_resampling": False, + # "mpg123:network": False, + # "mpg123:icy": False, + # "mpg123:id3v2": False, + # "mpg123:ieeefloat": False, + # "mpg123:layer1": False, + # "mpg123:layer2": False, + # "mpg123:layer3": False, + # "mpg123:moreinfo": False, + # "sdl2:vulkan": False, + # "sdl2:opengl": True, + # "sdl2:sdl2main": True, + } + no_copy_source = True + + @property + def _os_is_playstation2(self): + try: + return self.settings.os == "Playstation2" + except ConanException: + return False + + def configure(self): + if self.options.audio != "openal": + self.options.with_libsndfile = False + + def requirements(self): + self.requires("librw/{}".format(self.version)) + self.requires("mpg123/1.26.4") + if self.options.audio == "openal": + self.requires("openal/1.21.0") + elif self.options.audio == "miles": + self.requires("miles-sdk/{}".format(self.version)) + if self.options.with_libsndfile: + self.requires("libsndfile/1.0.30") + if self.options.with_opus: + self.requires("opusfile/0.12") + + def export_sources(self): + for d in ("cmake", "src"): + shutil.copytree(src=d, dst=os.path.join(self.export_sources_folder, d)) + self.copy("CMakeLists.txt") + + def validate(self): + if self.options["librw"].platform == "gl3" and self.options["librw"].gl3_gfxlib != "glfw": + raise ConanInvalidConfiguration("Only `glfw` is supported as gl3_gfxlib.") + #if not self.options.with_opus: + # if not self.options["libsndfile"].with_external_libs: + # raise ConanInvalidConfiguration("reVC with opus support requires a libsndfile built with external libs (=ogg/flac/opus/vorbis)") + + @property + def _reVC_audio(self): + return { + "miles": "MSS", + "openal": "OAL", + }[str(self.options.audio)] + + def build(self): + if self.source_folder == self.build_folder: + raise Exception("cannot build with source_folder == build_folder") + try: + os.unlink(os.path.join(self.install_folder, "Findlibrw.cmake")) + tools.save("FindOpenAL.cmake", + textwrap.dedent( + """ + set(OPENAL_FOUND ON) + set(OPENAL_INCLUDE_DIR ${OpenAL_INCLUDE_DIRS}) + set(OPENAL_LIBRARY ${OpenAL_LIBRARIES}) + set(OPENAL_DEFINITIONS ${OpenAL_DEFINITIONS}) + """), append=True) + if self.options["librw"].platform == "gl3" and self.options["librw"].gl3_gfxlib == "glfw": + tools.save("Findglfw3.cmake", + textwrap.dedent( + """ + if(NOT TARGET glfw) + message(STATUS "Creating glfw TARGET") + add_library(glfw INTERFACE IMPORTED) + set_target_properties(glfw PROPERTIES + INTERFACE_LINK_LIBRARIES CONAN_PKG::glfw) + endif() + """), append=True) + tools.save("CMakeLists.txt", + textwrap.dedent( + """ + cmake_minimum_required(VERSION 3.0) + project(cmake_wrapper) + + include("{}/conanbuildinfo.cmake") + conan_basic_setup(TARGETS NO_OUTPUT_DIRS) + + add_subdirectory("{}" reVC) + """).format(self.install_folder.replace("\\", "/"), + self.source_folder.replace("\\", "/"))) + except FileNotFoundError: + pass + cmake = CMake(self) + cmake.definitions["REVC_AUDIO"] = self._reVC_audio + cmake.definitions["REVC_WITH_OPUS"] = self.options.with_opus + cmake.definitions["REVC_INSTALL"] = True + cmake.definitions["REVC_VENDORED_LIBRW"] = False + env = {} + 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() + + def package(self): + cmake = CMake(self) + cmake.install() |