Skip to content

Commit

Permalink
fixing virtualbuildenv (#4583)
Browse files Browse the repository at this point in the history
* fixing virtualbuildenv

* fixing broken tests

* test
  • Loading branch information
memsharded authored and lasote committed Feb 26, 2019
1 parent c72fa5b commit 2da6846
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 198 deletions.
5 changes: 4 additions & 1 deletion conans/client/generators/virtualbuildenv.py
Expand Up @@ -12,7 +12,10 @@ def __init__(self, conanfile):
compiler = conanfile.settings.get_safe("compiler")
if compiler == "Visual Studio":
self.env = VisualStudioBuildEnvironment(conanfile).vars_dict
self.env.update(vcvars_dict(conanfile.settings, output=conanfile.output))
settings_vars = vcvars_dict(conanfile.settings, output=conanfile.output)
for env_var in self.env:
self.env[env_var].extend(settings_vars.pop(env_var, []))
self.env.update(settings_vars)
else:
self.env = AutoToolsBuildEnvironment(conanfile).vars_dict

Expand Down
2 changes: 1 addition & 1 deletion conans/client/generators/virtualenv.py
Expand Up @@ -6,7 +6,7 @@

class VirtualEnvGenerator(Generator):

append_with_spaces = ["CPPFLAGS", "CFLAGS", "CXXFLAGS", "LIBS", "LDFLAGS", "CL"]
append_with_spaces = ["CPPFLAGS", "CFLAGS", "CXXFLAGS", "LIBS", "LDFLAGS", "CL", "_LINK_"]

def __init__(self, conanfile):
self.conanfile = conanfile
Expand Down
5 changes: 2 additions & 3 deletions conans/test/functional/generators/cmake_generator_test.py
@@ -1,7 +1,5 @@
import unittest
import os

from nose.plugins.attrib import attr
import unittest

from conans import tools
from conans.test.utils.tools import TestClient
Expand Down Expand Up @@ -40,6 +38,7 @@ def build(self):
os_build={os_build}
"""


class CMakeGeneratorTest(unittest.TestCase):

def _check_build_generator(self, os_build, generator):
Expand Down
40 changes: 38 additions & 2 deletions conans/test/integration/build_environment_test.py
@@ -1,8 +1,11 @@
import platform
import unittest
from textwrap import dedent

from conans.paths import CONANFILE
from conans.test.utils.tools import TestClient
from conans.test.utils.cpp_test_files import cpp_hello_conan_files


mylibh = '''
double mean(double a, double b);
Expand Down Expand Up @@ -59,9 +62,8 @@ def package_info(self):

class BuildEnvironmenTest(unittest.TestCase):

@unittest.skipUnless(platform.system() == "Linux", "Requires Linux")
def use_build_virtualenv_test(self):
if platform.system() != "Linux":
return
client = TestClient(path_with_spaces=False)
client.save({CONANFILE: conanfile, "mean.cpp": mylib, "mean.h": mylibh})
client.run("export . lasote/stable")
Expand Down Expand Up @@ -108,3 +110,37 @@ def build(self):
client.run("install . --build missing")
client.run("build .")
self.assertIn("15", client.user_io.out)

@unittest.skipUnless(platform.system() == "Windows", "Requires windows")
def use_build_virtualenv_windows_test(self):
files = cpp_hello_conan_files("hello", "0.1", use_cmake=False, with_exe=False)
client = TestClient(path_with_spaces=False)
client.save(files)
client.run("create . user/testing")
files = cpp_hello_conan_files("hello2", "0.1", deps=["hello/0.1@user/testing"],
use_cmake=False, with_exe=False)
client.save(files, clean_first=True)
client.run("create . user/testing")

reuse_conanfile = dedent('''
from conans import ConanFile
class ConanReuseLib(ConanFile):
requires = "hello2/0.1@user/testing"
generators = "virtualbuildenv"
settings = "os", "compiler", "build_type", "arch"
def build(self):
self.run('activate_build.bat && cl /c /EHsc hello.cpp')
self.run('activate_build.bat && lib hello.obj -OUT:helloapp.lib')
self.run('activate_build.bat && cl /EHsc main.cpp helloapp.lib')
''')

reuse = cpp_hello_conan_files("app", "0.1", deps=["hello2/0.1@user/testing"],
use_cmake=False)
reuse["conanfile.py"] = reuse_conanfile
client.save(reuse, clean_first=True)
client.run("install .")
client.run("build .")
client.runner("main.exe", cwd=client.current_folder)
self.assertIn("Hello app;Hello hello2;Hello hello", ";".join(str(client.out).splitlines()))
34 changes: 0 additions & 34 deletions conans/test/unittests/client/build/cmake_flags.py

This file was deleted.

157 changes: 0 additions & 157 deletions conans/test/unittests/client/build/visual_environment.py

This file was deleted.

0 comments on commit 2da6846

Please sign in to comment.