Skip to content

Commit

Permalink
targets: allow dependencies to have dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Filipe Laíns <lains@riseup.net>
  • Loading branch information
FFY00 committed Feb 25, 2021
1 parent b514d27 commit d4c836a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
26 changes: 17 additions & 9 deletions build_targets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import argparse
import itertools
import logging
import os
import os.path
Expand Down Expand Up @@ -101,6 +102,7 @@ def __init__(
self,
debug: bool = False,
linker_script: Optional[str] = None,
dependencies: Optional[List[BuildDependency]] = None,
**kwargs: Any,
) -> None:
self.__log = logging.getLogger(self.__class__.__name__)
Expand All @@ -117,7 +119,7 @@ def __init__(
'include_files': [],
'c_flags': [],
'ld_flags': [],
'dependencies': [],
'dependencies': dependencies or [],
'external_include': [],
}

Expand Down Expand Up @@ -280,6 +282,14 @@ def vendor_c_flags(self) -> List[str]:
fr'-DOI_VERSION=\"{self.version}\"',
]

@property
def dependencies(self) -> List[BuildDependency]:
return self._settings['dependencies']

@dependencies.setter
def dependencies(self, value: List[BuildDependency]) -> None:
self._settings['dependencies'] = value


class _BuildConfigurationMeta(type):
'''
Expand Down Expand Up @@ -354,14 +364,6 @@ def __init__(
if self.toolchain is None:
raise BuildConfigurationError('No toolchain specified')

@property
def dependencies(self) -> List[BuildDependency]:
return self._settings['dependencies']

@dependencies.setter
def dependencies(self, value: List[BuildDependency]) -> None:
self._settings['dependencies'] = value


class BuildConfiguration(_BuildConfiguration, metaclass=_BuildConfigurationMeta):
pass
Expand All @@ -378,6 +380,12 @@ def external_include(self) -> List[str]:
def external_include(self, value: List[str]) -> None:
self._settings['external_include'] = value

@property
def dependencies_include(self) -> List[str]:
return list(itertools.chain.from_iterable([
dependency.external_include for dependency in self.dependencies
]))


class BuildDependency(_BuildDependency, metaclass=_BuildConfigurationMeta):
pass
6 changes: 4 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,11 @@ def write_ninja(self, file: str = 'build.ninja') -> None:
continue
nw.comment(f'{dependency.name} objects')
nw.newline()
c_include_flags = [f'-I{path}' for path in dependency.include]
c_include_flags = {
f'-I{path}' for path in dependency.include + dependency.dependencies_include
}
for file in set(dependency.source):
objs += cc_abs(file, variables=[('c_include_flags', c_include_flags)])
objs += cc_abs(file, variables=[('c_include_flags', list(c_include_flags))])
nw.newline()

# compile target sources into objects
Expand Down

0 comments on commit d4c836a

Please sign in to comment.