Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proposing base_source_folder, and folders.root (#10654)
* proposing base_source_folder, and folders.root * Update conans/model/layout.py Co-authored-by: Luis Martinez <lasote@gmail.com> * [feature] `ConfDefinition` and `Conf` enhancements. (#10537) * first approach. Big changes in Conf * Fixing errors * Fixing more tests * Deleted useless iteration * All the tests passing * Testing * Added items method * fixed rebased * Keeping old functions for backward compatibility * backward compatibility * Keeping indentation * Ordering methods and improved legacy logic * Added fixme * Reverted breaking changes * Added more complete test * Added more access Conf tests * Added docstring * Splitted string asserts * Added get/pop functions * Breaking refactor. Trying new structure * fixing tests * Changing tests * Fixed tests * Fixed Python 2.x problems * Removed useless layer of types * Fixed py2 * Fixed errors and added cast param to apply function to convert any type * Added TODO * Improved docstring * Fixed error * Update conans/model/conf.py Co-authored-by: James <james@conan.io> * Update conans/model/conf.py Co-authored-by: James <james@conan.io> * Added check_type and removed cast * Changed main structure. Now simpler and more powerful * Explicit default * Fixed error * Simplified compile options * Changed all the legacy conf getitem built-ins * Fixed test * Fixed bad type * Added more tests * More tests * Fix test for Python2 * Added more tests. Fixed corner-cases * Added one cli test and improved boolean conf UX * Moved str conveersion * Added one more mechanism to other smart conversion. Added more tests * Removed useless OR Co-authored-by: James <james@conan.io> * [PkgConfigDeps] Added new property `component_version` (#10633) * Added custom versions and descriptions for components * Changed property to component_version. Backported to legacy PkgConfig * package_folder available when "conan install" consumer (#10655) * WIP: Test failing * output_folder absolute only when existing * Fix test windows * added a few conf checkers (#10656) * Use absolute paths in conanbuild.sh (#10653) * use absolute path * Update conans/test/integration/environment/test_env.py Co-authored-by: James <james@conan.io> * fix tests * fix test * fix win * fix win Co-authored-by: James <james@conan.io> * Cleanup tmpdirs (#10663) * refactor toolchain (#10665) * fix not finding the Premake executable (#10250) Co-authored-by: James <james@conan.io> * review Co-authored-by: Luis Martinez <lasote@gmail.com> Co-authored-by: Francisco Ramírez <franchuti688@gmail.com> Co-authored-by: Carlos Zoido <mrgalleta@gmail.com> Co-authored-by: Enhex <enhex0@gmail.com>
- Loading branch information
1 parent
dff225b
commit 50daee0
Showing
7 changed files
with
144 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import textwrap | ||
|
||
from conans.test.utils.tools import TestClient | ||
|
||
|
||
def test_exports_sources_patch(): | ||
""" | ||
tests that using ``self.base_source_folder`` we can access both from the source() and build() | ||
methods the folder where the exported sources (patches, new build files) are. And maintain | ||
a local flow without exports copies | ||
""" | ||
c = TestClient() | ||
conanfile = textwrap.dedent(""" | ||
import os, shutil | ||
from conan import ConanFile | ||
from conan.tools.files import load, copy, save | ||
class Pkg(ConanFile): | ||
name = "pkg" | ||
version = "0.1" | ||
exports_sources = "CMakeLists.txt", "patches*" | ||
def layout(self): | ||
self.folders.source = "src" | ||
def source(self): | ||
save(self, "CMakeLists.txt", "old, bad") # EMULATE A DOWNLOAD! | ||
base_source = self.base_source_folder | ||
mypatch = load(self, os.path.join(base_source, "patches/mypatch")) | ||
self.output.info("MYPATCH-SOURCE {}".format(mypatch)) | ||
shutil.copy(os.path.join(base_source, "CMakeLists.txt"), | ||
"CMakeLists.txt") | ||
def build(self): | ||
path = os.path.join(self.source_folder, "CMakeLists.txt") | ||
cmake = load(self, path) | ||
self.output.info("MYCMAKE-BUILD: {}".format(cmake)) | ||
path = os.path.join(self.base_source_folder, "patches/mypatch") | ||
cmake = load(self, path) | ||
self.output.info("MYPATCH-BUILD: {}".format(cmake)) | ||
""") | ||
c.save({"conanfile.py": conanfile, | ||
"patches/mypatch": "mypatch!", | ||
"CMakeLists.txt": "mycmake!"}) | ||
c.run("create .") | ||
assert "pkg/0.1: MYPATCH-SOURCE mypatch!" in c.out | ||
assert "pkg/0.1: MYCMAKE-BUILD: mycmake!" in c.out | ||
assert "pkg/0.1: MYPATCH-BUILD: mypatch!" in c.out | ||
|
||
# Local flow | ||
c.run("install .") | ||
c.run("source .") | ||
assert "conanfile.py (pkg/0.1): MYPATCH-SOURCE mypatch!" in c.out | ||
assert c.load("CMakeLists.txt") == "mycmake!" # My original one | ||
assert c.load("src/CMakeLists.txt") == "mycmake!" # The one patched by "source()" | ||
c.run("build .") | ||
assert "conanfile.py (pkg/0.1): MYCMAKE-BUILD: mycmake!" in c.out | ||
assert "conanfile.py (pkg/0.1): MYPATCH-BUILD: mypatch!" in c.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import textwrap | ||
|
||
from conans.test.utils.tools import TestClient | ||
|
||
|
||
def test_exports_sources_own_code_in_subfolder(): | ||
""" test that we can put the conanfile in a subfolder, and it can work. The key is | ||
the exports_sources() method that can do: | ||
os.path.join(self.recipe_folder, "..") | ||
And the layout: self.folders.root = ".." | ||
""" | ||
c = TestClient() | ||
conanfile = textwrap.dedent(""" | ||
import os | ||
from conan import ConanFile | ||
from conan.tools.files import load, copy | ||
class Pkg(ConanFile): | ||
name = "pkg" | ||
version = "0.1" | ||
def layout(self): | ||
self.folders.root = ".." | ||
self.folders.source = "." | ||
self.folders.build = "build" | ||
def export_sources(self): | ||
source_folder = os.path.join(self.recipe_folder, "..") | ||
copy(self, "*.txt", source_folder, self.export_sources_folder) | ||
def source(self): | ||
cmake = load(self, "CMakeLists.txt") | ||
self.output.info("MYCMAKE-SRC: {}".format(cmake)) | ||
def build(self): | ||
path = os.path.join(self.source_folder, "CMakeLists.txt") | ||
cmake = load(self, path) | ||
self.output.info("MYCMAKE-BUILD: {}".format(cmake)) | ||
""") | ||
c.save({"conan/conanfile.py": conanfile, | ||
"CMakeLists.txt": "mycmake!"}) | ||
c.run("create conan") | ||
assert "pkg/0.1: MYCMAKE-SRC: mycmake!" in c.out | ||
assert "pkg/0.1: MYCMAKE-BUILD: mycmake!" in c.out | ||
|
||
# Local flow | ||
c.run("install conan") | ||
# SOURCE NOT CALLED! It doesnt make sense (will fail due to local exports) | ||
c.run("build conan") | ||
assert "conanfile.py (pkg/0.1): MYCMAKE-BUILD: mycmake!" in c.out |