From f421d30f302cbd06212a7b18146123ef05dba500 Mon Sep 17 00:00:00 2001 From: Edgar Date: Mon, 3 Sep 2018 09:52:52 +0200 Subject: [PATCH] Added conan --- .travis.yml | 41 +++++++++++++++++++++++++++++++++++ .travis/install.sh | 25 +++++++++++++++++++++ .travis/run.sh | 13 +++++++++++ CMakeLists.txt | 54 ++++++++++++++++++++++++++++++++++++++++++++++ appveyor.yml | 24 +++++++++++++++++++++ build.py | 7 ++++++ conanfile.py | 32 +++++++++++++++++++++++++++ 7 files changed, 196 insertions(+) create mode 100644 .travis.yml create mode 100644 .travis/install.sh create mode 100644 .travis/run.sh create mode 100644 CMakeLists.txt create mode 100644 appveyor.yml create mode 100644 build.py create mode 100644 conanfile.py diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..189bc2c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,41 @@ + +env: + global: + - CONAN_REFERENCE: "MofileReader/0.1.2" + - CONAN_USERNAME: "anotherfoxguy" + - CONAN_LOGIN_USERNAME: "anotherfoxguy" + - CONAN_CHANNEL: "MofileReader" + - CONAN_UPLOAD: "https://api.bintray.com/conan/anotherfoxguy/ror-dependencies" + +linux: &linux + os: linux + sudo: required + language: python + python: "3.6" + services: + - docker +osx: &osx + os: osx + language: generic +matrix: + include: + + - <<: *linux + env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=lasote/conangcc49 + + - <<: *linux + env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=lasote/conangcc5 + + - <<: *linux + env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=lasote/conangcc6 + + - <<: *linux + env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=lasote/conangcc7 + +install: + - chmod +x .travis/install.sh + - ./.travis/install.sh + +script: + - chmod +x .travis/run.sh + - ./.travis/run.sh diff --git a/.travis/install.sh b/.travis/install.sh new file mode 100644 index 0000000..9da0265 --- /dev/null +++ b/.travis/install.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e +set -x + +if [[ "$(uname -s)" == 'Darwin' ]]; then + brew update || brew update + brew outdated pyenv || brew upgrade pyenv + brew install pyenv-virtualenv + brew install cmake || true + + if which pyenv > /dev/null; then + eval "$(pyenv init -)" + fi + + pyenv install 2.7.10 + pyenv virtualenv 2.7.10 conan + pyenv rehash + pyenv activate conan +fi + +pip install conan --upgrade +pip install conan_package_tools + +conan user diff --git a/.travis/run.sh b/.travis/run.sh new file mode 100644 index 0000000..0a3488e --- /dev/null +++ b/.travis/run.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e +set -x + +if [[ "$(uname -s)" == 'Darwin' ]]; then + if which pyenv > /dev/null; then + eval "$(pyenv init -)" + fi + pyenv activate conan +fi + +python build.py diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a4b221c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,54 @@ +#------------------------------------------------------- +# moFileReader Main Build Script +# +# Defined Variables: +# - COMPILE_DLL +# - ON : Compiles the code as a shared Library +# - OFF : Compiles the code as a static Library +# - BUILD_DEBUG +# - ON : Compiles Debug-Information into the output +# - OFF : Optimizes the compilation with O2. +# +# Run cmake with -DVARNAME=ON/OFF to benefit from those +# possible settings. +#------------------------------------------------------- +cmake_minimum_required(VERSION 2.6) +project(moFileReader) + +# Set Output Directories. +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ../bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ../lib) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ../lib) + + +# The main include directory +include_directories(BEFORE ../include) + +# executable build directory +add_subdirectory(bin) + +# Let the user choose between static lib and dll +# To use it, call cmake -DCOMPILE_DLL=ON +option(COMPILE_DLL "Set this to ON if you want to compile the library as an DLL. When this is OFF, a static library is created (default)." OFF) + +# Dependency +link_directories(../lib) + +if ( NOT COMPILE_DLL ) + + # Static build + add_library(moFileReader.static STATIC ../src/moFileReader.cpp ../src/mo.cpp) + +else ( COMPILE_DLL ) + + # DLL + add_definitions(-D_USRDLL -DMOFILE_EXPORTS) + add_library(moFileReader SHARED ../src/moFileReader.cpp ../src/mo.cpp) + +endif () + + + + + + diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..23eaa0e --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,24 @@ +build: false +image: Visual Studio 2017 + +environment: + PYTHON: "C:\\Python27" + PYTHON_VERSION: "2.7.8" + PYTHON_ARCH: "32" + + CONAN_REFERENCE: "MofileReader/0.1.2" + CONAN_USERNAME: "anotherfoxguy" + CONAN_LOGIN_USERNAME: "anotherfoxguy" + CONAN_CHANNEL: "MofileReader" + CONAN_UPLOAD: "https://api.bintray.com/conan/anotherfoxguy/ror-dependencies" + CONAN_VISUAL_VERSIONS: 15 + + +install: + - set PATH=%PATH%;%PYTHON%/Scripts/ + - pip.exe install conan --upgrade + - pip.exe install conan_package_tools + - conan user # It creates the conan data directory + +test_script: + - python build.py diff --git a/build.py b/build.py new file mode 100644 index 0000000..64e8245 --- /dev/null +++ b/build.py @@ -0,0 +1,7 @@ +from conan.packager import ConanMultiPackager + + +if __name__ == "__main__": + builder = ConanMultiPackager() + builder.add_common_builds() + builder.run() diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..7a224fe --- /dev/null +++ b/conanfile.py @@ -0,0 +1,32 @@ +from conans import ConanFile, CMake, tools +import os + +class MofilereaderConan(ConanFile): + name = "MofileReader" + version = "0.1.2" + license = "MIT" + url = "https://github.com/AnotherFoxGuy/conan-MofileReader/" + description = "This API lets you read .mo-Files and use their content just as you would do with GNUs gettext." + settings = "os", "compiler", "build_type", "arch" + #options = {"shared": [True, False]} + #default_options = "shared=False" + generators = "cmake" + + def source(self): + self.run("git clone https://bitbucket.org/scorcher24/mofilereader.git .") + + def build(self): + cmake = CMake(self) + cmake.configure(source_folder="build") + cmake.build() + + def package(self): + self.copy("*.h", dst="include", src="include") + self.copy("*.lib", dst="lib", src=os.path.join("..", "lib"), keep_path=False) + self.copy("*.dll", dst="bin", keep_path=False) + self.copy("*.so", dst="lib", keep_path=False) + self.copy("*.dylib", dst="lib", keep_path=False) + self.copy("*.a", dst="lib", keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["MofileReader"]