summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-09-24 18:44:30 +0200
committerGitHub <noreply@github.com>2020-09-24 18:44:30 +0200
commit645ff23cb27ddafac613c17871d85b71ac8fbdbd (patch)
tree3a15608c8f9fdd8ceba464aea0322382416bf0fd
parent218a8da8ba4a10c702a5ca8c03af935f17116938 (diff)
parentfd90123f88595c725491a715de6343df436b7e36 (diff)
Merge pull request #5 from leoetlino/check-matchings
ci: Check matching functions for each push and PR build
-rw-r--r--.github/workflows/build.yml6
-rw-r--r--.github/workflows/check.yml27
-rw-r--r--src/KingSystem/ActorSystem/actTag.h2
-rw-r--r--src/KingSystem/Utils/Thread/Event.h2
-rwxr-xr-xtools/check.py11
-rw-r--r--tools/utils.py6
6 files changed, 48 insertions, 6 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 01319abf..61c2f182 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -25,3 +25,9 @@ jobs:
working-directory: ./build
- name: Build
run: ninja -C build
+ - uses: actions/upload-artifact@v2
+ with:
+ name: build
+ path: |
+ build/uking
+ data/uking_functions.csv
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
new file mode 100644
index 00000000..d6729aff
--- /dev/null
+++ b/.github/workflows/check.yml
@@ -0,0 +1,27 @@
+name: check
+on:
+ workflow_run:
+ workflows: ["build"]
+ types:
+ - completed
+jobs:
+ check-matchings:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: haya14busa/action-workflow_run-status@967ed83efa565c257675ed70cfe5231f062ddd94
+ - uses: actions/checkout@v2
+ - run: git submodule update --init --recursive
+ - name: Install pip
+ run: sudo apt update && sudo apt install -y python3-pip
+ - name: Install tool dependencies
+ run: sudo python3 -m pip install capstone colorama cxxfilt pyelftools gpg wget
+ - name: Download executable
+ run: wget https://static.zeldamods.org/botw/16A91992BBA71201E98756F3BC8F5D2F.elf.gpg
+ - name: Decrypt executable
+ run: gpg --quiet --batch --yes --decrypt --passphrase="${{ secrets.leo_secret }}" --output data/main.elf 16A91992BBA71201E98756F3BC8F5D2F.elf.gpg
+ - name: Download artifacts
+ uses: dawidd6/action-download-artifact@3cd20b2b63293848b29e22223f515baf725ed98f
+ with:
+ workflow: build.yml
+ - name: Check matchings
+ run: tools/check.py
diff --git a/src/KingSystem/ActorSystem/actTag.h b/src/KingSystem/ActorSystem/actTag.h
index 23990488..7581ecaf 100644
--- a/src/KingSystem/ActorSystem/actTag.h
+++ b/src/KingSystem/ActorSystem/actTag.h
@@ -27,7 +27,7 @@ private:
u32 mHash;
};
-#define KSYS_ACT_DEFINE_TAG(NAME) inline constexpr Tag NAME{#NAME}
+#define KSYS_ACT_DEFINE_TAG(NAME) inline constexpr Tag NAME(#NAME)
namespace tags {
diff --git a/src/KingSystem/Utils/Thread/Event.h b/src/KingSystem/Utils/Thread/Event.h
index e8400708..7c59c339 100644
--- a/src/KingSystem/Utils/Thread/Event.h
+++ b/src/KingSystem/Utils/Thread/Event.h
@@ -1,8 +1,8 @@
#pragma once
+#include <thread/seadAtomic.h>
#include <thread/seadEvent.h>
#include "KingSystem/Utils/Types.h"
-#include <thread/seadAtomic.h>
namespace ksys::util {
diff --git a/tools/check.py b/tools/check.py
index 15648727..9732dcf9 100755
--- a/tools/check.py
+++ b/tools/check.py
@@ -4,6 +4,7 @@ import capstone as cs
from elftools.elf.elffile import ELFFile
import diff_settings
from pathlib import Path
+import sys
from typing import Any, Dict, Set
import utils
@@ -49,7 +50,7 @@ def check_function(addr: int, size: int, name: str) -> bool:
try:
base_fn = get_fn_from_base_elf(addr, size)
except KeyError:
- utils.fail(f"couldn't find base function 0x{addr:016x} for {name}")
+ utils.print_error(f"couldn't find base function 0x{addr:016x} for {name}")
return False
try:
@@ -127,14 +128,18 @@ def check_function(addr: int, size: int, name: str) -> bool:
def main() -> None:
+ failed = False
for func in utils.get_functions():
if not func.decomp_name:
continue
if func.status == utils.FunctionStatus.Matching:
if not check_function(func.addr, func.size, func.decomp_name):
- utils.fail(f"{func.decomp_name} was marked as matching but does not match")
- return
+ utils.print_error(f"{func.decomp_name} was marked as matching but does not match")
+ failed = True
+
+ if failed:
+ sys.exit(1)
if __name__ == "__main__":
diff --git a/tools/utils.py b/tools/utils.py
index a6463d2c..ab544aab 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -68,6 +68,10 @@ def warn(msg: str):
sys.stderr.write(f"{Fore.MAGENTA}{Style.BRIGHT}warning:{Fore.RESET} {msg}{Style.RESET_ALL}\n")
-def fail(msg: str):
+def print_error(msg: str):
sys.stderr.write(f"{Fore.RED}{Style.BRIGHT}error:{Fore.RESET} {msg}{Style.RESET_ALL}\n")
+
+
+def fail(msg: str):
+ print_error(msg)
sys.exit(1)