Compare commits

..

No commits in common. "master" and "v2.1.0" have entirely different histories.

8 changed files with 68 additions and 164 deletions

1
.gitignore vendored
View File

@ -75,4 +75,3 @@ install_manifest.txt
compile_commands.json compile_commands.json
CTestTestfile.cmake CTestTestfile.cmake
_deps _deps
CMakeUserPresets.json

View File

@ -7,8 +7,8 @@
# CMake requirement and general configuration # CMake requirement and general configuration
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.12)
cmake_policy(VERSION 3.15) cmake_policy(VERSION 3.12)
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
if(DEFINED ENV{MS_COMPATIBLE}) if(DEFINED ENV{MS_COMPATIBLE})
set(CMAKE_GNUtoMS ON) # Enable compatibility level to exported libraries set(CMAKE_GNUtoMS ON) # Enable compatibility level to exported libraries
@ -24,6 +24,7 @@ else() # Standalone project mode, should not be used for release.
set(RSE_TEXTURE_NAME RSETexture) set(RSE_TEXTURE_NAME RSETexture)
endif() endif()
set(RSP_TEXTURE_LIB_NAME RSPTexture${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR}) set(RSP_TEXTURE_LIB_NAME RSPTexture${PROJECT_VERSION_MAJOR}${PROJECT_VERSION_MINOR})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")

13
Jenkinsfile vendored
View File

@ -12,6 +12,7 @@ pipeline {
stage('Prepare') { stage('Prepare') {
steps { steps {
cleanWs() cleanWs()
rtConanClient(id: "conan", userHome: "/home/jackcartersmith")
} }
} }
stage('Build') { stage('Build') {
@ -21,16 +22,20 @@ pipeline {
dir("linux") { dir("linux") {
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]]) checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Texture'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]])
sh 'git submodule update --init --recursive' sh 'git submodule update --init --recursive'
sh 'conan install . -of build -s build_type=Release -o "&:tools=True" -pr:b=default -pr:h=default --build=missing' dir("build") {
cmakeBuild buildDir: 'build', cmakeArgs: '-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DRSPTEXTURE_SHARED=ON -DRSPTEXTURE_STATIC=OFF -DBUILD_TOOLS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release', installation: 'latest', steps: [[args: 'all']] rtConanRun(clientId: "conan", command: "install .. --build=missing")
}
cmakeBuild buildDir: 'build', installation: 'latest', steps: [[args: 'all']]
} }
}, },
windows: { windows: {
dir("windows") { dir("windows") {
checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Terrain'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]]) checkout([$class: 'GitSCM', branches: [[name: '**']], browser: [$class: 'GiteaBrowser', repoUrl: 'https://git.jcsmith.fr/JCS-Prod/RSE-Terrain'], extensions: [], userRemoteConfigs: [[credentialsId: 'jenkins-ssh', url: 'ssh://git@git.jcsmith.fr:2322/JCS-Prod/RSE-Texture.git']]])
sh 'git submodule update --init --recursive' sh 'git submodule update --init --recursive'
sh 'conan install . -of build -s build_type=Release -o "&:tools=True" -pr:b=default -pr:h=windows --build=missing' dir("build") {
cmakeBuild buildDir: 'build', cmakeArgs: '-DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DRSPTEXTURE_SHARED=ON -DRSPTEXTURE_STATIC=OFF -DBUILD_TOOLS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres', installation: 'latest', steps: [[args: 'all']] rtConanRun(clientId: "conan", command: "install .. -pr:b=default -pr:h=windows --build=missing")
}
cmakeBuild buildDir: 'build', cmakeArgs: '-DGNU_HOST=x86_64-w64-mingw32 -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw_cross_toolchain.cmake', installation: 'latest', steps: [[args: 'all']]
} }
} }
) )

View File

@ -44,39 +44,45 @@ Due to issue with copyrights, I can't provide samples... You need to extract HMT
Necessary libs (provided only in windows release) for running and for compiling. Necessary libs (provided only in windows release) for running and for compiling.
- [zlib](https://www.zlib.net/) (1.3.1) - libpng (1.6.37)
- [libpng](http://www.libpng.org/pub/png/libpng.html) (1.6.43)
### Compiling ### Compiling
I've a preference for compiling libraries by hand, mainly for backward compatibility, but I recommend using Conan packages manager (https://conan.io) for simplicity (I've abandonned the support for conan v1 as it's now considered as deprecated). You can compile on both Windows (MinGW) or native Linux system thanks to CMake, you only need to adjust your dependencies on Windows or use Conan packages manager (https://conan.io).
libpng16-dev distrib package can be used on debian/ubuntu.
To compile, just clone and launch cmake:
```shell ```shell
conan install . -of build -b missing -s build_type=Release -o tools=True -pr:b=default -pr:h=default cmake .
cmake --preset conan-release -G "Unix Makefiles" make
cmake --build --preset conan-release make install
``` ```
If your CMake<3.23, you should use this command for generation instead of preset one: On Windows system, I can suggest you to use Conan support to help you with dependencies:
`cmake . -S build -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DRSPTEXTURE_SHARED=ON -DRSPTEXTURE_STATIC=OFF -DBUILD_TOOLS=ON -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"` ```shell
mkdir build
cd build
conan install .. --build=missing
cmake .. -G "MinGW Makefiles"
make
```
Beware to use the same release/debug configuration with CMake using Conan! Adjust CMake preset or Conan configuration if necessary. If you want to do it manually without Conan support, you will probably need to specify the dependency flags for CMake. Ex:
On Windows environment, you can use MinGW `-G "MinGW Makefiles"` or Ninja `-G "Ninja"` as CMake generator. `cmake.exe -D"ZLIB_INCLUDE_DIR=zlib/1.2.12/include" -D"ZLIB_LIBRARY=zlib/1.2.12/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.37/include" -D"PNG_LIBRARY=libpng/1.6.37/lib/libpng.dll.a" . -G "MinGW Makefiles"`
### Compiling (options) We can also use cross-compilation (after installing `mingw64` and `cmake` packages on your distrib):
There are a few configurable build options: ```shell
mkdir build && cd build
- RSPTEXTURE_SHARED Enable the build of shared version of the library ("shared" conan option) cmake -DGNU_HOST=x86_64-w64-mingw32 \
- RSPTEXTURE_STATIC Enable the build of static version of the library ("shared" conan option) -DCMAKE_TOOLCHAIN_FILE=../mingw_cross_toolchain.cmake \
- BUILD_TOOLS Enable the build of the standalone tools (necessary to use the lib directly) ("tools" conan option) -D"ZLIB_INCLUDE_DIR=zlib/1.2.12/include" \
-D"ZLIB_LIBRARY=zlib/1.2.12/lib/libzlib.dll.a" \
### Compiling (old-way) -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.37/include" \
-D"PNG_LIBRARY=libpng/1.6.37/lib/libpng.dll.a" \
If you want to do it manually without Conan, you will probably need to specify the dependency flags for CMake. Ex: ..
cmake --build .
`cmake.exe -D"ZLIB_INCLUDE_DIR=zlib/1.3.1/include" -D"ZLIB_LIBRARY=zlib/1.3.1/lib/libzlib.dll.a" -D"PNG_PNG_INCLUDE_DIR=libpng/1.6.43/include" -D"PNG_LIBRARY=libpng/1.6.43/lib/libpng.dll.a" -DRSPTEXTURE_SHARED=ON -DRSPTEXTURE_STATIC=OFF -DBUILD_TOOLS=ON . -G "MinGW Makefiles"` ```
I've tested cross-compilation too, but since I want to check that Conan is working properly at each release, I've integrated it into the Jenkins flow using Conan for the cross-abstraction.

View File

@ -12,7 +12,7 @@ include(CheckCSourceCompiles)
if(BUILD_TOOLS) if(BUILD_TOOLS)
# Import needed packages and references their include path # Import needed packages and references their include path
find_package(PNG 1.6.40 REQUIRED) find_package(PNG 1.6.37 REQUIRED)
include_directories(${PNG_INCLUDE_DIR}) include_directories(${PNG_INCLUDE_DIR})
@ -40,11 +40,9 @@ if(BUILD_TOOLS)
endif() endif()
# Link externals libraries to the linker # Link externals libraries to the linker
if (TARGET PNG::PNG) if(RSPTEXTURE_SHARED)
if(RSPTEXTURE_SHARED) target_link_libraries(rse-texture PRIVATE rsp-texture-lib ${PNG_LIBRARIES})
target_link_libraries(rse-texture PRIVATE rsp-texture-lib PNG::PNG) elseif(RSPTEXTURE_STATIC)
elseif(RSPTEXTURE_STATIC) target_link_libraries(rse-texture PRIVATE rsp-texture-libstatic ${PNG_LIBRARIES})
target_link_libraries(rse-texture PRIVATE rsp-texture-libstatic PNG::PNG)
endif()
endif() endif()
endif() endif()

View File

@ -0,0 +1,8 @@
SET(CMAKE_SYSTEM_NAME Windows)
IF("${GNU_HOST}" STREQUAL "")
SET(GNU_HOST i586-mingw32msvc)
ENDIF()
# Prefix detection only works with compiler id "GNU"
SET(CMAKE_C_COMPILER ${GNU_HOST}-gcc)
# CMake doesn't automatically look for prefixed 'windres', do it manually:
SET(CMAKE_RC_COMPILER ${GNU_HOST}-windres)

View File

@ -1,126 +0,0 @@
import os
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake
from conan.tools.files import copy
from conan.tools.scm import Git, Version
required_conan_version = ">=2.3"
class rse_texture(ConanFile):
name = "rsptexturelib"
package_type = "library"
version = "2.1.0"
revision_mode = "scm"
license = "GPL-3.0"
author = "JackCarterSmith <jackcartersmith@jcsmith.fr>"
url = "https://git.jcsmith.fr/JCS-Prod/RSE-Texture"
description = "Rogue Squadron 3D (PC) game textures files (HMT) extractor"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps"
options = {
"shared": [True, False],
"tools": [True, False],
"fPIC": [True, False]
}
default_options = {
"shared": True,
"tools": False,
"fPIC": True
}
@property
def _is_msvc(self):
return str(self.settings.compiler) in ["Visual Studio", "msvc"]
#def validate(self):
# if self.settings.os == "Macos":
# raise ConanInvalidConfiguration("MacOS not supported")
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
self.options["libpng"].shared = True
self.options["libpng"].sse = True
if self.options.shared:
self.options.rm_safe("fPIC")
def requirements(self):
if self.options.tools:
self.requires("zlib/1.3.1")
self.requires("libpng/1.6.43")
def source(self):
git = Git(self)
cargs = ['--single-branch', '--recursive', '--depth', '1', '--branch', 'v' + self.version]
git.clone(url="https://git.jcsmith.fr/JCS-Prod/RSE-Texture.git", target=".", args=cargs)
# def _patch(self):
# replace_in_file(self, os.path.join(self.source_folder, "RSPTextureLib", "CMakeLists.txt"),
# 'set_target_properties(rsp-texture-libstatic PROPERTIES OUTPUT_NAME "${RSP_TEXTURE_LIB_NAME}_static")',
# 'set_target_properties(rsp-texture-libstatic PROPERTIES OUTPUT_NAME "${RSP_TEXTURE_LIB_NAME}")')
def export_sources(self):
copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder)
# def layout(self):
# cmake_layout(self, src_folder='.', build_folder='build')
def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["RSPTEXTURE_SHARED"] = self.options.shared
tc.cache_variables["RSPTEXTURE_STATIC"] = not self.options.shared
tc.cache_variables["BUILD_TOOLS"] = self.options.tools
#tc.cache_variables["BUILD_DEBUG"] = self.settings.build_type == "Debug"
tc.generate()
#cmdeps = CMakeDeps(self)
#cmpdeps.set_property("zlib", "cmake_find_mode", "both")
#cmpdeps.set_property("libpng", "cmake_find_mode", "both")
#if self.options.shared:
#cmdeps.configuration = "ReleaseShared"
#cmdeps.generate()
for dep in self.dependencies.values():
if len(dep.cpp_info.bindirs) > 0:
if self.settings.os == "Windows":
if self._is_msvc:
copy(self, "*.dll", dep.cpp_info.bindirs[0], os.path.join(self.build_folder, "bin", str(self.settings.build_type)))
else:
copy(self, "*.dll", dep.cpp_info.bindirs[0], os.path.join(self.build_folder, "bin"))
else:
copy(self, "*.so", dep.cpp_info.bindirs[0], os.path.join(self.build_folder, "bin"))
def build(self):
cmbuilder = CMake(self)
#self._patch()
cmbuilder.configure()
cmbuilder.build()
def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, pattern="*.h", src=os.path.join(self.source_folder, "include"), dst=os.path.join(self.package_folder, "include"))
copy(self, pattern="*.a", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
copy(self, pattern="*.so", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
copy(self, pattern="*.lib", src=self.build_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False)
copy(self, pattern="*.dll", src=self.build_folder, dst=os.path.join(self.package_folder, "bin"), keep_path=False)
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "RSETexture")
self.cpp_info.set_property("cmake_target_name", "RSETexture")
self.cpp_info.set_property("cmake_module_target_name", "RSETexture::RSETexture")
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.names["cmake_find_package"] = "RSETexture"
self.cpp_info.names["cmake_find_package_multi"] = "RSETexture"
self.cpp_info.includedirs = ["include"]
prefix = "lib" if self._is_msvc else ""
#suffix = "d" if self.settings.build_type == "Debug" else ""
suffix = ""
major_min_version = f"{Version(self.version).major}{Version(self.version).minor}"
self.cpp_info.libs = ["{}RSETexture{}{}".format(prefix, major_min_version, suffix)]

13
conanfile.txt Normal file
View File

@ -0,0 +1,13 @@
[requires]
zlib/1.2.12
libpng/1.6.37
[generators]
cmake
cmake_find_package
[options]
libpng:shared=True
[imports]
bin, *.dll -> ./bin