build a tool in scons, then using it
2004-11-01 16:29
363 查看
from
http://www.scons.org/cgi-bin/wiki/UsingCodeGenerators
==
One fairly common requirement in builds is to create some tool from source code, and then use that tool as part of the build to generate other files. This example shows how to do that, with thanks to Gary Oberbrunner. The tool to be generated is named mk_vds, and is built from the source file mk_vds.c. Then .txt input files are used by mk_vds to generate .vds files.
# SConstruct file
env=Environment()
# Create the mk_vds generator tool
mk_vds_tool = env.Program(target= 'mk_vds', source = 'mk_vds.c')
# This emitter will be used later by a Builder, and has an explcit dependency on the mk_vds tool
def mk_vds_emitter(target, source, env):
env.Depends(target, mk_vds_tool)
return (target, source)
# Create a builder (that uses the emitter) to build .vds files from .txt files
# The use of abspath is so that mk_vds's directory doesn't have to be added to the shell path.
bld = Builder(action = mk_vds[0].abspath + ' < $SOURCE > $TARGET',
emitter = mk_vds_emitter,
suffix = '.vds', src_suffix = '.txt')
# Add the new Builder to the list of builders
env['BUILDERS']['MK_VDS'] = bld
# Generate foo.vds from foo.txt using mk_vds
env.MK_VDS('foo.txt')
If you look at the resulting dependency tree you can see it works:
% scons --debug=tree foo.vds
+-foo.vds
+-foo.txt
+-mk_vds
+-mk_vds.o
+-mk_vds.c
http://www.scons.org/cgi-bin/wiki/UsingCodeGenerators
==
One fairly common requirement in builds is to create some tool from source code, and then use that tool as part of the build to generate other files. This example shows how to do that, with thanks to Gary Oberbrunner. The tool to be generated is named mk_vds, and is built from the source file mk_vds.c. Then .txt input files are used by mk_vds to generate .vds files.
# SConstruct file
env=Environment()
# Create the mk_vds generator tool
mk_vds_tool = env.Program(target= 'mk_vds', source = 'mk_vds.c')
# This emitter will be used later by a Builder, and has an explcit dependency on the mk_vds tool
def mk_vds_emitter(target, source, env):
env.Depends(target, mk_vds_tool)
return (target, source)
# Create a builder (that uses the emitter) to build .vds files from .txt files
# The use of abspath is so that mk_vds's directory doesn't have to be added to the shell path.
bld = Builder(action = mk_vds[0].abspath + ' < $SOURCE > $TARGET',
emitter = mk_vds_emitter,
suffix = '.vds', src_suffix = '.txt')
# Add the new Builder to the list of builders
env['BUILDERS']['MK_VDS'] = bld
# Generate foo.vds from foo.txt using mk_vds
env.MK_VDS('foo.txt')
If you look at the resulting dependency tree you can see it works:
% scons --debug=tree foo.vds
+-foo.vds
+-foo.txt
+-mk_vds
+-mk_vds.o
+-mk_vds.c
相关文章推荐
- Build a Simple Program Using Boost in(std::cin) : What does it mean?
- Build Google IG like Ajax Start Page in 7 days using ASP.NET Ajax and .NET 3.0
- I read that if you specify too large a heap (using -Xmx) then it will slow down the application, is
- Android - 警告:it is always overridden by the value specified in the Gradle build script
- Build a JavaScript Compressor tool using NodeJS, ExpressJS, Jade, UglifyJS tutorial Read more: http
- How to create a DLL library in C and then use it with C#
- [Nuxt] Build a Vue.js Form then use Vuex Actions to Post to an API in Nuxt
- Error: Your project contains C++ files but it is not using a supported native build system
- ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supp
- build sl4a in eclipse and using on device.
- Build Google IG like Ajax Start Page in 7 days using ASP.NET Ajax and .NET 3.0
- Your password has expired. To log in you must change it using a client that supports expired pass...
- Build Google IG like Ajax Start Page in 7 days using ASP.NET Ajax and .NET 3.0
- How to create a project from existing source in Eclipse and then find it?
- Force stop and then start a full crawl on all content sources in a SharePoint 2010 farm using PowerShell(转)
- Live in the future, then build what’s missing.
- 使用cocapods报错 [!] Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes
- [Tip]Add VS Command Prompt As External Tool Into VS In Case missing it
- 解决“OperationalError: (1862, 'Your password has expired. To log in you must change it using ...”
- Your password has expired.To log in you must change it using a client that supports expired password