Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mwccgap.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def main() -> None:
parser.add_argument("--as-path", type=Path, default=Path("mipsel-linux-gnu-as"))
parser.add_argument("--as-march", type=str, default="allegrex")
parser.add_argument("--as-mabi", type=str, default="32")
parser.add_argument("--as-flags", nargs="*", default=[])
parser.add_argument("--use-wibo", action="store_true")
parser.add_argument("--wibo-path", type=Path, default=Path("wibo"))
parser.add_argument("--asm-dir-prefix", type=Path)
Expand All @@ -35,7 +36,7 @@ def main() -> None:

args, c_flags = parser.parse_known_args()

as_flags = ["-G0"] # TODO: base this on -sdatathreshold value from c_flags
default_as_flags = ["-G0"] # TODO: base this on -sdatathreshold value from c_flags

try:
with tempfile.NamedTemporaryFile(suffix=".c", dir=args.src_dir) as temp_c_file:
Expand All @@ -53,9 +54,9 @@ def main() -> None:
as_path=args.as_path,
as_march=args.as_march,
as_mabi=args.as_mabi,
as_flags=default_as_flags + args.as_flags,
use_wibo=args.use_wibo,
wibo_path=args.wibo_path,
as_flags=as_flags,
asm_dir_prefix=args.asm_dir_prefix,
macro_inc_path=args.macro_inc_path,
c_file_encoding=args.target_encoding,
Expand Down
5 changes: 4 additions & 1 deletion mwccgap/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ def preprocess_s_file(
if line.startswith("/* Handwritten function"):
# ignore handwritten comment
continue
if line.startswith("/*") and re.sub(BLOCK_COMMENT_REGEX, "", line).strip() == "":
if (
line.startswith("/*")
and re.sub(BLOCK_COMMENT_REGEX, "", line).strip() == ""
):
# ignore multi-line comments
continue
if line.startswith("#"):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_dollar_symbol(self):
self.assertTrue(c_lines[0].startswith("static "))

def test_comments(self):
asm_contents ="""
asm_contents = """
/* Generated by spimdisasm 1.39.3 */

/* Handwritten function */
Expand All @@ -192,6 +192,7 @@ def test_comments(self):
self.assertEqual(expected_nops + 2, len(c_lines))
self.assertEqual(0, len(rodata_entries))


class TestPreprocessSFileExceptions(unittest.TestCase):
def test_rodata_unknown_directive(self):
asm_contents = """
Expand Down