Comments (6)
I'd say that a dict is a little more pythonic and readable:
env["LIBS"] = " ".join(...)
env["OTHER_ENV_VAR"] = "my_var_value"
Not sure about the multiplatform approach, does even the "env" command works in win? If not, what would be the approach. Also it is important to define the scope, I guess that they are just per-command, so if using some other approach in win, make sure that it restores the env to its previous state.
from conan.
Forget win. I'm talking about classic configure and make.
Dict? Restore env???? What?? I suggest just a helper to create the universal flags in unix like configures . That code is what I'm using in every single conanfile that uses configure for linux and mac. My feature request is reuse the function code. I don't get what should be more pythonic or why it should be a dict.
from conan.
Ok, I misunderstood the scope of the issue. I'd create a Env helper, similar to the CMake one, that receives a deps_cpp_info object in its constructor.
from conan.
For windows support maybe:
https://msdn.microsoft.com/en-us/library/6y6t9esh(v=vs.110).aspx
Variables should be used like this:
headers_paths = ";".join(['"%s"' % lib for lib in self.deps_cpp_info.include_paths])
lib_paths= ";".join(['"%s"' % lib for lib in self.deps_cpp_info.lib_paths])
command = "set PATH=%%PATH%%;%s && set LIB=%%LIB%%;%s && COMPILE COMMANDS"
I'm trying right now in windows.
from conan.
Finally it seems to work:
def generic_env_configure_vars(self):
"""Reusable in any lib with configure!!"""
if self.settings.os == "Linux" or self.settings.os == "Macos":
libs = 'LIBS="%s"' % " ".join(["-l%s" % lib for lib in self.deps_cpp_info.libs])
ldflags = 'LDFLAGS="%s"' % " ".join(["-L%s" % lib for lib in self.deps_cpp_info.lib_paths])
archflag = "-m32" if self.settings.arch == "x86" else ""
cflags = 'CFLAGS="%s %s"' % (archflag, " ".join(self.deps_cpp_info.cflags))
cpp_flags = 'CPPFLAGS="%s %s"' % (archflag, " ".join(self.deps_cpp_info.cppflags))
command = "env %s %s %s %s" % (libs, ldflags, cflags, cpp_flags)
elif self.settings.os == "Windows" and self.settings.compiler == "Visual Studio":
cl_args = " ".join(['/I"%s"' % lib for lib in self.deps_cpp_info.include_paths])
lib_paths= ";".join(['"%s"' % lib for lib in self.deps_cpp_info.lib_paths])
command = "SET LIB=%s;%%LIB%% && SET CL=%s" % (lib_paths, cl_args)
Maybe are missing link and compiler options, but I hadn't and I couldn´t test them.
from conan.
ConfigureEnvironment(deps_cpp_info)
from conan.
Related Issues (20)
- Fix BazelDeps in the build context
- Multiple Consume Packages Lead to 403 Forbidden on bzip2 dependency HOT 4
- [question] CMake generators don't check compiler version mismatch HOT 6
- [feature] Expand ```.conanrc``` to allow difinition of local default profiles HOT 2
- [bug] invalid libcxx options with CMakeToolchain on QNX if CC has been overridden HOT 3
- [question] Packaging prebuilt projects with existing FooConfing.cmake and Generating Multiple CMake Presets HOT 2
- [question] conan2: reexport recipe with sources HOT 3
- [feature] python_requires; change package_id through attributes HOT 2
- Conan version 2.1.0 - pkgconf/2.1.0: WARN: The use of 'unix_path_legacy_compat' is deprecated in Conan 2.0 and does not perform path conversions. This is retained for compatibility with Conan 1.x and will be removed in a future version. HOT 1
- [bug] Unable to use "specific names" as values for conf entries HOT 4
- [question] Using profile host and profile build in conan create HOT 2
- [bug] package query does not work for me HOT 4
- [bug] invalid action for conan --version comman HOT 1
- [question] Can I create dynamic package option name? HOT 3
- [bug] MSVC toolchain integration is broken with short paths HOT 7
- [bug] regression where cross-compiling abseil generates invalid syntax in CMake toolchain file HOT 7
- [bug] CMakeToolchain generates invalid CMAKE_GENERATOR_TOOLSET for older toolsets+update HOT 3
- [bug] Channel overriding inconsistent between build / create / graph HOT 6
- [question] Force looking for the most compatible package HOT 2
- [question] How to call generator without install command HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from conan.