原文档链接:https://spack.readthedocs.io/en/latest/spack.build_systems.html#module-spack.build_systems.makefile
spack.build_systems.makefile 模块介绍
使用可编辑 Makefile
构建的包的专用类
这个类提供了三个可以被覆盖的方法:
edit
build
install
通常来说edit
方法需要被覆盖,而build
,install
方法并不需要覆盖(bushi)
方法 | 目的 |
---|---|
build_targets |
指定build 阶段的make 目标 |
install_targets |
指定install 阶段的make 目标 |
build_directory() |
Makefile 所在的位置(build阶段所在的目录) |
常用方法
edit(self, spec, prefix)
主要作用为在执行build
之前编辑Makefile
,例如修改各类依赖库的位置
经常用到的操作:
需要引用源码中的某些文件,因此要获取安装过程中源码位置
1 | pwd = os.getcwd() |
需要编辑Makefile
的某一项,示例地址:stream
1 | # 使用FileFilter正则表达式替换 |
或编辑类似make.inc
的文件,示例地址:elk
1 | def edit(self, spec, prefix): |
1 | def edit(self, spec, prefix): |
build(self, spec,prefix)
通过传递的build_targets
参数,调用make
常用操作:
修改build
目录(更喜欢用with working_dir('src'):
)
1 | build_directory = 'src' |
setup_build_environment(self, env)
设置build
阶段的环境变量,示例如下:
1 | def setup_build_environment(self, env): |
其余方法
build(spec, prefix)[source]
Calls make, passing build_targets as targets.
propertybuild_directory
Returns the directory containing the main Makefile
Returns
build directory
build_system_class= ‘MakefilePackage’
This attribute is used in UI queries that need to know the build system base class
build_targets= []
Targets for make during the build() phase
build_time_test_callbacks= [‘check’]
Callback names for build-time test
check()[source]
Searches the Makefile for targets test and check and runs them if found.
edit(spec, prefix)[source]
Edits the Makefile before calling make. This phase cannot be defaulted.
install(spec, prefix)[source]
Calls make, passing install_targets as targets.
install_targets= [‘install’]
Targets for make during the install() phase
install_time_test_callbacks= [‘installcheck’]
Callback names for install-time test
installcheck()[source]
Searches the Makefile for an installcheck target and runs it if found.
phases= [‘edit’, ‘build’, ‘install’]
Phases of a package that is built with an hand-written Makefile