@@ -1572,13 +1572,28 @@ def get_config_options():
1572
1572
"MLK_BREAK_PCT" , # Use in PCT breakage test]
1573
1573
"MLK_CONFIG_NO_ASM_VALUE_BARRIER" , # TODO: Add to config?
1574
1574
"MLK_CHECK_APIS" ,
1575
- "MLK_CONFIG_API_XXX" ,
1576
- "MLK_USE_NATIVE_XXX" ,
1577
1575
]
1578
1576
1579
1577
return configs
1580
1578
1581
1579
1580
+ def is_macro_pattern (m ):
1581
+ if not m .endswith ("_XXX" ):
1582
+ return None
1583
+ return m [:- 4 ]
1584
+
1585
+
1586
+ def is_valid_macro_pattern (m , macros ):
1587
+ pattern = is_macro_pattern (m )
1588
+ if pattern is None :
1589
+ return False
1590
+ # Check that there is at least one macro following the pattern
1591
+ for mp in macros :
1592
+ if mp .startswith (pattern ):
1593
+ return True
1594
+ return False
1595
+
1596
+
1582
1597
def check_macro_typos_in_file (filename , macro_check ):
1583
1598
"""Checks for typos in MLK_XXX and MLKEM_XXX identifiers."""
1584
1599
status_update ("check-macros" , filename )
@@ -1591,9 +1606,14 @@ def check_macro_typos_in_file(filename, macro_check):
1591
1606
rest = m .group (2 )
1592
1607
if macro_check (txt , rest , filename ) is False :
1593
1608
line_no = content [: m .start ()].count ("\n " ) + 1
1594
- raise Exception (
1595
- f"Likely typo { txt } in { filename } :{ line_no } ? Not a defined macro."
1596
- )
1609
+ if is_macro_pattern (txt ):
1610
+ raise Exception (
1611
+ f"Likely typo { txt } in { filename } :{ line_no } ? No macro following the pattern exists"
1612
+ )
1613
+ else :
1614
+ raise Exception (
1615
+ f"Likely typo { txt } in { filename } :{ line_no } ? Not a defined macro nor valid pattern"
1616
+ )
1597
1617
1598
1618
1599
1619
def get_syscaps ():
@@ -1610,7 +1630,7 @@ def check_macro_typos():
1610
1630
macros .update (get_config_options ())
1611
1631
1612
1632
def macro_check (m , rest , filename ):
1613
- if m in macros :
1633
+ if m in macros or is_valid_macro_pattern ( m , macros ) :
1614
1634
return True
1615
1635
1616
1636
is_autogen = filename == "scripts/autogen"
@@ -1638,12 +1658,7 @@ def check_macro_typos():
1638
1658
if filename .endswith (".ml" ):
1639
1659
return True
1640
1660
1641
- # 4. Exclude regexp patterns in `autogen`
1642
- if is_autogen :
1643
- if rest .startswith ("\\ " ) or m in ["MLK_XXX" , "MLK_SOURCE_XXX" ]:
1644
- return True
1645
-
1646
- # 5. AWS-LC importer patch
1661
+ # 4. AWS-LC importer patch
1647
1662
if is_autogen or filename == "integration/awslc/awslc.patch" :
1648
1663
return True
1649
1664
0 commit comments