Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2016-09-20 18:52:38 +0000
committerEric Williams2016-09-23 20:38:38 +0000
commitdbc432e340f2168dcc647291bbcce8b8f785a20d (patch)
tree47d9e0d41a491d0e0cc44ad5775fac89d807bad6 /bundles/org.eclipse.swt.tools
parenta433151f0baf59ad9520ca6e8949b1c32e5cf845 (diff)
downloadeclipse.platform.swt-dbc432e340f2168dcc647291bbcce8b8f785a20d.tar.gz
eclipse.platform.swt-dbc432e340f2168dcc647291bbcce8b8f785a20d.tar.xz
eclipse.platform.swt-dbc432e340f2168dcc647291bbcce8b8f785a20d.zip
Bug 501855: [GTK] Add script to check which dynamic functions are
deprecated This script (when run) compares all dynamic functions from os_custom.h with a list of deprecated GTK3 symbols. The list of GTK3 symbols is fetched from the GTK website in order to provide up to date information. Most of these functions will already have been handled, but some become deprecated over time. We are unable to catch these cases with the compiler since these functions are not compiled. For these cases, this script is useful. Usage: Running without any options prints a list of deprecated dynamic functions to console. Running with the "-f" option will write the list of dynamic deprecated functions to a file calld "dynamic_deprecated_functions.txt", which is stored in the same directory as the script. Change-Id: Iac32086b8e1225545a92a05b68a8cfa84542b76e Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt.tools')
-rwxr-xr-xbundles/org.eclipse.swt.tools/dynamic_deprecated.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt.tools/dynamic_deprecated.py b/bundles/org.eclipse.swt.tools/dynamic_deprecated.py
new file mode 100755
index 0000000000..2870e9b1d1
--- /dev/null
+++ b/bundles/org.eclipse.swt.tools/dynamic_deprecated.py
@@ -0,0 +1,78 @@
+#!/usr/bin/python3
+
+import sys
+import re
+from urllib.request import urlopen
+from html.parser import HTMLParser
+
+API_URL = "https://developer.gnome.org/gtk3/stable/api-index-deprecated.html"
+OS_CUSTOM_FILE = "./../org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h"
+FUNCTION_LIST = []
+DEPRECATED_FUNCTION_LIST = []
+DEPRECATED_SYMBOLS = ""
+
+# This script is Python 3 only.
+#
+# USAGE OPTIONS:
+# <no option specified>: prints list of deprecated dynamic functions to console.
+# -f: writes the list of deprecated dynamic functions to a file called dynamic_deprecated_functions.txt.
+# The file is in the same directory as the script
+
+
+def download_deprecated_symbols():
+ # Fetch latest deprecated symbols from the latest stable GTK3 API
+ with urlopen(API_URL) as url:
+ dep_file = url.read()
+
+ return str(dep_file);
+
+def populate_function_list():
+ # Read os_custom.h from file
+ with open(OS_CUSTOM_FILE) as f:
+ os_custom = f.read()
+
+ return str(os_custom);
+
+def find_deprecated_functions(custom_str, dep_str):
+ regex = r"((\w)+(_)+(LIB)(\s)+(LIB_)+)+"
+ matchList = re.findall(regex, custom_str)
+
+ # Search through list of regex matches, strip the "_LIB" and populate
+ # the dynamic function list.
+ for match in matchList:
+ location = match[0].find("_LIB")
+ function_name = match[0][:location]
+ FUNCTION_LIST.append(function_name)
+
+ # Check each dynamic function and see if it's deprecated: if so, populate
+ # the deprecated function list.
+ for func in FUNCTION_LIST:
+ if func in deprecated:
+ DEPRECATED_FUNCTION_LIST.append(func)
+
+ return;
+
+
+if __name__ == "__main__":
+ deprecated = download_deprecated_symbols()
+ os_custom_str = populate_function_list()
+ find_deprecated_functions(os_custom_str, deprecated)
+
+ # If the list of deprecated functions is empty, print a warning and exit
+ if not DEPRECATED_FUNCTION_LIST:
+ print("No dynamic functions are deprecated!")
+ sys.exit(0)
+
+ # If the user specified the "-f" option, the output will be written to
+ # a file named "dynamic_deprecated_functions.txt"
+ if len(sys.argv) == 2 and "-f" in str(sys.argv):
+ with open("dynamic_deprecated_functions.txt","w") as f:
+ for i in DEPRECATED_FUNCTION_LIST:
+ f.write(i + "\n")
+ f.close()
+ # If no options are specified, print the list to console
+ else:
+ for i in DEPRECATED_FUNCTION_LIST:
+ print(i)
+
+ sys.exit(0)

Back to the top