Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target: stm32f1: pass CMSIS dependencies to TinyUSB #32

Merged
merged 2 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 build_targets/families.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ def ld_flags(self) -> List[str]:
]

def dependencies(self) -> List[BuildDependency]:
return [
cmsis_deps = [
CMSISDependency(components=['Core']),
CMSISDeviceSTM32F1Dependency(),
TinyUSBDependency(),
]
return cmsis_deps + [
TinyUSBDependency(dependencies=cmsis_deps),
]
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