• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4
5
6from recipe_engine import recipe_api
7
8
9class 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', '')
15    env.update(env_dict)
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)
19
20    return self.m.context(env=env)
21