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

Author Topic: Script to compile latest SFML  (Read 2530 times)

0 Members and 1 Guest are viewing this topic.

TheVirtualDragon

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • Control + Alt + Delete!
Script to compile latest SFML
« on: June 07, 2012, 12:29:12 pm »
To keep up with the latest SFML sources (and to practice my Python skills), I have made a script which downloads and compiles SFML. It is for Linux (and possibly for Mac). Here is the Python source code:

#!/usr/bin/env python

import os

ask = raw_input("This is a script written to compile the latest version of SFML.\nLets face it, bleeding edge technology rocks!\ \n\nDo you want to continue?(y/n) ")

if ask is 'y':
    print("\n\nDownloading source...\n\n")
    download = os.system("wget -O SFML_src https://github.com/SFML/SFML/tarball/master")
       
    if download == 0:
            print("\nExtracting tarball...\n\n")
            extract = os.system("tar -zxvf ./SFML_src")
               
            if extract == 0:
                    rename = raw_input("\n\nPlease rename SFML source file (LaurentGomila-SFML...) to SFML.\nType OK to continue")
                       
                    if rename is 'OK' or 'ok' or 'Ok':
                            print("\n\nInstalling dependencies...\n\n")
                            depinst = os.system("sudo apt-get install cmake libpthread-stubs0-dev libx11-dev \
                            libxrandr-dev libfreetype6-dev libglew1.6-dev libgl1-mesa-dev libjpeg8-dev libsndfile1-dev\
                            libopenal-dev")
                               
                            if depinst == 0:
                                print("\n\nBuilding SFML...\n\n")
                                config = os.system("cmake ./SFML")
                                   
                                if config == 0:
                                    print("\n\nCompiling...\n\n")
                                    makeSF = os.system("make")
                                       
                                    if makeSF == 0:
                                        print("\n\nInstalling...\n\n")
                                        installSF = os.system("sudo make install")
                                           
                                        if installSF == 0:
                                            print("\n\nRunning ldconfig...\n\n")
                                            os.system("sudo ldconfig")
                                            finish = raw_input("\n\nSFML installed successfully. Press enter to finish.")
                                            if finish == '\n':
                                                pass                                   
                                            else:
                                                print("An error occured while making SFML")
                                        else:
                                            print("\n\nAn error occured while compiling SFML source with cmake\n\n")
                                else:
                                    print("\n\nAn error occured while installing required dependencies.\n\n")
                        else:
                            print("\n\nAn error occurred. Check if the source file was renamed\n\n")
                else:
                    print("\n\nAn error occured while extreacting the file\n\n")                                                       
        else:
            print("\n\nAn error occured while downloading.\n\n")
else:
    exit()
 

I'm still learning Python (I use C++ mostly, but Python can do somethings quicker, like this), so this script can probably be improved loads but I wrote it because it's going to be handy in the future.
Note: at one point, it will ask you to rename the extracted file (called LaurentGomila-SFML-[loads of letters and numbers]) to SFML.
Warning: This will overwrite your previous SFML installation.

[attachment deleted by admin]
« Last Edit: June 07, 2012, 01:46:44 pm by TheVirtualDragon »

bastien

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • http://bastien-leonard.alwaysdata.net
Re: Script to compile latest SFML
« Reply #1 on: June 07, 2012, 01:49:50 pm »
This is a good occasion to learn and use a library like Clint.
Check out pysfml-cython, an up to date Python 2/3 binding for SFML 2: https://github.com/bastienleonard/pysfml-cython

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Script to compile latest SFML
« Reply #2 on: June 09, 2012, 02:20:59 pm »
What about a

git pull && make install

? ;)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Script to compile latest SFML
« Reply #3 on: June 09, 2012, 07:45:09 pm »
And for the first time:
git clone URL && cmake-gui

 ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything