如何在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 invokes的环境中.但是,您可以使用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屋!
查看全文