Re: Distinguishing Debian and Fedora

Russel Winder <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.devel
Message-ID <[email protected]>
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:[email protected]
41 Buckmaster Road    m: +44 7770 465 077   xmpp: [email protected]
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

_______________________________________________
Scons-dev mailing list
[email protected]
https://pairlist2.pair.net/mailman/listinfo/scons-dev
signature.asc (application/pgp-signature, 181 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEABECAAYFAlaeIS8ACgkQ+ooS3F10Be/L7ACgxGLLTo/59qwsZOzyRthK8i6K
xmMAoOkAM2L8IAyd4PVYvvweSGkuPK2s
=bskj
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.