conan+ci: update
This commit is contained in:
parent
9c5b50536e
commit
dd01289f38
59
.github/workflows/build-cmake-conan.yml
vendored
59
.github/workflows/build-cmake-conan.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Build using conan
|
name: Build using conan+cmake
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
push:
|
push:
|
||||||
@ -10,18 +10,22 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
os: [windows-latest, ubuntu-latest, macos-latest]
|
||||||
platform: ['null', 'gl3', 'd3d9', 'ps2']
|
platform: ['null', 'gl3', 'd3d9', 'ps2']
|
||||||
|
gl3_gfxlib: ['glfw', 'sdl2']
|
||||||
exclude:
|
exclude:
|
||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
platform: ps2
|
platform: ps2
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
platform: d3d9
|
platform: d3d9
|
||||||
- os: ubuntu-latest
|
|
||||||
platform: ps2 # FIXME: add ps2toolchain conan package + ps2 profile
|
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
platform: d3d9
|
platform: d3d9
|
||||||
- os: macos-latest
|
- platform: 'null'
|
||||||
platform: ps2
|
gl3_gfxlib: sdl2
|
||||||
|
- platform: d3d9
|
||||||
|
gl3_gfxlib: sdl2
|
||||||
|
- platform: ps2
|
||||||
|
gl3_gfxlib: sdl2
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
continue-on-error: ${{ matrix.platform == 'ps2' }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
@ -30,17 +34,50 @@ jobs:
|
|||||||
- name: "Setup conan"
|
- name: "Setup conan"
|
||||||
run: |
|
run: |
|
||||||
python -m pip install conan
|
python -m pip install conan
|
||||||
conan user
|
conan config init
|
||||||
conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan
|
|
||||||
conan config set log.print_run_commands=True
|
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: |
|
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:
|
env:
|
||||||
CONAN_SYSREQUIRES_MODE: enabled
|
CONAN_SYSREQUIRES_MODE: enabled
|
||||||
- name: "conan build (build librw)"
|
- name: "Build librw (conan build)"
|
||||||
run: |
|
run: |
|
||||||
conan build ${{ github.workspace }} -if build -bf build -pf package
|
conan build ${{ github.workspace }} -if build -bf build -pf package
|
||||||
- name: "conan package (package librw)"
|
- name: "Package librw (conan package)"
|
||||||
run: |
|
run: |
|
||||||
conan package ${{ github.workspace }} -if build -bf build -pf package
|
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
|
||||||
|
57
conanfile.py
57
conanfile.py
@ -1,5 +1,5 @@
|
|||||||
from conans import ConanFile, CMake, tools
|
from conans import ConanFile, CMake, tools
|
||||||
from conans.errors import ConanInvalidConfiguration
|
from conans.errors import ConanException, ConanInvalidConfiguration
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import textwrap
|
import textwrap
|
||||||
@ -18,21 +18,39 @@ class LibrwConan(ConanFile):
|
|||||||
default_options = {
|
default_options = {
|
||||||
"platform": "gl3",
|
"platform": "gl3",
|
||||||
"gl3_gfxlib": "glfw",
|
"gl3_gfxlib": "glfw",
|
||||||
|
"openal:with_external_libs": False,
|
||||||
"sdl2:vulkan": False,
|
"sdl2:vulkan": False,
|
||||||
"sdl2:opengl": True,
|
"sdl2:opengl": True,
|
||||||
"sdl2:sdl2main": False,
|
"sdl2:sdl2main": True,
|
||||||
}
|
}
|
||||||
no_copy_source = 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):
|
def config_options(self):
|
||||||
|
if self._os_is_playstation2:
|
||||||
|
self.options.platform = "ps2"
|
||||||
if self.settings.os == "Windows":
|
if self.settings.os == "Windows":
|
||||||
self.options["sdl2"].directx = False
|
self.options["sdl2"].directx = False
|
||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
if self.options.platform != "gl3":
|
if self.options.platform != "gl3":
|
||||||
del self.options.gl3_gfxlib
|
del self.options.gl3_gfxlib
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
if self.options.platform == "d3d9" and self.settings.os != "Windows":
|
if self.options.platform == "d3d9" and self.settings.os != "Windows":
|
||||||
raise ConanInvalidConfiguration("d3d9 can only be built for 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):
|
def requirements(self):
|
||||||
if self.options.platform == "gl3":
|
if self.options.platform == "gl3":
|
||||||
@ -41,6 +59,10 @@ class LibrwConan(ConanFile):
|
|||||||
self.requires("glfw/3.3.2")
|
self.requires("glfw/3.3.2")
|
||||||
elif self.options.gl3_gfxlib == "sdl2":
|
elif self.options.gl3_gfxlib == "sdl2":
|
||||||
self.requires("sdl2/2.0.12@bincrafters/stable")
|
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):
|
def export_sources(self):
|
||||||
for d in ("cmake", "skeleton", "src", "tools"):
|
for d in ("cmake", "skeleton", "src", "tools"):
|
||||||
@ -62,16 +84,17 @@ class LibrwConan(ConanFile):
|
|||||||
def build(self):
|
def build(self):
|
||||||
if self.source_folder == self.build_folder:
|
if self.source_folder == self.build_folder:
|
||||||
raise Exception("cannot build with source_folder == build_folder")
|
raise Exception("cannot build with source_folder == build_folder")
|
||||||
tools.save("Findglfw3.cmake",
|
if self.options.platform == "gl3" and self.options.gl3_gfxlib == "glfw":
|
||||||
textwrap.dedent(
|
tools.save("Findglfw3.cmake",
|
||||||
"""
|
textwrap.dedent(
|
||||||
if(NOT TARGET glfw)
|
"""
|
||||||
message(STATUS "Creating glfw TARGET")
|
if(NOT TARGET glfw)
|
||||||
add_library(glfw INTERFACE IMPORTED)
|
message(STATUS "Creating glfw TARGET")
|
||||||
set_target_properties(glfw PROPERTIES
|
add_library(glfw INTERFACE IMPORTED)
|
||||||
INTERFACE_LINK_LIBRARIES CONAN_PKG::glfw) #$<BUILD_INTERFACE:CONAN_PKG::glfw>)
|
set_target_properties(glfw PROPERTIES
|
||||||
endif()
|
INTERFACE_LINK_LIBRARIES CONAN_PKG::glfw)
|
||||||
"""), append=True)
|
endif()
|
||||||
|
"""), append=True)
|
||||||
tools.save("CMakeLists.txt",
|
tools.save("CMakeLists.txt",
|
||||||
textwrap.dedent(
|
textwrap.dedent(
|
||||||
"""
|
"""
|
||||||
@ -85,11 +108,17 @@ class LibrwConan(ConanFile):
|
|||||||
""").format(self.install_folder.replace("\\", "/"),
|
""").format(self.install_folder.replace("\\", "/"),
|
||||||
self.source_folder.replace("\\", "/")))
|
self.source_folder.replace("\\", "/")))
|
||||||
cmake = CMake(self)
|
cmake = CMake(self)
|
||||||
|
env = {}
|
||||||
cmake.definitions["LIBRW_PLATFORM"] = self._librw_platform
|
cmake.definitions["LIBRW_PLATFORM"] = self._librw_platform
|
||||||
cmake.definitions["LIBRW_INSTALL"] = True
|
cmake.definitions["LIBRW_INSTALL"] = True
|
||||||
|
cmake.definitions["LIBRW_TOOLS"] = True
|
||||||
if self.options.platform == "gl3":
|
if self.options.platform == "gl3":
|
||||||
cmake.definitions["LIBRW_GL3_GFXLIB"] = str(self.options.gl3_gfxlib).upper()
|
cmake.definitions["LIBRW_GL3_GFXLIB"] = str(self.options.gl3_gfxlib).upper()
|
||||||
cmake.configure(source_folder=self.build_folder)
|
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()
|
cmake.build()
|
||||||
|
|
||||||
def package(self):
|
def package(self):
|
||||||
@ -98,7 +127,7 @@ class LibrwConan(ConanFile):
|
|||||||
|
|
||||||
def package_info(self):
|
def package_info(self):
|
||||||
self.cpp_info.includedirs.append(os.path.join("include", "librw"))
|
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":
|
if self.options.platform == "null":
|
||||||
self.cpp_info.defines.append("RW_NULL")
|
self.cpp_info.defines.append("RW_NULL")
|
||||||
elif self.options.platform == "gl3":
|
elif self.options.platform == "gl3":
|
||||||
|
Loading…
Reference in New Issue
Block a user