Cleanup public includes directory.
This CL updates various files in the includes directory to ensure that (1) they do
not depend on headers in /src and (2) that they minimize their dependence on external
headers.
To ensure that we don't regress this behavior a new build target has been added to
build a single cpp file that contains all* public includes and is compiled with
only those directories in the include path.
* The exception is those includes that depend on OS specific headers
BUG=skia:2941
NOTRY=true
Review URL: https://codereview.chromium.org/721903002
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index ac56f44..8eca40c 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -15,9 +15,7 @@
'<(skia_include_path)/gpu/GrConfig.h',
'<(skia_include_path)/gpu/GrContext.h',
'<(skia_include_path)/gpu/GrCoordTransform.h',
- '<(skia_include_path)/gpu/GrFontScaler.h',
'<(skia_include_path)/gpu/GrFragmentProcessor.h',
- '<(skia_include_path)/gpu/GrGlyph.h',
'<(skia_include_path)/gpu/GrGpuResource.h',
'<(skia_include_path)/gpu/GrInvariantOutput.h',
'<(skia_include_path)/gpu/GrPaint.h',
@@ -84,7 +82,9 @@
'<(skia_src_path)/gpu/GrDrawTarget.h',
'<(skia_src_path)/gpu/GrDrawTargetCaps.h',
'<(skia_src_path)/gpu/GrFontScaler.cpp',
+ '<(skia_src_path)/gpu/GrFontScaler.h',
'<(skia_src_path)/gpu/GrGeometryBuffer.h',
+ '<(skia_src_path)/gpu/GrGlyph.h',
'<(skia_src_path)/gpu/GrGpu.cpp',
'<(skia_src_path)/gpu/GrGpu.h',
'<(skia_src_path)/gpu/GrGpuResourceCacheAccess.h',
diff --git a/gyp/tools.gyp b/gyp/tools.gyp
index c1419dd..93ad0df 100644
--- a/gyp/tools.gyp
+++ b/gyp/tools.gyp
@@ -30,6 +30,7 @@
'skpmaker',
'skimage',
'test_image_decoder',
+ 'test_public_includes',
],
'conditions': [
['skia_shared_lib',
@@ -624,6 +625,75 @@
'include_dirs': [ '../tools', ],
},
},
+ {
+ 'target_name': 'test_public_includes',
+ 'type': 'static_library',
+ #'cflags!': [ '-Wno-unused-parameter' ],
+ 'variables': {
+ 'includes_to_test': [
+ '<(skia_include_path)/animator',
+ '<(skia_include_path)/c',
+ '<(skia_include_path)/config',
+ '<(skia_include_path)/core',
+ '<(skia_include_path)/effects',
+ '<(skia_include_path)/gpu',
+ '<(skia_include_path)/images',
+ '<(skia_include_path)/pathops',
+ '<(skia_include_path)/pdf',
+ '<(skia_include_path)/pipe',
+ '<(skia_include_path)/ports',
+ '<(skia_include_path)/svg',
+ '<(skia_include_path)/utils',
+ '<(skia_include_path)/views',
+ '<(skia_include_path)/xml',
+ ],
+ 'paths_to_ignore': [
+ '<(skia_include_path)/gpu/gl/GrGLConfig_chrome.h',
+ '<(skia_include_path)/ports/SkTypeface_mac.h',
+ '<(skia_include_path)/ports/SkTypeface_win.h',
+ '<(skia_include_path)/utils/ios',
+ '<(skia_include_path)/utils/mac',
+ '<(skia_include_path)/utils/win',
+ '<(skia_include_path)/utils/SkDebugUtils.h',
+ '<(skia_include_path)/utils/SkJSONCPP.h',
+ '<(skia_include_path)/utils/SkWGL.h',
+ '<(skia_include_path)/views/animated',
+ '<(skia_include_path)/views/SkOSWindow_Android.h',
+ '<(skia_include_path)/views/SkOSWindow_iOS.h',
+ '<(skia_include_path)/views/SkOSWindow_Mac.h',
+ '<(skia_include_path)/views/SkOSWindow_NaCl.h',
+ '<(skia_include_path)/views/SkOSWindow_SDL.h',
+ '<(skia_include_path)/views/SkOSWindow_Unix.h',
+ '<(skia_include_path)/views/SkOSWindow_Win.h',
+ '<(skia_include_path)/views/SkWindow.h',
+ '<(skia_include_path)/xml/SkJS.h',
+ ],
+ },
+ 'include_dirs': [
+ '<@(includes_to_test)',
+ ],
+ 'sources': [
+ # unused_param_test.cpp is generated by the action below.
+ '<(INTERMEDIATE_DIR)/test_public_includes.cpp',
+ ],
+ 'actions': [
+ {
+ 'action_name': 'generate_includes_cpp',
+ 'inputs': [
+ '../tools/generate_includes_cpp.py',
+ '<@(includes_to_test)',
+ # This causes the gyp generator on mac to fail
+ #'<@(paths_to_ignore)',
+ ],
+ 'outputs': [
+ '<(INTERMEDIATE_DIR)/test_public_includes.cpp',
+ ],
+ 'action': ['python', '../tools/generate_includes_cpp.py',
+ '--ignore', '<(paths_to_ignore)',
+ '<@(_outputs)', '<@(includes_to_test)'],
+ },
+ ],
+ },
],
'conditions': [
['skia_shared_lib',
diff --git a/include/core/SkWriteBuffer.h b/include/core/SkWriteBuffer.h
index 04acbf1..4dbe17b 100644
--- a/include/core/SkWriteBuffer.h
+++ b/include/core/SkWriteBuffer.h
@@ -9,7 +9,6 @@
#ifndef SkWriteBuffer_DEFINED
#define SkWriteBuffer_DEFINED
-#include "SkBitmapHeap.h"
#include "SkData.h"
#include "SkPath.h"
#include "SkPicture.h"
@@ -17,6 +16,7 @@
#include "SkWriter32.h"
class SkBitmap;
+class SkBitmapHeap;
class SkFactorySet;
class SkFlattenable;
class SkNamedFactorySet;
diff --git a/include/xml/SkBML_WXMLParser.h b/include/xml/SkBML_WXMLParser.h
index 74f164c..20239c2 100644
--- a/include/xml/SkBML_WXMLParser.h
+++ b/include/xml/SkBML_WXMLParser.h
@@ -40,7 +40,7 @@
char* fAttrValues[256];
// important that these are U8, so we get automatic wrap-around
- U8 fNextElem, fNextAttrName, fNextAttrValue;
+ uint8_t fNextElem, fNextAttrName, fNextAttrValue;
};
#endif // SkBML_WXMLParser_DEFINED
diff --git a/include/views/android/AndroidKeyToSkKey.h b/platform_tools/android/app/jni/AndroidKeyToSkKey.h
similarity index 100%
rename from include/views/android/AndroidKeyToSkKey.h
rename to platform_tools/android/app/jni/AndroidKeyToSkKey.h
diff --git a/platform_tools/android/app/jni/com_skia_SkiaSampleRenderer.cpp b/platform_tools/android/app/jni/com_skia_SkiaSampleRenderer.cpp
index da7c13d..169670a 100644
--- a/platform_tools/android/app/jni/com_skia_SkiaSampleRenderer.cpp
+++ b/platform_tools/android/app/jni/com_skia_SkiaSampleRenderer.cpp
@@ -15,7 +15,7 @@
#include "SkWindow.h"
#include <jni.h>
-#include "android/AndroidKeyToSkKey.h"
+#include "AndroidKeyToSkKey.h"
///////////////////////////////////////////
diff --git a/src/core/SkWriteBuffer.cpp b/src/core/SkWriteBuffer.cpp
index f2be41b..c79d275 100644
--- a/src/core/SkWriteBuffer.cpp
+++ b/src/core/SkWriteBuffer.cpp
@@ -8,6 +8,7 @@
#include "SkWriteBuffer.h"
#include "SkBitmap.h"
+#include "SkBitmapHeap.h"
#include "SkData.h"
#include "SkPixelRef.h"
#include "SkPtrRecorder.h"
diff --git a/include/gpu/GrFontScaler.h b/src/gpu/GrFontScaler.h
similarity index 100%
rename from include/gpu/GrFontScaler.h
rename to src/gpu/GrFontScaler.h
diff --git a/include/gpu/GrGlyph.h b/src/gpu/GrGlyph.h
similarity index 100%
rename from include/gpu/GrGlyph.h
rename to src/gpu/GrGlyph.h
diff --git a/include/views/unix/XkeysToSkKeys.h b/src/views/unix/XkeysToSkKeys.h
similarity index 100%
rename from include/views/unix/XkeysToSkKeys.h
rename to src/views/unix/XkeysToSkKeys.h
diff --git a/include/views/unix/keysym2ucs.h b/src/views/unix/keysym2ucs.h
similarity index 100%
rename from include/views/unix/keysym2ucs.h
rename to src/views/unix/keysym2ucs.h
diff --git a/tools/generate_includes_cpp.py b/tools/generate_includes_cpp.py
new file mode 100644
index 0000000..1a6f117
--- /dev/null
+++ b/tools/generate_includes_cpp.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+
+'''
+Copyright 2014 Google Inc.
+
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+'''
+
+import os
+import optparse
+import posixpath
+import re
+
+
+def is_ignored(full_path, ignore_list):
+ for ignore_path in ignore_list:
+ if re.match(full_path, ignore_path, re.I):
+ return True
+ return False
+
+
+def find_header_files(include_dirs, ignore_list):
+ """Return a list of all '.h' files in top_dir.
+
+ Args:
+ include_dirs: Paths to the directories within which to recursively search
+ for files ending in '.h'
+ ignore_list: Paths to both files and directories that are to be excluded
+ from the search for headers
+
+ Returns:
+ A list of all the files inside include_dirs that end in '.h', relative to
+ their respective include_dir that are not explicitly ignored.
+ """
+ headers = []
+ for top_dir in include_dirs:
+ for filename in os.listdir(top_dir):
+ full_path = posixpath.join(top_dir, filename)
+ if is_ignored(full_path, ignore_list):
+ continue
+ elif os.path.isdir(full_path):
+ nested_headers = find_header_files([full_path], ignore_list)
+ for nested_header in nested_headers:
+ headers.append(os.path.join(filename, nested_header))
+ elif filename.endswith('.h'):
+ headers.append(filename)
+ return headers
+
+
+def GenerateIncludeCPP(output_file, include_dirs, ignore_list):
+ headers = find_header_files(include_dirs, ignore_list)
+
+ # Emit resulting source file.
+ with open(os.path.join(os.getcwd(), output_file), "w+") as output:
+ for header in headers:
+ output.write("#include <%s>\n" % header)
+
+
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option("--ignore", action="store", type="string", dest="ignore",
+ help="file to write the processed sources array to.")
+ parser.set_usage("""generate_include_cpp out.cpp include_dir
+ out.cpp: C++ code to be generated.
+ include_dirs: directories to traverse for include files""")
+ (options, args) = parser.parse_args()
+
+ GenerateIncludeCPP(args[0], args[1:], options.ignore.split())
+
+
+if __name__ == "__main__":
+ main()