Example #1
0
def check_myconfig(compiler, feature_file, myconfig, pre_header=None):
    # This does not work on all compilers, so if the parsing fails
    # we just bail out.
    external_defs = []

    if pre_header:
        try:
            external_features = Defines(compiler).defines(pre_header)
        except CalledProcessError as ex:
            print_exception(ex)
            return

        external_defs = ['-D' + s for s in external_features]

    try:
        my_features = Defines(compiler, flags=external_defs).defines(myconfig)
    except CalledProcessError as ex:
        print_exception(ex)
        return

    # Parse feature file
    defs = featuredefs.defs(feature_file)

    error_state = False
    for e in (my_features & defs.externals):
        error_state = True
        my_features.remove(e)
        print(
            "External feature '{}' can not be defined in myconfig.".format(e))

    for u in (my_features - defs.features):
        if u.startswith('__'):
            continue
        error_state = True
        handle_unknown(u, defs.features)

    if error_state:
        raise FeatureError("There were errors in '{}'".format(sys.argv[3]))
    else:
        return
Example #2
0
from __future__ import print_function
import time, string
import inspect, sys, os 
# find featuredefs.py 
moduledir = os.path.dirname(inspect.getfile(inspect.currentframe()))
sys.path.append(os.path.join(moduledir, '..'))
import featuredefs 

if len(sys.argv) != 4:
    print("Usage: {} DEFFILE HPPFILE CPPFILE".format(sys.argv[0]), file=sys.stderr)
    exit(2)

deffilename, hfilename, cfilename = sys.argv[1:5]

print("Reading definitions from " + deffilename + "...")
defs = featuredefs.defs(deffilename)
print("Done.")

print("Writing " + hfilename + "...")
hfile = open(hfilename, 'w');

hfile.write("""/* 
WARNING: This file was autogenerated by

   %s on %s

   Do not modify it or your changes will be overwritten!
   Modify features.def instead.
*/
#ifndef _FEATURECONFIG_HPP
#define _FEATURECONFIG_HPP
Example #3
0
import sys
import os
# find featuredefs.py
moduledir = os.path.dirname(inspect.getfile(inspect.currentframe()))
sys.path.append(os.path.join(moduledir, '..'))
import featuredefs

if len(sys.argv) != 4:
    print("Usage: {} DEFFILE HPPFILE CPPFILE".format(sys.argv[0]),
          file=sys.stderr)
    exit(2)

deffilename, hfilename, cfilename = sys.argv[1:5]

print("Reading definitions from " + deffilename + "...")
defs = featuredefs.defs(deffilename)
print("Done.")

print("Writing " + hfilename + "...")
hfile = open(hfilename, 'w')

hfile.write("""/*
WARNING: This file was autogenerated by

   %s on %s

   Do not modify it or your changes will be overwritten!
   Modify features.def instead.
*/
#ifndef ESPRESSO_FEATURECONFIG_HPP
#define ESPRESSO_FEATURECONFIG_HPP
#
# Check whether all features used in the code are defined
#
from __future__ import print_function
import sys, os, re, fileinput
sys.path.append(os.path.join(sys.path[0], '..', '..', 'config'))

import featuredefs

if len(sys.argv) < 3:
    print("Usage: %s DEFFILE [FILE...]" % sys.argv[0])
    exit(2)

print("Checking for completeness of features in test configurations...")

fdefs = featuredefs.defs(sys.argv[1])

featurefound = set()
featurere = re.compile('^#define (\w+)')
for line in fileinput.input(sys.argv[2:]):
    res = featurere.match(line)
    if res is not None:
        feature = res.group(1)
        featurefound.add(feature)

unused = fdefs.features.difference(featurefound)
unused = unused.difference(fdefs.notestfeatures)
if len(unused) > 0:
    for feature in unused:
        print("check_myconfig_complete: %s is not used" % feature)
else:
#
# Check whether all features used in the code are defined
#
from __future__ import print_function
import sys, os, re, fileinput
sys.path.append(os.path.join(sys.path[0], '..', 'src'))

import featuredefs

if len(sys.argv) < 3:
    print("Usage: %s DEFFILE [FILE...]" % sys.argv[0])
    exit(2)

print("Checking for completeness of features in test configurations...")

fdefs = featuredefs.defs(sys.argv[1])

featurefound = set()
featurere = re.compile('^#define (\w+)')
for line in fileinput.input(sys.argv[2:]):
    res = featurere.match(line)
    if res is not None:
        feature = res.group(1)
        featurefound.add(feature)

unused = fdefs.features.difference(featurefound)
unused = unused.difference(fdefs.notestfeatures)
if len(unused) > 0:
    for feature in unused:
        print("check_myconfig_complete: %s is not used" % feature)
else: