From 373ab0c0b18e3e6f1ec870ac3ab6dde9013ba9b2 Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 11 Sep 2023 12:22:27 +0200 Subject: [PATCH 01/13] add sconsdeps --- conan/tools/scons/__init__.py | 1 + conan/tools/scons/sconsdeps.py | 61 +++++++++++++++++++ conans/client/generators/__init__.py | 5 +- .../toolchains/scons/test_sconsdeps.py | 8 +++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 conan/tools/scons/__init__.py create mode 100644 conan/tools/scons/sconsdeps.py create mode 100644 conans/test/functional/toolchains/scons/test_sconsdeps.py diff --git a/conan/tools/scons/__init__.py b/conan/tools/scons/__init__.py new file mode 100644 index 00000000000..b8aed953fba --- /dev/null +++ b/conan/tools/scons/__init__.py @@ -0,0 +1 @@ +from conan.tools.scons.sconsdeps import SconsDeps diff --git a/conan/tools/scons/sconsdeps.py b/conan/tools/scons/sconsdeps.py new file mode 100644 index 00000000000..73a57f6ee7b --- /dev/null +++ b/conan/tools/scons/sconsdeps.py @@ -0,0 +1,61 @@ +from jinja2 import Template + +from conan.tools._check_build_profile import check_using_build_profile +from conans.model.new_build_info import NewCppInfo +from conans.util.files import save + + +class SconsDeps: + def __init__(self, conanfile): + self._conanfile = conanfile + self._ordered_deps = [] + self._generator_file = 'SConscript_conan' + check_using_build_profile(self._conanfile) + + @property + def ordered_deps(self): + if not self._ordered_deps: + deps = self._conanfile.dependencies.host.topological_sort + self._ordered_deps = [dep for dep in reversed(deps.values())] + return self._ordered_deps + + def _get_cpp_info(self): + ret = NewCppInfo() + for dep in self.ordered_deps: + dep_cppinfo = dep.cpp_info.aggregated_components() + ret.merge(dep_cppinfo) + return ret + + def generate(self): + save(self._generator_file, self._content) + + @property + def _content(self): + template = Template(""" + "{{dep}}" : { + "CPPPATH" : {{info.includedirs}}, + "LIBPATH" : {{info.libdirs}}, + "BINPATH" : {{info.bindirs}}, + "LIBS" : {{info.libs + info.system_libs}}, + "FRAMEWORKS" : {{info.frameworks}}, + "FRAMEWORKPATH" : {{info.frameworkdirs}}, + "CPPDEFINES" : {{info.defines}}, + "CXXFLAGS" : {{info.cxxflags}}, + "CCFLAGS" : {{info.cflags}}, + "SHLINKFLAGS" : {{info.sharedlinkflags}}, + "LINKFLAGS" : {{info.exelinkflags}}, + }, + "{{dep}}_version" : "{{info.version}}", + """) + sections = ["conan = {\n"] + all_flags = template.render(dep="conan", info=self._get_cpp_info()) + sections.append(all_flags) + host_req = self._conanfile.dependencies.host + test_req = self._conanfile.dependencies.test + all_deps = list(host_req.values()) + list(test_req.values()) + for dep in all_deps: + dep_flags = template.render(dep=dep.ref.name, info=dep.cpp_info) + sections.append(dep_flags) + sections.append("}\n") + sections.append("Return('conan')\n") + return "\n".join(sections) diff --git a/conans/client/generators/__init__.py b/conans/client/generators/__init__.py index ebe9e720cbe..62491a7fb97 100644 --- a/conans/client/generators/__init__.py +++ b/conans/client/generators/__init__.py @@ -73,7 +73,7 @@ def __init__(self): "VirtualRunEnv", "VirtualBuildEnv", "AutotoolsDeps", "AutotoolsToolchain", "BazelDeps", "BazelToolchain", "PkgConfigDeps", "VCVars", "IntelCC", "XcodeDeps", "PremakeDeps", "XcodeToolchain", - "MesonDeps", "NMakeToolchain", "NMakeDeps"] + "MesonDeps", "NMakeToolchain", "NMakeDeps", "SconsDeps"] def add(self, name, generator_class, custom=False): if name not in self._generators or custom: @@ -156,6 +156,9 @@ def _new_generator(self, generator_name, output): elif generator_name == "NMakeDeps": from conan.tools.microsoft import NMakeDeps return NMakeDeps + elif generator_name == "SconsDeps": + from conan.tools.scons import SconsDeps + return SconsDeps else: raise ConanException("Internal Conan error: Generator '{}' " "not commplete".format(generator_name)) diff --git a/conans/test/functional/toolchains/scons/test_sconsdeps.py b/conans/test/functional/toolchains/scons/test_sconsdeps.py new file mode 100644 index 00000000000..f22e40a9205 --- /dev/null +++ b/conans/test/functional/toolchains/scons/test_sconsdeps.py @@ -0,0 +1,8 @@ +from conans.test.utils.tools import TestClient + + +def test_sconsdeps(): + client = TestClient(path_with_spaces=False) + client.run("new hello/0.1 --template=cmake_lib") + client.run("create . -tf=None") + client.run("install hello/0.1@ -g SconsDeps") From 1940413ecf6520aa9103358f486d1db52f15f525 Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 11 Sep 2023 12:26:32 +0200 Subject: [PATCH 02/13] wip --- conans/client/generators/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conans/client/generators/__init__.py b/conans/client/generators/__init__.py index 62491a7fb97..3c6f62b907d 100644 --- a/conans/client/generators/__init__.py +++ b/conans/client/generators/__init__.py @@ -73,7 +73,7 @@ def __init__(self): "VirtualRunEnv", "VirtualBuildEnv", "AutotoolsDeps", "AutotoolsToolchain", "BazelDeps", "BazelToolchain", "PkgConfigDeps", "VCVars", "IntelCC", "XcodeDeps", "PremakeDeps", "XcodeToolchain", - "MesonDeps", "NMakeToolchain", "NMakeDeps", "SconsDeps"] + "MesonDeps", "NMakeToolchain", "NMakeDeps", "SConsDeps"] def add(self, name, generator_class, custom=False): if name not in self._generators or custom: @@ -156,7 +156,7 @@ def _new_generator(self, generator_name, output): elif generator_name == "NMakeDeps": from conan.tools.microsoft import NMakeDeps return NMakeDeps - elif generator_name == "SconsDeps": + elif generator_name == "SConsDeps": from conan.tools.scons import SconsDeps return SconsDeps else: From 9a80885ca299343875aa5da5204e23c41744c94a Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 11 Sep 2023 13:05:20 +0200 Subject: [PATCH 03/13] wip --- conan/tools/scons/sconsdeps.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/conan/tools/scons/sconsdeps.py b/conan/tools/scons/sconsdeps.py index 73a57f6ee7b..986534a48f8 100644 --- a/conan/tools/scons/sconsdeps.py +++ b/conan/tools/scons/sconsdeps.py @@ -1,10 +1,8 @@ from jinja2 import Template - from conan.tools._check_build_profile import check_using_build_profile from conans.model.new_build_info import NewCppInfo from conans.util.files import save - class SconsDeps: def __init__(self, conanfile): self._conanfile = conanfile @@ -32,29 +30,29 @@ def generate(self): @property def _content(self): template = Template(""" - "{{dep}}" : { - "CPPPATH" : {{info.includedirs}}, - "LIBPATH" : {{info.libdirs}}, - "BINPATH" : {{info.bindirs}}, - "LIBS" : {{info.libs + info.system_libs}}, - "FRAMEWORKS" : {{info.frameworks}}, + "{{dep_name}}" : { + "CPPPATH" : {{info.includedirs}}, + "LIBPATH" : {{info.libdirs}}, + "BINPATH" : {{info.bindirs}}, + "LIBS" : {{info.libs + info.system_libs}}, + "FRAMEWORKS" : {{info.frameworks}}, "FRAMEWORKPATH" : {{info.frameworkdirs}}, - "CPPDEFINES" : {{info.defines}}, - "CXXFLAGS" : {{info.cxxflags}}, - "CCFLAGS" : {{info.cflags}}, + "CPPDEFINES" : {{info.defines}}, + "CXXFLAGS" : {{info.cxxflags}}, + "CCFLAGS" : {{info.cflags}}, "SHLINKFLAGS" : {{info.sharedlinkflags}}, - "LINKFLAGS" : {{info.exelinkflags}}, + "LINKFLAGS" : {{info.exelinkflags}}, }, - "{{dep}}_version" : "{{info.version}}", + {% if dep_version is not none %}"{{dep_name}}_version" : "{{dep_version}}",{% endif %} """) sections = ["conan = {\n"] - all_flags = template.render(dep="conan", info=self._get_cpp_info()) + all_flags = template.render(dep_name="conan-aggregated", dep_version=None, info=self._get_cpp_info()) sections.append(all_flags) host_req = self._conanfile.dependencies.host test_req = self._conanfile.dependencies.test all_deps = list(host_req.values()) + list(test_req.values()) for dep in all_deps: - dep_flags = template.render(dep=dep.ref.name, info=dep.cpp_info) + dep_flags = template.render(dep_name=dep.ref.name, dep_version=dep.ref.version, info=dep.cpp_info) sections.append(dep_flags) sections.append("}\n") sections.append("Return('conan')\n") From 73f9a5b6435d8a7f03a096bca0735b82156a5bdf Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 11 Sep 2023 13:32:43 +0200 Subject: [PATCH 04/13] wip --- conan/tools/scons/sconsdeps.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/conan/tools/scons/sconsdeps.py b/conan/tools/scons/sconsdeps.py index 986534a48f8..1c643f1ae98 100644 --- a/conan/tools/scons/sconsdeps.py +++ b/conan/tools/scons/sconsdeps.py @@ -46,12 +46,12 @@ def _content(self): {% if dep_version is not none %}"{{dep_name}}_version" : "{{dep_version}}",{% endif %} """) sections = ["conan = {\n"] - all_flags = template.render(dep_name="conan-aggregated", dep_version=None, info=self._get_cpp_info()) + all_flags = template.render(dep_name="conandeps", dep_version=None, info=self._get_cpp_info()) sections.append(all_flags) - host_req = self._conanfile.dependencies.host - test_req = self._conanfile.dependencies.test - all_deps = list(host_req.values()) + list(test_req.values()) - for dep in all_deps: + + # TODO: Add here in 2.0 the "skip": False trait + host_req = self._conanfile.dependencies.filter({"build": False}).values() + for dep in host_req: dep_flags = template.render(dep_name=dep.ref.name, dep_version=dep.ref.version, info=dep.cpp_info) sections.append(dep_flags) sections.append("}\n") From 6ad2b4220a0851c04c186932d4a54fc84241c1c8 Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 11 Sep 2023 16:58:58 +0200 Subject: [PATCH 05/13] integration test --- conan/tools/scons/sconsdeps.py | 9 +- conans/test/conftest.py | 3 + .../toolchains/scons/test_sconsdeps.py | 7 ++ .../integration/toolchains/scons/__init__.py | 0 .../toolchains/scons/test_scondeps.py | 98 +++++++++++++++++++ 5 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 conans/test/integration/toolchains/scons/__init__.py create mode 100644 conans/test/integration/toolchains/scons/test_scondeps.py diff --git a/conan/tools/scons/sconsdeps.py b/conan/tools/scons/sconsdeps.py index 1c643f1ae98..1c44a869216 100644 --- a/conan/tools/scons/sconsdeps.py +++ b/conan/tools/scons/sconsdeps.py @@ -3,11 +3,12 @@ from conans.model.new_build_info import NewCppInfo from conans.util.files import save + class SconsDeps: def __init__(self, conanfile): self._conanfile = conanfile self._ordered_deps = [] - self._generator_file = 'SConscript_conan' + self._generator_file = 'SConscript_conandeps' check_using_build_profile(self._conanfile) @property @@ -46,13 +47,15 @@ def _content(self): {% if dep_version is not none %}"{{dep_name}}_version" : "{{dep_version}}",{% endif %} """) sections = ["conan = {\n"] - all_flags = template.render(dep_name="conandeps", dep_version=None, info=self._get_cpp_info()) + all_flags = template.render(dep_name="conandeps", dep_version=None, + info=self._get_cpp_info()) sections.append(all_flags) # TODO: Add here in 2.0 the "skip": False trait host_req = self._conanfile.dependencies.filter({"build": False}).values() for dep in host_req: - dep_flags = template.render(dep_name=dep.ref.name, dep_version=dep.ref.version, info=dep.cpp_info) + dep_flags = template.render(dep_name=dep.ref.name, dep_version=dep.ref.version, + info=dep.cpp_info) sections.append(dep_flags) sections.append("}\n") sections.append("Return('conan')\n") diff --git a/conans/test/conftest.py b/conans/test/conftest.py index f41b99dbaa8..0e3ec7d91fb 100644 --- a/conans/test/conftest.py +++ b/conans/test/conftest.py @@ -156,6 +156,9 @@ "system": {"path": {'Windows': 'C:/bazel/bin', "Darwin": '/Users/jenkins/bin'}}, }, + 'scons': { + "default": "system" + }, 'premake': { "exe": "premake5", "default": "5.0.0", diff --git a/conans/test/functional/toolchains/scons/test_sconsdeps.py b/conans/test/functional/toolchains/scons/test_sconsdeps.py index f22e40a9205..b044b542d5a 100644 --- a/conans/test/functional/toolchains/scons/test_sconsdeps.py +++ b/conans/test/functional/toolchains/scons/test_sconsdeps.py @@ -1,6 +1,13 @@ +import platform + +import pytest + from conans.test.utils.tools import TestClient +@pytest.mark.skipif(platform.system() != "Linux", reason="SCons functional tests" + "only for Linux") +@pytest.mark.tool("scons") def test_sconsdeps(): client = TestClient(path_with_spaces=False) client.run("new hello/0.1 --template=cmake_lib") diff --git a/conans/test/integration/toolchains/scons/__init__.py b/conans/test/integration/toolchains/scons/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/conans/test/integration/toolchains/scons/test_scondeps.py b/conans/test/integration/toolchains/scons/test_scondeps.py new file mode 100644 index 00000000000..36af33ce0b9 --- /dev/null +++ b/conans/test/integration/toolchains/scons/test_scondeps.py @@ -0,0 +1,98 @@ +import re +import textwrap + +from conans.test.utils.tools import TestClient + + +def test_sconsdeps(): + dep = textwrap.dedent(""" + from conan import ConanFile + class ExampleConanIntegration(ConanFile): + name = "{dep}" + version = "0.1" + def package_info(self): + self.cpp_info.includedirs = ["{dep}_includedir"] + self.cpp_info.libdirs = ["{dep}_libdir"] + self.cpp_info.bindirs = ["{dep}_bindir"] + self.cpp_info.libs = ["{dep}_lib"] + self.cpp_info.frameworks = ["{dep}_frameworks"] + self.cpp_info.frameworkdirs = ["{dep}_frameworkdirs"] + self.cpp_info.defines = ["{dep}_defines"] + self.cpp_info.cxxflags = ["{dep}_cxxflags"] + self.cpp_info.cflags = ["{dep}_cflags"] + self.cpp_info.sharedlinkflags = ["{dep}_sharedlinkflags"] + self.cpp_info.exelinkflags = ["{dep}_exelinkflags"] + """) + + consumer = textwrap.dedent(""" + from conan import ConanFile + from conan.tools.layout import basic_layout + + class ExampleConanIntegration(ConanFile): + generators = 'SConsDeps' + requires = 'dep1/0.1', 'dep2/0.1' + """) + + c = TestClient() + c.save({"dep1/conanfile.py": dep.format(dep="dep1"), + "dep2/conanfile.py": dep.format(dep="dep2"), + "consumer/conanfile.py": consumer}) + c.run("create dep1") + c.run("create dep2") + c.run("install consumer") + sconsdeps = c.load("SConscript_conandeps") + + # remove all cache paths from the output but the last component + def clean_paths(text): + pattern = r"'/[^']+/([^'/]+)'" + return re.sub(pattern, r"'\1'", text) + + expected_content = [""" + "conandeps" : { + "CPPPATH" : ['dep2_includedir', 'dep1_includedir'], + "LIBPATH" : ['dep2_libdir', 'dep1_libdir'], + "BINPATH" : ['dep2_bindir', 'dep1_bindir'], + "LIBS" : ['dep2_lib', 'dep1_lib'], + "FRAMEWORKS" : ['dep2_frameworks', 'dep1_frameworks'], + "FRAMEWORKPATH" : ['dep2_frameworkdirs', 'dep1_frameworkdirs'], + "CPPDEFINES" : ['dep2_defines', 'dep1_defines'], + "CXXFLAGS" : ['dep2_cxxflags', 'dep1_cxxflags'], + "CCFLAGS" : ['dep2_cflags', 'dep1_cflags'], + "SHLINKFLAGS" : ['dep2_sharedlinkflags', 'dep1_sharedlinkflags'], + "LINKFLAGS" : ['dep2_exelinkflags', 'dep1_exelinkflags'], + }, + """, """ + "dep1" : { + "CPPPATH" : ['dep1_includedir'], + "LIBPATH" : ['dep1_libdir'], + "BINPATH" : ['dep1_bindir'], + "LIBS" : ['dep1_lib'], + "FRAMEWORKS" : ['dep1_frameworks'], + "FRAMEWORKPATH" : ['dep1_frameworkdirs'], + "CPPDEFINES" : ['dep1_defines'], + "CXXFLAGS" : ['dep1_cxxflags'], + "CCFLAGS" : ['dep1_cflags'], + "SHLINKFLAGS" : ['dep1_sharedlinkflags'], + "LINKFLAGS" : ['dep1_exelinkflags'], + }, + "dep1_version" : "0.1", + """, """ + "dep2" : { + "CPPPATH" : ['dep2_includedir'], + "LIBPATH" : ['dep2_libdir'], + "BINPATH" : ['dep2_bindir'], + "LIBS" : ['dep2_lib'], + "FRAMEWORKS" : ['dep2_frameworks'], + "FRAMEWORKPATH" : ['dep2_frameworkdirs'], + "CPPDEFINES" : ['dep2_defines'], + "CXXFLAGS" : ['dep2_cxxflags'], + "CCFLAGS" : ['dep2_cflags'], + "SHLINKFLAGS" : ['dep2_sharedlinkflags'], + "LINKFLAGS" : ['dep2_exelinkflags'], + }, + "dep2_version" : "0.1", + """] + + clean_sconsdeps = clean_paths(sconsdeps) + for block in expected_content: + assert block in clean_sconsdeps From e258f5d84b7bb37e2803f49660071afec4b0acc3 Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 11 Sep 2023 17:18:09 +0200 Subject: [PATCH 06/13] fix name --- conan/tools/scons/__init__.py | 2 +- conan/tools/scons/sconsdeps.py | 2 +- conans/client/generators/__init__.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conan/tools/scons/__init__.py b/conan/tools/scons/__init__.py index b8aed953fba..f05959eaf69 100644 --- a/conan/tools/scons/__init__.py +++ b/conan/tools/scons/__init__.py @@ -1 +1 @@ -from conan.tools.scons.sconsdeps import SconsDeps +from conan.tools.scons.sconsdeps import SConsDeps diff --git a/conan/tools/scons/sconsdeps.py b/conan/tools/scons/sconsdeps.py index 1c44a869216..06872b02ed9 100644 --- a/conan/tools/scons/sconsdeps.py +++ b/conan/tools/scons/sconsdeps.py @@ -4,7 +4,7 @@ from conans.util.files import save -class SconsDeps: +class SConsDeps: def __init__(self, conanfile): self._conanfile = conanfile self._ordered_deps = [] diff --git a/conans/client/generators/__init__.py b/conans/client/generators/__init__.py index 3c6f62b907d..386c6c50f5c 100644 --- a/conans/client/generators/__init__.py +++ b/conans/client/generators/__init__.py @@ -157,8 +157,8 @@ def _new_generator(self, generator_name, output): from conan.tools.microsoft import NMakeDeps return NMakeDeps elif generator_name == "SConsDeps": - from conan.tools.scons import SconsDeps - return SconsDeps + from conan.tools.scons import SConsDeps + return SConsDeps else: raise ConanException("Internal Conan error: Generator '{}' " "not commplete".format(generator_name)) From f93393c0f2d1dbc5c885c684f8c6679fa4f7756c Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 11 Sep 2023 18:18:15 +0200 Subject: [PATCH 07/13] fix empty dirs --- conan/tools/scons/sconsdeps.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/conan/tools/scons/sconsdeps.py b/conan/tools/scons/sconsdeps.py index 06872b02ed9..1a29ce9470d 100644 --- a/conan/tools/scons/sconsdeps.py +++ b/conan/tools/scons/sconsdeps.py @@ -32,17 +32,17 @@ def generate(self): def _content(self): template = Template(""" "{{dep_name}}" : { - "CPPPATH" : {{info.includedirs}}, - "LIBPATH" : {{info.libdirs}}, - "BINPATH" : {{info.bindirs}}, - "LIBS" : {{info.libs + info.system_libs}}, - "FRAMEWORKS" : {{info.frameworks}}, - "FRAMEWORKPATH" : {{info.frameworkdirs}}, - "CPPDEFINES" : {{info.defines}}, - "CXXFLAGS" : {{info.cxxflags}}, - "CCFLAGS" : {{info.cflags}}, - "SHLINKFLAGS" : {{info.sharedlinkflags}}, - "LINKFLAGS" : {{info.exelinkflags}}, + "CPPPATH" : {{info.includedirs or []}}, + "LIBPATH" : {{info.libdirs or []}}, + "BINPATH" : {{info.bindirs or []}}, + "LIBS" : {{(info.libs or []) + (info.system_libs or [])}}, + "FRAMEWORKS" : {{info.frameworks or []}}, + "FRAMEWORKPATH" : {{info.frameworkdirs or []}}, + "CPPDEFINES" : {{info.defines or []}}, + "CXXFLAGS" : {{info.cxxflags or []}}, + "CCFLAGS" : {{info.cflags or []}}, + "SHLINKFLAGS" : {{info.sharedlinkflags or []}}, + "LINKFLAGS" : {{info.exelinkflags or []}}, }, {% if dep_version is not none %}"{{dep_name}}_version" : "{{dep_version}}",{% endif %} """) From 3bd21d93ddbd078feed597d1fdfb277a29d15d77 Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 11 Sep 2023 18:37:54 +0200 Subject: [PATCH 08/13] add functional test --- .../toolchains/scons/test_sconsdeps.py | 171 +++++++++++++++++- 1 file changed, 168 insertions(+), 3 deletions(-) diff --git a/conans/test/functional/toolchains/scons/test_sconsdeps.py b/conans/test/functional/toolchains/scons/test_sconsdeps.py index b044b542d5a..722f33db1d5 100644 --- a/conans/test/functional/toolchains/scons/test_sconsdeps.py +++ b/conans/test/functional/toolchains/scons/test_sconsdeps.py @@ -1,4 +1,5 @@ import platform +import textwrap import pytest @@ -10,6 +11,170 @@ @pytest.mark.tool("scons") def test_sconsdeps(): client = TestClient(path_with_spaces=False) - client.run("new hello/0.1 --template=cmake_lib") - client.run("create . -tf=None") - client.run("install hello/0.1@ -g SconsDeps") + + conanfile = textwrap.dedent("""\ + import os + + from conan import ConanFile + from conan.tools.files import copy + + + class helloConan(ConanFile): + name = "hello" + version = "1.0" + settings = "os", "compiler", "build_type", "arch" + + exports_sources = "src/*" + + # TODO: check what would be the correct layout and how to interact with + # SCons scripts + def layout(self): + self.folders.source = "src" + + def build(self): + debug_opt = '--debug-build' if self.settings.build_type == 'Debug' else '' + self.run(f'scons -C {self.folders.source} {debug_opt}') + + def package(self): + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder),) + copy(self, "*.lib", src=self.source_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.a", src=self.source_folder, dst=os.path.join(self.package_folder, "lib"), keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["hello"] + + """) + + hello_cpp = textwrap.dedent("""\ + #include + #include "hello.h" + + void hello(){ + #ifdef NDEBUG + std::cout << "Hello World Release!" < Date: Mon, 11 Sep 2023 18:42:23 +0200 Subject: [PATCH 09/13] minor changes --- conans/test/integration/toolchains/scons/test_scondeps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/test/integration/toolchains/scons/test_scondeps.py b/conans/test/integration/toolchains/scons/test_scondeps.py index 36af33ce0b9..4d9cd98ca7f 100644 --- a/conans/test/integration/toolchains/scons/test_scondeps.py +++ b/conans/test/integration/toolchains/scons/test_scondeps.py @@ -45,7 +45,7 @@ class ExampleConanIntegration(ConanFile): # remove all cache paths from the output but the last component def clean_paths(text): pattern = r"'/[^']+/([^'/]+)'" - return re.sub(pattern, r"'\1'", text) + return re.sub(pattern, r"'\1'", text.replace("\\", "/")) expected_content = [""" "conandeps" : { From 517233eb8382f9fbfb8b347e11353e414360d6d2 Mon Sep 17 00:00:00 2001 From: czoido Date: Mon, 11 Sep 2023 21:28:39 +0200 Subject: [PATCH 10/13] fix --- conans/test/integration/toolchains/scons/test_scondeps.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conans/test/integration/toolchains/scons/test_scondeps.py b/conans/test/integration/toolchains/scons/test_scondeps.py index 4d9cd98ca7f..d4856771f53 100644 --- a/conans/test/integration/toolchains/scons/test_scondeps.py +++ b/conans/test/integration/toolchains/scons/test_scondeps.py @@ -44,8 +44,9 @@ class ExampleConanIntegration(ConanFile): # remove all cache paths from the output but the last component def clean_paths(text): + text = text.replace("\\", "/") pattern = r"'/[^']+/([^'/]+)'" - return re.sub(pattern, r"'\1'", text.replace("\\", "/")) + return re.sub(pattern, r"'\1'", text) expected_content = [""" "conandeps" : { From f718ef359a644b0b9543c85023dc4cf78293873c Mon Sep 17 00:00:00 2001 From: czoido Date: Tue, 12 Sep 2023 07:50:17 +0200 Subject: [PATCH 11/13] better init --- conan/tools/scons/sconsdeps.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conan/tools/scons/sconsdeps.py b/conan/tools/scons/sconsdeps.py index 1a29ce9470d..fa8b3ef219b 100644 --- a/conan/tools/scons/sconsdeps.py +++ b/conan/tools/scons/sconsdeps.py @@ -7,13 +7,13 @@ class SConsDeps: def __init__(self, conanfile): self._conanfile = conanfile - self._ordered_deps = [] + self._ordered_deps = None self._generator_file = 'SConscript_conandeps' check_using_build_profile(self._conanfile) @property def ordered_deps(self): - if not self._ordered_deps: + if self._ordered_deps is None: deps = self._conanfile.dependencies.host.topological_sort self._ordered_deps = [dep for dep in reversed(deps.values())] return self._ordered_deps From 50a9748a860b575606bb112197b0c257746040f4 Mon Sep 17 00:00:00 2001 From: czoido Date: Tue, 12 Sep 2023 07:50:28 +0200 Subject: [PATCH 12/13] fix win? --- conans/test/integration/toolchains/scons/test_scondeps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/test/integration/toolchains/scons/test_scondeps.py b/conans/test/integration/toolchains/scons/test_scondeps.py index d4856771f53..17088ab218a 100644 --- a/conans/test/integration/toolchains/scons/test_scondeps.py +++ b/conans/test/integration/toolchains/scons/test_scondeps.py @@ -45,7 +45,7 @@ class ExampleConanIntegration(ConanFile): # remove all cache paths from the output but the last component def clean_paths(text): text = text.replace("\\", "/") - pattern = r"'/[^']+/([^'/]+)'" + pattern = r"'[A-Za-z]?[:]?[/]?[^']+/([^'/]+)'" return re.sub(pattern, r"'\1'", text) expected_content = [""" From e93ba6e44794bb150e9ca18d77048e8643bd553f Mon Sep 17 00:00:00 2001 From: czoido Date: Tue, 12 Sep 2023 17:36:13 +0200 Subject: [PATCH 13/13] change naming --- conan/tools/scons/sconsdeps.py | 4 ++-- conans/test/functional/toolchains/scons/test_sconsdeps.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conan/tools/scons/sconsdeps.py b/conan/tools/scons/sconsdeps.py index fa8b3ef219b..7469621b101 100644 --- a/conan/tools/scons/sconsdeps.py +++ b/conan/tools/scons/sconsdeps.py @@ -46,7 +46,7 @@ def _content(self): }, {% if dep_version is not none %}"{{dep_name}}_version" : "{{dep_version}}",{% endif %} """) - sections = ["conan = {\n"] + sections = ["conandeps = {\n"] all_flags = template.render(dep_name="conandeps", dep_version=None, info=self._get_cpp_info()) sections.append(all_flags) @@ -58,5 +58,5 @@ def _content(self): info=dep.cpp_info) sections.append(dep_flags) sections.append("}\n") - sections.append("Return('conan')\n") + sections.append("Return('conandeps')\n") return "\n".join(sections) diff --git a/conans/test/functional/toolchains/scons/test_sconsdeps.py b/conans/test/functional/toolchains/scons/test_sconsdeps.py index 722f33db1d5..4d23a48af9e 100644 --- a/conans/test/functional/toolchains/scons/test_sconsdeps.py +++ b/conans/test/functional/toolchains/scons/test_sconsdeps.py @@ -117,9 +117,9 @@ def package_info(self): build_path_relative_to_sconstruct = Dir('.').path - conan = SConscript('./SConscript_conandeps') + conandeps = SConscript('./SConscript_conandeps') - flags = conan["conandeps"] + flags = conandeps["conandeps"] env.MergeFlags(flags) env.Program("main", "main.cpp")