Skip to content

Commit

Permalink
dropped support for multiple property sets in build request
Browse files Browse the repository at this point in the history
  • Loading branch information
grisumbras committed Nov 26, 2019
1 parent d1fe429 commit 0d63592
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: Build

on:
push:
Expand Down
14 changes: 5 additions & 9 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
:toc: preamble

image:https://api.bintray.com/packages/grisumbras/conan/b2-helper%3Agrisumbras/images/download.svg[Download,link=https://bintray.com/grisumbras/conan/b2-helper%3Agrisumbras/_latestVersion]
image:https://github.com/grisumbras/b2-helper/workflows/ci/badge.svg[Build status,link=https://github.com/grisumbras/b2-helper/actions]
image:https://github.com/grisumbras/b2-helper/workflows/Build/badge.svg?branch=master[Build status,link=https://github.com/grisumbras/b2-helper/actions]

____
https://conan.io[Conan] buid helper for projects that use
https://conan.io[Conan] build helper for projects that use
https://boostorg.github.io/build[Boost.Build]
____

Expand All @@ -24,7 +24,7 @@ package:
[source,python]
----
from conans import python_requires
b2 = python_requires("b2-helper/[>=0.1]@grisumbras/testing")
b2 = python_requires("b2-helper/[>=0.7.0]@grisumbras/stable")
----

== Usage
Expand Down Expand Up @@ -188,8 +188,7 @@ class MyConan(ConanFile):
* `package_folder` path to folder that will contain install artifacts.
* `project_config` path to created project configuration file.
* `executable` Boost.Build executable that will be used.
* `properties` a collection of property sets that will be used in build
request.
* `properties` property set that will be used in build request.
* `options` a collection of CLI options.


Expand All @@ -199,9 +198,6 @@ TBD
=== `class OptionsProxy`
TBD

=== `class PropertiesProxy`
TBD

=== `class PropertySet`
TBD

Expand All @@ -212,4 +208,4 @@ Dmitry Arkhipov <grisumbras@gmail.com>
Patches welcome!

== License
link:LICENSE[BSL-1.0] (C) 2018 Dmitry Arkhipov
link:LICENSE[BSL-1.0] (C) 2018-2019 Dmitry Arkhipov
99 changes: 6 additions & 93 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class B2ToolConan(ConanFile):
name = "b2-helper"
version = "0.6.0"
version = "0.7.0"
description = "conan helper for projects built with b2"
url = "http://github.com/grisumbras/b2-helper"
homepage = url
Expand Down Expand Up @@ -542,81 +542,6 @@ def _init_setting(self, setting, alias=None):
getattr(self, "_init_" + (alias or setting))(value)


class PropertiesProxy(object):
"""
Proxy object that allows accessing property sets for associated B2
instance. Provides both dict and attribute access for its first property
set. Also, provides index and iterator access to all property sets.
Examples:
props.toolset = "gcc"
props.toolset # "gcc"
props[0].toolset # "gcc"
props.add().toolset = "msvc"
props[1].toolset # "msvc"
"""

def __init__(self, b2, no_defaults=False):
"""
Initializes this instance. Creates a single property set element.
:param b2: associated B2 instance;
:param no_defaults: disable collecting default values from conanfile's
settings and options for the original and all added
property sets.
"""

setter = super().__setattr__
setter("_b2", b2)
setter("_no_defaults", no_defaults)
setter("_property_sets", [])
self.add()

def __getitem__(self, key):
if isinstance(key, (numbers.Number, slice)):
return self._property_sets[key]
return self._property_sets[0][key]

def __setitem__(self, key, value):
if isinstance(self, (numbers.Number, slice)):
self._property_sets[key] = value
self._property_sets[0][key] = value

def __delitem__(self, key):
if isinstance(self, (numbers.Number, slice)):
del self._property_sets[key]
del self._property_sets[0][key]

def __getattr__(self, key):
return getattr(self._property_sets[0], key)

def __setattr__(self, key, value):
setattr(self._property_sets[0], key, value)

def __delattr__(self, key):
delattr(self._property_sets[0], key)

def __iter__(self):
return iter(self._property_sets)

def add(self, no_defaults=None):
"""
Adds and returns a property set.
:param defaults: if `False`, fill with default properties;
if `True`, do not fill with default properties;
if `None`, fill with default properties if
`no_defaults=True` was passed to constructor.
"""

if no_defaults is None:
no_defaults = self._no_defaults

self._property_sets.append(PropertySet(self._b2, no_defaults))
return self._property_sets[-1]


class ToolsetModulesProxy(dict):
"""
dict subclass that acts as a collection of toolset modules.
Expand Down Expand Up @@ -761,7 +686,7 @@ def __init__(self, conanfile, no_defaults=False):
self.include = []

self.using = ToolsetModulesProxy()
self.properties = PropertiesProxy(self, no_defaults)
self.properties = PropertySet(self, no_defaults)

self.options = OptionsProxy(self)
if not no_defaults:
Expand Down Expand Up @@ -862,17 +787,9 @@ def configure(self):
include = path_escaped(include)
file.write("include \"%s\" ;\n" % include)

file.write("feature.feature conan-ps-request :")
for i, _ in enumerate(self.properties):
file.write(" ps%d" % i)
file.write(
" : optional propagated ;\n"
"project : requirements\n"
)
for i, ps in enumerate(self.properties):
for k, v in ps.flattened():
v = path_escaped(v)
file.write(" <conan-ps-request>ps%d:<%s>%s\n" % (i, k, v))
file.write("project : requirements\n")
for k, v in self.properties.flattened():
file.write(" <%s>%s\n" % (k, path_escaped(v)))
file.write(" ;\n")

def build(self, *targets):
Expand Down Expand Up @@ -915,12 +832,8 @@ def _build(self, targets):
"--build-dir=" + self.build_folder,
)

props = "conan-ps-request=" + ",".join((
("ps%d" % i) for i, _ in enumerate(self.properties)
))

args = itertools.chain(
[self.executable, props],
[self.executable],
targets,
special_options,
self.options.strings(),
Expand Down
15 changes: 4 additions & 11 deletions test_package/properties/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ class B2ToolTestConan(ConanFile):
exports_sources = "*.cpp", "*.jam"

def b2_setup_builder(self, builder):
ps1 = builder.properties[0]
ps1.threading = "multi"
ps1.link = "shared"

ps2 = builder.properties.add()
ps2.threading = "single"
ps2.link = "static"
ps = builder.properties
ps.threading = "multi"
ps.link = "shared"

return builder

Expand All @@ -35,8 +31,5 @@ def package(self):
else:
ext = ""
assert(os.path.exists(
os.path.join(self.package_folder, "bin", "main1" + ext)
))
assert(os.path.exists(
os.path.join(self.package_folder, "bin", "main2" + ext)
os.path.join(self.package_folder, "bin", "main" + ext)
))
5 changes: 2 additions & 3 deletions test_package/properties/jamroot.jam
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import package ;
project my-project ;


exe main1 : main.cpp : <threading>single:<build>no <link>static:<build>no ;
exe main2 : main.cpp : <threading>multi:<build>no <link>shared:<build>no ;
package.install install my-project : : main1 main2 ;
exe main : main.cpp : <threading>single:<build>no <link>static:<build>no ;
package.install install my-project : : main ;
alias test ; # empty target
explicit install test ;

0 comments on commit 0d63592

Please sign in to comment.