fosu 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. fosu-0.2.0/.clang-format +3 -0
  2. fosu-0.2.0/.git-blame-ignore-revs +2 -0
  3. fosu-0.2.0/.github/workflows/format.yml +24 -0
  4. fosu-0.2.0/.github/workflows/native.yml +120 -0
  5. fosu-0.2.0/.github/workflows/python-wheels.yml +137 -0
  6. fosu-0.2.0/.gitignore +12 -0
  7. fosu-0.2.0/.pre-commit-config.yaml +24 -0
  8. fosu-0.2.0/AGENTS.md +60 -0
  9. fosu-0.2.0/CMakeLists.txt +270 -0
  10. fosu-0.2.0/PKG-INFO +162 -0
  11. fosu-0.2.0/README.md +156 -0
  12. fosu-0.2.0/bench/common.py +18 -0
  13. fosu-0.2.0/bench/comparison/.gitignore +4 -0
  14. fosu-0.2.0/bench/comparison/README.md +158 -0
  15. fosu-0.2.0/bench/comparison/configure.py +74 -0
  16. fosu-0.2.0/bench/comparison/dotnet/Comparison.csproj +17 -0
  17. fosu-0.2.0/bench/comparison/dotnet/Program.cs +85 -0
  18. fosu-0.2.0/bench/comparison/dotnet/packages.lock.json +1132 -0
  19. fosu-0.2.0/bench/comparison/native_worker.cc +51 -0
  20. fosu-0.2.0/bench/comparison/node_worker.cjs +44 -0
  21. fosu-0.2.0/bench/comparison/package-lock.json +61 -0
  22. fosu-0.2.0/bench/comparison/package.json +8 -0
  23. fosu-0.2.0/bench/comparison/prepare.sh +29 -0
  24. fosu-0.2.0/bench/comparison/python_batch.py +111 -0
  25. fosu-0.2.0/bench/comparison/python_batch_worker.py +54 -0
  26. fosu-0.2.0/bench/comparison/python_worker.py +99 -0
  27. fosu-0.2.0/bench/comparison/report.py +271 -0
  28. fosu-0.2.0/bench/comparison/requirements.txt +12 -0
  29. fosu-0.2.0/bench/comparison/run.py +202 -0
  30. fosu-0.2.0/bench/comparison/rust/Cargo.lock +112 -0
  31. fosu-0.2.0/bench/comparison/rust/Cargo.toml +13 -0
  32. fosu-0.2.0/bench/comparison/rust/src/main.rs +46 -0
  33. fosu-0.2.0/bench/comparison/test_report.py +119 -0
  34. fosu-0.2.0/bench/corpus/README.md +27 -0
  35. fosu-0.2.0/bench/feature_matrix.cc +109 -0
  36. fosu-0.2.0/bench/generate_corpus.cc +107 -0
  37. fosu-0.2.0/bench/library_compare.cc +86 -0
  38. fosu-0.2.0/bench/library_module.cc +28 -0
  39. fosu-0.2.0/bench/profile_parse.cc +144 -0
  40. fosu-0.2.0/bench/python_compare.py +95 -0
  41. fosu-0.2.0/bench/python_feature_matrix.py +82 -0
  42. fosu-0.2.0/bench/run.py +83 -0
  43. fosu-0.2.0/bench/summarize.py +66 -0
  44. fosu-0.2.0/cmake/Development.cmake +91 -0
  45. fosu-0.2.0/cmake/Hardening.cmake +42 -0
  46. fosu-0.2.0/cmake/Python.cmake +28 -0
  47. fosu-0.2.0/cmake/fosuConfig.cmake.in +3 -0
  48. fosu-0.2.0/docs/build.md +67 -0
  49. fosu-0.2.0/docs/comparison.md +154 -0
  50. fosu-0.2.0/docs/compatibility.md +156 -0
  51. fosu-0.2.0/docs/library.md +72 -0
  52. fosu-0.2.0/docs/performance.md +164 -0
  53. fosu-0.2.0/docs/python.md +144 -0
  54. fosu-0.2.0/pyproject.toml +68 -0
  55. fosu-0.2.0/python/core.map +1 -0
  56. fosu-0.2.0/python/fosu/__init__.py +158 -0
  57. fosu-0.2.0/python/fosu/_core.pyi +27 -0
  58. fosu-0.2.0/python/fosu/_model.py +232 -0
  59. fosu-0.2.0/python/fosu/py.typed +0 -0
  60. fosu-0.2.0/src/fosu/arena.h +334 -0
  61. fosu-0.2.0/src/fosu/beatmap.h +250 -0
  62. fosu-0.2.0/src/fosu/beatmap_header.h +63 -0
  63. fosu-0.2.0/src/fosu/bindings/python.cc +835 -0
  64. fosu-0.2.0/src/fosu/compiler.h +19 -0
  65. fosu-0.2.0/src/fosu/engine/hit_objects/common_fields.h +190 -0
  66. fosu-0.2.0/src/fosu/engine/hit_objects/object_types.h +86 -0
  67. fosu-0.2.0/src/fosu/engine/hit_objects/samples.h +111 -0
  68. fosu-0.2.0/src/fosu/engine/hit_objects/slider.h +536 -0
  69. fosu-0.2.0/src/fosu/engine/parse_document.h +136 -0
  70. fosu-0.2.0/src/fosu/engine/parsing/field_values.h +56 -0
  71. fosu-0.2.0/src/fosu/engine/parsing/key_value.h +96 -0
  72. fosu-0.2.0/src/fosu/engine/parsing/lines.h +64 -0
  73. fosu-0.2.0/src/fosu/engine/parsing/numbers.h +225 -0
  74. fosu-0.2.0/src/fosu/engine/parsing/sample_sets.h +15 -0
  75. fosu-0.2.0/src/fosu/engine/parsing/section_names.h +33 -0
  76. fosu-0.2.0/src/fosu/engine/parsing/string_lookup.h +76 -0
  77. fosu-0.2.0/src/fosu/engine/parsing_engine.h +25 -0
  78. fosu-0.2.0/src/fosu/engine/primitives/byte_scan.h +30 -0
  79. fosu-0.2.0/src/fosu/engine/primitives/digit_groups.h +68 -0
  80. fosu-0.2.0/src/fosu/engine/primitives/packed_digits.h +82 -0
  81. fosu-0.2.0/src/fosu/engine/primitives/vector_ops.h +109 -0
  82. fosu-0.2.0/src/fosu/engine/runtime/cpu_features.h +91 -0
  83. fosu-0.2.0/src/fosu/engine/runtime/entry.cc +7 -0
  84. fosu-0.2.0/src/fosu/engine/runtime/loader.cc +221 -0
  85. fosu-0.2.0/src/fosu/engine/runtime/loader.h +10 -0
  86. fosu-0.2.0/src/fosu/engine/sections/colours.h +54 -0
  87. fosu-0.2.0/src/fosu/engine/sections/difficulty.h +58 -0
  88. fosu-0.2.0/src/fosu/engine/sections/editor.h +76 -0
  89. fosu-0.2.0/src/fosu/engine/sections/events.h +189 -0
  90. fosu-0.2.0/src/fosu/engine/sections/general.h +118 -0
  91. fosu-0.2.0/src/fosu/engine/sections/hit_objects.h +431 -0
  92. fosu-0.2.0/src/fosu/engine/sections/metadata.h +27 -0
  93. fosu-0.2.0/src/fosu/engine/sections/timing_points.h +101 -0
  94. fosu-0.2.0/src/fosu/engine/third_party/fast_float.h +4443 -0
  95. fosu-0.2.0/src/fosu/engine/third_party/fast_float.md +13 -0
  96. fosu-0.2.0/src/fosu/engine/timing_points/beat_length.h +20 -0
  97. fosu-0.2.0/src/fosu/engine/timing_points/point.h +265 -0
  98. fosu-0.2.0/src/fosu/enums.h +23 -0
  99. fosu-0.2.0/src/fosu/io.h +257 -0
  100. fosu-0.2.0/src/fosu/legacy_rules.h +57 -0
  101. fosu-0.2.0/src/fosu/mods.h +112 -0
  102. fosu-0.2.0/src/fosu/os.h +65 -0
  103. fosu-0.2.0/src/fosu/parse_options.h +27 -0
  104. fosu-0.2.0/src/fosu/parser.h +384 -0
  105. fosu-0.2.0/src/fosu/result.h +59 -0
  106. fosu-0.2.0/src/fosu/runtime.cc +13 -0
  107. fosu-0.2.0/src/fosu/runtime.h +13 -0
  108. fosu-0.2.0/src/fosu/slider_event.h +17 -0
  109. fosu-0.2.0/src/fosu/slider_events.h +95 -0
  110. fosu-0.2.0/src/fosu/slider_geometry.h +605 -0
  111. fosu-0.2.0/src/fosu/slider_path.h +63 -0
  112. fosu-0.2.0/src/fosu/slider_timing.h +152 -0
  113. fosu-0.2.0/src/fosu/stacking.h +154 -0
  114. fosu-0.2.0/tests/fixtures/official/.gitignore +1 -0
  115. fosu-0.2.0/tests/fuzz_parser.cc +34 -0
  116. fosu-0.2.0/tests/parser.dict +15 -0
  117. fosu-0.2.0/tests/reference/native.cc +31 -0
  118. fosu-0.2.0/tests/reference/numeric.cc +67 -0
  119. fosu-0.2.0/tests/reference/official/OfficialReference.csproj +15 -0
  120. fosu-0.2.0/tests/reference/official/Program.cs +102 -0
  121. fosu-0.2.0/tests/reference/official/README.md +59 -0
  122. fosu-0.2.0/tests/reference/official/RawFields.cs +306 -0
  123. fosu-0.2.0/tests/reference/official/build.sh +20 -0
  124. fosu-0.2.0/tests/reference/scalar_engine.cc +10 -0
  125. fosu-0.2.0/tests/support/canonical_dump.h +207 -0
  126. fosu-0.2.0/tests/support/decode.py +145 -0
  127. fosu-0.2.0/tests/support/equality.h +9 -0
  128. fosu-0.2.0/tests/support/scalar_engine.h +11 -0
  129. fosu-0.2.0/tests/support/test.h +47 -0
  130. fosu-0.2.0/tests/test_binary_hardening.py +50 -0
  131. fosu-0.2.0/tests/test_build.py +86 -0
  132. fosu-0.2.0/tests/test_dispatch.cc +81 -0
  133. fosu-0.2.0/tests/test_hardening.cc +161 -0
  134. fosu-0.2.0/tests/test_hitobject_fields.cc +174 -0
  135. fosu-0.2.0/tests/test_library_exports.py +20 -0
  136. fosu-0.2.0/tests/test_numeric.cc +350 -0
  137. fosu-0.2.0/tests/test_official.py +321 -0
  138. fosu-0.2.0/tests/test_official_values.py +177 -0
  139. fosu-0.2.0/tests/test_python.py +972 -0
  140. fosu-0.2.0/tests/test_sections.cc +841 -0
  141. fosu-0.2.0/tests/test_storage.cc +471 -0
  142. fosu-0.2.0/tests/test_string_lookup.cc +39 -0
  143. fosu-0.2.0/tests/typing/python_api.py +58 -0
  144. fosu-0.2.0/tests/validate_corpus.cc +69 -0
  145. fosu-0.2.0/tests/verify_python.py +127 -0
  146. fosu-0.2.0/tests/verify_stream.py +100 -0
@@ -0,0 +1,3 @@
1
+ BasedOnStyle: Chromium
2
+ AllowShortLambdasOnASingleLine: Empty
3
+ ColumnLimit: 90
@@ -0,0 +1,2 @@
1
+ # Apply the repository's clang-format style (#32).
2
+ 785a565f667a082ad8df18d8b5cb0ec0baf3d407
@@ -0,0 +1,24 @@
1
+ name: Code quality
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [master]
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ format:
14
+ runs-on: ubuntu-24.04
15
+ steps:
16
+ - uses: actions/checkout@v6
17
+ with:
18
+ persist-credentials: false
19
+ - uses: actions/setup-python@v6
20
+ with:
21
+ python-version: '3.12'
22
+ - run: python -m pip install pre-commit==4.6.0
23
+ - name: Check formatting and Python types
24
+ run: pre-commit run --all-files --show-diff-on-failure
@@ -0,0 +1,120 @@
1
+ name: Native parser checks
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [master]
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ native:
14
+ runs-on: ubuntu-24.04
15
+ steps:
16
+ - uses: actions/checkout@v6
17
+ with:
18
+ persist-credentials: false
19
+ - run: cmake -S . -B build/native -G Ninja -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc
20
+ - run: cmake --build build/native --target check bench-build references -j"$(nproc)"
21
+ - run: python3 tests/test_build.py build/native
22
+ - name: Exercise benchmark and corpus tools
23
+ run: |
24
+ python3 -m unittest discover -s bench/comparison -p 'test_*.py'
25
+ build/native/generate_corpus build/smoke-corpus
26
+ build/native/library_compare build/smoke-corpus 2 build/native/library_native.so build/native/library_native.so > build/library.csv
27
+ python3 bench/summarize.py build/library.csv
28
+ build/native/validate_corpus build/smoke-corpus build/native/numeric_oracle.so
29
+
30
+ native-configurations:
31
+ runs-on: ubuntu-24.04
32
+ steps:
33
+ - uses: actions/checkout@v6
34
+ with:
35
+ persist-credentials: false
36
+ - name: Check scalar and debug builds
37
+ run: |
38
+ cmake -S . -B build/scalar -G Ninja -DFOSU_ISA=scalar -DCMAKE_CXX_COMPILER=g++
39
+ cmake --build build/scalar --target check -j"$(nproc)"
40
+ cmake -S . -B build/debug -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=g++
41
+ cmake --build build/debug --target test-binaries -j"$(nproc)"
42
+ ctest --test-dir build/debug -L parser --output-on-failure
43
+
44
+ native-emulation:
45
+ runs-on: ubuntu-24.04
46
+ steps:
47
+ - uses: actions/checkout@v6
48
+ with:
49
+ persist-credentials: false
50
+ - name: Check dispatch without AVX
51
+ run: |
52
+ sudo apt-get update -qq
53
+ sudo apt-get install -y qemu-user g++-aarch64-linux-gnu
54
+ cmake -S . -B build/native -G Ninja -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc
55
+ cmake --build build/native --target test_dispatch -j"$(nproc)"
56
+ qemu-x86_64 -cpu Nehalem build/native/test_dispatch auto
57
+ qemu-x86_64 -cpu Nehalem build/native/test_dispatch avx2
58
+ - name: Check Linux AArch64 dispatch and parsing
59
+ run: |
60
+ cmake -S . -B build/arm64 -G Ninja \
61
+ -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 \
62
+ -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
63
+ -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
64
+ '-DCMAKE_CROSSCOMPILING_EMULATOR=qemu-aarch64;-L;/usr/aarch64-linux-gnu'
65
+ cmake --build build/arm64 --target test-binaries -j"$(nproc)"
66
+ ctest --test-dir build/arm64 --output-on-failure -R '^(numeric|sections|hitobject_fields|storage|hardening|binary_hardening|dispatch_.*)$'
67
+
68
+ native-sanitizers:
69
+ runs-on: ubuntu-24.04
70
+ steps:
71
+ - uses: actions/checkout@v6
72
+ with:
73
+ persist-credentials: false
74
+ - name: Sanitizers and fuzzing
75
+ run: |
76
+ cmake -S . -B build/sanitize -G Ninja -DFOSU_SANITIZE=ON -DCMAKE_CXX_COMPILER=clang++
77
+ cmake --build build/sanitize --target check fuzz-smoke -j"$(nproc)"
78
+
79
+ native-macos:
80
+ runs-on: macos-26
81
+ steps:
82
+ - uses: actions/checkout@v6
83
+ with:
84
+ persist-credentials: false
85
+ - run: cmake -S . -B build/native -G Ninja
86
+ - run: cmake --build build/native --target check bench-build references -j3
87
+ - run: python3 tests/test_build.py build/native
88
+ - run: cmake -S . -B build/sanitize -G Ninja -DFOSU_SANITIZE=ON
89
+ - run: cmake --build build/sanitize --target check -j3
90
+
91
+ native-windows:
92
+ runs-on: windows-2025
93
+ steps:
94
+ - uses: actions/checkout@v6
95
+ with:
96
+ persist-credentials: false
97
+ - run: cmake -S . -B build/native -G "Visual Studio 18 2026" -A x64
98
+ - run: cmake --build build/native --config Release --target check
99
+ - run: python tests/test_build.py build/native
100
+
101
+ official-acceptance:
102
+ runs-on: ubuntu-24.04
103
+ steps:
104
+ - uses: actions/checkout@v6
105
+ with:
106
+ persist-credentials: false
107
+ - uses: actions/setup-dotnet@v4
108
+ with:
109
+ dotnet-version: 8.0.x
110
+ - uses: actions/setup-python@v6
111
+ with:
112
+ python-version: '3.12'
113
+ - run: python -m pip install build
114
+ - run: python -m build --sdist --outdir dist
115
+ - run: python -m pip install dist/*.tar.gz
116
+ - run: sh tests/reference/official/build.sh
117
+ - run: python tests/test_official.py
118
+ - run: FOSU_BACKEND=scalar python tests/test_official.py
119
+ - run: python tests/test_official_values.py --corpus tests/fixtures/official --report /tmp/official-values.json
120
+ - run: FOSU_BACKEND=scalar python tests/test_official_values.py --corpus tests/fixtures/official --report /tmp/official-values-scalar.json
@@ -0,0 +1,137 @@
1
+ name: Python wheels
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [master]
7
+ release:
8
+ types: [published]
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ wheels:
16
+ name: Wheel / ${{ matrix.platform }}
17
+ runs-on: ${{ matrix.runner }}
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ include:
22
+ - runner: ubuntu-24.04
23
+ platform: linux-x86_64
24
+ - runner: ubuntu-24.04-arm
25
+ platform: linux-aarch64
26
+ - runner: macos-26
27
+ platform: macos-arm64
28
+ - runner: macos-26-intel
29
+ platform: macos-x86_64
30
+ - runner: windows-2025
31
+ platform: windows-x86_64
32
+ steps:
33
+ - uses: actions/checkout@v6
34
+ with:
35
+ persist-credentials: false
36
+ - uses: pypa/cibuildwheel@v4.2.1
37
+ env:
38
+ CIBW_ARCHS: native
39
+ - uses: actions/upload-artifact@v4
40
+ with:
41
+ name: fosu-wheel-${{ matrix.platform }}
42
+ path: wheelhouse/*.whl
43
+
44
+ installed:
45
+ name: Installed / ${{ matrix.platform }} / Python ${{ matrix.python }}
46
+ needs: wheels
47
+ runs-on: ${{ matrix.runner }}
48
+ strategy:
49
+ fail-fast: false
50
+ matrix:
51
+ include:
52
+ - runner: ubuntu-24.04
53
+ platform: linux-x86_64
54
+ python: '3.14'
55
+ - runner: ubuntu-24.04-arm
56
+ platform: linux-aarch64
57
+ python: '3.14'
58
+ - runner: macos-26
59
+ platform: macos-arm64
60
+ python: '3.14'
61
+ - runner: macos-26-intel
62
+ platform: macos-x86_64
63
+ python: '3.14'
64
+ - runner: windows-2025
65
+ platform: windows-x86_64
66
+ python: '3.14'
67
+ steps:
68
+ - uses: actions/checkout@v6
69
+ with:
70
+ persist-credentials: false
71
+ - uses: actions/setup-python@v6
72
+ with:
73
+ python-version: ${{ matrix.python }}
74
+ - uses: actions/download-artifact@v4
75
+ with:
76
+ name: fosu-wheel-${{ matrix.platform }}
77
+ path: wheelhouse
78
+ - run: python -m pip install pytest mypy==2.3.1
79
+ - run: python -m pip install --no-index --find-links wheelhouse fosu
80
+ - run: python -m pytest tests/test_python.py
81
+ - run: python -m pytest tests/test_python.py
82
+ env:
83
+ FOSU_BACKEND: scalar
84
+ - run: python tests/test_binary_hardening.py
85
+
86
+ source-install:
87
+ name: Source install / Unix Makefiles
88
+ runs-on: ubuntu-22.04
89
+ steps:
90
+ - uses: actions/checkout@v6
91
+ with:
92
+ persist-credentials: false
93
+ - uses: actions/setup-python@v6
94
+ with:
95
+ python-version: '3.12'
96
+ - run: CMAKE_GENERATOR="Unix Makefiles" python -m pip install '.[test]'
97
+ - run: python -m pytest tests/test_python.py
98
+
99
+ sdist:
100
+ name: Source distribution
101
+ if: github.event_name == 'release'
102
+ runs-on: ubuntu-24.04
103
+ steps:
104
+ - uses: actions/checkout@v6
105
+ with:
106
+ persist-credentials: false
107
+ - uses: actions/setup-python@v6
108
+ with:
109
+ python-version: '3.14'
110
+ - run: python -m pip install build
111
+ - run: python -m build --sdist
112
+ - uses: actions/upload-artifact@v4
113
+ with:
114
+ name: fosu-sdist
115
+ path: dist/*.tar.gz
116
+
117
+ publish:
118
+ name: Publish release artifacts
119
+ if: github.event_name == 'release'
120
+ needs: [wheels, sdist]
121
+ runs-on: ubuntu-24.04
122
+ environment:
123
+ name: pypi
124
+ url: https://pypi.org/p/fosu
125
+ permissions:
126
+ contents: write
127
+ id-token: write
128
+ steps:
129
+ - uses: actions/download-artifact@v4
130
+ with:
131
+ pattern: fosu-*
132
+ path: dist
133
+ merge-multiple: true
134
+ - run: gh release upload "${{ github.event.release.tag_name }}" dist/* --clobber --repo "$GITHUB_REPOSITORY"
135
+ env:
136
+ GH_TOKEN: ${{ github.token }}
137
+ - uses: pypa/gh-action-pypi-publish@release/v1
fosu-0.2.0/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ .vscode/
2
+ build/
3
+ __pycache__/
4
+ dist/
5
+ *.egg-info/
6
+ python/fosu/*.so
7
+ python/fosu/*.dylib
8
+ .pytest_cache/
9
+ .mypy_cache/
10
+ tests/reference/official/obj/
11
+ tests/reference/official/bin/
12
+ *.osu
@@ -0,0 +1,24 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.16.6
4
+ hooks:
5
+ - id: ruff-check
6
+ args: [--config=pyproject.toml]
7
+ types_or: [python, pyi]
8
+ - id: ruff-format
9
+ args: [--config=pyproject.toml]
10
+ types_or: [python, pyi]
11
+ - repo: https://github.com/pre-commit/mirrors-clang-format
12
+ rev: v22.1.8
13
+ hooks:
14
+ - id: clang-format
15
+ types_or: [c, c++]
16
+ exclude: ^src/fosu/engine/third_party/fast_float\.h$
17
+ - repo: https://github.com/pre-commit/mirrors-mypy
18
+ rev: v2.3.1
19
+ hooks:
20
+ - id: mypy
21
+ args: [--config-file=pyproject.toml]
22
+ pass_filenames: false
23
+ types: [file]
24
+ files: ^(python/|tests/typing/|pyproject\.toml$|\.pre-commit-config\.yaml$)
fosu-0.2.0/AGENTS.md ADDED
@@ -0,0 +1,60 @@
1
+ # Working on FOSU
2
+
3
+ FOSU is in active, pre-release development with no production consumers.
4
+ Interfaces may break. Optimize for useful code changes, not release-level polish.
5
+
6
+ ## Design and scope
7
+
8
+ - Prefer readable, domain-accurate code, explicit ownership, and simple inputs
9
+ and results. Favor returning parsed values over mutable output parameters
10
+ where practical. Near-zero-cost abstractions should earn their complexity.
11
+ - Change interfaces directly and update affected callers. Do not preserve aliases,
12
+ old formats, or speculative extension points unless explicitly requested.
13
+ - Before editing, define the question and briefly trace the affected implementation,
14
+ callers, tests, and build boundaries. Do not turn focused work into a repo audit.
15
+ - Preserve unrelated user changes. Do not add optional refinements while preparing
16
+ a passing change for merge; mention worthwhile follow-ups separately.
17
+
18
+ ## Verification proportional to the change
19
+
20
+ - During iteration, build the affected target and run focused tests.
21
+ - For internal parsing refactors, start with focused tests and the small all-mode
22
+ compatibility sample. Use broader official-parser/full-corpus checks for
23
+ meaningful acceptance, normalization, or representation changes once settled.
24
+ - Keep correctness tests, strict Python typing, and memory-safety checks. Arena,
25
+ lifetime, bounds, and SIMD-load changes warrant relevant sanitizer checks.
26
+ - Test the relevant platform first. Reserve cross-platform and installed-package
27
+ checks for settled candidates whose changed boundaries warrant them, or releases.
28
+ - Docs-only changes need a content/link review, not builds, wheel installs,
29
+ compatibility sweeps, or performance measurements.
30
+ - Reuse still-valid results. Re-run affected checks after fixes and report skipped
31
+ checks honestly; a sample is not proof of full compatibility.
32
+
33
+ ## Performance experiments
34
+
35
+ - Screen one hypothesis cheaply on the relevant CPU with the small representative
36
+ all-mode performance corpus. Keep pathological cases in correctness tests.
37
+ - Reject clear losers early. Use reversed-order runs, confirmation samples, the
38
+ second machine, and combinations only for promising candidates.
39
+ - Compare identical API boundaries, outputs, corpora, build settings, and hosts.
40
+ Separate native parsing from eager Python conversion. Build before timing and
41
+ avoid competing builds, tests, or benchmarks on the measurement host.
42
+ - Do not chase tiny uncertain wins indefinitely, especially if they add complexity.
43
+ Report uncertainty; cleaner code can be worth more than a marginal speedup.
44
+ - Preserve competitor benchmarks. Rerun and publish comparisons at meaningful
45
+ milestones or when requested, not after every internal optimization.
46
+ - Keep experimental binaries and raw reports in ignored build directories.
47
+ Rejected experiments need a concise finding, not permanent tooling or documents.
48
+
49
+ ## Documentation and tooling budget
50
+
51
+ - Maintain a short README, working usage examples, and important contracts and
52
+ limitations. Update docs only when needed to avoid misleading users or broken
53
+ instructions; do not synchronize implementation narratives after every refactor.
54
+ - Do not refresh public timing tables, expand API field inventories, or create
55
+ architecture/history documents as routine completion work. Clearly label stale
56
+ measurements; do not present them as current.
57
+ - Put experiment history and migration details in PR descriptions, not maintained
58
+ docs. Prefer deleting redundant prose to repeatedly updating it.
59
+ - Reuse existing tooling. Add automation only for demonstrated recurring friction;
60
+ prefer one small entry point over a framework or overlapping scripts.
@@ -0,0 +1,270 @@
1
+ cmake_minimum_required(VERSION 3.26)
2
+ # Native release builds retain assertions; tests also explicitly enable them.
3
+ # Python extension targets define NDEBUG independently.
4
+ if(NOT CMAKE_HOST_WIN32)
5
+ set(CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE STRING "Release C++ flags")
6
+ set(CMAKE_C_FLAGS_RELEASE "-O2" CACHE STRING "Release C flags")
7
+ set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug C++ flags")
8
+ endif()
9
+
10
+ project(fosu VERSION 0.2.0 LANGUAGES C CXX)
11
+ include(CTest)
12
+ include(GNUInstallDirs)
13
+
14
+ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
15
+ set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
16
+ endif()
17
+ set(CMAKE_CXX_STANDARD 20)
18
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
19
+ set(CMAKE_CXX_EXTENSIONS OFF)
20
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
21
+
22
+ set(FOSU_ISA auto CACHE STRING "Native targets: auto, scalar, avx2, neon")
23
+ set_property(CACHE FOSU_ISA PROPERTY STRINGS auto scalar avx2 neon)
24
+ option(FOSU_SANITIZE "Enable address, undefined and float-cast sanitizers" OFF)
25
+ option(FOSU_ARENA_TELEMETRY "Instrument arena use in the profiling driver" OFF)
26
+ set(_python OFF)
27
+ if(SKBUILD)
28
+ set(_python ON)
29
+ endif()
30
+ option(FOSU_BUILD_PYTHON "Build the CPython stable-ABI extension" ${_python})
31
+ set(_bundled OFF)
32
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT FOSU_SANITIZE AND NOT SKBUILD)
33
+ set(_bundled ON)
34
+ endif()
35
+ if(DEFINED ENV{FOSU_BUNDLE_RUNTIME})
36
+ set(_bundled "$ENV{FOSU_BUNDLE_RUNTIME}")
37
+ elseif(DEFINED ENV{CIBUILDWHEEL} AND "$ENV{CIBUILDWHEEL}" STREQUAL "1")
38
+ set(_bundled ON)
39
+ endif()
40
+ option(FOSU_BUNDLE_RUNTIME "Bundle the Linux C++ runtime" ${_bundled})
41
+ set(_processor "${CMAKE_SYSTEM_PROCESSOR}")
42
+ if(APPLE AND CMAKE_OSX_ARCHITECTURES)
43
+ set(_processor "${CMAKE_OSX_ARCHITECTURES}")
44
+ endif()
45
+ set(_x86 OFF)
46
+ if(_processor MATCHES "^(x86_64|AMD64|amd64)$")
47
+ set(_x86 ON)
48
+ endif()
49
+ set(_arm64 OFF)
50
+ if(_processor MATCHES "^(aarch64|arm64|ARM64)$")
51
+ set(_arm64 ON)
52
+ endif()
53
+ # Header-only tools select instructions at compile time; compiled products dispatch.
54
+ set(_header_isa "${FOSU_ISA}")
55
+ if(FOSU_ISA STREQUAL "auto")
56
+ if(_x86)
57
+ set(_header_isa avx2)
58
+ elseif(_arm64)
59
+ set(_header_isa neon)
60
+ else()
61
+ set(_header_isa scalar)
62
+ endif()
63
+ endif()
64
+ if(NOT FOSU_ISA MATCHES "^(auto|scalar|avx2|neon)$")
65
+ message(FATAL_ERROR "FOSU_ISA must be auto, scalar, avx2 or neon")
66
+ endif()
67
+ if(FOSU_ISA STREQUAL "avx2" AND NOT _x86)
68
+ message(FATAL_ERROR "AVX2 requires an x86-64 target; use a cross-compilation toolchain")
69
+ endif()
70
+ if(FOSU_ISA STREQUAL "neon" AND NOT _arm64)
71
+ message(FATAL_ERROR "NEON requires an AArch64 target")
72
+ endif()
73
+ if(NOT CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$")
74
+ message(FATAL_ERROR "fosu currently supports Linux, macOS and Windows")
75
+ endif()
76
+
77
+ add_library(fosu_headers INTERFACE)
78
+ add_library(fosu::headers ALIAS fosu_headers)
79
+ set_target_properties(fosu_headers PROPERTIES EXPORT_NAME headers)
80
+ target_include_directories(fosu_headers INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
81
+ target_compile_features(fosu_headers INTERFACE cxx_std_20)
82
+ target_sources(fosu_headers INTERFACE FILE_SET HEADERS BASE_DIRS src FILES
83
+ src/fosu/arena.h
84
+ src/fosu/beatmap.h
85
+ src/fosu/beatmap_header.h
86
+ src/fosu/compiler.h
87
+ src/fosu/enums.h
88
+ src/fosu/io.h
89
+ src/fosu/legacy_rules.h
90
+ src/fosu/mods.h
91
+ src/fosu/slider_geometry.h
92
+ src/fosu/slider_path.h
93
+ src/fosu/slider_event.h
94
+ src/fosu/slider_events.h
95
+ src/fosu/stacking.h
96
+ src/fosu/slider_timing.h
97
+ src/fosu/os.h
98
+ src/fosu/parse_options.h
99
+ src/fosu/parser.h
100
+ src/fosu/result.h
101
+ src/fosu/runtime.h
102
+ src/fosu/engine/hit_objects/common_fields.h
103
+ src/fosu/engine/hit_objects/object_types.h
104
+ src/fosu/engine/hit_objects/samples.h
105
+ src/fosu/engine/hit_objects/slider.h
106
+ src/fosu/engine/parse_document.h
107
+ src/fosu/engine/parsing/field_values.h
108
+ src/fosu/engine/parsing/key_value.h
109
+ src/fosu/engine/parsing/lines.h
110
+ src/fosu/engine/parsing/numbers.h
111
+ src/fosu/engine/parsing/sample_sets.h
112
+ src/fosu/engine/parsing/section_names.h
113
+ src/fosu/engine/parsing/string_lookup.h
114
+ src/fosu/engine/parsing_engine.h
115
+ src/fosu/engine/primitives/byte_scan.h
116
+ src/fosu/engine/primitives/digit_groups.h
117
+ src/fosu/engine/primitives/packed_digits.h
118
+ src/fosu/engine/primitives/vector_ops.h
119
+ src/fosu/engine/sections/colours.h
120
+ src/fosu/engine/sections/difficulty.h
121
+ src/fosu/engine/sections/editor.h
122
+ src/fosu/engine/sections/events.h
123
+ src/fosu/engine/sections/general.h
124
+ src/fosu/engine/sections/hit_objects.h
125
+ src/fosu/engine/sections/metadata.h
126
+ src/fosu/engine/sections/timing_points.h
127
+ src/fosu/engine/third_party/fast_float.h
128
+ src/fosu/engine/timing_points/beat_length.h
129
+ src/fosu/engine/timing_points/point.h
130
+ )
131
+
132
+ function(fosu_profile target)
133
+ if(NOT MSVC)
134
+ target_compile_definitions(${target} PRIVATE $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>)
135
+ endif()
136
+ if(FOSU_SANITIZE)
137
+ if(MSVC)
138
+ message(FATAL_ERROR "FOSU_SANITIZE requires Clang or GCC")
139
+ endif()
140
+ target_compile_options(${target} PRIVATE -O1 -g -fsanitize=address,undefined,float-cast-overflow -fno-sanitize-recover=all)
141
+ target_link_options(${target} PRIVATE -fsanitize=address,undefined,float-cast-overflow)
142
+ endif()
143
+ endfunction()
144
+
145
+ # Product policy stays here; the header-only target imposes no tuning flags.
146
+ include(cmake/Hardening.cmake)
147
+ function(fosu_configure target isa product)
148
+ target_link_libraries(${target} PRIVATE fosu_headers)
149
+ if(MSVC)
150
+ target_compile_options(${target} PRIVATE /W4)
151
+ else()
152
+ target_compile_options(${target} PRIVATE -Wall -Wextra)
153
+ endif()
154
+ if(isa STREQUAL "scalar")
155
+ target_compile_definitions(${target} PRIVATE FOSU_DISABLE_SIMD)
156
+ elseif(isa STREQUAL "avx2")
157
+ target_compile_definitions(${target} PRIVATE FOSU_COMPILE_AVX2)
158
+ endif()
159
+ if(_x86 AND isa STREQUAL "scalar" AND NOT MSVC)
160
+ target_compile_options(${target} PRIVATE -march=x86-64)
161
+ endif()
162
+ if(product STREQUAL "python")
163
+ if(MSVC)
164
+ target_compile_options(${target} PRIVATE /O2)
165
+ else()
166
+ target_compile_options(${target} PRIVATE -O3 -g0)
167
+ endif()
168
+ target_compile_definitions(${target} PRIVATE NDEBUG)
169
+ if(isa STREQUAL "avx2")
170
+ if(MSVC)
171
+ target_compile_options(${target} PRIVATE /arch:AVX2)
172
+ else()
173
+ target_compile_options(${target} PRIVATE -mavx2 -mbmi -mbmi2)
174
+ endif()
175
+ endif()
176
+ elseif(isa STREQUAL "avx2")
177
+ if(MSVC)
178
+ target_compile_options(${target} PRIVATE /arch:AVX2)
179
+ else()
180
+ target_compile_options(${target} PRIVATE -march=x86-64-v3)
181
+ endif()
182
+ endif()
183
+ if(WIN32 AND product STREQUAL "native")
184
+ target_compile_options(${target} PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/UNDEBUG,-UNDEBUG>)
185
+ endif()
186
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
187
+ if(isa STREQUAL "avx2" OR product STREQUAL "python")
188
+ target_compile_options(${target} PRIVATE -fno-plt)
189
+ endif()
190
+ endif()
191
+ fosu_harden(${target})
192
+ fosu_profile(${target})
193
+ endfunction()
194
+ function(fosu_runtime target)
195
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
196
+ if(FOSU_BUNDLE_RUNTIME)
197
+ target_link_options(${target} PRIVATE -static-libstdc++ -static-libgcc)
198
+ endif()
199
+ target_link_options(${target} PRIVATE -Wl,--exclude-libs,ALL)
200
+ endif()
201
+ endfunction()
202
+ function(fosu_executable target source)
203
+ add_executable(${target} EXCLUDE_FROM_ALL ${source})
204
+ fosu_configure(${target} "${_header_isa}" native)
205
+ endfunction()
206
+
207
+ # The core owns Parser lifetime and storage. ISA libraries execute the shared parser.
208
+ function(fosu_dispatch target product)
209
+ fosu_configure(${target} scalar "${product}")
210
+ target_sources(${target} PRIVATE src/fosu/engine/runtime/loader.cc)
211
+ target_link_libraries(${target} PRIVATE ${CMAKE_DL_LIBS})
212
+ target_compile_definitions(${target} PRIVATE
213
+ FOSU_DEFAULT_BACKEND="${FOSU_ISA}"
214
+ FOSU_ENGINE_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"
215
+ FOSU_MANAGED_ARENA_CLEANUP)
216
+ set_target_properties(${target} PROPERTIES
217
+ CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON)
218
+ set(variant "")
219
+ if(_x86 AND NOT FOSU_ISA STREQUAL "scalar")
220
+ set(variant avx2)
221
+ target_compile_definitions(${target} PRIVATE FOSU_HAS_AVX2)
222
+ elseif(_arm64 AND NOT FOSU_ISA STREQUAL "scalar")
223
+ set(variant neon)
224
+ target_compile_definitions(${target} PRIVATE FOSU_HAS_NEON)
225
+ endif()
226
+ if(variant)
227
+ set(engine fosu_${product}_${variant})
228
+ if(NOT TARGET ${engine})
229
+ add_library(${engine} SHARED src/fosu/engine/runtime/entry.cc)
230
+ fosu_configure(${engine} "${variant}" "${product}")
231
+ fosu_runtime(${engine})
232
+ set_target_properties(${engine} PROPERTIES
233
+ OUTPUT_NAME fosu_engine_${variant}
234
+ CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON)
235
+ if(product STREQUAL "python")
236
+ set_target_properties(${engine} PROPERTIES
237
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/python-engine")
238
+ install(TARGETS ${engine} LIBRARY DESTINATION fosu RUNTIME DESTINATION fosu)
239
+ else()
240
+ install(TARGETS ${engine}
241
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
242
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
243
+ endif()
244
+ endif()
245
+ add_dependencies(${target} ${engine})
246
+ endif()
247
+ endfunction()
248
+
249
+ if(NOT SKBUILD)
250
+ add_library(fosu SHARED src/fosu/runtime.cc)
251
+ add_library(fosu::fosu ALIAS fosu)
252
+ target_link_libraries(fosu PUBLIC fosu_headers)
253
+ target_compile_definitions(fosu PRIVATE FOSU_BUILDING_RUNTIME)
254
+ fosu_dispatch(fosu native)
255
+ fosu_runtime(fosu)
256
+ set_target_properties(fosu PROPERTIES CXX_VISIBILITY_PRESET hidden)
257
+ target_include_directories(fosu PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
258
+ install(TARGETS fosu fosu_headers EXPORT fosuTargets
259
+ FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
260
+ install(FILES src/fosu/engine/third_party/fast_float.md DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fosu/engine/third_party)
261
+ install(EXPORT fosuTargets NAMESPACE fosu:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fosu)
262
+ include(CMakePackageConfigHelpers)
263
+ configure_package_config_file(cmake/fosuConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/fosuConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fosu)
264
+ write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/fosuConfigVersion.cmake COMPATIBILITY SameMajorVersion)
265
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fosuConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/fosuConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/fosu)
266
+ include(cmake/Development.cmake)
267
+ endif()
268
+ if(FOSU_BUILD_PYTHON)
269
+ include(cmake/Python.cmake)
270
+ endif()