Remove the PRINTER cmake option and other irrelevant code
parent
b3f3f0538e
commit
99b847bf98
|
|
@ -21,17 +21,9 @@ endif()
|
||||||
#
|
#
|
||||||
# You should specify those options when invoking CMake. Example:
|
# You should specify those options when invoking CMake. Example:
|
||||||
# ~~~
|
# ~~~
|
||||||
# cmake .. <other options> -DPRINTER=MMU
|
# cmake .. <other options> -DCUSTOM_COMPILE_OPTIONS=-DENABLE_FEATURE_X
|
||||||
# ~~~
|
# ~~~
|
||||||
|
|
||||||
set(PRINTER_VALID_OPTS "MMU")
|
|
||||||
|
|
||||||
set(PRINTER
|
|
||||||
"MMU"
|
|
||||||
CACHE
|
|
||||||
STRING
|
|
||||||
"Select the MMU unit for which you want to compile the project (valid values are ${PRINTER_VALID_OPTS})."
|
|
||||||
)
|
|
||||||
set(PROJECT_VERSION_SUFFIX
|
set(PROJECT_VERSION_SUFFIX
|
||||||
"<auto>"
|
"<auto>"
|
||||||
CACHE
|
CACHE
|
||||||
|
|
@ -53,13 +45,6 @@ set(CUSTOM_COMPILE_OPTIONS
|
||||||
CACHE STRING "Allows adding custom C/C++ flags"
|
CACHE STRING "Allows adding custom C/C++ flags"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Validate options
|
|
||||||
foreach(OPTION "PRINTER")
|
|
||||||
if(NOT ${OPTION} IN_LIST ${OPTION}_VALID_OPTS)
|
|
||||||
message(FATAL_ERROR "Invalid ${OPTION} ${${OPTION}}: Valid values are ${${OPTION}_VALID_OPTS}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Resolve BUILD_NUMBER and PROJECT_VERSION_* variables
|
# Resolve BUILD_NUMBER and PROJECT_VERSION_* variables
|
||||||
resolve_version_variables()
|
resolve_version_variables()
|
||||||
|
|
||||||
|
|
@ -86,7 +71,6 @@ message(
|
||||||
STATUS "Project version with short suffix: ${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}"
|
STATUS "Project version with short suffix: ${PROJECT_VERSION}${PROJECT_VERSION_SUFFIX_SHORT}"
|
||||||
)
|
)
|
||||||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
||||||
message(STATUS "Printer: ${PRINTER}")
|
|
||||||
|
|
||||||
# eclipse sets those variables, so lets just use them so we don't get a warning about unused
|
# eclipse sets those variables, so lets just use them so we don't get a warning about unused
|
||||||
# variables
|
# variables
|
||||||
|
|
|
||||||
|
|
@ -61,31 +61,6 @@ def get_dependency(name):
|
||||||
return install_dir
|
return install_dir
|
||||||
|
|
||||||
|
|
||||||
class Printer(Enum):
|
|
||||||
"""Represents the -DPRINTER CMake option."""
|
|
||||||
|
|
||||||
MMU = 'MMU'
|
|
||||||
|
|
||||||
|
|
||||||
#class Bootloader(Enum):
|
|
||||||
# """Represents the -DBOOTLOADER CMake option."""
|
|
||||||
#
|
|
||||||
# NO = 'NO'
|
|
||||||
# EMPTY = 'EMPTY'
|
|
||||||
# YES = 'YES'
|
|
||||||
#
|
|
||||||
# @property
|
|
||||||
# def file_component(self):
|
|
||||||
# if self == Bootloader.NO:
|
|
||||||
# return 'NOBOOT'
|
|
||||||
# elif self == Bootloader.EMPTY:
|
|
||||||
# return 'EMPTYBOOT'
|
|
||||||
# elif self == Bootloader.YES:
|
|
||||||
# return 'BOOT'
|
|
||||||
# else:
|
|
||||||
# raise NotImplementedError
|
|
||||||
|
|
||||||
|
|
||||||
class BuildType(Enum):
|
class BuildType(Enum):
|
||||||
"""Represents the -DCONFIG CMake option."""
|
"""Represents the -DCONFIG CMake option."""
|
||||||
|
|
||||||
|
|
@ -93,15 +68,6 @@ class BuildType(Enum):
|
||||||
RELEASE = 'RELEASE'
|
RELEASE = 'RELEASE'
|
||||||
|
|
||||||
|
|
||||||
#class HostTool(Enum):
|
|
||||||
# """Known host tools."""
|
|
||||||
#
|
|
||||||
# png2font = "png2font"
|
|
||||||
# bin2cc = "bin2cc"
|
|
||||||
# hex2dfu = "hex2dfu"
|
|
||||||
# makefsdata = "makefsdata"
|
|
||||||
|
|
||||||
|
|
||||||
class BuildConfiguration(ABC):
|
class BuildConfiguration(ABC):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_cmake_cache_entries(self):
|
def get_cmake_cache_entries(self):
|
||||||
|
|
@ -121,14 +87,12 @@ class BuildConfiguration(ABC):
|
||||||
|
|
||||||
class FirmwareBuildConfiguration(BuildConfiguration):
|
class FirmwareBuildConfiguration(BuildConfiguration):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
printer: Printer,
|
|
||||||
build_type: BuildType,
|
build_type: BuildType,
|
||||||
toolchain: Path = None,
|
toolchain: Path = None,
|
||||||
generator: str = None,
|
generator: str = None,
|
||||||
version_suffix: str = None,
|
version_suffix: str = None,
|
||||||
version_suffix_short: str = None,
|
version_suffix_short: str = None,
|
||||||
custom_entries: List[str] = None):
|
custom_entries: List[str] = None):
|
||||||
self.printer = printer
|
|
||||||
self.build_type = build_type
|
self.build_type = build_type
|
||||||
self.toolchain = toolchain or FirmwareBuildConfiguration.default_toolchain(
|
self.toolchain = toolchain or FirmwareBuildConfiguration.default_toolchain(
|
||||||
)
|
)
|
||||||
|
|
@ -139,8 +103,7 @@ class FirmwareBuildConfiguration(BuildConfiguration):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_toolchain() -> Path:
|
def default_toolchain() -> Path:
|
||||||
return Path(
|
return Path(__file__).resolve().parent.parent / 'cmake/AnyAvrGcc.cmake'
|
||||||
__file__).resolve().parent.parent / 'cmake/AnyAvrGcc.cmake'
|
|
||||||
|
|
||||||
def get_cmake_cache_entries(self):
|
def get_cmake_cache_entries(self):
|
||||||
entries = []
|
entries = []
|
||||||
|
|
@ -149,7 +112,6 @@ class FirmwareBuildConfiguration(BuildConfiguration):
|
||||||
str(get_dependency('ninja'))))
|
str(get_dependency('ninja'))))
|
||||||
entries.extend([
|
entries.extend([
|
||||||
('CMAKE_MAKE_PROGRAM', 'FILEPATH', str(get_dependency('ninja'))),
|
('CMAKE_MAKE_PROGRAM', 'FILEPATH', str(get_dependency('ninja'))),
|
||||||
('PRINTER', 'STRING', self.printer.value),
|
|
||||||
('CMAKE_TOOLCHAIN_FILE', 'FILEPATH', str(self.toolchain)),
|
('CMAKE_TOOLCHAIN_FILE', 'FILEPATH', str(self.toolchain)),
|
||||||
('CMAKE_BUILD_TYPE', 'STRING', self.build_type.value.title()),
|
('CMAKE_BUILD_TYPE', 'STRING', self.build_type.value.title()),
|
||||||
('PROJECT_VERSION_SUFFIX', 'STRING', self.version_suffix or ''),
|
('PROJECT_VERSION_SUFFIX', 'STRING', self.version_suffix or ''),
|
||||||
|
|
@ -170,7 +132,6 @@ class FirmwareBuildConfiguration(BuildConfiguration):
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
components = [
|
components = [
|
||||||
self.printer.name,
|
|
||||||
self.build_type.value,
|
self.build_type.value,
|
||||||
]
|
]
|
||||||
return '_'.join(components)
|
return '_'.join(components)
|
||||||
|
|
@ -178,7 +139,6 @@ class FirmwareBuildConfiguration(BuildConfiguration):
|
||||||
|
|
||||||
class BuildResult:
|
class BuildResult:
|
||||||
"""Represents a result of an attempt to build the project."""
|
"""Represents a result of an attempt to build the project."""
|
||||||
|
|
||||||
def __init__(self, config_returncode: int, build_returncode: Optional[int],
|
def __init__(self, config_returncode: int, build_returncode: Optional[int],
|
||||||
stdout: Path, stderr: Path, products: List[Path]):
|
stdout: Path, stderr: Path, products: List[Path]):
|
||||||
self.config_returncode = config_returncode
|
self.config_returncode = config_returncode
|
||||||
|
|
@ -281,7 +241,6 @@ def store_products(products: List[Path], build_config: BuildConfiguration,
|
||||||
|
|
||||||
def list_of(EnumType):
|
def list_of(EnumType):
|
||||||
"""Create an argument-parser for comma-separated list of values of some Enum subclass."""
|
"""Create an argument-parser for comma-separated list of values of some Enum subclass."""
|
||||||
|
|
||||||
def convert(val):
|
def convert(val):
|
||||||
if val == '':
|
if val == '':
|
||||||
return []
|
return []
|
||||||
|
|
@ -305,12 +264,6 @@ def cmake_cache_entry(arg):
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
# yapf: disable
|
# yapf: disable
|
||||||
parser.add_argument(
|
|
||||||
'--printer',
|
|
||||||
type=list_of(Printer),
|
|
||||||
default=list(Printer),
|
|
||||||
help='Printer type (default: {default}).'.format(
|
|
||||||
default=','.join(str(p.value.lower()) for p in Printer)))
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--build-type',
|
'--build-type',
|
||||||
type=list_of(BuildType),
|
type=list_of(BuildType),
|
||||||
|
|
@ -348,12 +301,6 @@ def main():
|
||||||
'--toolchain',
|
'--toolchain',
|
||||||
type=Path,
|
type=Path,
|
||||||
help='Path to a CMake toolchain file to be used.')
|
help='Path to a CMake toolchain file to be used.')
|
||||||
parser.add_argument(
|
|
||||||
'--host-tools',
|
|
||||||
action='store_true',
|
|
||||||
help=('Build host tools (png2font and others). '
|
|
||||||
'Turned on by default with --generate-cproject only.')
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--no-build',
|
'--no-build',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
|
@ -388,13 +335,11 @@ def main():
|
||||||
# prepare configurations
|
# prepare configurations
|
||||||
configurations = [
|
configurations = [
|
||||||
FirmwareBuildConfiguration(
|
FirmwareBuildConfiguration(
|
||||||
printer=printer,
|
|
||||||
build_type=build_type,
|
build_type=build_type,
|
||||||
version_suffix=args.version_suffix,
|
version_suffix=args.version_suffix,
|
||||||
version_suffix_short=args.version_suffix_short,
|
version_suffix_short=args.version_suffix_short,
|
||||||
generator=args.generator,
|
generator=args.generator,
|
||||||
custom_entries=args.cmake_def) for printer in args.printer
|
custom_entries=args.cmake_def) for build_type in args.build_type
|
||||||
for build_type in args.build_type
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# build everything
|
# build everything
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue