Skip to content

Access yaml-cpp version from within a program.#349

Open
samkellett wants to merge 2 commits intojbeder:masterfrom
galaxysoftware:master
Open

Access yaml-cpp version from within a program.#349
samkellett wants to merge 2 commits intojbeder:masterfrom
galaxysoftware:master

Conversation

@samkellett
Copy link
Copy Markdown

I have added the ability to get the yaml-cpp version via the new yaml-cpp/version.h header so that I can test that I am using the correct one (if travis gets out of sync with a dev computer for example). I have added tests for this.

I was unsure how you generated your include guards so I stuck with a hand-written one. Additionally I was unsure of whether version.h.in really lived inside include/yaml-cpp. I'm inclined to say that it isn't as that means that it will get installed along with the other headers. If you have any other suggestion I'll be happy to move it.

Cheers

@jbeder
Copy link
Copy Markdown
Owner

jbeder commented Jan 10, 2016

I'm uncertain that this is a positive change. In general, I'm hesitant to add source files that are generated by the build tool. What other major projects have this feature?

@jbeder
Copy link
Copy Markdown
Owner

jbeder commented Jan 11, 2016

It looks like boost writes the file manually (at least, the file version.hpp shows up directly in its downloaded tarball, and is not generated by the build tool). I'd slightly prefer that.

I'm still not sure if I understand the use case here. What is the situation in which your unit test would fail?

@samkellett
Copy link
Copy Markdown
Author

sorry i deleted that message as i wanted to provide a more thorough one
when i got home from work. the test i expect to fail is if i update my
developer machine to use a new library but forget to update my .travis.yml
script to download the updated library.

On 11 January 2016 at 14:32, Jesse Beder notifications@github.com wrote:

It looks like boost writes the file manually (at least, the file
version.hpp shows up directly in its downloaded tarball, and is not
generated by the build tool). I'd slightly prefer that.

I'm still not sure if I understand the use case here. What is the
situation in which your unit test would fail?


Reply to this email directly or view it on GitHub
#349 (comment).

@jbeder
Copy link
Copy Markdown
Owner

jbeder commented Jan 11, 2016

Ah, I think understand (although I do not use travis myself, so my next question might be not possible). Why not, instead, use the same tools to build your development version as your prod or CI version?

@samkellett
Copy link
Copy Markdown
Author

nar, travis doesn't make that so easy. it requires a yml file that ends up looking like a bastardised bash script (here's mine: https://github.com/galaxysoftware/galaxy/blob/master/.travis.yml). this can be solved by having all external dependencies in-tree and built with the product but this isn't that appealing w/r/t to scale over time

@jbeder
Copy link
Copy Markdown
Owner

jbeder commented Jan 12, 2016

FWIW, I'd strongly recommend having external deps in-tree. Makes for a very simple build system, and you don't get any versioning surprises.

Anyways, what do you think about just writing version.h manually?

@samkellett
Copy link
Copy Markdown
Author

yeah it's simpler for sure but i find it doesn't scale as well and can add to the build time unnecessarily.

re: hand-made version.h yeah i'd be cool with that although i think the unit test should still draw the variables from cmake to verify that it's up-to-date with the rest of the project. i'd be happy to redo this patch that way if you like?

@jbeder
Copy link
Copy Markdown
Owner

jbeder commented Jan 30, 2016

Sure, that sounds good.

Switched around the header and unit test. Now the unit test is created by CMake using the variables
set in there and the version.h header is created manually. Unit test checks that both the CMake
variables and header share the same version.
@samkellett
Copy link
Copy Markdown
Author

there you go. :)

lemme know what you think

@Spartan322
Copy link
Copy Markdown

Aren't pragmas ignored if they are not supported by the compiler? (making testing for #pragma once useless)

And couldn't you practically stringify the three version macros for YAML_CPP_VERSION?

@samkellett
Copy link
Copy Markdown
Author

Aren't pragmas ignored if they are not supported by the compiler? (making testing for #pragma once useless)

maybe i'm not sure. i based this header off of the existing files.

And couldn't you practically stringify the three version macros for YAML_CPP_VERSION?

yeah you could. i'm happy to do it either way.

@Spartan322
Copy link
Copy Markdown

I suggest stringifying for YAML_CPP_VERSION would be better as it'll ensure consistency and correctness (at least according to what is already in that header)


#define YAML_CPP_VERSION_MAJOR 0
#define YAML_CPP_VERSION_MINOR 5
#define YAML_CPP_VERSION_PATCH 2
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll have to update this to 3 :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if that's the case then should the equivalent variable in the top-level CMakeLists.txt also be 3? especially as this is the variable that is used to generate the version_test that this file is checked against.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is.

@jbeder
Copy link
Copy Markdown
Owner

jbeder commented Mar 26, 2016

Sorry for the delay. Overall structure LGTM, just a few nits. Once you update them, please squash and rebase to HEAD.

@kriben
Copy link
Copy Markdown

kriben commented Mar 23, 2017

I would like this as well. Is there anything I can do to have it merge faster?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants