Add Copy headers support for RTEMS-libbsd

在移植OpenSSL库的过程中,碰到了问题:

当我从FreeBSD import 文件并port to RTEMS时,被include的头文件的文件路径和其实际的文件路径不同时,会造成编译错误,因为编译器waf找不到头文件。一个例子就是:the <openssl/opensslv.h>. The source for this file is in freebsd/crypto/openssl/crypto/opensslv.h.

针对这个bug,可以将这种头文件copy to 一个暂时的文件夹中,接下来才就详细描述如何实现:


1. Add a temporary catalog in builder.py

def includes():
      return ['-Irtemsbsd/include',
 +            '-Ilibbsd_build/include',
              '-Ifreebsd/sys',
              '-Ifreebsd/sys/contrib/pf',
              '-Ifreebsd/sys/net',


2.Add the copy method in waf_generator.py

#
# 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')
headerPaths = builder.headerPaths()
self.add('    header_build_copy_paths = [')
for hp in 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("libbsd_build/include", headers[2])')
self.add('        start_dir = bld.path.find_dir(headers[0])')
self.add('        for header in start_dir.ant_glob("**/" + headers[1]):')
self.add('            relsourcepath = os.path.relpath(str(header), start=str(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('')


So if the imported files installed into a directory with a different name then it's source directory, then this files will be copied into build/arm-rtems4.12-beagleboneblack/libbsd_build/include folder.

因此如果imported file 的路径和其源文件路径不同时,该文件会被copy至build/arm-rtems4.12-beagleboneblack/libbsd_build/include文件夹下。

转载于:https://www.cnblogs.com/sichenzhao/p/9320256.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值