如何在 Makefile 中设置子进程的环境变量 [英] How to set child process' environment variable in Makefile
本文介绍了如何在 Makefile 中设置子进程的环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改此 Makefile:
I would like to change this Makefile:
SHELL := /bin/bash
PATH := node_modules/.bin:$(PATH)
boot:
@supervisor
--harmony
--watch etc,lib
--extensions js,json
--no-restart-on error
lib
test:
NODE_ENV=test mocha
--harmony
--reporter spec
test
clean:
@rm -rf node_modules
.PHONY: test clean
到:
SHELL := /bin/bash
PATH := node_modules/.bin:$(PATH)
boot:
@supervisor
--harmony
--watch etc,lib
--extensions js,json
--no-restart-on error
lib
test: NODE_ENV=test
test:
mocha
--harmony
--reporter spec
test
clean:
@rm -rf node_modules
.PHONY: test clean
不幸的是第二个不起作用(节点进程仍然使用默认的NODE_ENV
运行.
Unfortunately the second one does not work (the node process still runs with the default NODE_ENV
.
我错过了什么?
推荐答案
默认情况下,make 变量不会导出到进程 make 调用的环境中.但是,您可以使用 make 的 export
来强制他们这样做.更改:
Make variables are not exported into the environment of processes make invokes... by default. However you can use make's export
to force them to do so. Change:
test: NODE_ENV = test
为此:
test: export NODE_ENV = test
(假设您拥有足够现代的 GNU make >= 3.77 版本).
(assuming you have a sufficiently modern version of GNU make >= 3.77 ).
这篇关于如何在 Makefile 中设置子进程的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文