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

Modularize build system #1143

Merged
merged 114 commits into from
Dec 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
68920fd
Move file versioning.py into subdirectory "versioning".
michael-rapp Nov 19, 2024
2c65e21
Add functions "parse" and "parse_version_number" to class Version.
michael-rapp Nov 20, 2024
8ab8140
Add utility functions "read_file" and "write_file".
michael-rapp Nov 19, 2024
524c834
Move file changelog.py into subdirectory "versioning".
michael-rapp Nov 19, 2024
53c2631
Add utility function "import_source_file".
michael-rapp Nov 19, 2024
3a486cf
Add class DirectorySearch.
michael-rapp Nov 19, 2024
58d27d5
Add class PhonyTarget.
michael-rapp Nov 19, 2024
36b7115
Dynamically register targets for updating the project's version and c…
michael-rapp Nov 19, 2024
916ad9e
Move file command_line.py into subdirectory "util".
michael-rapp Nov 19, 2024
5517ef0
Move file environment.py into subdirectory "util".
michael-rapp Nov 19, 2024
a98d802
Add utility function "format_iterable".
michael-rapp Nov 20, 2024
16f5760
Add utility function "in_virtual_environment".
michael-rapp Nov 20, 2024
68eb2db
Add class Command.
michael-rapp Nov 20, 2024
6b4dfb3
Add class Pip.
michael-rapp Nov 20, 2024
92fc0b1
Add classes Program and PythonModule.
michael-rapp Nov 20, 2024
aba685c
Add class BuildUnit.
michael-rapp Nov 21, 2024
2fc1866
Remove function "install_build_dependencies".
michael-rapp Nov 21, 2024
84db22d
Move class BuildOptions into a separate file.
michael-rapp Nov 21, 2024
8c55dad
Move classes MesonSetup, MesonConfigure, MesonCompile and MesonInstal…
michael-rapp Nov 21, 2024
58b412e
Split file compilation.py into files cpp.py and cython.py.
michael-rapp Nov 21, 2024
c9a132e
Move file build_options.py into subdirectory "compilation".
michael-rapp Nov 21, 2024
da355ee
Move file meson.py into subdirectory "compilation".
michael-rapp Nov 21, 2024
754a69c
Add enum Language.
michael-rapp Nov 22, 2024
4cec8f8
Add classes Module and ModuleRegistry.
michael-rapp Nov 21, 2024
a82b03e
Add class FileSearch.
michael-rapp Nov 23, 2024
ba5d478
Add class CodeModule.
michael-rapp Nov 21, 2024
4eadc0d
Add class CompilationModule.
michael-rapp Nov 21, 2024
6bc5292
Add class PhonyTarget.Builder.
michael-rapp Nov 22, 2024
7f16083
Add class TargetBuilder.
michael-rapp Nov 22, 2024
82c93a5
Split file code_style.py into files code_style_cpp.py, code_style_pyt…
michael-rapp Nov 23, 2024
85f7607
Rename file modules.py to modules_old.py.
michael-rapp Nov 23, 2024
8aea45d
Dynamically register modules.
michael-rapp Nov 23, 2024
10d8bc2
Move classes ClangFormat and CppLint into separate files.
michael-rapp Nov 23, 2024
677104e
Move class MdFormat into a separate file.
michael-rapp Nov 23, 2024
8feb7bd
Move class YamlFix into a separate file.
michael-rapp Nov 23, 2024
841d9c2
Move classes Yapf, ISort and PyLint into separate files.
michael-rapp Nov 23, 2024
8cccf14
Allow to set multiple functions or runnables via a PhonyTarget.Builder.
michael-rapp Nov 24, 2024
24daa60
Allow targets to depend on others.
michael-rapp Nov 25, 2024
6e52e59
Dynamically register targets and modules for checking and enforcing t…
michael-rapp Nov 23, 2024
c7666ad
Rename file dependencies.py to python_dependencies.py.
michael-rapp Nov 26, 2024
ee7c4c5
Add class Table.
michael-rapp Nov 26, 2024
7f5cade
Add class TextFile.
michael-rapp Nov 26, 2024
87d5a81
Add class YamlFile.
michael-rapp Nov 26, 2024
df7362b
Add class GithubApi.
michael-rapp Nov 26, 2024
4b7ef4f
Dynamically register targets for checking and updating GitHub Actions.
michael-rapp Nov 26, 2024
dfe0362
Remove function "by_name" from class BuildUnit.
michael-rapp Nov 27, 2024
8036d09
Add function "for_build_unit" to class Pip.
michael-rapp Nov 27, 2024
026f3ae
Add function "install_all_packages" to class Pip.
michael-rapp Nov 27, 2024
c1fb353
Add function "filter_by_name" to class FileSearch.
michael-rapp Nov 27, 2024
88f88cf
Add class PythonDependencyModule.
michael-rapp Nov 27, 2024
e237e7d
Dynamically register targets and modules for installing Python runtim…
michael-rapp Nov 27, 2024
b75dc1d
Move __init__.py file.
michael-rapp Nov 27, 2024
5c4bde0
Add function "list_outdated_dependencies" to class Pip.
michael-rapp Nov 28, 2024
4227924
Dynamically register target for checking dependency versions.
michael-rapp Nov 30, 2024
372434d
Add class BuildTarget.
michael-rapp Nov 30, 2024
bdabfd9
Allow to add custom filters to a FileSearch.
michael-rapp Nov 30, 2024
ee2ce06
Add classes Requirements and RequirementsFiles.
michael-rapp Dec 2, 2024
2e41016
Add classes VersionFile and DevelopmentVersionFile.
michael-rapp Dec 2, 2024
267d9ab
Add classes ChangesetFile and ChangelogFile.
michael-rapp Dec 2, 2024
f53108a
Replace property "requirements_file" of class BuildUnit with function…
michael-rapp Dec 2, 2024
6def0e6
Add property "target_names" to class TargetRegistry.
michael-rapp Dec 2, 2024
d5b86d4
Dynamically register targets for cleaning up output files.
michael-rapp Dec 2, 2024
6190c7d
Remove log statement from class Pip.
michael-rapp Dec 2, 2024
769f126
Allow to exclude subdirectories by substrings when using the classes …
michael-rapp Dec 2, 2024
b1a2647
Dynamically register targets and modules for compiling code.
michael-rapp Dec 2, 2024
913b9dc
Dynamically register targets and modules for testing C++ code.
michael-rapp Dec 2, 2024
2464f34
Allow to add filters to a DirectorySearch.
michael-rapp Dec 3, 2024
31f861b
Dynamically register targets and modules for testing Python code.
michael-rapp Dec 3, 2024
a72cc16
Move module definitions into appropriate subpackages.
michael-rapp Dec 3, 2024
9f7daa4
Add class PipList.
michael-rapp Dec 4, 2024
e15ff24
Add class Project.
michael-rapp Dec 4, 2024
1c2a18e
Allow specifying the input files required by a BuildTarget.
michael-rapp Dec 5, 2024
02ceef4
Add function "set_symlinks" to class FileSearch.
michael-rapp Dec 5, 2024
9da4a2a
Dynamically register targets and modules for building and installing …
michael-rapp Dec 5, 2024
5ded431
Replace enum Language with class FileType.
michael-rapp Dec 5, 2024
f89be9d
Add class Log.
michael-rapp Dec 6, 2024
17ebb44
Override "__str__" function in subclasses of the class Module.
michael-rapp Dec 6, 2024
57c84cf
Override "__str__" function in subclasses of the class Target.
michael-rapp Dec 6, 2024
c019318
Add utility function "delete_files".
michael-rapp Dec 8, 2024
5bada72
Replace scons with custom implementation.
michael-rapp Dec 9, 2024
5c54d11
Update file paths mentioned in the documentation.
michael-rapp Dec 10, 2024
8a0db5e
Fix name of environment variable mentioned in the documentation.
michael-rapp Dec 10, 2024
cf4e325
Pass individual modules to functions of the class PhonyTarget.Runnabl…
michael-rapp Dec 11, 2024
02446e9
Move files into new package "core".
michael-rapp Dec 11, 2024
b88e609
Remove file venv.py.
michael-rapp Dec 11, 2024
7be5ce4
Remove file reflection.py.
michael-rapp Dec 11, 2024
046cd43
Move files into new package "targets".
michael-rapp Dec 11, 2024
a8e5af1
Only run build targets if output files are missing or input files hav…
michael-rapp Dec 11, 2024
cfaab75
Add function "for_file" to class BuildUnit.
michael-rapp Dec 11, 2024
e43f796
Remove obsolete functions from class Target.Builder.
michael-rapp Dec 11, 2024
7340add
Add type hints to function arguments.
michael-rapp Dec 11, 2024
7b17117
Add utility function "create_directories".
michael-rapp Dec 11, 2024
89db992
Dynamically register targets and modules for generating C++ API docum…
michael-rapp Dec 11, 2024
d8177be
Add constructor argument "suffixes" to class FileType.
michael-rapp Dec 12, 2024
809317b
Dynamically register targets and modules for generating Python API do…
michael-rapp Dec 12, 2024
e1c52ff
Allow to exclude files by name when using the class FileSearch.
michael-rapp Dec 12, 2024
6e80455
Catch exceptions.
michael-rapp Dec 12, 2024
4495ad6
Fix filtering files by name when using a FileSearch.
michael-rapp Dec 12, 2024
9cb6fdd
Add function "run_all" to class BuildTarget.Runnable.
michael-rapp Dec 12, 2024
7b465e9
Dynamically register targets for generating index files referencing A…
michael-rapp Dec 12, 2024
c720b9e
Dynamically register targets and modules for generating Sphinx docume…
michael-rapp Dec 12, 2024
42f12f4
Define default target.
michael-rapp Dec 13, 2024
a309d56
Edit comments.
michael-rapp Dec 13, 2024
b06b079
Fix pylint errors.
michael-rapp Dec 13, 2024
3f4c0ed
Format template files.
michael-rapp Dec 13, 2024
6204aad
Make filters for running workflow steps more fine-grained.
michael-rapp Dec 13, 2024
a986164
Update changelog.
michael-rapp Dec 13, 2024
291b16b
Automatically create build directory if it does not exist.
michael-rapp Dec 13, 2024
268120c
Fix search for test directories.
michael-rapp Dec 13, 2024
c07ece2
Apply "mdformat" to files with suffix ".md.template".
michael-rapp Dec 14, 2024
56b3f17
Fix installation of external programs on Windows.
michael-rapp Dec 14, 2024
fe37092
Remove build directories when cleaning target "compile".
michael-rapp Dec 14, 2024
65f8dba
Specify build options when setting up meson for compiling Cython code.
michael-rapp Dec 14, 2024
dbe5442
Clean all targets if the default target should be cleaned.
michael-rapp Dec 14, 2024
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
Prev Previous commit
Next Next commit
Move class MdFormat into a separate file.
michael-rapp committed Dec 8, 2024
commit 677104e590be542250dc187c4f61c648756120c2
Empty file.
28 changes: 28 additions & 0 deletions scons/code_style/markdown/mdformat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Author: Michael Rapp ([email protected])

Provides classes that allow to run the external program "mdformat".
"""
from glob import glob
from os import path

from util.run import Program


class MdFormat(Program):
"""
Allows to run the external program "mdformat".
"""

def __init__(self, directory: str, recursive: bool = False, enforce_changes: bool = False):
"""
:param directory: The path to the directory, the program should be applied to
:param recursive: True, if the program should be applied to subdirectories, False otherwise
:param enforce_changes: True, if changes should be applied to files, False otherwise
"""
super().__init__('mdformat', '--number', '--wrap', 'no', '--end-of-line', 'lf')
self.add_conditional_arguments(not enforce_changes, '--check')
suffix_md = '*.md'
glob_path = path.join(directory, '**', '**', suffix_md) if recursive else path.join(directory, suffix_md)
self.add_arguments(*glob(glob_path, recursive=recursive))
self.add_dependencies('mdformat-myst')
28 changes: 3 additions & 25 deletions scons/code_style_md.py
Original file line number Diff line number Diff line change
@@ -3,41 +3,19 @@

Provides utility functions for checking and enforcing code style definitions.
"""
from glob import glob
from os import path

from code_style.markdown.mdformat import MdFormat
from modules_old import DOC_MODULE, PYTHON_MODULE
from util.run import Program

MD_DIRS = [('.', False), (DOC_MODULE.root_dir, True), (PYTHON_MODULE.root_dir, True)]


class Mdformat(Program):
"""
Allows to run the external program "mdformat".
"""

def __init__(self, directory: str, recursive: bool = False, enforce_changes: bool = False):
"""
:param directory: The path to the directory, the program should be applied to
:param recursive: True, if the program should be applied to subdirectories, False otherwise
:param enforce_changes: True, if changes should be applied to files, False otherwise
"""
super().__init__('mdformat', '--number', '--wrap', 'no', '--end-of-line', 'lf')
self.add_conditional_arguments(not enforce_changes, '--check')
suffix_md = '*.md'
glob_path = path.join(directory, '**', '**', suffix_md) if recursive else path.join(directory, suffix_md)
self.add_arguments(*glob(glob_path, recursive=recursive))
self.add_dependencies('mdformat-myst')


def check_md_code_style(**_):
"""
Checks if the Markdown files adhere to the code style definitions. If this is not the case, an error is raised.
"""
for directory, recursive in MD_DIRS:
print('Checking Markdown code style in the directory "' + directory + '"...')
Mdformat(directory, recursive=recursive).run()
MdFormat(directory, recursive=recursive).run()


def enforce_md_code_style(**_):
@@ -46,4 +24,4 @@ def enforce_md_code_style(**_):
"""
for directory, recursive in MD_DIRS:
print('Formatting Markdown files in the directory "' + directory + '"...')
Mdformat(directory, recursive=recursive, enforce_changes=True).run()
MdFormat(directory, recursive=recursive, enforce_changes=True).run()