Skip to content

Commit

Permalink
[WIP] Port to Meson build system
Browse files Browse the repository at this point in the history
Powerful build system for building potential Python extensions and in
general any C/C++/<your-favourite-language> code.

Straightforward Python-like syntax, integration with editable
environments using automatic rebuilds, source/wheel distribution, build
introspection, reproducible builds and more!

Todo:
    - separate Tox and Makefile related changes
    - include test files

Closes #125
  • Loading branch information
HarryMichal committed Nov 27, 2023
1 parent 484ef8b commit a1b2eee
Show file tree
Hide file tree
Showing 48 changed files with 721 additions and 67 deletions.
44 changes: 25 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
test:
python3 -m pytest --durations=10 --cov=./ --cov-report term-missing:skip-covered tests/
.PHONY: dev install check linting test docs docs-release docs-html docs-dirhtml docs-latex release

# Base build requirements are not installed automatically.
# Inspired by https://meson-python.readthedocs.io/en/latest/how-to-guides/editable-installs.html
dev:
$(info [INFO] Make sure you're using a virtual environment for development)
python3 -m pip install meson-python meson ninja
python3 -m pip install --no-build-isolation --config-settings=editable-verbose=true --config-settings=setup-args=-Dbuildtype=debug --editable .[test,typing,lint,docs]
install:
python3 -m pip install .

check:
check: linting
mypy perun/

# Setuptools fails for nested requirements file when installed as `pip install .`, so sadly no
# simple "dev" optional dependency
dev:
pip3 install -e .[typing,lint,test,docs]
linting:
black -q perun/

install:
pip3 install .
test:
$(info [INFO] Make sure you're using a virtual environment for testing. See 'make dev')
python3 -m pytest --durations=10 --cov=./ --cov-report term-missing:skip-covered tests/

docs:
$(MAKE) -C docs html
docs: docs-html docs-dirhtml docs-latex

docs-latex:
$(MAKE) -C docs latex
docs-release: dev docs
cp ./docs/_build/latex/Perun.pdf ./docs/pdf/perun.pdf

docs-all:
docs-html:
$(MAKE) -C docs html

docs-dirhtml:
$(MAKE) -C docs dirhtml
$(MAKE) -C docs latex

docs-release: dev docs-latex docs
cp ./docs/_build/latex/Perun.pdf ./docs/pdf/perun.pdf
docs-latex:
$(MAKE) -C docs latex

pypi-release:
release:
python3 -m build

.PHONY: init test docs install dev run-gui gh-pages docs-latex docs-release docs-all
30 changes: 30 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
project(
'perun',
'c',
version: '0.21.6',
license: 'GPL-3',
meson_version: '>=1.0.0',
default_options: [
'buildtype=debugoptimized',
'c_std=c11',
'optimization=2',
],
)

py3 = import('python').find_installation(pure: false)
py3_dep = py3.dependency()

perun_files = files(
'LICENSE',
'pyproject.toml',
'tox.ini',
)

perun_dir = 'perun'

py3.install_sources(
perun_files,
subdir: perun_dir,
)

subdir('perun')
21 changes: 21 additions & 0 deletions perun/check/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
perun_check_dir = perun_dir / 'check'

perun_check_files = files(
'__init__.py',
'average_amount_threshold.py',
'best_model_order_equality.py',
'exclusive_time_outliers.py',
'factory.py',
'fast_check.py',
'general_detection.py',
'integral_comparison.py',
'linear_regression.py',
'local_statistics.py',
'nonparam_helpers.py',
'polynomial_regression.py',
)

py3.install_sources(
perun_check_files,
subdir: perun_check_dir,
)
14 changes: 14 additions & 0 deletions perun/cli_groups/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
perun_cli_groups_dir = perun_dir / 'cli_groups'

perun_cli_groups_files = files(
'__init__.py',
'check_cli.py',
'config_cli.py',
'run_cli.py',
'utils_cli.py',
)

py3.install_sources(
perun_cli_groups_files,
subdir: perun_cli_groups_dir
)
22 changes: 22 additions & 0 deletions perun/collect/bounds/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
perun_collect_bounds_dir = perun_collect_dir / 'bounds'

perun_collect_bounds_files = files(
'__init__.py',
'parser.py',
'run.py',
)

libedit_2_dep = dependency('libedit', version: ['>=2.0.0', '<3.0.0'], required: false)

#if libedit_2_dep.found()
py3.install_sources(
perun_collect_bounds_files,
subdir: perun_collect_bounds_dir,
)

install_subdir(
'bin',
install_dir: py3.get_install_dir() / perun_collect_bounds_dir,
install_tag: 'python-runtime',
)
#endif
20 changes: 20 additions & 0 deletions perun/collect/complexity/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
perun_collect_complexity_dir = perun_collect_dir / 'complexity'

perun_collect_complexity_files = files(
'__init__.py',
'configurator.py',
'makefiles.py',
'run.py',
'symbols.py',
)

py3.install_sources(
perun_collect_complexity_files,
subdir: perun_collect_complexity_dir,
)

install_subdir(
'cpp_sources',
install_dir: py3.get_install_dir() / perun_collect_complexity_dir,
install_tag: 'python-runtime',
)
30 changes: 30 additions & 0 deletions perun/collect/memory/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
perun_collect_memory_dir = perun_collect_dir / 'memory'

perun_collect_memory_c_files = files(
'backtrace.c',
'backtrace.h',
'malloc.c',
)

# $(CC) -shared -fPIC malloc.c backtrace.c -o malloc.so -lunwind -ldl

shared_library(
'malloc.so',
perun_collect_memory_c_files,
install: true,
install_dir: py3.get_install_dir() / perun_collect_memory_dir,
link_args: ['-lunwind', '-ldl'],
)

perun_collect_memory_files = files(
'__init__.py',
'filter.py',
'parsing.py',
'run.py',
'syscalls.py',
)

py3.install_sources(
perun_collect_memory_files,
subdir: perun_collect_memory_dir,
)
16 changes: 16 additions & 0 deletions perun/collect/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
perun_collect_dir = perun_dir / 'collect'

perun_collect_files = files(
'__init__.py',
)

py3.install_sources(
perun_collect_files,
subdir: perun_collect_dir,
)

subdir('bounds')
subdir('complexity')
subdir('memory')
subdir('time')
subdir('trace')
11 changes: 11 additions & 0 deletions perun/collect/time/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
perun_collect_time_dir = perun_collect_dir / 'time'

perun_collect_time_files = files(
'__init__.py',
'run.py',
)

py3.install_sources(
perun_collect_time_files,
subdir: perun_collect_time_dir,
)
13 changes: 13 additions & 0 deletions perun/collect/trace/ebpf/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
perun_collect_trace_ebpf_dir = perun_collect_trace_dir / 'ebpf'

perun_collect_trace_ebpf_files = files(
'__init__.py',
'ebpf.py',
'engine.py',
'program.py',
)

py3.install_sources(
perun_collect_trace_ebpf_files,
subdir: perun_collect_trace_ebpf_dir,
)
23 changes: 23 additions & 0 deletions perun/collect/trace/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
perun_collect_trace_dir = perun_collect_dir / 'trace'

perun_collect_trace_files = files(
'__init__.py',
'collect_engine.py',
'configuration.py',
'probes.py',
'processes.py',
'run.py',
'strategy.py',
'threads.py',
'values.py',
'watchdog.py',
)

py3.install_sources(
perun_collect_trace_files,
subdir: perun_collect_trace_dir,
)

subdir('ebpf')
subdir('optimizations')
subdir('systemtap')
22 changes: 22 additions & 0 deletions perun/collect/trace/optimizations/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
perun_collect_trace_optimizations_dir = perun_collect_trace_dir / 'optimizations'

perun_collect_trace_optimizations_files = files(
'__init__.py',
'call_graph.py',
'call_graph_levels.py',
'cg_projection.py',
'diff_tracing.py',
'dynamic_baseline.py',
'dynamic_sampling.py',
'dynamic_stats.py',
'optimization.py',
'static_baseline.py',
'structs.py',
)

py3.install_sources(
perun_collect_trace_optimizations_files,
subdir: perun_collect_trace_optimizations_dir,
)

subdir('resources')
14 changes: 14 additions & 0 deletions perun/collect/trace/optimizations/resources/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
perun_collect_trace_optimizations_resources_dir = perun_collect_trace_optimizations_dir / 'resources'

perun_collect_trace_optimizations_resources_files = files(
'__init__.py',
'angr_provider.py',
'manager.py',
'perun_call_graph.py',
'perun_dynamic_stats.py',
)

py3.install_sources(
perun_collect_trace_optimizations_resources_files,
subdir: perun_collect_trace_optimizations_resources_dir,
)
13 changes: 13 additions & 0 deletions perun/collect/trace/systemtap/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
perun_collect_trace_systemtap_dir = perun_collect_trace_dir / 'systemtap'

perun_collect_trace_systemtap_files = files(
'__init__.py',
'engine.py',
'parse_compact.py',
'script_compact.py',
)

py3.install_sources(
perun_collect_trace_systemtap_files,
subdir: perun_collect_trace_systemtap_dir,
)
12 changes: 12 additions & 0 deletions perun/fuzz/evaluate/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
perun_fuzz_evaluate_dir = perun_fuzz_dir / 'evaluate'

perun_fuzz_evaluate_files = files(
'__init__.py',
'by_coverage.py',
'by_perun.py',
)

py3.install_sources(
perun_fuzz_evaluate_files,
subdir: perun_fuzz_evaluate_dir
)
20 changes: 20 additions & 0 deletions perun/fuzz/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
perun_fuzz_dir = perun_dir / 'fuzz'

perun_fuzz_files = files(
'__init__.py',
'factory.py',
'filesystem.py',
'filetype.py',
'helpers.py',
'interpret.py',
'randomizer.py',
'structs.py',
)

py3.install_sources(
perun_fuzz_files,
subdir: perun_fuzz_dir
)

subdir('evaluate')
subdir('methods')
13 changes: 13 additions & 0 deletions perun/fuzz/methods/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
perun_fuzz_methods_dir = perun_fuzz_dir / 'methods'

perun_fuzz_methods_files = files(
'__init__.py',
'binary.py',
'textfile.py',
'xml.py',
)

py3.install_sources(
perun_fuzz_methods_files,
subdir: perun_fuzz_methods_dir
)
20 changes: 20 additions & 0 deletions perun/logic/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
perun_logic_dir = perun_dir / 'logic'

perun_logic_files = files(
'__init__.py',
'commands.py',
'config.py',
'config_templates.py',
'index.py',
'locks.py',
'pcs.py',
'runner.py',
'stats.py',
'store.py',
'temp.py',
)

py3.install_sources(
perun_logic_files,
subdir: perun_logic_dir,
)
Loading

0 comments on commit a1b2eee

Please sign in to comment.