Code Monkey home page Code Monkey logo

Comments (6)

memsharded avatar memsharded commented on May 18, 2024

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.

lasote avatar lasote commented on May 18, 2024

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.

memsharded avatar memsharded commented on May 18, 2024

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.

lasote avatar lasote commented on May 18, 2024

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.

lasote avatar lasote commented on May 18, 2024

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.

lasote avatar lasote commented on May 18, 2024

ConfigureEnvironment(deps_cpp_info)

from conan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.