Skip to content

Commit

Permalink
build: align minimum build requirements with ndn-cxx
Browse files Browse the repository at this point in the history
Change-Id: Ia28aabc9e496f7467fa58525cde97d44ad159003
  • Loading branch information
Pesa committed Aug 21, 2023
1 parent 52f1664 commit 5110a8a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
31 changes: 21 additions & 10 deletions .waf-tools/default-compiler-flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import platform
from waflib import Configure, Logs, Utils


def options(opt):
opt.add_option('--debug', '--with-debug', action='store_true', default=False,
help='Compile in debugging mode with minimal optimizations (-Og)')


def configure(conf):
conf.start_msg('Checking C++ compiler version')

Expand All @@ -18,19 +20,22 @@ def configure(conf):
if cxx == 'gcc':
if ccver < (7, 4, 0):
errmsg = ('The version of gcc you are using is too old.\n'
'The minimum supported gcc version is 7.4.')
'The minimum supported gcc version is 9.3.')
elif ccver < (9, 3, 0):
warnmsg = ('Using a version of gcc older than 9.3 is not '
'officially supported and may result in build failures.')
conf.flags = GccFlags()
elif cxx == 'clang':
if Utils.unversioned_sys_platform() == 'darwin':
if ccver < (10, 0, 0):
errmsg = ('The version of Xcode you are using is too old.\n'
'The minimum supported Xcode version is 11.3.')
elif ccver < (11, 0, 0):
warnmsg = ('Using a version of Xcode older than 11.3 is not '
'The minimum supported Xcode version is 12.4.')
elif ccver < (12, 0, 0):
warnmsg = ('Using a version of Xcode older than 12.4 is not '
'officially supported and may result in build failures.')
elif ccver < (6, 0, 0):
elif ccver < (7, 0, 0):
errmsg = ('The version of clang you are using is too old.\n'
'The minimum supported clang version is 6.0.')
'The minimum supported clang version is 7.0.')
conf.flags = ClangFlags()
else:
warnmsg = f'{cxx} compiler is unsupported'
Expand All @@ -45,14 +50,15 @@ def configure(conf):
else:
conf.end_msg(ccverstr)

conf.areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
conf.areCustomCxxflagsPresent = len(conf.env.CXXFLAGS) > 0

# General flags are always applied (e.g., selecting C++ language standard)
generalFlags = conf.flags.getGeneralFlags(conf)
conf.add_supported_cxxflags(generalFlags['CXXFLAGS'])
conf.add_supported_linkflags(generalFlags['LINKFLAGS'])
conf.env.DEFINES += generalFlags['DEFINES']


@Configure.conf
def check_compiler_flags(conf):
# Debug or optimized CXXFLAGS and LINKFLAGS are applied only if the
Expand All @@ -75,10 +81,11 @@ def check_compiler_flags(conf):

conf.env.DEFINES += extraFlags['DEFINES']


@Configure.conf
def add_supported_cxxflags(self, cxxflags):
"""
Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
Check which cxxflags are supported by the active compiler and add them to env.CXXFLAGS variable.
"""
if len(cxxflags) == 0:
return
Expand All @@ -94,10 +101,11 @@ def add_supported_cxxflags(self, cxxflags):
self.end_msg(' '.join(supportedFlags))
self.env.prepend_value('CXXFLAGS', supportedFlags)


@Configure.conf
def add_supported_linkflags(self, linkflags):
"""
Check which linkflags are supported by compiler and add them to env.LINKFLAGS variable
Check which linkflags are supported by the active compiler and add them to env.LINKFLAGS variable.
"""
if len(linkflags) == 0:
return
Expand Down Expand Up @@ -130,9 +138,10 @@ def getOptimizedFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}


class GccBasicFlags(CompilerFlags):
"""
This class defines basic flags that work for both gcc and clang compilers
This class defines basic flags that work for both gcc and clang compilers.
"""
def getGeneralFlags(self, conf):
flags = super(GccBasicFlags, self).getGeneralFlags(conf)
Expand Down Expand Up @@ -174,6 +183,7 @@ def getOptimizedFlags(self, conf):
flags['LINKFLAGS'] += ['-Wl,-O1']
return flags


class GccFlags(GccBasicFlags):
def getDebugFlags(self, conf):
flags = super(GccFlags, self).getDebugFlags(conf)
Expand All @@ -193,6 +203,7 @@ def getOptimizedFlags(self, conf):
flags['CXXFLAGS'] += ['-Wno-psabi'] # Bug #5106
return flags


class ClangFlags(GccBasicFlags):
def getGeneralFlags(self, conf):
flags = super(ClangFlags, self).getGeneralFlags(conf)
Expand Down
6 changes: 3 additions & 3 deletions docs/INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Prerequisites
Download the PSync library and build it according to the instructions available at
https://github.com/named-data/PSync#build

- ChronoSync library [optional]
- ChronoSync library [optional, deprecated]

For testing purposes, NLSR can be optionally built with Chronosync support. Download
For testing purposes, NLSR can be optionally built with ChronoSync support. Download
the ChronoSync library and build it according to the instructions available at
https://github.com/named-data/ChronoSync#build

Expand All @@ -29,7 +29,7 @@ Prerequisites
the ndn-svs library and build it according to the instructions available at
https://github.com/named-data/ndn-svs#installation

Note that at least one sync library must be enabled.
Note that at least one Sync library must be enabled.

Build
-----
Expand Down

0 comments on commit 5110a8a

Please sign in to comment.