[Scons-dev] Distinguishing Debian and Fedora

Russel Winder russel at winder.org.uk
Tue Jan 19 06:42:38 EST 2016


The following is a "doodle" for the direction I think the whole
platform detection thing should go. It is all about removing strings as
selectors, which has to be a bad thing given the propensity of many to
mis-spell things. 


from enum import Enum, unique

@unique
class OS_Type(Enum):
    posix = 0
    linux_debian = 1
    linux_fedora = 2
    darwin = 3
    windows_win32 = 4
    windows_cygwin = 5
    windows_mingw = 6

def which_posix():
    with open('/etc/os-release') as f:
        for line in f:
            if 'ID' in line:
                return {
                    'debian': OS_Type.linux_debian,
                    'fedora': OS_Type.linux_fedora,
                    }[line.split('=')[1].strip()]
        return OS_Type.posix

environment = Environment(
    tools=('g++', 'gnulink'),
)

platform = {
    'posix': which_posix(),
    'darwin': OS_Type.darwin,
}[environment['PLATFORM']]

environment.MergeFlags('!pkg-config --cflags --libs gtkmm-3.0')

if platform == OS_Type.linux_fedora:
    environment.MergeFlags('!pkg-config --cflags --libs gstreamermm-
0.10')
elif platform == OS_Type.linux_debian:
    environment.MergeFlags('!pkg-config --cflags --libs gstreamermm-
1.0')
else:
    print('Platform not understood.')
    Exit(1)

environment.Program('stuff.cpp', CXXFLAGS=['-std=c++14', '-W', '-
Wall'])




-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <https://pairlist2.pair.net/pipermail/scons-dev/attachments/20160119/3a4deaad/attachment.pgp>


More information about the Scons-dev mailing list