You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.1 KiB
30 lines
1.1 KiB
from pathlib import Path |
|
|
|
from jinja2 import Template |
|
|
|
from conan.tools.env import VirtualRunEnv |
|
from conans.model import Generator |
|
|
|
|
|
class GitHubActionsRunEnv(Generator): |
|
|
|
@property |
|
def filename(self): |
|
filepath = str(Path(self.conanfile.generators_folder).joinpath("activate_github_actions_runenv")) |
|
if self.conanfile.settings.get_safe("os") == "Windows": |
|
if self.conanfile.conf.get("tools.env.virtualenv:powershell", check_type = bool): |
|
filepath += ".ps1" |
|
else: |
|
filepath += ".bat" |
|
else: |
|
filepath += ".sh" |
|
return filepath |
|
|
|
@property |
|
def content(self): |
|
template = Template("""{% for k, v in envvars.items() %}echo "{{ k }}={{ v }}" >> ${{ env_prefix }}GITHUB_ENV\n{% endfor %}""") |
|
build_env = VirtualRunEnv(self.conanfile) |
|
env = build_env.environment() |
|
envvars = env.vars(self.conanfile, scope = "run") |
|
env_prefix = "Env:" if self.conanfile.settings.os == "Windows" else "" |
|
return template.render(envvars = envvars, env_prefix = env_prefix)
|
|
|