Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3862354
Set tree-sitter-cpp to v20.0.5 tag.
Rot127 Mar 21, 2024
c4250ac
Fix Python TS bindings to <0.22.0.
Rot127 Mar 21, 2024
1939cfe
Restructure auto-sync scripts to allow packaging.
Rot127 Mar 21, 2024
6db4e94
Add formatting check to CI
Rot127 Mar 21, 2024
40a060a
Run ufmt
Rot127 Mar 21, 2024
28d17d0
Manually run Py formatting workflow
Rot127 Mar 21, 2024
452d3c0
Add Patch tests to workflow
Rot127 Mar 21, 2024
cf34ceb
Replace ufmt with simple usort and black chaining.
Rot127 Mar 21, 2024
e1fef6a
Remove usort check because it differs locally to Github although same…
Rot127 Mar 21, 2024
34933ae
Move requirements for AS into pyproject.toml
Rot127 Mar 21, 2024
b9b6f47
Update README.md
Rot127 Mar 21, 2024
c674c6a
Add tests for inc generation.
Rot127 Mar 21, 2024
d0fc56c
Add clang-format to pypackage dependencies.
Rot127 Mar 21, 2024
56bb737
Use https to clone, not ssh
Rot127 Mar 21, 2024
a5516f8
Rename HelerMethods -> Helper
Rot127 Mar 21, 2024
6ebfc7b
Make patches directory a submodule for pip install .
Rot127 Mar 21, 2024
e9118a0
Move llvm clone to vendor dir.
Rot127 Mar 21, 2024
e0c930f
Fix path issues (dirs no created automatically etc.)
Rot127 Mar 21, 2024
e359e88
Add license info to auto-sync
Rot127 Mar 21, 2024
aaece20
Properly implement all Patch tests.
Rot127 Mar 22, 2024
02f21ae
Extract method to test patching result.
Rot127 Mar 22, 2024
da8d895
Import classes directly into test file
Rot127 Mar 22, 2024
5544e71
Let Github checkout action download the tree-sitter submodule
Rot127 Mar 22, 2024
ba08e5b
Fixup .reuse dir
Rot127 Mar 22, 2024
aeb66e9
Fix sdist build by moving all license to LICENSES/
Rot127 Mar 22, 2024
d1f4b5d
Add printVectorIndex to templateswith argument deduction.
Rot127 Mar 22, 2024
e3441e5
Formatting of config files
Rot127 Mar 22, 2024
f26fe3a
Allow to fix none typedefed enums.
Rot127 Mar 22, 2024
190d5d2
Add test for full translation to AS workflow.
Rot127 Mar 22, 2024
a95071b
Typo and better names
Rot127 Mar 22, 2024
b1e5dad
Don't delete generated files for later translation
Rot127 Mar 22, 2024
4423b87
Delete present files before moving
Rot127 Mar 22, 2024
fcee187
Replace deprecated call.
Rot127 Mar 22, 2024
d84ccd2
Fix CI
Rot127 Mar 22, 2024
a69bc94
Replace LGPL-3 with BSD-3
Rot127 Mar 23, 2024
e9caca7
Add tests for header patcher.
Rot127 Mar 23, 2024
4176765
Some cleanups in the Differ.
Rot127 Mar 23, 2024
a0bf99b
Add basic tests for Differ persistence.
Rot127 Mar 23, 2024
eb0cf5a
Implement editing of diffs with an editor.
Rot127 Mar 23, 2024
2489fc0
Move Patch test files into own directory
Rot127 Mar 23, 2024
5051f53
Create paths if allowed by the Path handler.
Rot127 Mar 25, 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
66 changes: 66 additions & 0 deletions .github/workflows/auto-sync.yml
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,6 @@ android-ndk-*

# python virtual env
.venv/

# Auto-sync files
suite/auto-sync/src/autosync.egg-info
20 changes: 20 additions & 0 deletions .reuse/dep5
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 <unisono@quyllur.org>
License: BSD-3

Files: src/autosync/cpptranslator/arch_config.json
Copyright: 2022 Rot127 <unisono@quyllur.org>
License: BSD-3

Files: src/autosync/cpptranslator/saved_patches.json
Copyright: 2022 Rot127 <unisono@quyllur.org>
License: BSD-3

Files: src/autosync/path_vars.json
Copyright: 2022 Rot127 <unisono@quyllur.org>
License: BSD-3

9 changes: 9 additions & 0 deletions .reuse/templates/license-template.jinja2
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.
11 changes: 11 additions & 0 deletions LICENSES/LICENSE_BSD_3_CLAUSE.txt
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.
2 changes: 1 addition & 1 deletion bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def copy_sources():
src.extend(glob.glob(os.path.join(BUILD_DIR, "*.mk")))

src.extend(glob.glob(os.path.join(BUILD_DIR, "Makefile")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "LICENSE*")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "LICENSES/*")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "README")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "*.TXT")))
src.extend(glob.glob(os.path.join(BUILD_DIR, "RELEASE_NOTES")))
Expand Down
4 changes: 0 additions & 4 deletions dev_requirements.txt

This file was deleted.

4 changes: 3 additions & 1 deletion suite/auto-sync/.gitignore
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

20 changes: 10 additions & 10 deletions suite/auto-sync/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<!--
Copyright © 2022 Rot127 <unisono@quyllur.org>
Copyright © 2024 2022 Rot127 <unisono@quyllur.org>
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

```
Expand All @@ -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
Expand All @@ -55,7 +55,7 @@ cd ../../
Run the updater

```
./Updater/ASUpdater.py -a <ARCH>
./src/autosync/ASUpdater.py -a <ARCH>
```

## Post-processing steps
Expand Down
2 changes: 0 additions & 2 deletions suite/auto-sync/Updater/.gitignore

This file was deleted.

67 changes: 0 additions & 67 deletions suite/auto-sync/Updater/PathVarHandler.py

This file was deleted.

7 changes: 0 additions & 7 deletions suite/auto-sync/Updater/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions suite/auto-sync/Updater/path_vars.json

This file was deleted.

2 changes: 0 additions & 2 deletions suite/auto-sync/Updater/requirements.txt

This file was deleted.

4 changes: 4 additions & 0 deletions suite/auto-sync/format_py.sh
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
23 changes: 23 additions & 0 deletions suite/auto-sync/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright © 2022 Rot127 <unisono@quyllur.org>
# Copyright © 2024 2022 Rot127 <unisono@quyllur.org>
# 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"}
Loading