Skip to content
Permalink
Browse files

Apply Conan Conventions

Signed-off-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information...
uilianries committed Apr 25, 2019
1 parent 2f3a358 commit 8894e8fa64dff99a6c986e027f6afcb82fc60ec9
Showing with 95 additions and 96 deletions.
  1. +3 −12 .travis.yml
  2. +2 −2 .travis/install.sh
  3. +5 −6 README.md
  4. +1 −9 appveyor.yml
  5. +1 −0 build.py
  6. +78 −63 conanfile.py
  7. +5 −4 test_package/conanfile.py
@@ -1,17 +1,8 @@
env:
global:
- CONAN_USERNAME: "conan"
- CONAN_LOGIN_USERNAME: "conanbot"
- CONAN_CHANNEL: "testing"
- CONAN_UPLOAD: "https://api.bintray.com/conan/conan-community/conan"
- CONAN_STABLE_BRANCH_PATTERN: "master"
- CONAN_UPLOAD_ONLY_WHEN_STABLE: 1 # Will only upload when the branch matches "master"

linux: &linux
os: linux
sudo: required
dist: xenial
language: python
python: "2.7.10"
python: "3.7"
services:
- docker
osx: &osx
@@ -24,7 +15,7 @@ matrix:
- <<: *linux
env: CONAN_CURRENT_PAGE=2 CONAN_TOTAL_PAGES=2
- <<: *linux
env: CONAN_DOCKER_IMAGE=lasote/conangcc49-i386
env: CONAN_DOCKER_IMAGE=conanio/gcc7-centos6-x86
- <<: *osx
osx_image: xcode9.2
env: CONAN_CURRENT_PAGE=1 CONAN_TOTAL_PAGES=2
@@ -13,8 +13,8 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
eval "$(pyenv init -)"
fi

pyenv install 2.7.10
pyenv virtualenv 2.7.10 conan
pyenv install 3.7.1
pyenv virtualenv 3.7.1 conan
pyenv rehash
pyenv activate conan
fi
@@ -1,7 +1,7 @@
[![Build Status](https://ci.appveyor.com/api/projects/status/github/lasote/conan-cmake-installer)](https://ci.appveyor.com/project/lasote/conan-cmake-installer)
[![Build Status Travis](https://travis-ci.org/conan-community/conan-cmake_installer.svg)](https://travis-ci.org/conan-community/conan-cmake_installer)
[![Build Status AppVeyor](https://ci.appveyor.com/api/projects/status/github/conan-community/conan-cmake_installer?svg=true)](https://ci.appveyor.com/project/ConanCIintegration/conan-cmake_installer)


# conan-cmake-installer
# Conan CMake Installer

[Bintray conan-center](https://bintray.com/conan/conan-center?filterByPkgName=cmake_installer%3Aconan) package for installing CMake.

@@ -18,7 +18,6 @@ The available versions are:
This package is useful as a conan **build_require**, you can use it to build other packages using the CMake packages.
This package will automatically configure your PATH, to point to the packaged CMake.
Check: [http://docs.conan.io/en/latest/mastering/build_requires.html](http://docs.conan.io/en/latest/mastering/build_requires.html)






@@ -1,15 +1,7 @@
build: false

environment:
PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.8"
PYTHON_ARCH: "32"

CONAN_USERNAME: "conan"
CONAN_LOGIN_USERNAME: "conanbot"
CONAN_CHANNEL: "testing"
CONAN_UPLOAD: "https://api.bintray.com/conan/conan-community/conan"
CONAN_STABLE_BRANCH_PATTERN: "master"
PYTHON: "C:\\Python37"
CONAN_UPLOAD_ONLY_WHEN_STABLE: 1
CONAN_TOTAL_PAGES: 2

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import os
import platform

@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
import os
from conans import tools, ConanFile
from conans import tools, ConanFile, CMake
from conans import __version__ as conan_version
from conans.model.version import Version
from conans.errors import ConanException, NotFoundException
from conans.errors import ConanInvalidConfiguration, NotFoundException, ConanException

available_versions = ["3.14.2", "3.14.1", "3.14.0",
"3.13.4", "3.13.3", "3.13.2", "3.13.1", "3.13.0",
@@ -24,101 +25,115 @@
class CMakeInstallerConan(ConanFile):
name = "cmake_installer"
description = "creates cmake binaries package"
license = "OSI-approved BSD 3-clause"
url = "http://github.com/lasote/conan-cmake-installer"
if conan_version < Version("1.0.0"):
settings = {"os": ["Windows", "Linux", "Macos"],
"arch": ["x86", "x86_64"]}
else:
settings = "os_build", "arch_build"
license = "BSD-3-clause"
url = "http://github.com/conan-community/conan-cmake-installer"
author = "Conan Community"
homepage = "https://github.com/Kitware/CMake"
topics = ("conan", "cmake", "build", "installer")
settings = "os_build", "arch_build", "compiler"
options = {"version": available_versions}
default_options = "version=" + [v for v in available_versions if "-" not in v][0]
build_policy = "missing"
default_options = {"version": [v for v in available_versions if "-" not in v][0]}
exports = "LICENSE"

def minor_version(self):
return ".".join(str(self.cmake_version).split(".")[:2])

def config_options(self):
if self.version >= Version("2.8"): # Means CMake version
self.options.remove("version")

def configure(self):
if self.os == "Macos" and self.arch == "x86":
raise Exception("Not supported x86 for OSx")
@property
def _source_subfolder(self):
return "source_subfolder"

@property
def arch(self):
def _arch(self):
return self.settings.get_safe("arch_build") or self.settings.get_safe("arch")

@property
def os(self):
def _os(self):
return self.settings.get_safe("os_build") or self.settings.get_safe("os")

@property
def cmake_version(self):
def _cmake_version(self):
if "version" in self.options:
return str(self.options.version)
else:
return self.version

def get_filename(self):
os_id = {"Macos": "Darwin", "Windows": "win32"}.get(str(self.os),
str(self.os))
arch_id = {"x86": "i386"}.get(self.arch, self.arch) if self.os != "Windows" else "x86"
if self.os == "Linux" and self.cmake_version in ("2.8.12", "3.0.2") and \
self.arch == "x86_64":
def _minor_version(self):
return ".".join(str(self._cmake_version).split(".")[:2])

def _get_filename(self):
os_id = {"Macos": "Darwin", "Windows": "win32"}.get(str(self._os),
str(self._os))
arch_id = {"x86": "i386"}.get(self._arch, self._arch) if self._os != "Windows" else "x86"
if self._os == "Linux" and self._cmake_version in ("2.8.12", "3.0.2") and \
self._arch == "x86_64":
arch_id = "i386"
if self.os == "Macos" and self.cmake_version == "2.8.12":
if self._os == "Macos" and self._cmake_version == "2.8.12":
arch_id = "universal"
return "cmake-%s-%s-%s" % (self.cmake_version, os_id, arch_id)
return "cmake-%s-%s-%s" % (self._cmake_version, os_id, arch_id)

def get_filename_src(self):
return "cmake-%s" % self.cmake_version
def _get_filename_src(self):
return "cmake-%s" % self._cmake_version

def build(self):
minor = self.minor_version()
ext = "tar.gz" if not self.os == "Windows" else "zip"
dest_file = "file.tgz" if self.os != "Windows" else "file.zip"
try:
url = "https://cmake.org/files/v%s/%s.%s" % (minor, self.get_filename(), ext)
def _build_from_source(self):
return os.path.exists(os.path.join(self.build_folder, self._source_subfolder, "configure"))

# https://cmake.org/files/v3.6/cmake-3.6.0-Linux-i386.tar.gz
# https://cmake.org/files/v3.6/cmake-3.6.0-Darwin-x86_64.tar.gz
# https://cmake.org/files/v3.5/cmake-3.5.2-win32-x86.zip
def config_options(self):
if self.version >= Version("2.8"): # Means CMake version
del self.options.version

self.output.info("Downloading: %s" % url)
tools.download(url, dest_file, verify=False)
tools.unzip(dest_file)
def configure(self):
if self._os == "Macos" and self._arch == "x86":
raise ConanInvalidConfiguration("Not supported x86 for OSx")

def source(self):
minor = self._minor_version()
ext = "tar.gz" if not self._os == "Windows" else "zip"
dest_file = "file.tgz" if self._os != "Windows" else "file.zip"
unzip_folder = self._get_filename()
try:
url = "https://cmake.org/files/v%s/%s.%s" % (minor, self._get_filename(), ext)
except NotFoundException:
if self.settings.get_safe("os_build") == "Windows":
raise ConanException("Building from sources under Windows is not supported")
raise ConanInvalidConfiguration("Building from sources under Windows is not supported")
url = "https://cmake.org/files/v%s/%s.%s" % (minor, self._get_filename_src(), ext)
unzip_folder = self._get_filename_src()

url = "https://cmake.org/files/v%s/%s.%s" % (minor, self.get_filename_src(), ext)
self.output.info("Downloading: %s" % url)
tools.get(url, filename=dest_file, verify=False)
os.rename(unzip_folder, self._source_subfolder)

# https://cmake.org/files/v3.6/cmake-3.6.0.tar.gz
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["CMAKE_BOOTSTRAP"] = False
cmake.configure(source_dir=self._source_subfolder)
return cmake

self.output.info("Downloading: %s" % url)
tools.download(url, dest_file, verify=False)
tools.unzip(dest_file)
def build(self):
if self._build_from_source():
cmake = self._configure_cmake()
cmake.build()

with tools.chdir(self.get_filename_src()):
self.run("./bootstrap --prefix=%s" % os.path.join(self.build_folder, self.get_filename()))
self.run("make")
self.run("make install")
def package_id(self):
del self.info.settings.compiler

def package(self):
if self.os == "Macos":
appname = "CMake.app" if self.version != "2.8.12" else "CMake 2.8-12.app"
self.copy("*", dst="", src=os.path.join(self.get_filename(), appname, "Contents"))
if self._build_from_source():
self.copy("Copyright.txt", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
else:
self.copy("*", dst="", src=self.get_filename())
if self._os == "Macos":
appname = "CMake.app" if self.version != "2.8.12" else "CMake 2.8-12.app"
self.copy("*", dst="", src=os.path.join(self._source_subfolder, appname, "Contents"))
else:
self.copy("*", dst="", src=self._source_subfolder)
self.copy("Copyright.txt", dst="licenses", src=os.path.join(self._source_subfolder, "doc", "cmake"))

def package_info(self):
if self.package_folder is not None:
minor = self.minor_version()
self.env_info.path.append(os.path.join(self.package_folder, "bin"))
minor = self._minor_version()
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
self.env_info.CMAKE_ROOT = self.package_folder
mod_path = os.path.join(self.package_folder, "share", "cmake-%s" % minor, "Modules")
self.env_info.CMAKE_MODULE_PATH = mod_path
if not os.path.exists(mod_path):
raise Exception("Module path not found: %s" % mod_path)
raise ConanException("Module path not found: %s" % mod_path)
else:
self.output.warn("No package folder was created.")
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
from six import StringIO
import conans
from conans import ConanFile


class ConanFileInst(conans.ConanFile):
class ConanFileInst(ConanFile):

def build(self):
pass
@@ -11,8 +12,8 @@ def test(self):
output = StringIO()
self.run("cmake --version", output=output)
self.output.info("Installed: %s" % str(output.getvalue()))
if self.requires["cmake_installer"].conan_reference.version != "1.0":
ver = str(self.requires["cmake_installer"].conan_reference.version)
if self.requires["cmake_installer"].ref.version != "1.0":
ver = str(self.requires["cmake_installer"].ref.version)
else:
ver = str(self.options["cmake_installer"].version)

0 comments on commit 8894e8f

Please sign in to comment.
You can’t perform that action at this time.