conan workflow using Eclipse CDT?

Created on 15 May 2017  路  11Comments  路  Source: conan-io/conan

We want to use Conan.io to manage our c/c++ dependencies with Artifactory as remote store.

We have to use the darn Eclipse CDT for our c/c++ projects so the conan's build will just call headless eclipse cmd line style or a bat script that call headless eclipse cmd line style. It builds sort of outside Conan or independent of Conan in the Eclipse workspace.

I would still like to use package cmd having configured my conanfile.py package() method, but it errors:
C:\svn\libraries\cpp\CppHelper\trunk>conan package CppHlpr/1.0.[email protected]/stable
ERROR: CppHlpr/1.0.[email protected]/stable: Package recipe has not been built locally
Please read the 'conan package' command help
Use 'conan install' or 'conan test_package' to build and create binaries

We therefore are using package_files cmd for already build binaries (created by eclipse headless) and header files but this cmd has some shortcomings compared to package cmd not being so rich to "configure".

For package_files cmd, it would be nice to have a Python package_files() method in the conanfile.py where copy statements etc. can be added like in package() method. Is there something like that possible?

Recap:

  • We use eclipse to compile Lib A. Conan should place then place binaries+headers of Lib A in Artifactory.
  • Lib B using Lib A as dependency(Conan should get this from Artifactory) is then build in Eclipse and Conan should place then place binaries+headers of Lib B in Artifactory.
    -Now the appl. using Lib B as dependency(Conan should get this from Artifactory) is then build in Eclipse and Conan should place then place binaries+headers of appl. in Artifactory.

Please give some tips and a conan workflow to do this using Eclipse CDT. Also ConanMultiPackager looks of interest, but again this Eclipse build "problem", how can I work around this in an elegant way?

question

Most helpful comment

FYI there is a quite new plugin available, works quite well for us: https://github.com/15knots/cmake4eclipse

All 11 comments

Hi @Twoflower2

I don't know how the Eclipse CDT works, neither about the "headless mode". However, I think it is worth investigating how to properly create packages with the normal flow, it is much more robust and automated. The package command, as it explains in the help, it is basically a "debug" command, to help debugging package recipes, but not really to create real packages. Also package_files is intended to checkin already pre-built binaries, when the build is not controlled or it is an external process. The package_files() method might not be possible, because such packaging is very independent on the package recipe right now.

We recently did a full Msft MSVC workflow: http://blog.conan.io/2017/05/11/C-C++-Binary-Package-Management-for-Visual-Studio.html. I think we should aim to do the same for Eclipse projects. Maybe you could try to setup a simple "Hello World" github repo, with same static library and executable, based on what you know about Eclipse CDT and trying to call such headless mode. So we could collaborate on it and try to investigate if possible to define an standard workflow. What do you think? Thanks for your feedback!

Since Eclipse CDT headless build is just a command to run on command line, have you tried declaring the build method using a simple self.run(...)? Something like:

def build(self):
    self.run("eclipse -nosplash --launcher.suppressErrors "
             "-application org.eclipse.cdt.managedbuilder.core.headlessbuild "
             "-data path_to_temp_workspace -import . -build")

The only issue is the workspace path, since it cannot be inside project directory, so if both conanfile.py and .cproject and on the same directory, you probably want to create the workspace in a new temp dir. Otherwise, if your .project is inside a directory relative to conanfile.py, then it is easier (-data . -import dirname).

Hallo @memsharded

Yes I fully agree and lets collaborate and get something out there for Eclipse CDT and then this workflow can evolve and be refined as we go along.

I added an Eclipse CDT Hello World Example. See the readme here.

The headless Eclipse works but I have not tested the Conan stuff and should not work yet.

Now we can chop and change. I this what you had in mind?

Good! I have forked it and started working doing some improvements and learning about eclipse CDT. The headless is not working yet, but I am on it. I will share and PR when I have something. Thanks!

Ok, no probs.

I forgot to mention that I tested this on Windows, get the Windows gcc compiler here Equation Solution build the compilers from GCC. I used Eclipse Mars, but newer Eclipse versions will just update the project files so no worries.

To test Eclipse projects: Try to open Eclipse with the workspace directory and then import the two projects and compile the hello library, copy/move the .a and .h to the hello inc and lib directories and compile the hello appl. and the hello.exe is created.
(I might have some path settings therefore "hardcoded" for compilers etc. in the Eclipse projects, so this might stuff you around until you use yours.)

I have a question: Regarding the projects in the workspace, they can be fine to load both the hello_statlib from there, but as you point out, I am having problems with the paths. When they are copied into the recipe, they do not longer match. Like <locationURI>PARENT-2-PROJECT_LOC/hallo_statlib/src/hello.cpp</locationURI>, because when the package is built in the local cache, the folder name hallo_statlib is not there.

The idea would be to create to packages, one for hello_statlib and the other for hello app, right? Shouldn't each one have its own project in the same repo. I am thinking I would have one repo with the hello_statlib, containing everything, the eclipse project, the sources, and the conanfile.py. I can clone, open Eclipse IDE and work, or create the package. Same for consumer packages/projects. Could you try to generate the projects there?

Hi @memsharded

Yes that is the idea that the library and the application/consumer are completely separate.

I now modified this on github to have the library and application/consumer in separate directories with their own Eclipse workspaces there in.

We use a proprietary compiler that won't work with cmake, so test_package() using cmake won't work. Only Eclipse can be used for compiling(otherwise I would have kicked out Eclipse looong ago.)

Please have a look now. (2x conanfile.py probably still quite incorrect in). What Conan cmds can I use to build the library, package and upload it and which ones to do the same for the appl. based on the readme.md Work-flow on high-level per project?

Hi @memsharded

Haven't got back to me on all my changes. Please see github. Headless Eclipse from the build() method is working flawlessly but the Conan cmds not. Do you mind to help out a bit so we can finish the little project?

  • As you can see the conan package cmd does not work and I do not understand what that msg means.
  • The conan upload therefore does not include the lib object in Artifactory.
  • I can't create or use the test_package program you created in the fork of this project for 2 reasons: 1) I can't use cmake/ forced to use Eclipse 2) the compilers are proprietary ty to HPE NonStop and not gcc, but let us ignore number 2 as a specific use case to me and not general.

c:\git\conan_cdt\hello_lib>conan info hello_statlib/1.0.0@PROJECT ID: 0ea6644d3c462f0d9fdffceca1d13609f3d075ea BuildID: None URL: https://github.com/Twoflower2/conan_cdt License: BSD Author: Twoflower2

c:\git\conan_cdt\hello_lib>conan export twoflower2/testing hello_statlib/1.0.0@twoflower2/testing export: Copied 1 '.h' files: hello.h hello_statlib/1.0.0@twoflower2/testing export: Copied 2 '' files: .cproject, .project hello_statlib/1.0.0@twoflower2/testing export: Copied 1 '.cpp' files: hello.cpp hello_statlib/1.0.0@twoflower2/testing: A new conanfile.py version was exported hello_statlib/1.0.0@twoflower2/testing: Folder: C:\Users\p.ludwick\.conan\data\hello_statlib\1.0.0\twoflower2\testing\export

c:\git\conan_cdt\hello_lib>conan install Requirements Packages PROJECT: Generated txt created conanbuildinfo.txt PROJECT: Generated conaninfo.txt

c:\git\conan_cdt\hello_lib>conan build

*c:\git\conan_cdt\hello_lib>conan package hello_statlib/1.0.0@twoflower2/testing ERROR: hello_statlib/1.0.0@twoflower2/testing: Package recipe has not been built locally Please read the 'conan package' command help Use 'conan install' or 'conan test_package' to build and create binaries
*

c:\git\conan_cdt\hello_lib>conan upload hello_statlib/1.0.0@twoflower2/testing -r conan-local --all Uploading hello_statlib/1.0.0@twoflower2/testing Uploading conanmanifest.txt Uploading conanfile.py Uploading conan_sources.tgz Uploaded conan recipe 'hello_statlib/1.0.0@twoflower2/testing' to 'conan-local': http://dev-build:8081/artifactory/api/conan/conan-local

@danimtb @memsharded @lasote

IF Eclipse get tighter integrated/supported say if a newer version of CDT integrate better with cmake or whatever in the future, please let us know.

FYI there is a quite new plugin available, works quite well for us: https://github.com/15knots/cmake4eclipse

many thanks @petermbauer !!

Was this page helpful?
0 / 5 - 0 ratings