1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 from recipe_engine import recipe_api
9 class EnvApi(recipe_api.RecipeApi):
10 def __call__(self, env_dict):
11 env = self.m.context.env
12 # If PATH is defined in both, merge them together, merging default_env into
13 # path by replacing %(PATH)s
14 upstream_path = env.get('PATH', '')
16 my_path = env_dict.get('PATH', '')
17 if upstream_path and my_path and upstream_path != my_path:
18 env['PATH'] = upstream_path.replace(r'%(PATH)s', my_path)
20 return self.m.context(env=env)