コード例 #1
0
def configure(env):
    from SCons.Script import Variables, Help

    opts = Variables()

    opts.Add("geomtools_scale_factor", 
        "The precision used for converting between integer and float coordinates throughout " +
        "poly backends implementations for computational robustness purposes.", "1e5")

    opts.Update(env)
    
    def help_format(env, opt, help, default, actual, aliases):
        if opt == "geomtools_scale_factor":
            fmt = "\n%s: %s.\n    default: %s (based on CMP_EPSILON)\n    actual: %s\n"
        else:
            fmt = "\n%s: %s.\n    default: %s\n    actual: %s\n"
        return fmt % (opt, help, default, actual)
    
    opts.FormatVariableHelpText = help_format
    Help(opts.GenerateHelpText(env))
コード例 #2
0
def configure(env):
    from SCons.Script import Variables, BoolVariable, Help, Exit
    import goost

    opts = Variables()
    for name in goost.get_components():
        opts.Add(
            BoolVariable("goost_%s_enabled" % (name),
                         "Build %s component." % (name), True))

    opts.Add(
        "goost_scale_factor",
        "The precision used for converting between integer and float coordinates.",
        "1e5")

    opts.Update(env)

    # Get a list of components which got disabled.
    disabled = []
    for name in goost.get_components():
        if not env["goost_%s_enabled" % (name)]:
            disabled.append(name)

    # Implicitly disable child components.
    for name in disabled:
        children = goost.get_child_components(name)
        for child_name in children:
            print("Goost: disabling `%s` component (%s)." % (child_name, name))
            env["goost_%s_enabled" % (child_name)] = False

    def help_format(env, opt, help, default, actual, aliases):
        if opt == "goost_scale_factor":
            fmt = "\n%s: %s.\n    default: %s (based on CMP_EPSILON)\n    actual: %s\n"
        else:
            fmt = "\n%s: %s.\n    default: %s\n    actual: %s\n"
        return fmt % (opt, help, default, actual)

    opts.FormatVariableHelpText = help_format
    Help(opts.GenerateHelpText(env))
コード例 #3
0
ファイル: config.py プロジェクト: goostengine/goost
def configure(env):
    from SCons.Script import Variables, BoolVariable, Help

    opts = Variables()

    # Config.
    components_config = {}
    components_enabled_by_default = True
    classes_config = {}
    classes_enabled_by_default = True

    # From `custom.py` file.
    try:
        import custom
        if hasattr(custom, "components"):
            components_config = custom.components
        if hasattr(custom, "components_enabled_by_default"):
            components_enabled_by_default = custom.components_enabled_by_default
        if hasattr(custom, "classes"):
            classes_config = custom.classes
        if hasattr(custom, "classes_enabled_by_default"):
            classes_enabled_by_default = custom.classes_enabled_by_default
    except ImportError:
        pass

    # From command-line (CLI arguments override arguments specified via file).
    opts.Add(
        BoolVariable(
            "goost_components_enabled",
            "Set to `no` to disable all components by default, and enable each component of interest manually",
            True))

    # Get a list of all components and add them, regardless of configuration.
    for name in goost.get_components()["enabled"]:  # All enabled by default.
        opts.Add(
            BoolVariable("goost_%s_enabled" % (name),
                         "Build %s component." % (name), True))

    # Math/Geometry.
    opts.Add(
        "goost_scale_factor",
        "The precision used for converting between integer and float coordinates.",
        "1e5")

    def help_format(env, opt, help, default, actual, aliases):
        if opt == "goost_scale_factor":
            fmt = "\n%s: %s.\n    default: %s (based on CMP_EPSILON)\n    actual: %s\n"
        else:
            fmt = "\n%s: %s.\n    default: %s\n    actual: %s\n"
        return fmt % (opt, help, default, actual)

    opts.FormatVariableHelpText = help_format

    # Must update environment to override `components_config` from CLI/file.
    # Do not call this method afterwards as the environment is going to be
    # updated manually. If you need to add more options not related to
    # components/classes, add them above.
    opts.Update(env)

    components = configure_components(env, components_config,
                                      components_enabled_by_default)
    classes = configure_classes(env, classes_config,
                                classes_enabled_by_default)

    if env["verbose"]:
        for class_name in classes["enabled"]:
            # Report rightmost child components only.
            for component_name in reversed(
                    goost.get_class_components(class_name)):
                skip = False
                if component_name in components["disabled"]:
                    print(
                        "Goost: Skipping class `%s`, because component `%s` is disabled."
                        % (class_name, component_name))
                    skip = True
                if skip:
                    break

    # Generate help text.
    Help(opts.GenerateHelpText(env))