build_ntops.py 776 Bytes
Newer Older
Jiacheng Huang's avatar
Jiacheng Huang committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import importlib
import pathlib

from infiniop.ninetoothed.build import BUILD_DIRECTORY_PATH

CURRENT_FILE_PATH = pathlib.Path(__file__)

SRC_DIR_PATH = CURRENT_FILE_PATH.parent.parent / "src"


def _find_and_build_ops():
    ops_path = SRC_DIR_PATH / "infiniop" / "ops"

    for op_dir in ops_path.iterdir():
        ninetoothed_path = op_dir / "ninetoothed"

        if ninetoothed_path.is_dir():
            module_path = ninetoothed_path / "build"
            relative_path = module_path.relative_to(SRC_DIR_PATH)
            import_name = ".".join(relative_path.parts)
            module = importlib.import_module(import_name)

            module.build()


if __name__ == "__main__":
27
    BUILD_DIRECTORY_PATH.mkdir(parents=True, exist_ok=True)
Jiacheng Huang's avatar
Jiacheng Huang committed
28
29

    _find_and_build_ops()