Changeset 96320 in webkit


Ignore:
Timestamp:
Sep 29, 2011 4:49:53 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: make inspector protocol validation a part of the build process.
https://bugs.webkit.org/show_bug.cgi?id=68999

Since we'd like to commit to inspector protocol backwards compatibility, violating it
should be a build failure.

Reviewed by Yury Semikhatsky.

  • CMakeLists.txt:
  • CodeGenerators.pri:
  • DerivedSources.make:
  • GNUmakefile.am:
  • WebCore.gyp/WebCore.gyp:
  • inspector/Inspector.draft-01.json:
  • inspector/Inspector.json:
  • inspector/generate-inspector-idl:
  • inspector/generate-protocol-externs:
  • inspector/validate-protocol-compatibility:
Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r96215 r96320  
    22052205# All Web Inspector generated files are created with this one call to CodeGeneratorInspector.pm
    22062206ADD_CUSTOM_COMMAND(
     2207    OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/Inspector.json.validated
     2208    MAIN_DEPENDENCY inspector/Inspector.json
     2209    DEPENDS ${WEBCORE_DIR}/inspector/validate-protocol-compatibility ${WEBCORE_DIR}/inspector/Inspector.json
     2210    COMMAND ${PYTHON_EXECUTABLE} ${WEBCORE_DIR}/inspector/validate-protocol-compatibility -o ${DERIVED_SOURCES_WEBCORE_DIR}/Inspector.json.validated ${WEBCORE_DIR}/inspector/Inspector.json
     2211    VERBATIM)
     2212
     2213ADD_CUSTOM_COMMAND(
    22072214    OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/Inspector.idl
    22082215    MAIN_DEPENDENCY inspector/Inspector.json
  • trunk/Source/WebCore/ChangeLog

    r96319 r96320  
     12011-09-28  Pavel Feldman  <pfeldman@google.com>
     2
     3        Web Inspector: make inspector protocol validation a part of the build process.
     4        https://bugs.webkit.org/show_bug.cgi?id=68999
     5
     6        Since we'd like to commit to inspector protocol backwards compatibility, violating it
     7        should be a build failure.
     8
     9        Reviewed by Yury Semikhatsky.
     10
     11        * CMakeLists.txt:
     12        * CodeGenerators.pri:
     13        * DerivedSources.make:
     14        * GNUmakefile.am:
     15        * WebCore.gyp/WebCore.gyp:
     16        * inspector/Inspector.draft-01.json:
     17        * inspector/Inspector.json:
     18        * inspector/generate-inspector-idl:
     19        * inspector/generate-protocol-externs:
     20        * inspector/validate-protocol-compatibility:
     21
    1222011-09-27  Pavel Feldman  <pfeldman@google.com>
    223
  • trunk/Source/WebCore/CodeGenerators.pri

    r95911 r96320  
    669669
    670670# GENERATOR 2: inspector idl compiler
     671inspectorValidate.output = $${WC_GENERATED_SOURCES_DIR}/Inspector.json.validated
     672inspectorValidate.input = INSPECTOR_JSON
     673inspectorValidate.wkScript = $$PWD/inspector/validate-protocol-compatibility
     674inspectorValidate.commands = python $$inspectorValidate.wkScript -o $${WC_GENERATED_SOURCES_DIR}/Inspector.json.validated $$PWD/inspector/Inspector.json
     675inspectorValidate.depends = $$PWD/inspector/validate-protocol-compatibility
     676inspectorValidate.wkAddOutputToSources = false
     677addExtraCompiler(inspectorValidate)
     678
    671679inspectorJSON.output = $${WC_GENERATED_SOURCES_DIR}/Inspector.idl
    672680inspectorJSON.input = INSPECTOR_JSON
  • trunk/Source/WebCore/DerivedSources.make

    r96064 r96320  
    889889# Inspector interfaces generator
    890890
     891Inspector.json.validated : Inspector.json inspector/validate-protocol-compatibility
     892        python $(WebCore)/inspector/validate-protocol-compatibility -o Inspector.json.validated $(WebCore)/inspector/Inspector.json
     893
    891894Inspector.idl : Inspector.json inspector/generate-inspector-idl
    892895        python $(WebCore)/inspector/generate-inspector-idl -o Inspector.idl $(WebCore)/inspector/Inspector.json
  • trunk/Source/WebCore/GNUmakefile.am

    r95919 r96320  
    688688
    689689# All Web Inspector generated files are created with this one call to CodeGeneratorInspector.pm
     690DerivedSources/WebCore/Inspector.json.validated : $(WebCore)/inspector/Inspector.json $(WebCore)/inspector/validate-protocol-compatibility
     691        $(PYTHON) $(WebCore)/inspector/validate-protocol-compatibility -o $(GENSOURCES_WEBCORE)/Inspector.json.validated $(WebCore)/inspector/Inspector.json
     692
    690693DerivedSources/WebCore/Inspector.idl : $(WebCore)/inspector/Inspector.json $(WebCore)/inspector/generate-inspector-idl
    691694        $(PYTHON) $(WebCore)/inspector/generate-inspector-idl -o $(GENSOURCES_WEBCORE)/Inspector.idl $(WebCore)/inspector/Inspector.json
  • trunk/Source/WebCore/WebCore.gyp/WebCore.gyp

    r96233 r96320  
    339339      'type': 'none',
    340340      'actions': [
     341         {
     342          'action_name': 'validateInspectorProtocol',
     343          'inputs': [
     344            '../inspector/validate-protocol-compatibility',
     345            '../inspector/Inspector.json',
     346          ],
     347          'outputs': [
     348            '<(SHARED_INTERMEDIATE_DIR)/webcore/Inspector.json.validated',
     349          ],
     350          'variables': {
     351            'generator_include_dirs': [
     352            ],
     353          },
     354          'action': [
     355            'python',
     356            '../inspector/validate-protocol-compatibility',
     357            '-o',
     358            '<@(_outputs)',
     359            '<@(_inputs)'
     360          ],
     361          'message': 'Validate inspector protocol for backwards compatibility',
     362        },
    341363        {
    342364          'action_name': 'generateInspectorProtocolIDL',
  • trunk/Source/WebCore/inspector/Inspector.draft-01.json

    r96106 r96320  
    1 [
    2     {
     1{
     2    "version": "draft-01",
     3    "compatible": [],
     4    "domains" : [{
    35        "domain": "Inspector",
     6        "hidden": true,
    47        "types": [],
    58        "commands": [
     
    12461249    {
    12471250        "domain": "CSS",
     1251        "hidden": true,
    12481252        "description": "This domain exposes CSS read/write operations. All CSS objects, like stylesheets, rules, and styles, have an associated <code>id</code> used in subsequent operations on the related object. Each object type has a specific <code>id</code> structure, and those are not interchangeable between objects of different kinds. CSS objects can be loaded using the <code>get*ForNode()</code> calls (which accept a DOM node id). Alternatively, a client can discover all the existing stylesheets with the <code>getAllStyleSheets()</code> method and subsequently load the required stylesheet contents using the <code>getStyleSheet[Text]()</code> methods.",
    12491253        "types": [
     
    19621966    {
    19631967        "domain": "Worker",
     1968        "hidden": true,
    19641969        "types": [],
    19651970        "commands": [
     
    20202025            }
    20212026        ]
    2022     }
    2023 ]
     2027    }]
     2028}
  • trunk/Source/WebCore/inspector/Inspector.json

    r96223 r96320  
    1 [
    2     {
     1{
     2    "version": "tip-of-tree",
     3    "compatible": ["draft-01"],
     4    "domains": [{
    35        "domain": "Inspector",
     6        "hidden": true,
    47        "types": [],
    58        "commands": [
     
    12121215                "parameters": [
    12131216                    { "name": "nodeId", "$ref": "NodeId", "description": "Id of the node that has changed." },
    1214                     { "name": "name", "type": "string", "description": "Local attribute name." }
     1217                    { "name": "name", "type": "string", "description": "A ttribute name." }
    12151218                ],
    12161219                "description": "Fired when <code>Element</code>'s attribute is removed."
     
    12691272    {
    12701273        "domain": "CSS",
     1274        "hidden": true,
    12711275        "description": "This domain exposes CSS read/write operations. All CSS objects, like stylesheets, rules, and styles, have an associated <code>id</code> used in subsequent operations on the related object. Each object type has a specific <code>id</code> structure, and those are not interchangeable between objects of different kinds. CSS objects can be loaded using the <code>get*ForNode()</code> calls (which accept a DOM node id). Alternatively, a client can discover all the existing stylesheets with the <code>getAllStyleSheets()</code> method and subsequently load the required stylesheet contents using the <code>getStyleSheet[Text]()</code> methods.",
    12721276        "types": [
     
    19851989    {
    19861990        "domain": "Worker",
     1991        "hidden": true,
    19871992        "types": [],
    19881993        "commands": [
     
    20432048            }
    20442049        ]
    2045     }
    2046 ]
     2050    }]
     2051}
  • trunk/Source/WebCore/inspector/generate-inspector-idl

    r95919 r96320  
    4343json_string = json_string.replace(": true", ": True")
    4444json_string = json_string.replace(": false", ": false")
    45 json_api = eval(json_string)
     45json_api = eval(json_string)["domains"]
    4646
    4747output_file = open(output_path, "w")
  • trunk/Source/WebCore/inspector/generate-protocol-externs

    r93706 r96320  
    4343json_string = json_string.replace(": true", ": True")
    4444json_string = json_string.replace(": false", ": false")
    45 json_api = eval(json_string)
     45json_api = eval(json_string)["domains"]
    4646
    4747output_file = open(output_path, "w")
  • trunk/Source/WebCore/inspector/validate-protocol-compatibility

    r96106 r96320  
    297297    for i in range(len(errors)):
    298298        if errors[i] != golden_errors[i]:
    299             print "Self-test failed"
    300299            return False
    301300    return True
     
    303302def main():
    304303    if not self_test():
    305         return
    306 
    307     if len(sys.argv) < 3:
    308         print "Usage: %s Inspector.draft-01.json Inspector.json" % sys.argv[0]
    309         return
    310 
    311     schema_1 = load_json(sys.argv[1])
    312     schema_2 = load_json(sys.argv[2])
    313 
    314     errors = compare_schemas(schema_1, schema_2)
    315     for error in errors:
    316         print error
     304        sys.stderr.write("Self-test failed")
     305        return 1
     306
     307    if len(sys.argv) < 4 or sys.argv[1] != "-o":
     308        sys.stderr.write("Usage: %s -o OUTPUT_FILE INPUT_FILE\n" % sys.argv[0])
     309        return 1
     310
     311    output_path = sys.argv[2]
     312    output_file = open(output_path, "w")
     313
     314    input_path = sys.argv[3]
     315    dir_name = os.path.dirname(input_path)
     316    schema = load_json(input_path)
     317    sys.stdout.write("Validating schema: %s\n" % schema["version"])
     318    compatible = schema["compatible"]
     319    errors_found = False
     320    for version in compatible:
     321        schema = load_json(input_path) # reload since modified while comparing
     322        version_file_name = os.path.normpath(dir_name + "/Inspector." + version + ".json")
     323        version_schema = load_json(version_file_name)
     324        errors = compare_schemas(version_schema["domains"], schema["domains"])
     325        if len(errors) > 0:
     326            errors_found = True
     327            sys.stderr.write("  compatibility with %s: FAILED\n" % version)
     328            for error in errors:
     329                sys.stderr.write( "    %s\n" % error)
     330        else:
     331            sys.stderr.write("  compatibility with %s: SUCCESS\n" % version)
     332    if errors_found:
     333        return 1
    317334
    318335if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.