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

from pathlib import Path
from jinja2 import Template
from conan.tools.env import VirtualBuildEnv
from conans.model import Generator
class GitHubActionsBuildEnv(Generator):
@property
def filename(self):
filepath = str(Path(self.conanfile.generators_folder).joinpath("activate_github_actions_buildenv"))
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 = VirtualBuildEnv(self.conanfile)
env = build_env.environment()
envvars = env.vars(self.conanfile, scope = "build")
env_prefix = "Env:" if self.conanfile.settings.os == "Windows" else ""
return template.render(envvars = envvars, env_prefix = env_prefix)