diff --git a/README.md b/README.md index 8e443d56..75eb241e 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,8 @@ There are also two additional parameters of the ``add_common_builds``: - **shared_option_name**: If your conanfile.py have an option **shared**, the generated builds will contain automatically the "True/False" combination for that option. Pass "False" to deactivate it or "lib_name:shared_option_name" to specify a custom option name, e.j: boost:my_shared`` - **dll_with_static_runtime**: Will add also the combination of runtime MT with shared libraries. +- **header_only**: If your conanfile.py have an option **header_only**, the generated builds will contain automatically the "True/False" combination for that option [#454](https://github.com/conan-io/conan-package-tools/issues/454). +- **build_all_options_values**: It includes all possible values for the listed options [#457](https://github.com/conan-io/conan-package-tools/issues/457). ``` from cpt.packager import ConanMultiPackager @@ -365,7 +367,19 @@ In case you want to integrate CPT with other tools, for example you want to have Alternatively you can use the `CPT_SUMMARY_FILE` environment variable to set the summary file path +## Using all values for custom options +Sometimes you want to include more options to your matrix, including all possible combinations, so that, you can use **build_all_options_values**: + from cpt.packager import ConanMultiPackager + + + if __name__ == "__main__": + builder = ConanMultiPackager(reference="mypackage/0.1.0") + builder.add_common_builds(build_all_options_values=["mypackage:foo", "mypackage:bar"]) + builder.run() + +Now let's say mypackage's recipe contains the follow options: *shared*, *fPIC*, *foo* and *bar*. Both *foo* and *bar* can accept **True** or **False**. +The method add_common_builds will generate a matrix including both *foo* and *bar* with all possible combinations. ## Using Docker @@ -1099,6 +1113,7 @@ Using **CONAN_CLANG_VERSIONS** env variable in Travis ci or Appveyor: rebuild all packages. - "all": Build all requirements. - **test_folder**: Custom test folder consumed by Conan create, e.j .conan/test_package +- **lockfile**: Custom conan lockfile to be used, e.j. conan.lock. Default [None] - **conanfile**: Custom conanfile consumed by Conan create. e.j. conanfile.py - **config_url**: Conan config URL be installed before to build e.j https://github.com/bincrafters/conan-config.git - **config_args**: Conan config arguments used when installing conan config @@ -1139,12 +1154,15 @@ The current commit message can contain special messages: ## Complete ConanMultiPackager methods reference: -- **add_common_builds(shared_option_name=None, pure_c=True, dll_with_static_runtime=False)**: Generate a set of package configurations and add them to the +- **add_common_builds(shared_option_name=None, pure_c=True, dll_with_static_runtime=False, reference=None, header_only=True, build_all_options_values=None)**: Generate a set of package configurations and add them to the list of packages that will be created. - **shared_option_name**: If given, ConanMultiPackager will add different configurations for -o shared=True and -o shared=False. - **pure_c**: ConanMultiPackager won't generate different builds for the **libstdc++** c++ standard library, because it is a pure C library. - **dll_with_static_runtime**: generate also build for "MT" runtime when the library is shared. + - **reference**: Custom package reference + - **header_only**: Generate new builds following header-only options [#454](https://github.com/conan-io/conan-package-tools/issues/454) + - **build_all_options_values**: Include all values for the listed options [#457](https://github.com/conan-io/conan-package-tools/issues/457) - **login(remote_name)**: Performs a `conan user` command in the specified remote. @@ -1205,6 +1223,7 @@ This is especially useful for CI integration. - **CONAN_ARCHS**: Architectures to build for, comma separated, e.g. "x86,x86_64" - **CONAN_OPTIONS**: Conan build options, comma separated, e.g. "foobar:with_bar=True,foobar:with_qux=False" - **CONAN_SHARED_OPTION_NAME**: Set `shared_option_name` by environment variable, e.g. "mypackagename:shared" +- **CONAN_BUILD_ALL_OPTIONS_VALUES**: Set `build_all_options_values` by environment variable, e.g. "mypackagename:foo,mypackagename:bar" - **CONAN_BUILD_TYPES**: Build types to build for, comma separated, e.g. "Release,Debug" - **CONAN_CPPSTDS**: List containing values for `compiler.cppstd`. Default None - **CONAN_VISUAL_VERSIONS**: Visual versions, comma separated, e.g. "12,14" @@ -1231,6 +1250,7 @@ This is especially useful for CI integration. Set it with the bash executable path if it’s not in the PATH or you want to use a different one. - **CONAN_PIP_USE_SUDO** Use "sudo" when invoking pip, by default it will use sudo when not using Windows and not running docker image "conanio/". "False" to deactivate. - **CONAN_PIP_COMMAND** Run custom `pip` command when updating Conan. e.g. "/usr/bin/pip2" +- **CONAN_DOCKER_PIP_COMMAND** Run custom `pip` command when updating Conan and CPT in Docker container. e.g. "/usr/bin/pip2" - **CONAN_DOCKER_USE_SUDO** Use "sudo" when invoking docker, by default it will use sudo when not using Windows. "False" to deactivate. - **CONAN_ALLOW_GCC_MINORS** Declare this variable if you want to allow gcc >=5 versions with the minor (5.1, 6.3 etc). - **CONAN_EXCLUDE_VCVARS_PRECOMMAND** For Visual Studio builds, it exclude the vcvars call to set the environment. @@ -1246,6 +1266,7 @@ This is especially useful for CI integration. - **CONAN_BASE_PROFILE**: Apply options, settings, etc. to this profile instead of `default`. - **CONAN_IGNORE_SKIP_CI**: Ignore `[skip ci]` in commit message. - **CONAN_CONANFILE**: Custom conanfile consumed by Conan create. e.j. conanfile.py +- **CONAN_LOCKFILE**: Custom conan lockfile to be used, e.j. conan.lock. - **CPT_TEST_FOLDER**: Custom test_package path, e.j .conan/test_package - **CONAN_FORCE_SELINUX**: Force docker to relabel file objects on the shared volumes - **CONAN_SKIP_RECIPE_EXPORT**: If defined, the package recipe will only be exported on the first build. diff --git a/appveyor.yml b/appveyor.yml index 0ec57147..3f7abf42 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,13 +3,15 @@ environment: - PYTHON: "C:\\Python27" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 USE_UNSUPPORTED_CONAN_WITH_PYTHON_2: "1" - - PYTHON: "C:\\Python35" + TOXENV: "py27-conan-latest" + + - PYTHON: "C:\\Python37" APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 USE_UNSUPPORTED_CONAN_WITH_PYTHON_2: "1" + TOXENV: "py37-conan-latest" build: false install: - .ci/appveyor/install.bat test_script: - .ci/appveyor/test.bat - diff --git a/cpt/__init__.py b/cpt/__init__.py index f9f1f1e3..ed04df4b 100644 --- a/cpt/__init__.py +++ b/cpt/__init__.py @@ -1,6 +1,7 @@ -__version__ = '0.31.2' -NEWEST_CONAN_SUPPORTED = "1.22.300" +__version__ = '0.32.0' +NEWEST_CONAN_SUPPORTED = "1.23.000" + def get_client_version(): from conans.model.version import Version diff --git a/cpt/builds_generator.py b/cpt/builds_generator.py index c90df27e..4eba274c 100644 --- a/cpt/builds_generator.py +++ b/cpt/builds_generator.py @@ -6,11 +6,11 @@ from conans.model.version import Version from cpt.tools import split_colon_env, transform_list_options_to_dict -default_gcc_versions = ["4.9", "5", "6", "7", "8"] -default_clang_versions = ["3.8", "3.9", "4.0", "5.0", "6.0", "7.0"] +default_gcc_versions = ["4.9", "5", "6", "7", "8", "9"] +default_clang_versions = ["3.8", "3.9", "4.0", "5.0", "6.0", "7.0", "8", "9"] default_visual_versions = ["14", "15"] default_visual_runtimes = ["MT", "MD", "MTd", "MDd"] -default_apple_clang_versions = ["9.0", "9.1", "10.0"] +default_apple_clang_versions = ["9.0", "9.1", "10.0", "11.0"] default_archs = ["x86", "x86_64"] default_build_types = ["Release", "Debug"] default_cppstds = [None] @@ -142,7 +142,8 @@ def __init__(self, reference, os_name, gcc_versions, apple_clang_versions, clang options = [] self._options = transform_list_options_to_dict(options) - def get_builds(self, pure_c, shared_option_name, dll_with_static_runtime, reference=None): + def get_builds(self, pure_c, shared_option_name, dll_with_static_runtime, reference=None, + build_all_options_values=None): ref = reference or self._reference @@ -150,29 +151,35 @@ def get_builds(self, pure_c, shared_option_name, dll_with_static_runtime, refere if self._mingw_configurations: builds = get_mingw_builds(self._mingw_configurations, get_mingw_package_reference(), self._archs, - shared_option_name, self._build_types, self._cppstds, self._options, ref) + shared_option_name, self._build_types, self._cppstds, + self._options, ref, build_all_options_values) else: builds = [] builds.extend(get_visual_builds(self._visual_versions, self._archs, self._visual_runtimes, self._visual_toolsets, shared_option_name, dll_with_static_runtime, self._vs10_x86_64_enabled, - self._build_types, self._cppstds, self._options, ref)) + self._build_types, self._cppstds, self._options, ref, + build_all_options_values)) return builds elif self._os_name == "Linux": builds = get_linux_gcc_builds(self._gcc_versions, self._archs, shared_option_name, - pure_c, self._build_types, self._cppstds, self._options, ref) + pure_c, self._build_types, self._cppstds, self._options, ref, + build_all_options_values) builds.extend(get_linux_clang_builds(self._clang_versions, self._archs, shared_option_name, pure_c, self._build_types, - self._cppstds, self._options, ref)) + self._cppstds, self._options, ref, + build_all_options_values)) return builds elif self._os_name == "Darwin": return get_osx_apple_clang_builds(self._apple_clang_versions, self._archs, shared_option_name, pure_c, self._build_types, - self._cppstds, self._options, ref) + self._cppstds, self._options, ref, + build_all_options_values) elif self._os_name == "FreeBSD": return get_linux_clang_builds(self._clang_versions, self._archs, shared_option_name, - pure_c, self._build_types, self._cppstds, self._options, ref) + pure_c, self._build_types, self._cppstds, self._options, + ref, build_all_options_values) else: raise Exception("Unknown operating system: %s" % self._os_name) @@ -195,13 +202,13 @@ def __new__(cls, settings, options, env_vars, build_requires, reference): if isinstance(reference, str): reference = ConanFileReference.loads(reference) - return super(BuildConf, cls).__new__(cls, settings, options, env_vars, - build_requires, reference) + return super(BuildConf, cls).__new__(cls, settings, options, env_vars, build_requires, + reference) def get_mingw_builds(mingw_configurations, mingw_installer_reference, archs, shared_option_name, build_types, cppstds, - options, reference=None): + options, reference=None, build_all_options_values=None): builds = [] for config in mingw_configurations: version, arch, exception, thread = config @@ -213,11 +220,16 @@ def get_mingw_builds(mingw_configurations, mingw_installer_reference, "compiler.exception": exception} build_requires = {"*": [mingw_installer_reference]} - if shared_option_name: + if shared_option_name and not build_all_options_values: for shared in [True, False]: opt = copy.copy(options) opt[shared_option_name] = shared builds += _make_mingw_builds(settings, opt, build_requires, build_types, cppstds, reference) + elif build_all_options_values: + for option_values in build_all_options_values: + opt = copy.copy(options) + opt.update(option_values) + builds += _make_mingw_builds(settings, opt, build_requires, build_types, cppstds, reference) else: builds += _make_mingw_builds(settings, copy.copy(options), build_requires, build_types, cppstds, reference) @@ -241,7 +253,7 @@ def _make_mingw_builds(settings, options, build_requires, build_types, cppstds, def get_visual_builds(visual_versions, archs, visual_runtimes, visual_toolsets, shared_option_name, dll_with_static_runtime, vs10_x86_64_enabled, build_types, cppstds, - options, reference=None): + options, reference=None, build_all_options_values=None): visual_toolsets = visual_toolsets or get_env_visual_toolsets() ret = [] @@ -258,14 +270,16 @@ def get_visual_builds(visual_versions, archs, visual_runtimes, visual_toolsets, visual_builds = get_visual_builds_for_version(visual_runtimes, visual_version, arch, shared_option_name, dll_with_static_runtime, build_types, - cppstds, options, reference, toolset=toolset) + cppstds, options, reference, + toolset=toolset, + build_all_options_values=build_all_options_values) ret.extend(visual_builds) return ret def get_visual_builds_for_version(visual_runtimes, visual_version, arch, shared_option_name, dll_with_static_runtime, build_types, cppstds, options, - reference=None, toolset=None): + reference=None, toolset=None, build_all_options_values=None): base_set = {"compiler": "Visual Studio", "compiler.version": visual_version, "arch": arch} @@ -294,7 +308,7 @@ def get_visual_builds_for_version(visual_runtimes, visual_version, arch, shared_ partial_settings = {"build_type": bld, "compiler.runtime": rt} if cppstd: partial_settings["compiler.cppstd"] = cppstd - if shared_option_name: + if shared_option_name and not build_all_options_values: opt = copy.copy(options) opt[shared_option_name] = False sets.append((partial_settings, opt, {}, {})) @@ -309,6 +323,15 @@ def get_visual_builds_for_version(visual_runtimes, visual_version, arch, shared_ opt[shared_option_name] = True sets.append((partial_settings, opt, {}, {})) + elif build_all_options_values: + for option_values in build_all_options_values: + opt = copy.copy(options) + opt.update(option_values) + sets.append((partial_settings, opt, {}, {})) + if shared_option_name and rt in ['MT', 'MTd'] and dll_with_static_runtime: + new_opt = copy.copy(opt) + new_opt[shared_option_name] = True + sets.append((partial_settings, opt, {}, {})) else: sets.append((partial_settings, options, {}, {})) @@ -336,13 +359,14 @@ def get_build(compiler, the_arch, the_build_type, the_compiler_version, def get_osx_apple_clang_builds(apple_clang_versions, archs, shared_option_name, - pure_c, build_types, cppstds, options, reference=None): + pure_c, build_types, cppstds, options, reference=None, + build_all_options_values=None): ret = [] # Not specified compiler or compiler version, will use the auto detected for compiler_version in apple_clang_versions: for arch in archs: for cppstd in cppstds: - if shared_option_name: + if shared_option_name and not build_all_options_values: for shared in [True, False]: opt = copy.copy(options) opt[shared_option_name] = shared @@ -355,6 +379,19 @@ def get_osx_apple_clang_builds(apple_clang_versions, archs, shared_option_name, ret.append(get_build("apple-clang", arch, build_type_it, compiler_version, None, None, opt, reference)) + elif build_all_options_values: + for option_values in build_all_options_values: + opt = copy.copy(options) + opt.update(option_values) + for build_type_it in build_types: + if not pure_c: + ret.append(get_build("apple-clang", arch, build_type_it, + compiler_version, cppstd, + "libc++", opt, reference)) + else: + ret.append(get_build("apple-clang", arch, build_type_it, + compiler_version, None, + None, opt, reference)) else: for build_type_it in build_types: if not pure_c: @@ -370,13 +407,13 @@ def get_osx_apple_clang_builds(apple_clang_versions, archs, shared_option_name, def get_linux_gcc_builds(gcc_versions, archs, shared_option_name, pure_c, build_types, cppstds, - options, reference=None): + options, reference=None, build_all_options_values=None): ret = [] # Not specified compiler or compiler version, will use the auto detected for gcc_version in gcc_versions: for arch in archs: for cppstd in cppstds: - if shared_option_name: + if shared_option_name and not build_all_options_values: for shared in [True, False]: opt = copy.copy(options) opt[shared_option_name] = shared @@ -390,6 +427,21 @@ def get_linux_gcc_builds(gcc_versions, archs, shared_option_name, pure_c, build_ else: ret.append(get_build("gcc", arch, build_type_it, gcc_version, None, None, opt, reference)) + elif build_all_options_values: + for option_values in build_all_options_values: + opt = copy.copy(options) + opt.update(option_values) + for build_type_it in build_types: + if not pure_c: + ret.append(get_build("gcc", arch, build_type_it, gcc_version, + cppstd, "libstdc++", opt, reference)) + if float(gcc_version) >= 5: + ret.append(get_build("gcc", arch, build_type_it, gcc_version, + cppstd, "libstdc++11", opt, reference)) + else: + ret.append(get_build("gcc", arch, build_type_it, gcc_version, + None, None, opt, reference)) + else: for build_type_it in build_types: if not pure_c: @@ -405,13 +457,13 @@ def get_linux_gcc_builds(gcc_versions, archs, shared_option_name, pure_c, build_ def get_linux_clang_builds(clang_versions, archs, shared_option_name, pure_c, build_types, cppstds, - options, reference=None): + options, reference=None, build_all_options_values=None): ret = [] # Not specified compiler or compiler version, will use the auto detected for clang_version in clang_versions: for arch in archs: for cppstd in cppstds: - if shared_option_name: + if shared_option_name and not build_all_options_values: for shared in [True, False]: opt = copy.copy(options) opt[shared_option_name] = shared @@ -424,6 +476,19 @@ def get_linux_clang_builds(clang_versions, archs, shared_option_name, pure_c, bu else: ret.append(get_build("clang", arch, build_type_it, clang_version, None, None, opt, reference)) + elif build_all_options_values: + for option_values in build_all_options_values: + opt = copy.copy(options) + opt.update(option_values) + for build_type_it in build_types: + if not pure_c: + ret.append(get_build("clang", arch, build_type_it, clang_version, + cppstd, "libstdc++", opt, reference)) + ret.append(get_build("clang", arch, build_type_it, clang_version, + cppstd, "libc++", opt, reference)) + else: + ret.append(get_build("clang", arch, build_type_it, clang_version, + None, None, opt, reference)) else: for build_type_it in build_types: if not pure_c: diff --git a/cpt/ci_manager.py b/cpt/ci_manager.py index aa4e6f5e..2862eae9 100644 --- a/cpt/ci_manager.py +++ b/cpt/ci_manager.py @@ -35,6 +35,10 @@ def is_shippable(): return os.getenv("SHIPPABLE", False) +def is_github_actions(): + return os.getenv("GITHUB_ACTIONS", False) + + class CIManager(object): def __init__(self, printer): @@ -56,6 +60,8 @@ def __init__(self, printer): self.manager = AzurePipelinesManager(printer) elif is_shippable(): self.manager = ShippableManager(printer) + elif is_github_actions(): + self.manager = GitHubActionsManager(printer) else: self.manager = GenericManager(printer) @@ -281,6 +287,32 @@ def is_pull_request(self): return os.getenv("BUILD_REASON", "false") == "PullRequest" +class GitHubActionsManager(GenericManager): + def __init__(self, printer): + super(GitHubActionsManager, self).__init__(printer) + self.printer.print_message("CI detected: GitHub Actions") + + def get_commit_msg(self): + try: + msg = subprocess.check_output("git log -1 --format=%s%n%b {}".format(self.get_commit_id()), + shell=True).decode().strip() + return msg + except Exception: + return None + + def get_commit_id(self): + return os.getenv("GITHUB_SHA", None) + + def get_branch(self): + branch = os.getenv("GITHUB_REF", None) + if self.is_pull_request(): + branch = os.getenv("GITHUB_BASE_REF", "") + return branch + + def is_pull_request(self): + return os.getenv("GITHUB_EVENT_NAME", "") == "pull_request" + + class ShippableManager(GenericManager): def __init__(self, printer): diff --git a/cpt/packager.py b/cpt/packager.py index e45ae7ad..c9a08309 100644 --- a/cpt/packager.py +++ b/cpt/packager.py @@ -2,7 +2,9 @@ import platform import re import sys +import copy from collections import defaultdict +from itertools import product import six from conans import tools @@ -139,7 +141,8 @@ def __init__(self, username=None, channel=None, runner=None, upload_dependencies=None, force_selinux=None, skip_recipe_export=False, - update_dependencies=None): + update_dependencies=None, + lockfile=None): conan_version = get_client_version() @@ -262,6 +265,7 @@ def __init__(self, username=None, channel=None, runner=None, pip_found = True if tools.os_info.is_windows else tools.which(self.pip_command) if not pip_found or not "pip" in self.pip_command: raise Exception("CONAN_PIP_COMMAND: '{}' is not a valid pip command.".format(self.pip_command)) + self.docker_pip_command = os.getenv("CONAN_DOCKER_PIP_COMMAND", "pip") self.docker_shell = docker_shell or os.getenv("CONAN_DOCKER_SHELL") @@ -335,6 +339,8 @@ def __init__(self, username=None, channel=None, runner=None, get_bool_from_env("CONAN_SKIP_RECIPE_EXPORT") self.config_args = config_args or os.getenv("CONAN_CONFIG_ARGS") + self.lockfile = lockfile or os.getenv("CONAN_LOCKFILE") + def valid_pair(var, value): return (isinstance(value, six.string_types) or isinstance(value, bool) or @@ -452,7 +458,8 @@ def login(self, remote_name): self.auth_manager.login(remote_name) def add_common_builds(self, shared_option_name=None, pure_c=True, - dll_with_static_runtime=False, reference=None): + dll_with_static_runtime=False, reference=None, header_only=True, + build_all_options_values=None): if reference: if "@" in reference: reference = ConanFileReference.loads(reference) @@ -469,14 +476,63 @@ def add_common_builds(self, shared_option_name=None, pure_c=True, env_shared_option_name = os.getenv("CONAN_SHARED_OPTION_NAME", None) shared_option_name = env_shared_option_name if str(env_shared_option_name).lower() != "false" else False + build_all_options_values = build_all_options_values or split_colon_env("CONAN_BUILD_ALL_OPTIONS_VALUES") or [] + if not isinstance(build_all_options_values, list): + raise Exception("'build_all_options_values' must be a list. e.g. ['foo:opt', 'foo:bar']") + + conanfile = None + if os.path.exists(os.path.join(self.cwd, self.conanfile)): + conanfile = load_cf_class(os.path.join(self.cwd, self.conanfile), self.conan_api) + + header_only_option = None + if conanfile: + if hasattr(conanfile, "options") and conanfile.options and "header_only" in conanfile.options: + header_only_option = "%s:header_only" % reference.name + if shared_option_name is None: - if os.path.exists(os.path.join(self.cwd, self.conanfile)): - conanfile = load_cf_class(os.path.join(self.cwd, self.conanfile), self.conan_api) + if conanfile: if hasattr(conanfile, "options") and conanfile.options and "shared" in conanfile.options: shared_option_name = "%s:shared" % reference.name - tmp = self.build_generator.get_builds(pure_c, shared_option_name, dll_with_static_runtime, reference) - self._builds.extend(tmp) + # filter only valid options + raw_options_for_building = [opt[opt.find(":") + 1:] for opt in build_all_options_values] + for raw_option in reversed(raw_options_for_building): + if hasattr(conanfile, "options") and conanfile.options and \ + not isinstance(conanfile.options.get(raw_option), list): + raw_options_for_building.remove(raw_option) + if raw_options_for_building and conanfile: + # get option and its values + cloned_options = copy.copy(conanfile.options) + for key, value in conanfile.options.items(): + if key == "shared" and shared_option_name: + continue + elif key not in raw_options_for_building: + del cloned_options[key] + for key in cloned_options.keys(): + # add package reference to the option name + if not key.startswith("{}:".format(reference.name)): + cloned_options["{}:{}".format(reference.name, key)] = cloned_options.pop(key) + # combine all options x values (cartesian product) + build_all_options_values = [dict(zip(cloned_options, v)) for v in product(*cloned_options.values())] + + builds = self.build_generator.get_builds(pure_c, shared_option_name, + dll_with_static_runtime, reference, + build_all_options_values) + + if header_only_option and header_only: + if conanfile.default_options.get("header_only"): + cloned_builds = copy.deepcopy(builds) + for settings, options, env_vars, build_requires, reference in cloned_builds: + options.update({header_only_option: False}) + builds.extend(cloned_builds) + else: + settings, options, env_vars, build_requires, reference = builds[0] + cloned_options = copy.copy(options) + cloned_options.update({header_only_option: True}) + builds.append(BuildConf(copy.copy(settings), cloned_options, copy.copy(env_vars), + copy.copy(build_requires), reference)) + + self._builds.extend(builds) def add(self, settings=None, options=None, env_vars=None, build_requires=None, reference=None): settings = settings or {} @@ -628,6 +684,7 @@ def run_builds(self, curpage=None, total_pages=None, base_profile_name=None): config_args=self.config_args, upload_dependencies=self.upload_dependencies, conanfile=self.conanfile, + lockfile=self.lockfile, skip_recipe_export=skip_recipe_export, update_dependencies=self.update_dependencies) r.run() @@ -655,11 +712,13 @@ def run_builds(self, curpage=None, total_pages=None, base_profile_name=None): lcow_user_workaround=self.lcow_user_workaround, test_folder=self.test_folder, pip_install=self.pip_install, + docker_pip_command=self.docker_pip_command, config_url=self.config_url, config_args=self.config_args, printer=self.printer, upload_dependencies=self.upload_dependencies, conanfile=self.conanfile, + lockfile=self.lockfile, force_selinux=self.force_selinux, skip_recipe_export=skip_recipe_export, update_dependencies=self.update_dependencies) diff --git a/cpt/requirements.txt b/cpt/requirements.txt index e3d2b9cc..2f237179 100644 --- a/cpt/requirements.txt +++ b/cpt/requirements.txt @@ -1,3 +1,3 @@ -six>=1.10.0, <1.13.0 +six>=1.10.0, <1.15.0 conan>=1.7.0, <1.23.0 -tabulate==0.8.2 +tabulate>=0.8.0, <0.9.0 diff --git a/cpt/run_in_docker.py b/cpt/run_in_docker.py index 18c9b403..8db97878 100644 --- a/cpt/run_in_docker.py +++ b/cpt/run_in_docker.py @@ -33,9 +33,11 @@ def run(): abs_profile_path = save_profile_to_tmp(profile_text) base_profile_text = unscape_env(os.getenv("CPT_BASE_PROFILE")) config_url = unscape_env(os.getenv("CPT_CONFIG_URL")) + config_args = unscape_env(os.getenv("CPT_CONFIG_ARGS")) upload_dependencies = unscape_env(os.getenv("CPT_UPLOAD_DEPENDENCIES")) update_dependencies = unscape_env(os.getenv("CPT_UPDATE_DEPENDENCIES")) conanfile = unscape_env(os.getenv("CPT_CONANFILE")) + lockfile = unscape_env(os.getenv("CPT_LOCKFILE")) skip_recipe_export = unscape_env(os.getenv("CPT_SKIP_RECIPE_EXPORT")) if base_profile_text: base_profile_name = unscape_env(os.getenv("CPT_BASE_PROFILE_NAME")) @@ -46,10 +48,11 @@ def run(): runner = CreateRunner(abs_profile_path, reference, conan_api, uploader, build_policy=build_policy, printer=printer, upload=upload, upload_only_recipe=upload_only_recipe, - test_folder=test_folder, config_url=config_url, + test_folder=test_folder, config_url=config_url, config_args=config_args, upload_dependencies=upload_dependencies, conanfile=conanfile, skip_recipe_export=skip_recipe_export, - update_dependencies=update_dependencies) + update_dependencies=update_dependencies, + lockfile=lockfile) runner.run() diff --git a/cpt/runner.py b/cpt/runner.py index ee77fb4f..084f96c8 100644 --- a/cpt/runner.py +++ b/cpt/runner.py @@ -20,7 +20,7 @@ def __init__(self, profile_abs_path, reference, conan_api, uploader, cwd=None, printer=None, upload=False, upload_only_recipe=None, test_folder=None, config_url=None, config_args=None, upload_dependencies=None, conanfile=None, skip_recipe_export=False, - update_dependencies=False): + update_dependencies=False, lockfile=None): self.printer = printer or Printer() self._cwd = cwd or os.getcwd() @@ -37,6 +37,7 @@ def __init__(self, profile_abs_path, reference, conan_api, uploader, self._config_args = config_args self._upload_only_recipe = upload_only_recipe self._conanfile = conanfile + self._lockfile = lockfile self._upload_dependencies = upload_dependencies.split(",") if \ isinstance(upload_dependencies, str) else \ upload_dependencies @@ -124,7 +125,8 @@ def run(self): profile_names=[self._profile_abs_path], test_folder=self._test_folder, not_export=self.skip_recipe_export, - update=self._update_dependencies) + update=self._update_dependencies, + lockfile=self._lockfile) except exc_class as e: self.printer.print_rule() self.printer.print_message("Skipped configuration by the recipe: " @@ -168,6 +170,7 @@ def __init__(self, profile_text, base_profile_text, base_profile_name, reference lcow_user_workaround="", test_folder=None, pip_install=None, + docker_pip_command=None, config_url=None, config_args=None, printer=None, @@ -175,7 +178,8 @@ def __init__(self, profile_text, base_profile_text, base_profile_name, reference conanfile=None, force_selinux=None, skip_recipe_export=False, - update_dependencies=False): + update_dependencies=False, + lockfile=None): self.printer = printer or Printer() self._upload = upload @@ -201,10 +205,12 @@ def __init__(self, profile_text, base_profile_text, base_profile_name, reference self._runner = PrintRunner(runner, self.printer) self._test_folder = test_folder self._pip_install = pip_install + self._docker_pip_command = docker_pip_command self._config_url = config_url self._config_args = config_args self._upload_dependencies = upload_dependencies or [] self._conanfile = conanfile + self._lockfile = lockfile self._force_selinux = force_selinux self._skip_recipe_export = skip_recipe_export self._update_dependencies = update_dependencies @@ -213,18 +219,23 @@ def _pip_update_conan_command(self): commands = [] # Hack for testing when retrieving cpt from artifactory repo if "conan-package-tools" not in self._conan_pip_package: - commands.append("%s pip install conan_package_tools==%s " + commands.append("%s %s install conan_package_tools==%s " "--upgrade --no-cache" % (self._sudo_pip_command, + self._docker_pip_command, package_tools_version)) if self._conan_pip_package: - commands.append("%s pip install %s --no-cache" % (self._sudo_pip_command, + commands.append("%s %s install %s --no-cache" % (self._sudo_pip_command, + self._docker_pip_command, self._conan_pip_package)) else: - commands.append("%s pip install conan --upgrade --no-cache" % self._sudo_pip_command) + commands.append("%s %s install conan --upgrade --no-cache" % (self._sudo_pip_command, + self._docker_pip_command)) if self._pip_install: - commands.append("%s pip install %s --upgrade --no-cache" % (self._sudo_pip_command, " ".join(self._pip_install))) + commands.append("%s %s install %s --upgrade --no-cache" % (self._sudo_pip_command, + self._docker_pip_command, + " ".join(self._pip_install))) command = " && ".join(commands) return command @@ -330,6 +341,7 @@ def get_env_vars(self): ret["CPT_CONFIG_ARGS"] = escape_env(self._config_args) ret["CPT_UPLOAD_DEPENDENCIES"] = escape_env(self._upload_dependencies) ret["CPT_CONANFILE"] = escape_env(self._conanfile) + ret["CPT_LOCKFILE"] = escape_env(self._lockfile) ret["CPT_SKIP_RECIPE_EXPORT"] = self._skip_recipe_export ret["CPT_UPDATE_DEPENDENCIES"] = self._update_dependencies diff --git a/cpt/test/integration/basic_test.py b/cpt/test/integration/basic_test.py index babc1ccb..61bf6a87 100644 --- a/cpt/test/integration/basic_test.py +++ b/cpt/test/integration/basic_test.py @@ -283,3 +283,61 @@ def set_version(self): self.packager = ConanMultiPackager(out=self.output.write) self.packager.add_common_builds(pure_c=False) self.packager.run() + + def test_header_only_option_true(self): + header_only = self._test_header_only(False) + self.assertEqual(header_only, 1) + self.packager.run() + + def test_header_only_option_false(self): + header_only = self._test_header_only(True) + self.assertEqual(header_only, int(len(self.packager.builds) / 2)) + self.packager.run() + + def _test_header_only(self, default_value): + conanfile = """from conans import ConanFile +class Pkg(ConanFile): + name = "qux" + version = "0.1.0" + settings = "os" + options = {"header_only": [True, False], "shared": [True, False], "fPIC": [True, False]} + default_options = {"header_only": %s, "shared": False, "fPIC": True} + + def configure(self): + if self.options.header_only: + del self.options.shared + del self.options.fPIC + + def package_id(self): + if self.options.header_only: + self.info.header_only() +""" % default_value + tools.save(os.path.join(self.tmp_folder, "conanfile.py"), conanfile) + self.packager = ConanMultiPackager(out=self.output.write) + self.packager.add_common_builds(pure_c=False) + + header_only = 0 + for build in self.packager.builds: + _, options, _, _ = build + if options.get("qux:header_only") == (not default_value): + header_only += 1 + return header_only + + def test_build_all_option_values(self): + conanfile = """from conans import ConanFile +class Pkg(ConanFile): + name = "qux" + version = "0.1.0" + options = {"shared": [True, False], "fPIC": [True, False], + "header_only": [True, False], "foo": [True, False], + "bar": ["baz", "qux", "foobar"], "blah": "ANY"} + default_options = {"shared": False, "fPIC": True, "header_only": False, + "foo": False, "bar": "baz", "blah": 42} + + def configure(self): + self.output.info("hello all") +""" + tools.save(os.path.join(self.tmp_folder, "conanfile.py"), conanfile) + self.packager = ConanMultiPackager(out=self.output.write) + self.packager.add_common_builds(pure_c=False, build_all_options_values=["qux:foo", "qux:bar", "qux:blah"]) + self.packager.run() \ No newline at end of file diff --git a/cpt/test/integration/docker_test.py b/cpt/test/integration/docker_test.py index 86772bc0..b587088a 100644 --- a/cpt/test/integration/docker_test.py +++ b/cpt/test/integration/docker_test.py @@ -200,3 +200,37 @@ def test_docker_run_android(self): self.assertIn("compiler=clang", output) self.assertIn("arch=x86_64", output) self.assertIn("Cross-build from 'Linux:x86_64' to 'Android:x86_64'", output) + + @unittest.skipUnless(is_linux_and_have_docker(), "Requires Linux and Docker") + def test_docker_custom_pip_command(self): + conanfile = """from conans import ConanFile + import os + + class Pkg(ConanFile): + settings = "os", "compiler", "build_type", "arch" + requires = "zlib/1.2.11@conan/stable" + + def build(self): + pass + """ + self.save_conanfile(conanfile) + with tools.environment_append({"CONAN_DOCKER_ENTRY_SCRIPT": "pip install -U /tmp/cpt", + "CONAN_USERNAME": "bar", + "CONAN_DOCKER_IMAGE": "conanio/gcc8", + "CONAN_REFERENCE": "foo/0.0.1@bar/testing", + "CONAN_DOCKER_RUN_OPTIONS": "--network=host, --add-host=google.com:8.8.8.8 -v{}:/tmp/cpt".format( + self.root_project_folder), + "CONAN_DOCKER_IMAGE_SKIP_UPDATE": "TRUE", + "CONAN_FORCE_SELINUX": "TRUE", + "CONAN_DOCKER_SHELL": "/bin/bash -c", + "CONAN_DOCKER_PIP_COMMAND": "foobar" + }): + self.packager = ConanMultiPackager(gcc_versions=["8"], + archs=["x86_64"], + build_types=["Release"], + out=self.output.write) + self.packager.add({}) + with self.assertRaises(Exception) as raised: + self.packager.run() + self.assertIn("Error updating the image", str(raised.exception)) + self.assertIn("foobar install conan_package_tools", str(raised.exception)) diff --git a/cpt/test/unit/ci_manager_test.py b/cpt/test/unit/ci_manager_test.py index d95d3f0e..974299ad 100644 --- a/cpt/test/unit/ci_manager_test.py +++ b/cpt/test/unit/ci_manager_test.py @@ -195,6 +195,28 @@ def test_shippable_instance(self): self.assertEquals(manager.is_pull_request(), True) self.assertEquals(manager.is_tag(), True) + def test_github_actions_instance(self): + gha_env = {"GITHUB_ACTIONS": "true", + "GITHUB_SHA": "98e984eacf4e3dfea431c8850c8c181a08e8cf3d", + "GITHUB_REF": "testing/5.6.5", + "GITHUB_BASE_REF": "testing/5.6.5", + "GITHUB_EVENT_NAME": "push"} + with tools.environment_append(gha_env): + manager = CIManager(self.printer) + self.assertEquals(manager.get_branch(), gha_env["GITHUB_REF"]) + self.assertEquals(manager.get_commit_id(), gha_env["GITHUB_SHA"]) + self.assertEquals(manager.is_pull_request(), False) + + gha_env = {"GITHUB_ACTIONS": "true", + "GITHUB_SHA": "98e984eacf4e3dfea431c8850c8c181a08e8cf3d", + "GITHUB_REF": "quick_fix", + "GITHUB_BASE_REF": "testing/5.6.5", + "GITHUB_EVENT_NAME": "pull_request"} + with tools.environment_append(gha_env): + manager = CIManager(self.printer) + self.assertEquals(manager.get_branch(), gha_env["GITHUB_BASE_REF"]) + self.assertEquals(manager.get_commit_id(), gha_env["GITHUB_SHA"]) + self.assertEquals(manager.is_pull_request(), True) def test_build_policy(self): # Travis diff --git a/cpt/test/unit/generators_test.py b/cpt/test/unit/generators_test.py index cc81289e..eeb3403f 100644 --- a/cpt/test/unit/generators_test.py +++ b/cpt/test/unit/generators_test.py @@ -25,8 +25,7 @@ def test_mingw_generator(self): {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), ({'compiler.version': '4.9', 'compiler': 'gcc', 'compiler.libcxx': "libstdc++", 'build_type': 'Debug', 'compiler.exception': 'dwarf2', 'compiler.threads': 'posix', - 'arch': 'x86'}, - {'pack:shared': True}, + 'arch': 'x86'}, {'pack:shared': True}, {}, {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), @@ -136,6 +135,119 @@ def test_mingw_generator(self): self.assertEquals([tuple(a) for a in builds], expected) + mingw_configurations = [("4.9", "x86", "dwarf2", "posix")] + ref = ConanFileReference.loads("lib/1.0@conan/stable") + builds = get_mingw_builds(mingw_configurations, + ConanFileReference.loads("mingw_installer/1.0@conan/stable"), + ["x86"], "pack:shared", ["Release", "Debug"], [None], options={}, + reference=ref, + build_all_options_values=[ + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}]) + expected = [({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Release', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Release', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Release', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Release', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Release', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Release', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Release', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Release', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref), + + ({'arch': 'x86', 'compiler': 'gcc', 'compiler.version': '4.9', + 'compiler.threads': 'posix', 'compiler.exception': 'dwarf2', + 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, + {'*': [ConanFileReference.loads("mingw_installer/1.0@conan/stable")]}, ref)] + + self.assertEquals([tuple(a) for a in builds], expected) + def test_get_osx_apple_clang_builds(self): ref = ConanFileReference.loads("lib/1.0@conan/stable") builds = get_osx_apple_clang_builds(["8.0"], ["x86_64"], "pack:shared", pure_c=False, build_types=["Debug", "Release"], @@ -216,6 +328,72 @@ def test_get_osx_apple_clang_builds(self): {"qux:foobar": False, "foo:pkg": "bar"}, {}, {}, ref)] self.assertEquals([tuple(a) for a in builds], expected) + ref = ConanFileReference.loads("lib/1.0@conan/stable") + builds = get_osx_apple_clang_builds(["8.0"], ["x86_64"], "pack:shared", pure_c=False, + build_types=["Debug", "Release"], + cppstds=[None], + options={}, + reference=ref, + build_all_options_values=[ + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}]) + expected = [({'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Debug', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), ( + {'arch': 'x86_64', 'build_type': 'Release', 'compiler': 'apple-clang', + 'compiler.version': '8.0', 'compiler.libcxx': 'libc++'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref)] + + self.assertEquals([tuple(a) for a in builds], expected) + def test_get_linux_gcc_builds(self): builds = get_linux_gcc_builds(["6"], ["x86_64"], "pack:shared", pure_c=False, build_types=["Debug", "Release"], cppstds=[None], options={}) expected = [({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', 'compiler.version': '6', 'arch': 'x86_64'}, @@ -327,6 +505,121 @@ def test_get_linux_gcc_builds(self): {"qux:bar": "foo", "*:pkg": False}, {}, {}, None)] self.assertEquals([tuple(a) for a in builds], expected) + builds = get_linux_gcc_builds(["9"], ["x86_64"], "pack:shared", pure_c=False, + build_types=["Debug", "Release"], cppstds=[None], options={}, + build_all_options_values=[{"pack:shared": True, "pack:foo": True, "pack:bar": True}, + {"pack:shared": True, "pack:foo": False, "pack:bar": True}, + {"pack:shared": True, "pack:foo": True, "pack:bar": False}, + {"pack:shared": True, "pack:foo": False, "pack:bar": False}, + {"pack:shared": False, "pack:foo": True, "pack:bar": True}, + {"pack:shared": False, "pack:foo": False, "pack:bar": True}, + {"pack:shared": False, "pack:foo": True, "pack:bar": False}, + {"pack:shared": False, "pack:foo": False, "pack:bar": False}]) + expected = [({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, None), + + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, None), + + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, None), + + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, None), + + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, None), + + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, None), + + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, None), + + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, None), + ({'compiler': 'gcc', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++11', + 'compiler.version': '9', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, None)] + self.assertEquals([tuple(a) for a in builds], expected) + def test_get_linux_clang_builds(self): self.maxDiff = None ref = ConanFileReference.loads("lib/2.3@conan/stable") @@ -447,6 +740,126 @@ def test_get_linux_clang_builds(self): {"foo:bar": "qux", "pkg:shared": True}, {}, {}, ref)] self.assertEquals([tuple(a) for a in builds], expected) + builds = get_linux_clang_builds(["6.0"], ["x86_64"], "pack:shared", pure_c=False, + build_types=["Debug", "Release"], cppstds=[None], + options={}, reference=ref, + build_all_options_values=[ + {"pack:shared": True, "pack:foo": True, "pack:bar": True}, + {"pack:shared": True, "pack:foo": False, "pack:bar": True}, + {"pack:shared": True, "pack:foo": True, "pack:bar": False}, + {"pack:shared": True, "pack:foo": False, "pack:bar": False}, + {"pack:shared": False, "pack:foo": True, "pack:bar": True}, + {"pack:shared": False, "pack:foo": False, "pack:bar": True}, + {"pack:shared": False, "pack:foo": True, "pack:bar": False}, + {"pack:shared": False, "pack:foo": False, "pack:bar": False} + ]) + expected = [({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), + + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), + + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), + + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), + + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), + + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), + + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), + + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Debug', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libstdc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), + ({'compiler': 'clang', 'build_type': 'Release', 'compiler.libcxx': 'libc++', + 'compiler.version': '6.0', 'arch': 'x86_64'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref)] + + b = [tuple(a) for a in builds] + self.assertEquals(b, expected) + def test_visual_build_generator(self): ref = ConanFileReference.loads("lib/1.0@conan/stable") builds = get_visual_builds(visual_versions=["10", "14"], @@ -998,3 +1411,124 @@ def test_visual_toolsets(self): {}, {}, {}, None)] self.assertEquals([tuple(a) for a in builds], expected) + + ref = ConanFileReference.loads("lib/1.0@conan/stable") + builds = get_visual_builds(visual_versions=["10", "14"], + archs=["x86"], visual_runtimes=["MDd", "MTd"], + visual_toolsets=None, + shared_option_name=None, + dll_with_static_runtime=False, + vs10_x86_64_enabled=True, + build_types=["Debug", "Release", "RelWithDebInfo", "MinSizeRel"], + cppstds=[None], + options={}, + reference=ref, + build_all_options_values=[ + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}] + ) + + expected = [({'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '10', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MDd'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': True, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': True, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': True}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': False, 'pack:foo': True, 'pack:bar': False}, {}, {}, ref), ( + {'compiler': 'Visual Studio', 'compiler.version': '14', 'arch': 'x86', + 'build_type': 'Debug', 'compiler.runtime': 'MTd'}, + {'pack:shared': False, 'pack:foo': False, 'pack:bar': False}, {}, {}, ref)] + + self.assertEquals([tuple(a) for a in builds], expected) \ No newline at end of file diff --git a/cpt/test/unit/packager_test.py b/cpt/test/unit/packager_test.py index 4c16b640..fca0b145 100644 --- a/cpt/test/unit/packager_test.py +++ b/cpt/test/unit/packager_test.py @@ -557,7 +557,7 @@ def test_multiple_references(self): for _, _, _, _, reference in builder.items: self.assertTrue(str(reference) in ("lib/1.0@lasote/mychannel", "lib/2.0@lasote/mychannel")) - def select_defaults_test(self): + def test_select_defaults_test(self): with tools.environment_append({"CONAN_REFERENCE": "zlib/1.2.8"}): builder = ConanMultiPackager(platform_info=platform_mock_for("Linux"), gcc_versions=["4.8", "5"], @@ -1031,3 +1031,34 @@ def _check_run_calls(skip_recipe_export): packager.add_common_builds() packager.run() _check_run_calls(True) + + def test_lockfile(self): + builder = ConanMultiPackager(username="pepe", channel="testing", + reference="Hello/0.1", password="password", + visual_versions=[], gcc_versions=[], + apple_clang_versions=[], + runner=self.runner, + conan_api=self.conan_api, + remotes="otherurl", + platform_info=platform_mock_for("Darwin"), + lockfile="foobar.lock", + ci_manager=self.ci_manager) + builder.add_common_builds() + builder.run() + self.assertEquals("foobar.lock", self.conan_api.calls[-1].kwargs["lockfile"]) + + with tools.environment_append({"CONAN_LOCKFILE": "couse.lock"}): + self.conan_api = MockConanAPI() + builder = ConanMultiPackager(username="pepe", channel="testing", + reference="Hello/0.1", password="password", + visual_versions=[], gcc_versions=[], + apple_clang_versions=[], + runner=self.runner, + conan_api=self.conan_api, + remotes="otherurl", + platform_info=platform_mock_for("Darwin"), + build_policy=None, + ci_manager=self.ci_manager) + builder.add_common_builds() + builder.run() + self.assertEquals("couse.lock", self.conan_api.calls[-1].kwargs["lockfile"]) diff --git a/cpt/tools.py b/cpt/tools.py index 67d68daf..149f706c 100644 --- a/cpt/tools.py +++ b/cpt/tools.py @@ -1,9 +1,7 @@ import os -import subprocess def get_bool_from_env(var_name): - import os val = os.getenv(var_name, None) return str(val).lower() not in ("0", "none", "false")