Skip to content

Commit

Permalink
Add c/cxx compilers to host requirements
Browse files Browse the repository at this point in the history
Add options for additional environment variables that tool flags should be pulled from and use this to incorporate CPPFLAGS
  • Loading branch information
langmm committed May 31, 2024
1 parent 4328f2e commit 64df5d2
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
2 changes: 2 additions & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ requirements:
- scikit-build-core
- setuptools_scm
- sysv_ipc # [not win]
- {{ compiler('c') }}
- {{ compiler('cxx') }}
run:
- GitPython
- chevron
Expand Down
2 changes: 2 additions & 0 deletions utils/requirements/requirements.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{
"{{ compiler('c') }}": {
"method": "conda_recipe",
"host": true,
"flags": {
"build": true,
"build_only": true
Expand All @@ -41,6 +42,7 @@
{
"{{ compiler('cxx') }}": {
"method": "conda_recipe",
"host": true,
"flags": {
"build": true,
"build_only": true
Expand Down
2 changes: 2 additions & 0 deletions utils/requirements/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ general:
cross_build: True
- "{{ compiler('c') }}":
method: conda_recipe
host: True
flags:
build: True
build_only: True
- "{{ compiler('cxx') }}":
method: conda_recipe
host: True
flags:
build: True
build_only: True
Expand Down
2 changes: 1 addition & 1 deletion yggdrasil/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ def func(cls, args, return_str=False):
env_vars = ['CONDA_PREFIX', 'CONDA', 'SDKROOT', 'CC',
'CXX', 'FC', 'GFORTRAN', 'DISPLAY', 'CL',
'_CL_', 'LD', 'CFLAGS', 'CXXFLAGS',
'LDFLAGS', 'CONDA_JL_HOME',
'CPPFLAGS', 'LDFLAGS', 'CONDA_JL_HOME',
'CONDA_JL_CONDA_EXE', 'JULIA_DEPOT_PATH',
'JULIA_LOAD_PATH', 'JULIA_PROJECT',
'JULIA_SSL_CA_ROOTS_PATH']
Expand Down
1 change: 1 addition & 0 deletions yggdrasil/drivers/CModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CCompilerBase(CompilerBase):
default_executable_env = 'CC'
default_flags_env = 'CFLAGS'
default_flags = ['-g', '-Wall']
additional_flags_env = ['CPPFLAGS']
# GCC & CLANG have similar call patterns
# create_next_stage_tool = {
# 'attributes': {
Expand Down
23 changes: 16 additions & 7 deletions yggdrasil/drivers/CompiledModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3748,6 +3748,8 @@ def _build_env(self, key, to_update=None,
self.get(f'{k}_flags', dry_run=True,
no_additional_stages=True,
skip_no_additional_stages_flag=True))
for k in tool.additional_flags_env:
out[k] = ''
return out

def _runtime_env(self, to_update=None, **kwargs):
Expand Down Expand Up @@ -4073,6 +4075,7 @@ class CompilationToolBase(object):
default_flags = []
default_flags_env = None
default_libtype = None
additional_flags_env = []
output_key = '-o'
output_first = False
flag_options = OrderedDict()
Expand Down Expand Up @@ -4389,14 +4392,17 @@ def set_env(cls, existing=None, **kwargs):
if not cls.env_matches_tool():
config_vars = {}
cls.env_matches_tool(use_sysconfig=True, env=config_vars)
env_vars = []
env = getattr(cls, 'default_flags_env', None)
if env is not None:
if not isinstance(env, list):
env = [env]
for ienv in env:
existing.pop(ienv, [])
if ienv in config_vars:
existing[ienv] = config_vars[ienv]
env_vars += env
env_vars += cls.additional_flags_env
for ienv in env_vars:
existing.pop(ienv, [])
if ienv in config_vars:
existing[ienv] = config_vars[ienv]
return existing

@classmethod
Expand Down Expand Up @@ -4672,13 +4678,16 @@ def get_env_flags(cls):
use_sysconfig=True)
if exe and env_dict:
out += exe.split()[1:]
env_vars = []
env = getattr(cls, 'default_flags_env', None)
if env is not None:
if not isinstance(env, list):
env = [env]
for ienv in env:
new_val = env_dict.get(ienv, '').split()
out += [v for v in new_val if v not in out]
env_vars += env
env_vars += cls.additional_flags_env
for ienv in env_vars:
new_val = env_dict.get(ienv, '').split()
out += [v for v in new_val if v not in out]
return out

@classmethod
Expand Down

0 comments on commit 64df5d2

Please sign in to comment.