forked from 4z0t/SCFA-python-patcher
-
Notifications
You must be signed in to change notification settings - Fork 1
Pass patcher related options via config #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
4z0t
wants to merge
17
commits into
main
Choose a base branch
from
patcher-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+193
−113
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e5e60a5
add config support
4z0t 265f825
revert changes
4z0t f6d9d92
F
4z0t 670cfcf
pass args starting with second
4z0t 28d3b3f
add relative path support
4z0t 5466e6a
handle paths in run_system
4z0t 16e237c
make changes in test workflow
4z0t a20f44d
fix paths
4z0t 78a5709
reorder repo clones
4z0t f0cc0c0
remove redundant code
4z0t e919e7a
typo
4z0t 40e5368
properly handle shell commands
4z0t 251aab2
handle path separately
4z0t e1b26f2
pass value
4z0t fcc747b
f*ck shlex
4z0t 72d226a
use s_value
4z0t 05f4dc4
pain
4z0t File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 contains hidden or 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,58 @@ | ||
| { | ||
| "target_folder_path": "FA-Binary-Patches", | ||
| "input_name": "ForgedAlliance_base.exe", | ||
| "output_name": "ForgedAlliance_exxt.exe", | ||
| "clang": "clang++.exe", | ||
| "gcc": "g++.exe", | ||
| "linker": "ld.exe", | ||
| "clang_flags": [ | ||
| "-pipe", | ||
| "-m32", | ||
| "-O3", | ||
| "-nostdlib", | ||
| "-Werror", | ||
| "-masm=intel", | ||
| "-std=c++20", | ||
| "-march=core2" | ||
| ], | ||
| "gcc_flags": [ | ||
| "-pipe", | ||
| "-m32", | ||
| "-Os", | ||
| "-fno-exceptions", | ||
| "-nostdlib", | ||
| "-nostartfiles", | ||
| "-fpermissive", | ||
| "-masm=intel", | ||
| "-std=c++20", | ||
| "-march=core2", | ||
| "-mfpmath=both" | ||
| ], | ||
| "asm_flags": [ | ||
| "-pipe", | ||
| "-m32", | ||
| "-Os", | ||
| "-fno-exceptions", | ||
| "-nostdlib", | ||
| "-nostartfiles", | ||
| "-w", | ||
| "-fpermissive", | ||
| "-masm=intel", | ||
| "-std=c++20", | ||
| "-march=core2", | ||
| "-mfpmath=both" | ||
| ], | ||
| "functions": { | ||
| "_atexit": "0xA8211E", | ||
| "__Znwj": "0xA825B9", | ||
| "__ZdlPvj": "0x958C40", | ||
| "__imp__GetModuleHandleA@4": "0xC0F378", | ||
| "__imp__GetProcAddress@8": "0xC0F48C", | ||
| "___CxxFrameHandler3": "0xA8958C", | ||
| "___std_terminate": "0xA994FB", | ||
| "??_7type_info@@6B@": "0xD72A88", | ||
| "__CxxThrowException@8": "0x00A89950", | ||
| "_memset": "0xA89110", | ||
| "__invoke_watson": "0x00A848E8" | ||
| } | ||
| } |
This file contains hidden or 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 contains hidden or 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,70 @@ | ||
| import json | ||
| from pathlib import Path | ||
| from dataclasses import dataclass, field | ||
| from typing import Self | ||
|
|
||
|
|
||
| @dataclass | ||
| class Config: | ||
| path: Path | ||
| target_folder_path: Path | ||
| build_folder_path: Path | ||
| input_name: str = "ForgedAlliance_base.exe" | ||
| output_name: str = "ForgedAlliance_exxt.exe" | ||
|
|
||
| clang_path: Path = "clang++" | ||
| gcc_path: Path = "g++" | ||
| linker_path: Path = "ld" | ||
|
|
||
| clang_flags: tuple[str] = () | ||
| gcc_flags: tuple[str] = () | ||
| asm_flags: tuple[str] = () | ||
|
|
||
| functions: dict[str, str] = field(default_factory=dict) | ||
|
|
||
| @classmethod | ||
| def load_from_json(cls, path: Path) -> Self: | ||
| path = Path(path).resolve() | ||
| with open(path, 'r') as f: | ||
| config = json.load(f) | ||
|
|
||
| return cls( | ||
| path=path, | ||
| target_folder_path=config.get("target_folder_path", path.parent), | ||
| build_folder_path=config.get("build_folder_path"), | ||
| input_name=config.get("input_name", Config.input_name), | ||
| output_name=config.get("output_name", Config.output_name), | ||
| clang_path=config.get("clang", Config.clang_path), | ||
| gcc_path=config.get("gcc", Config.gcc_path), | ||
| linker_path=config.get("linker", Config.linker_path), | ||
| clang_flags=config.get("clang_flags", Config.clang_flags), | ||
| gcc_flags=config.get("gcc_flags", Config.gcc_flags), | ||
| asm_flags=config.get("asm_flags", Config.asm_flags), | ||
| functions=config.get("functions", {}), | ||
| ) | ||
|
|
||
| def __post_init__(self): | ||
| self.target_folder_path = Path(self.target_folder_path) | ||
|
|
||
| if not self.target_folder_path.is_absolute(): | ||
| self.target_folder_path = self.path.parent / self.target_folder_path | ||
|
|
||
| self.build_folder_path = Path(self.build_folder_path)\ | ||
| if self.build_folder_path \ | ||
| else self.target_folder_path / "build" | ||
|
|
||
| self.clang_path = Path(self.clang_path) | ||
| self.gcc_path = Path(self.gcc_path) | ||
| self.linker_path = Path(self.linker_path) | ||
|
|
||
| if not self.build_folder_path.is_absolute(): | ||
| raise ValueError( | ||
| "build_folder_path must be an absolute path to folder") | ||
4z0t marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @property | ||
| def input_path(self) -> Path: | ||
| return self.target_folder_path / self.input_name | ||
|
|
||
| @property | ||
| def output_path(self) -> Path: | ||
| return self.build_folder_path / self.output_name | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.