makefile - Makefile:修改目标中的变量
问题描述
我有一个包含文件列表的变量。它们将被传递到我的模拟环境。
VHDL_SOURCES += $(PWD)/common/ip/file1.vhd \
$(PWD)/common/ip/file2.vhd \
$(PWD)/common/ip/file3.vhd \
$(PWD)/common/ip/file4.vhd \
其中一个目标创建了一堆新文件,它们应该被添加到列表中。
# sim target: Add requirement filelist.txt
.PHONY: sim
sim: add_xilip_sources
# all other definitions are defined in the common makefile
include $(PWD)/scripts/cocotb/common_makefile/Makefile
.PHONY: add_xilip_sources
add_xilip_sources: $(BUILD_PWD)/filelist.txt
XILIP_FILES = $(shell cat $<) # read the filelist into an variable
# prepend the new filelist to the VHDL_SOURCES list.
$(BUILD_PWD)/filelist.txt: $(SCRIPT_PWD)/make_switch_ip.tcl
vivado -mode tcl -source $(SCRIPT_PWD)/make_switch_ip.tcl
如何修改目标中的变量?
解决方案
你不能。Make 是声明式的,或两步式的;首先指定构建环境,然后执行。您不能在执行时修改构建环境,例如变量,或者至少不能在不同的配方之间修改。
您可以做的是使用文件而不是变量:
# vhdl_sources.txt containing VHDL_SOURCES
# vhdl_sources.txt.full containing VHDL_SOURCES plus generated filelist.txt content
vhdl_sources.txt.full: $(BUILD_PWD)/filelist.txt vhdl_sources.txt
cat $^ > $@
推荐阅读
- python - How to determine how many strings in a list using while loop in python?
- html - Vue.js -How can I submit a form with the Enter key?
- python - lpinfo not found in docker
- java - getIntent().getExtra() is returing null value
- sql - SQL 将行合并到新列中
- ruby-on-rails - 如何直接将图像从 heroku 控制台上传到我的 s3 存储桶
- reactjs - 未捕获的类型错误:无法解构“未定义”的属性“getFirestore”,因为它未定义
- python-3.x - 在while循环之前检查iterable是否为空
- spring - Liquibase 优化更新日志问题的完整性(ValidationFailedException: Validation Failed)
- sql - 基于特定表值的 SQL 连接选择