conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.26k stars 980 forks source link

Conan doesn't seem to recognize settings' value 'None' #3930

Closed HerbertKoelman closed 6 years ago

HerbertKoelman commented 6 years ago

I've taylored my settings.yml file (see attached file). As one can see I've added a SDK notion and for OS Linux I mean to say that there is no known version (hence the None ).

With my settings I expected this to run just fine :

$ conan create .. rcs/testing -s os.sdk=None -s os=Linux
ERROR: Invalid setting 'None' is not a valid 'settings.os.sdk' value.
Possible values are ['N', 'e', 'n', 'o']
Read "http://docs.conan.io/en/latest/faq/troubleshooting.html#error-invalid-setting"

Obviously I was wrong.

I've searched the documentation, but failed to find some explanation on what's going on here.

Anyone ?


Settings.yml:

os: &os
  # Generic Linux
  Linux:
    sdk: None
  # Generic Windows
  Windows:
    sdk: None
  # bv_arm-cortex-a5_angstrom platform (Validators)
  Angstrom: # mainly validators
    sdk: ["2.2.4", "2.2.6", "2.2.7", "2.2.8"]
  # emm-bt_x86-atom-e3826_poky platform (Gates)
  Poky:
    sdk: ["1.8"]
  # sk_arm-xscale-pxa300_youtos (PVUs ; YouTransactor devices)
  Youtos: # OS for YouTransactor devices
    sdk: ["x.y"]

arch: &arch
  # bv_arm-cortex-a5_angstrom platform
  - armv7a
  # sk_arm-xscale-pxa300_youtos platform
  - armv5te
  # emm-bt_x86-atom-e3826_poky & pc_xxx platforms
  - x86
  - x86_64

# for cross building,
# - 'os_build/arch_build' for the system that runs build tools & Conan
# - 'os_target/arch_target' for the target system for which the tools generate code

os_target:
  *os

arch_target:
  *arch

os_build:
  - Linux
  - Windows

arch_build:
  - x86_64

compiler:
  gcc:
    version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9",
              "5", "5.1", "5.2", "5.3", "5.4", "5.5",
              "6", "6.1", "6.2", "6.3", "6.4",
              "7", "7.1", "7.2", "7.3",
              "8", "8.1"]
    libcxx: [libstdc++, libstdc++11]
  Visual Studio:
    runtime: [MD, MT, MTd, MDd]
    version: ["8", "9", "10", "11", "12", "14", "15"]
    toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp,
              v140, v140_xp, v140_clang_c2, LLVM-vs2012, LLVM-vs2012_xp,
              LLVM-vs2013, LLVM-vs2013_xp, LLVM-vs2014, LLVM-vs2014_xp,
              LLVM-vs2017, LLVM-vs2017_xp, v141, v141_xp, v141_clang_c2]
    libcxx: [libstdc++, libstdc++11, libc++]

cppstd: [None, 98, 11, 14, 17, 20]

build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel]

conanfile.py

from conans import ConanFile, CMake, tools

class CpppthreadConan(ConanFile):
    name = "cpp-pthread"
    default_user = "rcs"
    version = "1.8.0"
    license = "GPL 2018"
    author = "Herbert Koelman herbert.koelman@me.com"
    url = "https://github.com/HerbertKoelman/cpp-pthread/issues"
    description = "C++ wrapper of the pthread library"
    topics = ("c++", "CXX", "pthread")
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False]}
    default_options = "shared=False"
    generators = ("cmake_find_package","cmake_paths")
    exports_sources = ("*")

#    def source(self):
#        self.run("git clone https://github.com/memsharded/cpp-pthread.git")
#        self.run("cd cpp-pthread && git checkout static_shared")
#        # This small hack might be useful to guarantee proper /MT /MD linkage
#        # in MSVC if the packaged project doesn't have variables to set it
#        # properly
#        tools.replace_in_file("cpp-pthread/CMakeLists.txt", "# @CONAN@", '''include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)\nconan_basic_setup()''')

    def build(self):
        cmake = CMake(self)
        #cmake.configure(source_folder="src")
        cmake.configure()
        cmake.build()

        # Explicit way:
        # self.run('cmake %s/cpp-pthread %s'
        #          % (self.source_folder, cmake.command_line))
        # self.run("cmake --build . %s" % cmake.build_config)

    def package(self):
        self.copy("*.h", dst="include/pthread")
        self.copy("*.hpp", dst="include/pthread")
        self.copy("*cpp-pthread.lib", dst="lib", keep_path=False)
        self.copy("*.dll", dst="bin", keep_path=False)
        self.copy("*.so", dst="lib", keep_path=False)
        self.copy("*.dylib", dst="lib", keep_path=False)
        self.copy("*.a", dst="lib", keep_path=False)

    def package_info(self):
        self.cpp_info.libs = ["cpp-pthread"]

Full display:

Exporting package recipe
Linter warnings
    WARN: Linter. Line 1: Unused tools imported from conans
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 28 files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 1 '.sty' file: doxygen.sty
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 9 '.internal' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 4 '.marks' files: progress.marks, progress.marks, progress.marks, progress.marks
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 2 '.h' files: config.h, config.h
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 296 '.html' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 9 '.includecache' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 35 '.map' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 4 '.c' files: feature_tests.c, CMakeCCompilerId.c, feature_tests.c, CMakeCCompilerId.c
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 2 '.gz' files: cpp-pthread-1.7.3-Linux.tar.gz, cpp-pthread-1.7.3-Linux.tar.gz
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 41 '.tex' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 3 '.ac' files: configure.ac, configure.ac, configure.ac
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 32 '.hpp' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 6 '.bin' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 2 '.doxygen-tests' files: Doxyfile.doxygen-tests, Doxyfile.doxygen-tests
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 1 '.md' file: README.md
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 13 '.cpp' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 44 '.make' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 99 '.png' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 23 '.txt' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 1 '.iml' file: cpp-pthread.iml
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 2 '.sh' files: cpp-pthread-1.7.3-Linux.sh, cpp-pthread-1.7.3-Linux.sh
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 3 '.status' files: config.status, config.status, config.status
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 2 '.Z' files: cpp-pthread-1.7.3-Linux.tar.Z, cpp-pthread-1.7.3-Linux.tar.Z
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 1 '.guess' file: config.guess
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 5 '.out' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 136 '.js' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 13 '.eps' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 2 '.swp' files: .CMakeLists.txt.swp, .conanfile.py.swp
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 1 '.sub' file: config.sub
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 6 '.a' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 6 '.css' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 1 '.py' file: conanfile.py
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 55 '.cmake' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 2 '.doxygen' files: Doxyfile.doxygen, Doxyfile.doxygen
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 1 '.properties' file: sonar-project.properties
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 8 '.in' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 2 '.0' files: output.0, traces.0
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 7 '.xml' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 2 '.check_cache' files: cmake.check_cache, cmake.check_cache
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 5 '.so' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 40 '.o' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 8 '.log' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 36 '.md5' files:
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 3 '.cbp' files: Project.cbp, cpp-pthread.cbp, cpp-pthread-tests.cbp
cpp-pthread/1.8.0@rcs/testing exports_sources: Copied 2 '.cxx' files: feature_tests.cxx, feature_tests.cxx
cpp-pthread/1.8.0@rcs/testing: The stored package has not changed
Configuration:
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=5
compiler.libcxx=libstdc++
build_type=Release
os.sdk=None
[options]
[build_requires]
[env]

ERROR: Invalid setting 'None' is not a valid 'settings.os.sdk' value.
Possible values are ['N', 'e', 'n', 'o']
Read "http://docs.conan.io/en/latest/faq/troubleshooting.html#error-invalid-setting"
lasote commented 6 years ago

Hi, declaring a setting None in the settings.yml, like (Windows: sdk: None) file means "You allow the setting to be undefined". So pass -s os.sdk="None" makes no sense. Just avoid passing the setting and it will be None.

HerbertKoelman commented 6 years ago

That's what I thought too, but this command returns:

$ conan create .. rcs/testing -s os=Linux
ERROR: cpp-pthread/1.8.0@rcs/testing: 'settings.os.sdk' value not defined

Any idea ?

HerbertKoelman commented 6 years ago

Full output:

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=5
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]
ERROR: cpp-pthread/1.8.0@rcs/testing: 'settings.os.sdk' value not defined
lasote commented 6 years ago

Now, I know what is happening. If you want to allow None value you have to declare it as a list:

os: 
  Linux:
    sdk: [None]

But, you have to declare which values are also valid in that list. If you want to allow any value, use ANY:

os: 
  Linux:
    sdk: ANY

But then the "None" value is not allowed. In other words, you can only allow None if there is a known list of elements, something like sdk: [None, ANY] is not working. Is this what are you looking for?

HerbertKoelman commented 6 years ago

Thank you very much for your quick help.

Indeed, None needs to be a list member.

I fixed my settings.yml file and everything is fine.

Regards