【问题标题】:programatically install headers and dependent headers using scons使用 scons 以编程方式安装标头和依赖标头
【发布时间】:2011-09-28 01:26:38
【问题描述】:

我使用 scons 作为我的构建系统,我也想使用 scons 安装我的项目的开发头文件。我想避免维护所有需要的标头及其包含依赖项的列表,而是使用 scons 的内置依赖项解析魔法为我提供此列表。

例如,我有 2 个要安装的标头,明确地,Foo1.h 和 Foo2.h:

/* Foo1.h */
#ifndef FOO1_H_
#define FOO1_H_

#include "Bar.h"
#include <somelibrary.h>

/* header contents */

#endif /* FOO1_H_ */

和

/* Foo2.h */
#ifndef FOO2_H_
#define FOO2_H_

/* header contents */

#endif /* FOO2_H_ */

由于 Foo1.h 需要 Bar.h,我希望它也能自动安装。 somelibrary.h 不应该是已安装头文件的一部分。必须有某种方法来完成这个或必须有某种原因我正在尝试做的事情是不可取的。

感谢您的帮助!

【问题讨论】:

    标签: header dependencies installation scons


    【解决方案1】:

    嗯,我想出了答案。这里的代码 sn-p 将完全符合我所说的:

    def getDependentIncludes(environ, explicit_includes, search_path, depincludes):
        for inc in explicit_includes:
            if inc not in depincludes:
                depincludes.add(inc)
                incs = SCons.Defaults.CScan(inc, environ, search_path)
                getDependentIncludes(environ, incs, search_path, depincludes)
    # create a set of all the headers
    development_headers = set()
    # call function, with development_headers storing the result
    getDependentIncludes(env, 
                     external_facing_headers, 
                     include_dirs, development_headers)
    # print the glorious results
    names = map(lambda x : '"./' + os.path.relpath(str(x), Dir("#").abspath) + '"', development_headers)
    names.sort()
    print " ".join(names)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      • 1970-01-01
      • 2012-02-19
      • 1970-01-01
      • 1970-01-01
      • 2017-08-17
      • 1970-01-01
      相关资源
      最近更新 更多