-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor auto-sync updater This refactors the auto-sync updater scripts, adds multiple tests and some other smaller things: - Converts the updater in a proper Python package. - Renaming was done to fit this new package structure. - Format code with usort and black and enforce it with the CI. - Add license information to auto-sync scripts. - Update tree-sitter-cpp to v20.0.5 - Fix py-tree-sitter version to `< 0.22.0` due to tree-sitter/tree-sitter-cpp#250 - Allow file/dir creation of non existing paths. - Add CI tests for Patch, inc gen, translation and diff persistence testing. - Implement editing of diffs with an editor. - Fix: Add Namespace id also to anonymous enumeration members.
- Loading branch information
Showing
104 changed files
with
2,395 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Auto-Sync | ||
on: | ||
push: | ||
paths: | ||
- "suite/auto-sync/**" | ||
pull_request: | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: suite/auto-sync/ | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Install auto-sync package | ||
run: | | ||
pip install . | ||
- name: Check formatting | ||
run: | | ||
python3.11 -m black --check src/autosync | ||
- name: Build llvm-tblgen | ||
run: | | ||
git clone https://github.com/capstone-engine/llvm-capstone.git vendor/llvm_root | ||
cd vendor/llvm_root | ||
mkdir build | ||
cd build | ||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug ../llvm | ||
cmake --build . --target llvm-tblgen --config Debug | ||
cd ../../../ | ||
- name: Test generation of inc files | ||
run: | | ||
./src/autosync/ASUpdater.py -d -a AArch64 -s IncGen | ||
./src/autosync/ASUpdater.py -d -a Alpha -s IncGen | ||
./src/autosync/ASUpdater.py -d -a ARM -s IncGen | ||
./src/autosync/ASUpdater.py -d -a PPC -s IncGen | ||
- name: CppTranslator - Patch tests | ||
run: | | ||
python -m unittest src/autosync/cpptranslator/Tests/test_patches.py | ||
- name: CppTranslator - Differ tests | ||
run: | | ||
python -m unittest src/autosync/cpptranslator/Tests/test_differ.py | ||
- name: CppTranslator - Test translation | ||
run: | | ||
./src/autosync/ASUpdater.py --ci -d -a AArch64 -s Translate | ||
./src/autosync/ASUpdater.py --ci -d -a ARM -s Translate | ||
./src/autosync/ASUpdater.py --ci -d -a PPC -s Translate | ||
- name: Test Header patcher | ||
run: | | ||
python -m unittest src/autosync/Tests/test_header_patcher.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,3 +143,6 @@ android-ndk-* | |
|
||
# python virtual env | ||
.venv/ | ||
|
||
# Auto-sync files | ||
suite/auto-sync/src/autosync.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
Upstream-Name: CapstoneEngine | ||
Source: https://github.com/capstone-engine/capstone | ||
|
||
Files: src/autosync/cpptranslator/Tests/test_config.json | ||
Copyright: 2022 Rot127 <[email protected]> | ||
License: BSD-3 | ||
|
||
Files: src/autosync/cpptranslator/arch_config.json | ||
Copyright: 2022 Rot127 <[email protected]> | ||
License: BSD-3 | ||
|
||
Files: src/autosync/cpptranslator/saved_patches.json | ||
Copyright: 2022 Rot127 <[email protected]> | ||
License: BSD-3 | ||
|
||
Files: src/autosync/path_vars.json | ||
Copyright: 2022 Rot127 <[email protected]> | ||
License: BSD-3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% for copyright_line in copyright_lines %} | ||
{{ copyright_line }} | ||
{% endfor %} | ||
{% for contributor_line in contributor_lines %} | ||
SPDX-FileContributor: {{ contributor_line }} | ||
{% endfor %} | ||
{% for expression in spdx_expressions %} | ||
SPDX-License-Identifier: {{ expression }} | ||
{% endfor %} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Copyright (c) <year> <owner>. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
build/ | ||
vendor/llvm_root | ||
*/.idea | ||
Updater/config.json | ||
src/auto-sync/config.json | ||
src/autosync/cpptranslator/Tests/Differ/test_saved_patches.json | ||
src/autosync.egg-info | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
<!-- | ||
Copyright © 2022 Rot127 <[email protected]> | ||
Copyright © 2024 2022 Rot127 <[email protected]> | ||
SPDX-License-Identifier: BSD-3 | ||
--> | ||
|
||
# Architecture updater | ||
|
||
This is Capstones updater for some architectures. | ||
Unfortunately not all architectures are supported yet. | ||
|
||
## Install dependencies | ||
|
||
Install clang-format | ||
|
||
``` | ||
sudo apt install clang-format-18 | ||
``` | ||
|
||
Setup Python environment and Tree-sitter | ||
|
||
``` | ||
|
@@ -20,28 +20,28 @@ sudo apt install python3-venv | |
# Setup virtual environment in Capstone root dir | ||
python3 -m venv ./.venv | ||
source ./.venv/bin/activate | ||
pip3 install -r dev_requirements.txt | ||
``` | ||
|
||
Clone C++ grammar | ||
|
||
``` | ||
cd suite/auto-sync/ | ||
git submodule update --init --recursive ./vendor/ | ||
pip install -e . | ||
``` | ||
|
||
## Update | ||
|
||
Check if your architecture is supported. | ||
|
||
``` | ||
./Updater/ASUpdater.py -h | ||
./src/autosync/ASUpdater.py -h | ||
``` | ||
|
||
Clone Capstones LLVM fork and build `llvm-tblgen` | ||
|
||
``` | ||
git clone https://github.com/capstone-engine/llvm-capstone | ||
git clone https://github.com/capstone-engine/llvm-capstone vendor/llvm_root/ | ||
cd llvm-capstone | ||
git checkout auto-sync | ||
mkdir build | ||
|
@@ -55,7 +55,7 @@ cd ../../ | |
Run the updater | ||
|
||
``` | ||
./Updater/ASUpdater.py -a <ARCH> | ||
./src/autosync/ASUpdater.py -a <ARCH> | ||
``` | ||
|
||
## Post-processing steps | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/bash | ||
|
||
python3.11 -m usort format src/autosync | ||
python3.11 -m black src/autosync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright © 2022 Rot127 <[email protected]> | ||
# Copyright © 2024 2022 Rot127 <[email protected]> | ||
# SPDX-License-Identifier: BSD-3 | ||
|
||
[project] | ||
name = "autosync" | ||
version = "0.1.0" | ||
dependencies = [ | ||
"termcolor >= 2.3.0", | ||
"tree_sitter < 0.22.0", | ||
"black >= 24.3.0", | ||
"usort >= 1.0.8", | ||
"setuptools >= 69.2.0", | ||
"ninja >= 1.11.1.1", | ||
"cmake >= 3.28.3", | ||
"reuse >= 3.0.1", | ||
"clang-format >= 18.1.1", | ||
] | ||
requires-python = ">= 3.11" | ||
|
||
[tool.setuptools] | ||
packages = ["autosync", "autosync.cpptranslator", "autosync.cpptranslator.patches"] | ||
package-dir = {"" = "src"} |
Oops, something went wrong.