waf: ensure we don't build a library twice

This commit is contained in:
Andrew Tridgell 2016-05-10 14:21:43 +10:00
parent 9f84a22d22
commit fcd7611248

View File

@ -6,6 +6,7 @@ from waflib import Logs, Options, Utils
from waflib.Build import BuildContext from waflib.Build import BuildContext
from waflib.Configure import conf from waflib.Configure import conf
import os.path, os import os.path, os
from collections import OrderedDict
SOURCE_EXTS = [ SOURCE_EXTS = [
'*.S', '*.S',
@ -153,6 +154,10 @@ def _get_next_idx():
LAST_IDX += 1 LAST_IDX += 1
return LAST_IDX return LAST_IDX
def unique_list(items):
'''remove duplicate elements from a list while maintaining ordering'''
return list(OrderedDict.fromkeys(items))
@conf @conf
def ap_stlib(bld, **kw): def ap_stlib(bld, **kw):
if 'name' not in kw: if 'name' not in kw:
@ -163,7 +168,7 @@ def ap_stlib(bld, **kw):
bld.fatal('Missing libraries for ap_stlib') bld.fatal('Missing libraries for ap_stlib')
sources = [] sources = []
libraries = kw['libraries'] + bld.env.AP_LIBRARIES libraries = unique_list(kw['libraries'] + bld.env.AP_LIBRARIES)
for lib_name in libraries: for lib_name in libraries:
lib_node = bld.srcnode.find_dir('libraries/' + lib_name) lib_node = bld.srcnode.find_dir('libraries/' + lib_name)