Generate warnings for Preferences files
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2018 22:33:10 +0000 (22:33 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2018 22:33:10 +0000 (22:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189573

Reviewed by Sam Weinig.

Generate the "DO NOT EDIT" warnings, rather than have
them in the template (which was confusing).

While here, simplify some of the templating generation code
to avoid duplication.

* Scripts/GeneratePreferences.rb:
* Scripts/PreferencesTemplates/WebPageUpdatePreferences.cpp.erb:
* Scripts/PreferencesTemplates/WebPreferencesDefinitions.h.erb:
* Scripts/PreferencesTemplates/WebPreferencesExperimentalFeatures.cpp.erb:
* Scripts/PreferencesTemplates/WebPreferencesInternalDebugFeatures.cpp.erb:
* Scripts/PreferencesTemplates/WebPreferencesKeys.cpp.erb:
* Scripts/PreferencesTemplates/WebPreferencesKeys.h.erb:
* Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235993 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Scripts/GeneratePreferences.rb
Source/WebKit/Scripts/PreferencesTemplates/WebPageUpdatePreferences.cpp.erb
Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesDefinitions.h.erb
Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesExperimentalFeatures.cpp.erb
Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesInternalDebugFeatures.cpp.erb
Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesKeys.cpp.erb
Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesKeys.h.erb
Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb

index ba6aadb..f2bfe77 100644 (file)
@@ -1,3 +1,25 @@
+2018-09-13  Dean Jackson  <dino@grorg.org>
+
+        Generate warnings for Preferences files
+        https://bugs.webkit.org/show_bug.cgi?id=189573
+
+        Reviewed by Sam Weinig.
+
+        Generate the "DO NOT EDIT" warnings, rather than have
+        them in the template (which was confusing).
+
+        While here, simplify some of the templating generation code
+        to avoid duplication.
+
+        * Scripts/GeneratePreferences.rb:
+        * Scripts/PreferencesTemplates/WebPageUpdatePreferences.cpp.erb:
+        * Scripts/PreferencesTemplates/WebPreferencesDefinitions.h.erb:
+        * Scripts/PreferencesTemplates/WebPreferencesExperimentalFeatures.cpp.erb:
+        * Scripts/PreferencesTemplates/WebPreferencesInternalDebugFeatures.cpp.erb:
+        * Scripts/PreferencesTemplates/WebPreferencesKeys.cpp.erb:
+        * Scripts/PreferencesTemplates/WebPreferencesKeys.h.erb:
+        * Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb:
+
 2018-09-13  Keith Rollin  <krollin@apple.com>
 
         WebPageProxy::reportPageLoadResult can crash on some code paths
index 5ff5bd8..9a7a438 100755 (executable)
@@ -129,7 +129,9 @@ end
 class Preferences
   attr_accessor :preferences
 
-  def initialize(hash)
+  def initialize(hash, outputDirectory)
+    @outputDirectory = outputDirectory
+
     @preferences = []
     hash.each do |name, options|
       @preferences << Preference.new(name, options)
@@ -144,23 +146,25 @@ class Preferences
     @preferencesBoundToSetting = @preferences.select { |p| !p.webcoreBinding }
     @preferencesBoundToDeprecatedGlobalSettings = @preferences.select { |p| p.webcoreBinding == "DeprecatedGlobalSettings" }
     @preferencesBoundToRuntimeEnabledFeatures = @preferences.select { |p| p.webcoreBinding == "RuntimeEnabledFeatures" }
+
+    @warning = "THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT."
   end
 
-  def renderToFile(template, file)
-    template = File.join(File.dirname(__FILE__), template)
+  def renderTemplate(template)
+    templateFile = File.join(File.dirname(__FILE__), "PreferencesTemplates", template + ".erb")
 
-    output = ERB.new(File.read(template), 0, "-").result(binding)
-    File.open(file, "w+") do |f|
+    output = ERB.new(File.read(templateFile), 0, "-").result(binding)
+    File.open(File.join(@outputDirectory, template), "w+") do |f|
       f.write(output)
     end
   end
 end
 
-preferences = Preferences.new(parsedPreferences)
-preferences.renderToFile("PreferencesTemplates/WebPreferencesDefinitions.h.erb", File.join(options[:outputDirectory], "WebPreferencesDefinitions.h"))
-preferences.renderToFile("PreferencesTemplates/WebPageUpdatePreferences.cpp.erb", File.join(options[:outputDirectory], "WebPageUpdatePreferences.cpp"))
-preferences.renderToFile("PreferencesTemplates/WebPreferencesKeys.h.erb", File.join(options[:outputDirectory], "WebPreferencesKeys.h"))
-preferences.renderToFile("PreferencesTemplates/WebPreferencesKeys.cpp.erb", File.join(options[:outputDirectory], "WebPreferencesKeys.cpp"))
-preferences.renderToFile("PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb", File.join(options[:outputDirectory], "WebPreferencesStoreDefaultsMap.cpp"))
-preferences.renderToFile("PreferencesTemplates/WebPreferencesInternalDebugFeatures.cpp.erb", File.join(options[:outputDirectory], "WebPreferencesInternalDebugFeatures.cpp"))
-preferences.renderToFile("PreferencesTemplates/WebPreferencesExperimentalFeatures.cpp.erb", File.join(options[:outputDirectory], "WebPreferencesExperimentalFeatures.cpp"))
+preferences = Preferences.new(parsedPreferences, options[:outputDirectory])
+preferences.renderTemplate("WebPreferencesDefinitions.h")
+preferences.renderTemplate("WebPageUpdatePreferences.cpp")
+preferences.renderTemplate("WebPreferencesKeys.h")
+preferences.renderTemplate("WebPreferencesKeys.cpp")
+preferences.renderTemplate("WebPreferencesStoreDefaultsMap.cpp")
+preferences.renderTemplate("WebPreferencesInternalDebugFeatures.cpp")
+preferences.renderTemplate("WebPreferencesExperimentalFeatures.cpp")
index 7a181f0..201e40b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT.
+ * <%= @warning %>
  *
  * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
index e6774e2..dfc4b39 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT.
+ * <%= @warning %>
  *
  * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
index ff13d57..c6fba00 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT.
+ * <%= @warning %>
  *
  * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
index a56b269..60f5fe8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT.
+ * <%= @warning %>
  *
  * Copyright (C) 2017 Apple Inc. All rights reserved.
  *