Compare commits
2 commits
03bfdd3d99
...
da339ce00a
| Author | SHA1 | Date | |
|---|---|---|---|
| da339ce00a | |||
| 2381421776 |
8 changed files with 105 additions and 1 deletions
26
.forgejo/workflows/test.yml
Normal file
26
.forgejo/workflows/test.yml
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
# See Notices.txt for copyright information
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: debian-12
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- run: |
|
||||||
|
scripts/check-copyright.sh
|
||||||
|
- run: |
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -qq python3-venv wget
|
||||||
|
# copy of https://files.openpower.foundation/s/9izgC5Rogi5Ywmm/download/OPF_PowerISA_v3.1C.pdf
|
||||||
|
wget -O OPF_PowerISA_v3.1C.pdf https://libre-chip.org/OPF_PowerISA_v3.1C.pdf
|
||||||
|
echo "56372d23ece7e9e2c1b381a639443982a3e16e38109df1c141d655b779b61fdb OPF_PowerISA_v3.1C.pdf" | sha256sum -c
|
||||||
|
python3 -m venv --upgrade-deps .venv
|
||||||
|
. .venv/bin/activate
|
||||||
|
pip install -e .
|
||||||
|
parse_powerisa_pdf OPF_PowerISA_v3.1C.pdf &> >(tee out.log | grep '^page ') || { tail -n1000 out.log; false; }
|
||||||
|
echo "expected output (not all instructions are decoded yet, change when the output is improved):"
|
||||||
|
echo "c0b4592cbd0a3e59b9b2931a6a75a3d87ebf23bf453e8587a1522dd157f15ee9 powerisa-instructions.xml" | sha256sum -c
|
||||||
|
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,6 +1,9 @@
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
# See Notices.txt for copyright information
|
||||||
/.venv
|
/.venv
|
||||||
/.vscode
|
/.vscode
|
||||||
*.egg-info
|
*.egg-info
|
||||||
__pycache__
|
__pycache__
|
||||||
*.log
|
*.log
|
||||||
/powerisa-instructions.xml
|
/powerisa-instructions.xml
|
||||||
|
/*.pdf
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
<!--
|
||||||
|
SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
See Notices.txt for copyright information
|
||||||
|
-->
|
||||||
parser for the OPF PowerISA 3.1C pdf to attempt to extract all instructions' pseudo-code including subscripts/superscripts and other formatting
|
parser for the OPF PowerISA 3.1C pdf to attempt to extract all instructions' pseudo-code including subscripts/superscripts and other formatting
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
# See Notices.txt for copyright information
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from collections.abc import Generator, Iterable, Iterator, Callable
|
from collections.abc import Generator, Iterable, Iterator, Callable
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
# See Notices.txt for copyright information
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import Callable, Generic, Iterable, Iterator, TypeVar
|
from typing import Callable, Generic, Iterable, Iterator, TypeVar
|
||||||
from math import frexp, isfinite, isnan, ldexp
|
from math import frexp, isfinite, isnan, ldexp
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
# See Notices.txt for copyright information
|
||||||
from collections import abc
|
from collections import abc
|
||||||
from typing import Callable, Generic, Iterable, Iterator, Protocol, TypeAlias, TypeVar, overload
|
from typing import Callable, Generic, Iterable, Iterator, Protocol, TypeAlias, TypeVar, overload
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
# See Notices.txt for copyright information
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools >= 61.0"]
|
requires = ["setuptools >= 61.0"]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
|
||||||
63
scripts/check-copyright.sh
Executable file
63
scripts/check-copyright.sh
Executable file
|
|
@ -0,0 +1,63 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
# See Notices.txt for copyright information
|
||||||
|
set -e
|
||||||
|
|
||||||
|
function fail()
|
||||||
|
{
|
||||||
|
local error="$1"
|
||||||
|
echo "error: $error" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function fail_file()
|
||||||
|
{
|
||||||
|
local file="$1" line="$2" error="$3"
|
||||||
|
fail "$file:$((line + 1)): $error"
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_file()
|
||||||
|
{
|
||||||
|
local file="$1" regexes=("${@:2}")
|
||||||
|
local lines
|
||||||
|
mapfile -t lines < "$file"
|
||||||
|
if (("${#lines[@]}" == 0)); then
|
||||||
|
return # empty file, no copyright needed
|
||||||
|
fi
|
||||||
|
local line
|
||||||
|
for line in "${!regexes[@]}"; do
|
||||||
|
eval '[[ "${lines[i]}" =~ '"${regexes[i]}"' ]]' ||
|
||||||
|
fail_file "$file" "$line" "doesn't match regex: ${regexes[i]}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
POUND_HEADER=('^"# SPDX-License-Identifier: LGPL-3.0-or-later"$' '^"# See Notices.txt for copyright information"$')
|
||||||
|
MD_HEADER=('^"<!--"$' '^"SPDX-License-Identifier: LGPL-3.0-or-later"$' '^"See Notices.txt for copyright information"$')
|
||||||
|
|
||||||
|
function main()
|
||||||
|
{
|
||||||
|
local IFS=$'\n'
|
||||||
|
[[ -z "$(git status --porcelain)" ]] || fail "git repo is dirty"
|
||||||
|
local file
|
||||||
|
for file in $(git ls-tree --name-only --full-tree -r HEAD); do
|
||||||
|
case "/$file" in
|
||||||
|
*/LICENSE.md|*/Notices.txt)
|
||||||
|
# copyright file
|
||||||
|
;;
|
||||||
|
/.forgejo/workflows/*.yml|*/.gitignore|*.toml|*.py)
|
||||||
|
check_file "$file" "${POUND_HEADER[@]}"
|
||||||
|
;;
|
||||||
|
*.md)
|
||||||
|
check_file "$file" "${MD_HEADER[@]}"
|
||||||
|
;;
|
||||||
|
*.sh)
|
||||||
|
check_file "$file" '^'\''#!'\' "${POUND_HEADER[@]}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
fail_file "$file" 0 "unimplemented file kind -- you need to add it to $0"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
Loading…
Add table
Add a link
Reference in a new issue