Skip to content

Commit bd7a866

Browse files
Add new AutoBuild Scanner (#957)
This PR scan for KConfig-based build system and generate build suggestion with new AutoBuild scanner. --------- Signed-off-by: Arthur Chan <[email protected]> Co-authored-by: DavidKorczynski <[email protected]>
1 parent b6d5fe2 commit bd7a866

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

Diff for: experimental/build_generator/build_script_generator.py

+54
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,59 @@ def name(self):
784784
return 'cmake'
785785

786786

787+
class KConfigBuildScanner(AutoBuildBase):
788+
"""Auto builder for KConfig-based projects."""
789+
790+
def __init__(self):
791+
super().__init__()
792+
self.matches_found = {
793+
'Config.in': [],
794+
'Makefile': [],
795+
}
796+
797+
def is_matched(self):
798+
"""Returns True if the build heuristic found matching files."""
799+
# Ensure both Config.in and Makefile exists
800+
for found_matches in self.matches_found.values():
801+
if len(found_matches) == 0:
802+
return False
803+
return True
804+
805+
def steps_to_build(self) -> Iterator[AutoBuildContainer]:
806+
base_command = [
807+
'''
808+
make defconfig
809+
make
810+
find . -type f -name "*.o" > objfiles
811+
llvm-ar rcs libfuzz.a $(cat objfiles)
812+
'''
813+
]
814+
build_container = AutoBuildContainer()
815+
build_container.list_of_commands = base_command
816+
build_container.heuristic_id = self.name + '1'
817+
yield build_container
818+
819+
# Alternative to avoid Gold lld
820+
build_container_2 = AutoBuildContainer()
821+
base_command.append('export CFLAGS="${CFLAGS} -fuse-ld=lld"')
822+
base_command.append('export CFXXLAGS="${CXXFLAGS} -fuse-ld=lld"')
823+
build_container_2.list_of_commands = base_command
824+
build_container.heuristic_id = self.name + '2'
825+
yield build_container_2
826+
827+
# Alternative to avoid Gold lld and add thread/crypt libraries
828+
build_container_3 = AutoBuildContainer()
829+
base_command.append('export CFLAGS="${CFLAGS} -lpthread -lcrypt"')
830+
base_command.append('export CFXXLAGS="${CXXFLAGS} -lpthread -lcrypt"')
831+
build_container_3.list_of_commands = base_command
832+
build_container.heuristic_id = self.name + '3'
833+
yield build_container_3
834+
835+
@property
836+
def name(self):
837+
return 'kconfig'
838+
839+
787840
def match_build_heuristics_on_folder(abspath_of_target: str):
788841
"""Yields AutoBuildContainer objects.
789842
@@ -808,6 +861,7 @@ def match_build_heuristics_on_folder(abspath_of_target: str):
808861
BootstrapScanner(),
809862
AutogenScannerSH(),
810863
HeaderOnlyCBuilder(),
864+
KConfigBuildScanner(),
811865
]
812866

813867
checks_to_test = []

0 commit comments

Comments
 (0)