Bug 787600 - Pymake: Shell commands in submakes don't honour exported PATH and don't receive exported envvars. r=gps

This commit is contained in:
Siddharth Agarwal 2012-09-01 06:41:50 +05:30
parent 117a49819e
commit 1a35d991f1
4 changed files with 34 additions and 1 deletions

View File

@ -773,7 +773,8 @@ class ShellFunction(Function):
log.debug("%s: running shell command '%s'" % (self.loc, cline))
if msys:
cline = [shell, "-c", cline]
p = subprocess.Popen(cline, shell=not msys, stdout=subprocess.PIPE, cwd=makefile.workdir)
p = subprocess.Popen(cline, env=makefile.env, shell=not msys,
stdout=subprocess.PIPE, cwd=makefile.workdir)
stdout, stderr = p.communicate()
stdout = stdout.replace('\r\n', '\n')

View File

@ -0,0 +1,11 @@
# -*- Mode: Makefile -*-
shellresult := $(shell pathtest)
ifneq (2f7cdd0b-7277-48c1-beaf-56cb0dbacb24,$(filter $(shellresult),2f7cdd0b-7277-48c1-beaf-56cb0dbacb24))
$(error pathtest not found in submake shell function)
endif
all:
@pathtest
@pathtest | grep -q 2f7cdd0b-7277-48c1-beaf-56cb0dbacb24
@echo TEST-PASS

View File

@ -0,0 +1,16 @@
#T gmake skip
#T grep-for: "2f7cdd0b-7277-48c1-beaf-56cb0dbacb24"
ifdef __WIN32__
PS:=;
else
PS:=:
endif
export PATH := $(TESTPATH)/pathdir$(PS)$(PATH)
# This is similar to subprocess-path.mk, except we also check $(shell)
# invocations since they're affected by exported environment variables too,
# but only in submakes!
all:
$(MAKE) -f $(TESTPATH)/submake-path.makefile2

View File

@ -4,6 +4,11 @@ $(info MAKEFLAGS = '$(MAKEFLAGS)')
$(info MAKE = '$(MAKE)')
$(info value MAKE = "$(value MAKE)")
shellresult := $(shell echo -n $$EVAR)
ifneq ($(shellresult),eval)
$(error EVAR should be eval, is instead $(shellresult))
endif
all:
env
test "$(MAKELEVEL)" = "1"