This repository has been archived by the owner on Oct 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
conanfile.py
63 lines (53 loc) · 2.37 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from conans import ConanFile, tools, AutoToolsBuildEnvironment
class NinjaConan(ConanFile):
name = "ninja_installer"
version = "1.9.0"
description = "Ninja is a small build system with a focus on speed"
license = "Apache-2.0"
url = "https://github.com/bincrafters/conan-ninja_installer"
homepage = "https://github.com/ninja-build/ninja"
author = "Bincrafters <[email protected]>"
export = ["LICENSE.md"]
settings = "os_build", "arch_build", "compiler"
_source_subfolder = "source_subfolder"
def _build_vs(self):
with tools.chdir(self._source_subfolder):
with tools.vcvars(self.settings, filter_known_paths=False):
self.run("python configure.py --bootstrap")
def _build_configure(self):
with tools.chdir(self._source_subfolder):
cxx = os.environ.get("CXX", "g++")
if self.settings.os_build == "Linux":
if self.settings.arch_build == "x86":
cxx += " -m32"
elif self.settings.arch_build == "x86_64":
cxx += " -m64"
env_build = AutoToolsBuildEnvironment(self)
env_build_vars = env_build.vars
env_build_vars.update({'CXX': cxx})
with tools.environment_append(env_build_vars):
self.run("python configure.py --bootstrap")
def source(self):
archive_name = "v%s.tar.gz" % self.version
tools.get("%s/archive/%s" % (self.homepage, archive_name))
os.rename("ninja-%s" % self.version, self._source_subfolder)
def build(self):
if self.settings.os_build == "Windows":
self._build_vs()
else:
self._build_configure()
def package(self):
self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder)
self.copy(pattern="ninja*", dst="bin", src=self._source_subfolder)
def package_info(self):
# ensure ninja is executable
if str(self.settings.os_build) in ["Linux", "Macosx"]:
name = os.path.join(self.package_folder, "bin", "ninja")
os.chmod(name, os.stat(name).st_mode | 0o111)
self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))
self.env_info.CONAN_CMAKE_GENERATOR = "Ninja"
def package_id(self):
del self.info.settings.compiler