3

我们在 Mac、Linux 和 Windows 上使用 SCons + swtoolkit 构建系统。我们有一个 svn 存储库,其中包含我们所有的外部库依赖项,其路径位于环境变量 EXTERNAL_SDKS 中。

在我们的每个目标 SConscripts 中,我想找到一个方法来查找目标链接到的 EXTERNAL_SDKS 路径下的库,并在目标本身构建并放置在那里时将其复制到构建输出文件夹中。

我发现了一种使用 swtoolkit 中添加的组件的方法,但它会减慢 sconscripts 的解析速度(mac 上 15 秒以上,windows 上 1 分钟以上!!)。

有谁知道这样做的有效方法?

4

1 回答 1

2

I found an answer via Randall Spangler, the dev at Google that created swtoolkit. Thus this answer is specific to using swtoolkit with SCons.

Previously we were scanning our targets for dependencies, then determining what external libraries to copy from that dependency scan. This is what was causing the severe slowdown.

swtoolkit has an env.Publish() method that registers targets so that they can be used as dependencies for other targets. Once the external libraries have been published, they'll automatically be copied into the build output folder via the ReplicatePublished() call that is used within swtoolkit when a target is built.

He gave the following sample code:

thirdparty_libs = []
for dir in env.SubstList2('$THIRDPARTY_LIB_DIRS'):
  thirdparty_libs += env.Glob(dir + '/lib*.dylib')
  thirdparty_libs += env.Glob(dir + '/lib*.a')

import os
for lib in thirdparty_libs:
  name_parts = os.path.splitext(lib.name)
  if name_parts[1] == '.dylib':
    # TODO: Need to publish 'libfoo.dylib' or 'libfoo.a' as both
    # 'libfoo' and 'foo'.  Need to clean up sconscripts to remove 'lib' prefix
    # from all libs for mac, linux.
    lib_basename = name_parts[0]
    env.Publish(lib_basename, 'run', lib)
    env.Publish(lib_basename[3:], 'run', lib)

We modified this to suit our needs and placed it in the scripts that configure use of our external libraries. For example, in our BoostSettings module, this finds and publishes all of the boost libraries. If one of them is needed by a target, it is automatically copied into the build output folder.

于 2010-03-17T18:42:40.443 回答