Files
Diddy-Kong-Racing/tools/python/gcc_generate.py
Ryan Myers 6db9a8d6ea Splat merge (#470)
* First pass

* Fix n64crc and add submodules properly

* Fix other versions

* Match func_8005B818 for v80 code.

* Formatting

* Fix build for JPN in last commit. Still broken in post v77 roms though.

* Fix builds for other versions.

* Match load_menu_text for other versions.

* Fix progress script

* update m2c

* Modify asset tools to remove the LD script code.

* Fix asm file macro inclue

* Get a working splat version for us_1.0 to build from the assets tool.

* update asm differ

* Update tools again

* Fix the makefile to only compile assets when requested. This will build all versions successfully, and compile assets for us_1.0 when requested.

* First round of suggestions

* Small cleanup

* Fix the gcc_generate.py path.

* Make entrypointThreadStack

* Small addition to the last commit

* "Fix" score script. Still need to fix the score values themselves, but at least it runs and is kind of close.

* Much closer matching score script

* Fix the splat version due to a breaking change in 0.33.0 for this repo for now.

* Fix the main function name

* Add gitignore entries

* Fix the padding problem to be handled by objcopy instead of a binary pad from splat.

* Update the README and change dependencies to setup.

* Have a hasm header that can be tweaked.

* Still calculate the checksum on no_verify builds or they won't work.

* Add support for boot_custom.bin

* Fix custom boot ld code.

* Fix score script

* Fix gcc building.

* Update m2c

* Fix warning, stop ignoring mod assets, and add some handy make rules.

* Uggh, serves me right for not testing.

* First stab at modifiable entrypoint.

* Fix typo, and small README change

* Stop n64crd from defaulting to returning 6105, so we can properly fail if the CIC checksum fails. Also, fix the

* Extract custom boot script

* Update automated scripts.

* Woops, fixed the MAXCONTROLLERS thing now.

* Add the method for building binutils back. Sorry!

* Only use -m32 when the longbit says we're on a 64 bit platform.

* Woops....

* Hopefully fix arm detection for raspi ido downloads.
2025-03-25 09:07:00 -04:00

73 lines
2.4 KiB
Python

#!/usr/bin/python3
# Complete file list producer v0.7
# Written by ProjectRevoTPP
import os
from glob import glob
from itertools import chain
import sys
def holecount(file):
with open(file, 'r', encoding = 'utf-8') as infile:
contents = infile.readlines()
asm_count = 0
for i, line in enumerate(contents):
if(line.count("GLOBAL_ASM") > 0 and (i + 1 == len(contents) or contents[i+1].count("#endif") == 0)):
asm_count += 1
return asm_count
def noncount(file):
with open(file, 'r', encoding = 'utf-8') as infile:
contents = infile.readlines()
noncount = 0
for i, line in enumerate(contents):
if(line.count("NON_") > 0):
noncount += 1
return noncount
def holecount_all(src):
for subdir, dirs, files in os.walk(src):
for filename in files:
filepath = subdir + os.sep + filename
if(not filename.endswith('.c')):
continue
holes = holecount(filepath)
nonmatches = noncount(filepath)
if(holes > 0 and nonmatches > 0):
print(filename, holes, nonmatches)
return 1
paths = ('src', 'libultra')
# get file encoding type
def get_encoding_type(file):
with open(file, 'rb') as f:
rawdata = f.read()
return detect(rawdata)['encoding']
outfile = open(sys.argv[1], "w")
outfile.write("# This file is auto-generated. DO NOT MODIFY!\n\n")
outfile.write("GCC_SAFE_FILES := \\\n")
for directory in chain.from_iterable(os.walk(path) for path in paths):
for filename in glob(os.path.join(directory[0], "*.c")):
infile = open(filename, "r", encoding="ascii", errors="surrogateescape")
# Open content.
contents = infile.read()
# Set the counts.
nonm_count = contents.count("NON_MATCHING")
noneq_count = contents.count("NON_EQUIVALENT")
global_asm_count = contents.count("GLOBAL_ASM")
if nonm_count > 0:
print(filename + ": " + str(nonm_count))
if noneq_count > 0:
print(filename + ": " + str(noneq_count))
if global_asm_count > 0:
print(filename + ": " + str(global_asm_count))
# NOTE: As of now there is no distinction between unattempted files and unfinished ones.
if (nonm_count + noneq_count + global_asm_count) == 0 :
outfile.write(" $(BUILD_DIR)/")
outfile.write(os.path.splitext(filename)[0])
outfile.write(".c.o \\\n")
infile.close()
outfile.close()