Repository: conan-io/conan

Issue:
[question] build_id() and packaging prebuilt libraries
My team packages an SDK for a mcu vendor for conan distribution. The SDK comes as a zip file with the sdk sources and prebuilt libraries for 3 different compilers. 

I setup my conan recipe so that my `build()` method really just downloads the SDK of the right version from a publicly accessible link on the vendor's site. The `package()` method just copies the right libs based on the settings from the profile being used.

This is all working for me, but I would like to avoid pointlessly redownloading the sdk for each package binary I produce as all variants depend on the same sdk.

I found the `build_id()` method can do this, but it seems to only work for multiple build types. If I try to set `self.info_build.settings.compiler = "Any"` in the method I get and error about Any not being a valid selection. `ConanException: Invalid setting 'Any' is not a valid 'settings.compiler' value.`.

Is there some way to set that every compiler uses the same "build"? 

### Have you read the CONTRIBUTING guide?

- [x] I've read the CONTRIBUTING guide


Discussion:

Patch:
diff --git a/conans/model/settings.py b/conans/model/settings.py
index d55e0f37452..7270f8745f2 100644
--- a/conans/model/settings.py
+++ b/conans/model/settings.py
@@ -72,6 +72,7 @@ def copy_conaninfo_settings(self):
         else:
             result._definition = {k: v.copy_conaninfo_settings()
                                   for k, v in self._definition.items()}
+            result._definition["ANY"] = Settings()
         return result
 
     def __bool__(self):


Test patch:
diff --git a/conans/test/integration/package_id/build_id_test.py b/conans/test/integration/package_id/build_id_test.py
index 3a6078e31d3..4cf358e5880 100644
--- a/conans/test/integration/package_id/build_id_test.py
+++ b/conans/test/integration/package_id/build_id_test.py
@@ -134,6 +134,41 @@ def build(self):
         client.run("create . --name=pkg --version=0.1 ", assert_error=True)
         assert "ERROR: pkg/0.1: Error in build() method, line 5" in client.out
 
+    def test_any_os_arch(self):
+        conanfile_os = textwrap.dedent("""
+            import os
+            from conan import ConanFile
+
+            class MyTest(ConanFile):
+                name = "pkg"
+                version = "0.1"
+                settings = "os", "arch", "build_type", "compiler"
+
+                def build_id(self):
+                    self.info_build.settings.build_type = "AnyValue"
+                    self.info_build.settings.os = "AnyValue"
+                    self.info_build.settings.arch = "AnyValue"
+                    self.info_build.settings.compiler = "AnyValue"
+
+                def build(self):
+                    self.output.info("Building my code!")
+
+                def package(self):
+                    self.output.info("Packaging %s-%s!" % (self.settings.os, self.settings.arch))
+            """)
+
+        client = TestClient()
+        client.save({"conanfile.py": conanfile_os})
+        client.run("create .  -s os=Windows -s arch=x86_64 -s build_type=Release")
+        assert "pkg/0.1: Calling build()" in client.out
+        assert "Building my code!" in client.out
+        assert "Packaging Windows-x86_64!" in client.out
+        # Others must not build
+        client.run("create .  -s os=Linux -s arch=x86 -s build_type=Debug")
+        assert "pkg/0.1: Calling build()" not in client.out
+        assert "Building my code!" not in client.out
+        assert "Packaging Linux-x86!" in client.out
+
 
 def test_remove_require():
     c = TestClient()
diff --git a/conans/test/integration/package_id/package_id_test.py b/conans/test/integration/package_id/package_id_test.py
index 7f2904e7d27..9400203c135 100644
--- a/conans/test/integration/package_id/package_id_test.py
+++ b/conans/test/integration/package_id/package_id_test.py
@@ -59,6 +59,7 @@ class TestConan(ConanFile):
 
             def package_id(self):
                 self.info.settings.arch = "kk=kk"
+                self.info.settings.os = "yy=yy"
         """)
 
     client = TestClient(default_server_user=True)
@@ -159,8 +160,7 @@ def package_id(self):
 
 
 def test_package_id_validate_settings():
-    """ ``self.info`` has some validation, the first time it executes
-    https://github.com/conan-io/conan/issues/12693
+    """ ``self.info`` has no validation, as it allows to be mutated
     """
     conanfile = textwrap.dedent("""
         from conan import ConanFile
@@ -173,8 +173,8 @@ def package_id(self):
         """)
     c = TestClient()
     c.save({"conanfile.py": conanfile})
-    c.run("create . --name=pkg --version=0.1", assert_error=True)
-    assert "ConanException: Invalid setting 'DONT_EXIST' is not a valid 'settings.os' value" in c.out
+    c.run("create . --name=pkg --version=0.1")
+    # It used to fail,
 
 
 class TestBuildRequiresHeaderOnly: