Skip to content

Commit

Permalink
change default for source_buildenv, too risky (#15319)
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded committed Dec 21, 2023
1 parent 88f203f commit 1bd3f2a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion conans/__init__.py
Expand Up @@ -2,4 +2,4 @@
REVISIONS = "revisions" # Only when enabled in config, not by default look at server_launcher.py
OAUTH_TOKEN = "oauth_token"

__version__ = '2.0.15'
__version__ = '2.0.16'
2 changes: 1 addition & 1 deletion conans/client/source.py
Expand Up @@ -68,7 +68,7 @@ def config_source(export_source_folder, conanfile, hook_manager):
# First of all get the exported scm sources (if auto) or clone (if fixed)
# Now move the export-sources to the right location
merge_directories(export_source_folder, conanfile.folders.base_source)
if getattr(conanfile, "source_buildenv", True):
if getattr(conanfile, "source_buildenv", False):
with VirtualBuildEnv(conanfile, auto_generate=True).vars().apply():
run_source_method(conanfile, hook_manager)
else:
Expand Down
Expand Up @@ -39,6 +39,8 @@ class Pkg(ConanFile):
version = "0.1"
tool_requires = "tool/0.1"
source_buildenv = True
def source(self):
cmd = "mytool.bat" if platform.system() == "Windows" else "mytool.sh"
self.run(cmd)
Expand All @@ -63,6 +65,8 @@ class Pkg(ConanFile):
tool_requires = "tool/0.1"
settings = "build_type"
source_buildenv = True
def layout(self):
self.folders.source = "mysrc"
bt = self.settings.get_safe("build_type") or "Release"
Expand Down Expand Up @@ -101,6 +105,8 @@ class Pkg(ConanFile):
tool_requires = "tool/0.1"
settings = "build_type"
source_buildenv = True
def layout(self):
cmake_layout(self)
bt = self.settings.get_safe("build_type") or "Release"
Expand All @@ -118,7 +124,7 @@ def source(self):
c.run("source .")
assert "MY-TOOL! tool/0.1" in c.out

def test_source_buildenv_optout(self, client):
def test_source_buildenv_default_fail(self, client):
c = client

pkg = textwrap.dedent("""
Expand All @@ -130,15 +136,13 @@ class Pkg(ConanFile):
version = "0.1"
tool_requires = "tool/0.1"
source_buildenv = False
def source(self):
cmd = "mytool.bat" if platform.system() == "Windows" else "mytool.sh"
self.run(cmd)
""")
c.save({"conanfile.py": pkg})
c.run("create .", assert_error=True)
assert "ERROR: pkg/0.1: Error in source() method, line 14" in c.out
assert "ERROR: pkg/0.1: Error in source() method, line 12" in c.out

# Local will still work, because ``install`` generates env-scripts and no layout
c.run("install .")
Expand Down

0 comments on commit 1bd3f2a

Please sign in to comment.