How to use the cmake.codecheck.CodeCheck.Preprocessor function in cmake

To help you get started, we’ve selected a few cmake examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github widelands / widelands / cmake / codecheck / CodeCheck.py View on Github external
def check_file(self,fn, print_errors = True):
        if print_errors and fn in self._cache:
            print(self._cache[fn].rstrip())
            return
        errors = []

        benchmark_results = defaultdict(lambda: 0.)

        preprocessor = Preprocessor()

        # Check line by line (currently)
        with io.open(fn, "r", newline='', encoding='utf-8') as file:
            data = file.read()
            for c in self._checkers:
                if self._benchmark:
                    start = time()
                    e =  c.check_text( preprocessor, fn, data )
                    errors.extend( e )
                    benchmark_results[c.name] += time()-start
                else:
                    e =  c.check_text( preprocessor, fn, data )
                    errors.extend( e )
        errors.sort(key=lambda a: a[1])

        if len(errors) and print_errors: