Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Niko committed Mar 10, 2023
2 parents a4c4335 + 6029e9a commit 4776bc3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
4 changes: 2 additions & 2 deletions psx-modding-toolchain/tools/mod-builder/compile_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def parse_line(self, line: str) -> None:
self.ignore = True
return

if (self.address != 0) and ((self.address < self.min_addr) or (self.address > self.max_addr)):
if (self.address != 0) and (self.address != -1) and ((self.address < self.min_addr) or (self.address > self.max_addr)):
error_print("\n[BuildList-py] ERROR: address specified is not in the [" + hex(self.min_addr) + ", " + hex(self.max_addr) + "] range.")
error_print("[BuildList-py] at line " + str(line_count[0]) + ": " + self.original_line + "\n")
self.ignore = True
Expand All @@ -141,7 +141,7 @@ def calculate_address_base(self, symbol: str, offset: int) -> int:
return addr + offset
if is_number(symbol):
return int(symbol, 0) + offset
error_print("\n[BuildList-py] ERROR: invalid address or symbol at line " + str(line_count[0]) + ": " + self.original_line + "\n")
error_print("\n[BuildList-py] ERROR: undefined symbol: " + symbol + " at line: " + str(line_count[0]) + ": " + self.original_line + "\n")
return -1

def get_output_name(self) -> str:
Expand Down
38 changes: 17 additions & 21 deletions psx-modding-toolchain/tools/mod-builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def __init__(self) -> None:
self.num_options = len(self.actions)
self.window_title = GAME_NAME + " - " + MOD_NAME
self.python = str()
self.compilation_dep = list()
self.update_title()

def update_title(self):
Expand Down Expand Up @@ -86,6 +85,8 @@ def get_options(self) -> int:
return request_user_input(first_option=1, last_option=self.num_options, intro_msg=intro_msg, error_msg=error_msg)

def compile(self) -> None:
if os.path.isfile(ABORT_PATH):
return # Abort ongoing compilation chain due to an error that occured
if not check_compile_list():
print("\n[Compile-py] ERROR: " + COMPILE_LIST + " not found.\n")
return
Expand All @@ -98,9 +99,6 @@ def compile(self) -> None:
# if the file was already compiled
if MOD_NAME in file.readline().split():
return
if os.path.isfile(ABORT_PATH):
# Abort ongoing compilation chain due to an error that occured
return
game_syms = Syms()
make = Makefile(game_syms.get_build_id(), game_syms.get_files())
dependencies = []
Expand All @@ -117,22 +115,28 @@ def compile(self) -> None:
intro_msg = "[Compile-py] Would you like to continue to compilation process?\n\n1 - Yes\n2 - No\n"
error_msg = "ERROR: Wrong option. Please type a number from 1-2.\n"
if request_user_input(first_option=1, last_option=2, intro_msg=intro_msg, error_msg=error_msg) == 2:
return
if root:
delete_file(RECURSIVE_COMP_PATH)
return
else:
with open(ABORT_PATH, "w") as _:
return

if make.build_makefile():
if make.make():
with open(RECURSIVE_COMP_PATH, "a") as file:
file.write(MOD_NAME + " ")
else:
print("Aborting ongoing compilations. Press enter to continue.")
print("[Compile-py] Aborting ongoing compilations. Please press enter to continue.")
input()
with open(ABORT_PATH, "w") as _:
pass
if root:
delete_file(RECURSIVE_COMP_PATH)
return
else:
with open(ABORT_PATH, "w") as _:
return
curr_dir = os.getcwd() + "/"
if root:
self.compilation_dep.clear()
for dep in dependencies:
if root:
self.compilation_dep.append(dep)
os.chdir(dep)
command = self.python + get_distance_to_file(False, CONFIG_FILE) + "../../tools/mod-builder/main.py 1 " + str(game_syms.version)
os.system(command)
Expand All @@ -142,22 +146,14 @@ def compile(self) -> None:
delete_file(ABORT_PATH)
self.update_title()

def clean_files(self) -> None:
def clean(self) -> None:
delete_directory(DEBUG_FOLDER)
delete_directory(BACKUP_FOLDER)
delete_directory(OUTPUT_FOLDER)
delete_directory(TEXTURES_OUTPUT_FOLDER)
for file in COMPILATION_RESIDUES:
delete_file(file)

def clean(self) -> None:
self.clean_files()
curr_dir = os.getcwd() + "/"
for dep in self.compilation_dep:
os.chdir(dep)
self.clean_files()
os.chdir(curr_dir)

def clean_pch(self) -> None:
clean_pch()

Expand Down

0 comments on commit 4776bc3

Please sign in to comment.