mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 05:11:15 +08:00
waf_generator: Copy headers if necessary.
There are some cases, where a header is installed into a directory with a different name then it's source directory. In that case, the build might fail because the header is not found. One example would be the <openssl/opensslv.h>. The source for this file is in freebsd/crypto/openssl/crypto/opensslv.h. To allow the build to work in such cases too, copy such files into a temporary location in the build tree.
This commit is contained in:

committed by
Chris Johns

parent
097ccba6b0
commit
307b324a42
14
builder.py
14
builder.py
@@ -194,6 +194,10 @@ def includes():
|
||||
'-ImDNSResponder/mDNSPosix',
|
||||
'-Itestsuite/include']
|
||||
|
||||
def buildInclude():
|
||||
""" Returns the path where headers will be copied during build. """
|
||||
return 'build-include'
|
||||
|
||||
def cpuIncludes():
|
||||
return ['-Irtemsbsd/@CPU@/include',
|
||||
'-Ifreebsd/sys/@CPU@/include']
|
||||
@@ -205,6 +209,16 @@ def cxxflags():
|
||||
return []
|
||||
|
||||
def headerPaths():
|
||||
""" Returns a list of information about what header files should be
|
||||
installed.
|
||||
|
||||
The list is also used to find headers with a local path that doesn't match
|
||||
it's dest path. Due to the difference in the path name such files are
|
||||
problematic during the build if they are included using their later
|
||||
installation path (dest path) name. Therefore they are copied into a
|
||||
sub-directory of the build path so that they can be included with their
|
||||
normal installation path. """
|
||||
|
||||
# local path wildcard dest path
|
||||
return [('rtemsbsd/include', '*.h', ''),
|
||||
('rtemsbsd/mghttpd', 'mongoose.h', 'mghttpd'),
|
||||
|
@@ -83,6 +83,7 @@ def build(bld):
|
||||
includes += ["mDNSResponder/mDNSShared"]
|
||||
includes += ["mDNSResponder/mDNSPosix"]
|
||||
includes += ["testsuite/include"]
|
||||
includes += ["build-include"]
|
||||
|
||||
# Collect the libbsd uses
|
||||
libbsd_use = []
|
||||
@@ -123,6 +124,20 @@ def build(bld):
|
||||
rule = "sed -e 's/@NET_CFG_SELF_IP@/%s/' -e 's/@NET_CFG_NETMASK@/%s/' -e 's/@NET_CFG_PEER_IP@/%s/' -e 's/@NET_CFG_GATEWAY_IP@/%s/' < ${SRC} > ${TGT}" % (net_cfg_self_ip, net_cfg_netmask, net_cfg_peer_ip, net_cfg_gateway_ip),
|
||||
update_outputs = True)
|
||||
|
||||
# copy headers if necessary
|
||||
header_build_copy_paths = [
|
||||
]
|
||||
for headers in header_build_copy_paths:
|
||||
target = os.path.join("build-include", headers[2])
|
||||
start_dir = bld.path.find_dir(headers[0])
|
||||
for header in start_dir.ant_glob(os.path.join("**/", headers[1])):
|
||||
relsourcepath = header.path_from(start_dir)
|
||||
targetheader = os.path.join(target, relsourcepath)
|
||||
bld(features = 'subst',
|
||||
target = targetheader,
|
||||
source = header,
|
||||
is_copy = True)
|
||||
|
||||
# KVM Symbols
|
||||
bld(target = "rtemsbsd/rtems/rtems-kernel-kvm-symbols.c",
|
||||
source = "rtemsbsd/rtems/generate_kvm_symbols",
|
||||
|
@@ -392,7 +392,7 @@ class ModuleManager(builder.ModuleManager):
|
||||
self.add(' if bld.get_env()["RTEMS_ARCH"] == "i386":')
|
||||
self.add(' for i in %r:' % (builder.cpuIncludes()))
|
||||
self.add(' includes += ["%s" % (i[2:].replace("@CPU@", "x86"))]')
|
||||
for i in builder.includes():
|
||||
for i in builder.includes() + ['-I' + builder.buildInclude()]:
|
||||
self.add(' includes += ["%s"]' % (i[2:]))
|
||||
self.add('')
|
||||
self.add(' # Collect the libbsd uses')
|
||||
@@ -444,6 +444,28 @@ class ModuleManager(builder.ModuleManager):
|
||||
self.add(' update_outputs = True)')
|
||||
self.add('')
|
||||
|
||||
#
|
||||
# Add a copy rule for all headers where the install path and the source
|
||||
# path are not the same.
|
||||
#
|
||||
self.add(' # copy headers if necessary')
|
||||
self.add(' header_build_copy_paths = [')
|
||||
for hp in builder.headerPaths():
|
||||
if hp[2] != '' and not hp[0].endswith(hp[2]):
|
||||
self.add(' %s,' % (str(hp)))
|
||||
self.add(' ]')
|
||||
self.add(' for headers in header_build_copy_paths:')
|
||||
self.add(' target = os.path.join("%s", headers[2])' % (builder.buildInclude()))
|
||||
self.add(' start_dir = bld.path.find_dir(headers[0])')
|
||||
self.add(' for header in start_dir.ant_glob(os.path.join("**/", headers[1])):')
|
||||
self.add(' relsourcepath = header.path_from(start_dir)')
|
||||
self.add(' targetheader = os.path.join(target, relsourcepath)')
|
||||
self.add(' bld(features = \'subst\',')
|
||||
self.add(' target = targetheader,')
|
||||
self.add(' source = header,')
|
||||
self.add(' is_copy = True)')
|
||||
self.add('')
|
||||
|
||||
#
|
||||
# Add the specific rule based builders for generating files.
|
||||
#
|
||||
|
Reference in New Issue
Block a user