Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Travis build file?  (Read 5295 times)

0 Members and 1 Guest are viewing this topic.

davejc

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Travis build file?
« on: August 14, 2018, 10:21:22 am »
Can somebody post an example .travis.yml file? I just got introduced to it and I'm trying to get it to work. I've gotten through 13 failed builds without getting much of anywhere. I'm not really sure why because I'm running the same steps on my local Ubuntu distro which is actually giving me results. I barely have a working knowledge of cmake/travis-ci so this has been a bit of a challenge.

It might be worth noting that I can't find any info on this on here or anywhere on Google. Which means to me that either I'm doing something terribly wrong or I'm just not that bright

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Travis build file?
« Reply #1 on: August 14, 2018, 11:03:02 am »
If you're question is totally unrelated to another topic, please create a new topic next time. ;)

I've once created a Travis YAML file, but that was before SFML 2.5.0 and you'll have to change a few things (e.g. SFML_ROOT -> SFML_DIR as outlined in the CMake migration post). Additionally, there's room for optimization, it was currently mostly created to get it working.

If you have a specific issue, please provide your Travis YAML file and what the issue is exactly.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

davejc

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Travis build file?
« Reply #2 on: August 15, 2018, 04:25:37 am »
That's the yaml file that I basically used, except for the deployment stuff. Can you explain where to set the SFML_DIR? That was the part that I tried to set but wasn't exactly sure what the sfml root prefix was. Is that part of the cmake cache files after building SFML? That's probably what I'm doing wrong.

Why would it work on my local machine and not travis though?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Travis build file?
« Reply #3 on: August 15, 2018, 09:17:21 am »
You basically replace the SFML_ROOT in that file with SFML_DIR. On your local machine you might have SFML in a path known to the linker, while my Travis file, builds and installs SFML in a custom location.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: Travis build file?
« Reply #4 on: August 15, 2018, 10:08:09 am »
My travis.yml file is probably too complicated, but maybe it can helps to have another example to look at: https://github.com/texus/TGUI/blob/0.8/.travis.yml (there are different stages and jobs, but you only need to look at e.g. the "Linux (gcc 4.9)" job).
I don't have the scripts inside the yml itself, the actual script to build and use SFML can be found at https://github.com/texus/TGUI/blob/0.8/tests/travis_linux.sh.
(I just realized that it doesn't use SFML_DIR yet when building TGUI itself, but at the bottom of the script you find a cmake call where SFML_DIR is used, so that one is how you would have to call cmake on your project).

It might also help to show what error you are getting on travis, maybe someone else already encountered them (I've had plenty of cases where it build locally but failed on travis in the past, usually by stupid mistakes).
« Last Edit: August 15, 2018, 10:19:28 am by texus »
TGUI: C++ SFML GUI

davejc

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Travis build file?
« Reply #5 on: August 15, 2018, 08:14:40 pm »
This all may be too advanced for me..

I took a look at both of your files. The script doesn't complete because it can't find a SFML_LINUX dir. I don't even know what that's supposed to be. Is that a directory cmake creates when building SFML (in your configuration)? I'm not really sure how to debug this because I don't know what the files are.

Where is the SFML directory? Is that where it's supposedly installed? This is the part that I'm really confused about.

It might also help to show what error you are getting on travis, maybe someone else already encountered them (I've had plenty of cases where it build locally but failed on travis in the past, usually by stupid mistakes).

This is what I'm getting:

...
By not providing "FindSFML.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SFML", but
  CMake did not find one.
...

My understanding is that SFML 2.5+ doesn't use an FindSFML.cmake file so I shouldn't be getting this error if I'm doing it right, which clearly I'm not

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: Travis build file?
« Reply #6 on: August 15, 2018, 08:34:51 pm »
The SFML_LINUX folder in my script is where SFML will be installed to. This can be any folder you choose. You probably need to create this folder yourself first, in my case it always exists because it is specified as a cache dir and travis will create it for you in such case.

When you build SFML (which you download e.g. with "git clone"), CMAKE_INSTALL_PREFIX specifies which folder SFML will be installed to:
Code: [Select]
cmake -DCMAKE_INSTALL_PREFIX=$HOME/SFML_LINUX ..
When running "make install", the SFML headers and libraries will be placed under this $HOME/SFML_LINUX folder.

When building your own project afterwards, you just specify in which folder SFML was installed with SFML_DIR:
Code: [Select]
cmake -DSFML_DIR=$HOME/SFML_LINUX ..
TGUI: C++ SFML GUI

davejc

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Travis build file?
« Reply #7 on: August 15, 2018, 09:51:13 pm »
Ok makes sense, thanks. I'll keep working at it

davejc

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Travis build file?
« Reply #8 on: August 16, 2018, 02:08:38 am »
Well I finally got it working. The question I have goes back to the original post about the SFML 2.5 migration. eXpl0it3r linked the libraries like this:

target_link_libraries(SFMLTest sfml-graphics sfml-audio)

whereas it was suggested to do this:

target_link_libraries(SFMLTest SFML::graphics SFML::audio)

When I tried the latter, it gave me a cmake linking error. Whereas when I did the former, it worked as it was supposed to. Why is that? I thought the two syntax choices were interchangeable?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Travis build file?
« Reply #9 on: August 16, 2018, 07:06:06 am »
Just because someone mentioned that it would have been nice to use SFML::<Module> doesn't mean, that it was actually implemented. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

davejc

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • Email
Re: Travis build file?
« Reply #10 on: August 16, 2018, 07:33:47 am »
Gotcha, I was under the impression it was supposed to work.

Thanks for everyone's help

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Travis build file?
« Reply #11 on: August 16, 2018, 07:37:05 am »
We probably will add it in the future, but for now it's not implemented.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: Travis build file?
« Reply #12 on: August 16, 2018, 07:52:33 am »
I do it slightly differently and just use the default install paths. This set up builds with multiple compilers and for macOS (it's a little messy I admit...) https://github.com/JonnyPtn/SFML-DOOM/blob/master/.travis.yml

 

anything