From 9ac6c399e9de81f40e555cb6d4008886f4ebb3ca Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Sat, 21 May 2016 12:11:48 -0300 Subject: [PATCH] waf: accept env variable to append library Change check_librt() to do everything it needs to check for librt. --- Tools/ardupilotwaf/boards.py | 10 ++++------ Tools/ardupilotwaf/cxx_checks.py | 17 +++++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Tools/ardupilotwaf/boards.py b/Tools/ardupilotwaf/boards.py index 34f809ade1..ea76984128 100644 --- a/Tools/ardupilotwaf/boards.py +++ b/Tools/ardupilotwaf/boards.py @@ -184,12 +184,11 @@ class sitl(Board): '-O3', ] - cfg.check_librt() - env.LIB += [ 'm', ] - env.LIB += cfg.env.LIB_RT + + cfg.check_librt(env) env.LINKFLAGS += ['-pthread',] env.AP_LIBRARIES += [ @@ -216,12 +215,11 @@ class linux(Board): '-O3', ] - cfg.check_librt() - env.LIB += [ 'm', ] - env.LIB += cfg.env.LIB_RT + + cfg.check_librt(env) env.LINKFLAGS += ['-pthread',] env.AP_LIBRARIES = [ diff --git a/Tools/ardupilotwaf/cxx_checks.py b/Tools/ardupilotwaf/cxx_checks.py index f677018fa5..67bb317b3a 100644 --- a/Tools/ardupilotwaf/cxx_checks.py +++ b/Tools/ardupilotwaf/cxx_checks.py @@ -125,8 +125,8 @@ def ap_common_checks(cfg): ) @conf -def check_librt(cfg): - success = cfg.check( +def check_librt(cfg, env): + ret = cfg.check( compiler='cxx', fragment=''' #include @@ -140,10 +140,11 @@ def check_librt(cfg): mandatory=False, ) - if success: - return success + if ret: + return ret - return cfg.check( - compiler='cxx', - lib='rt', - ) + ret = cfg.check(compiler='cxx', lib='rt') + if ret: + env.LIB += cfg.env['LIB_RT'] + + return ret