skia2/include/BUILD.bazel

40 lines
1.1 KiB
Python
Raw Normal View History

[bazel] Add in hierarchical filegroup Bazel rules. The primary goal of this organization structure is to keep our top level BUILD.bazel file short, with as little logic as feasible. The logic required to control which files to include, which third_party deps are needed, what system libraries should be linked again, etc, should be in the BUILD.bazel file best should be as close to the affected files as feasible. In essence, we use filegroup() rules to bubble up the files needed to build Skia (all as one big cc_library call) and cc_library rules to bubble up the other components needed to build. For example, //src/ports/SkFontHost_FreeType.cpp needs FreeType, but only if we are compiling Skia with that type of font support. With the new organization structure in this CL, //src/ports/BUILD.bazel should have the logic that determines if the cpp file should be included in the build of Skia and if it is, that the Skia build should depend on //third_party:freetype2 Another example is //src/gpu/ganesh/BUILD.bazel, which chooses which of the dawn, gl, vulkan, etc backend sources, and the associated dependencies to include in the build. It does not specify what those are, but delegates to the BUILD.bazel files in the subdirectories housing the backend-specific code. The structure guidelines for BUILD.bazel files are as follows: - Have a filegroup() called "hdrs" (for public headers) or "srcs" (for private headers and all .cpp files) that is visible to the parent directory. This should list the files from the containing directory to include in the build. See //include/core/BUILD.bazel and //src/effects/BUILD.bazel as examples. - filegroup() rules can list a child directory's "hdrs" or "srcs" in their "srcs" attributes, but should not contain select statements pertaining to child directory files. See //include/gpu/BUILD.bazel and //src/gpu/ganesh/BUILD.bazel as examples. - May have a cc_library() called "deps". This can specify dependencies, cc_opts, and linkopts, but not srcs or hdrs. [1] See //src/codec/BUILD.bazel as an example. These should be visible to the parent directory. - "hdrs", "srcs", and "deps" for the primary Skia build (currently called "skia_core") should bubble up through //include/BUILD.bazel and //src/BUILD.bazel, one directory at a time. This CL demonstrates a very basic build of Skia with many features turned off (CPU only, no fonts, no codecs). Follow-on CLs will add to these rules as more targets are supported. See bazel/Makefile for the builds that work with just this CL. Suggested Review Order: - //BUILD.bazel to see the very small skia_core rule which delegates all the logic down stack. Note that it has a dependency on //bazel:defines_from_flags which will set all the defines listed there when compiling all the .cpp and .h files in skia_core *and* anything that depends on skia_core, but *not* //src:deps. - //include/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. Note that the filegroups in //include/private/... are called "srcs" to be similar to how Bazel wants "private headers" to be in the "srcs" of cc_library, cc_binary, etc. and only public headers are to be in "hdrs" [2]. - //src/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. //src/gpu/ganesh/... will be filled in for dawn, vulkan, and GL in the next CL. - //PRESUBMIT.py, which adds a check that runs buildifier [3] on modified BUILD.bazel files to make sure they stay consistently formatted. - //bazel/... to see the new option I added to make sksl opt-in or opt-out, so one could build Skia with sksl, but not with a gpu backend. - Misc .h and .cpp files, whose includes were removed if unnecessary or #ifdef'd out to make the minimal build work without GPU or SkSL includes. - //bazel/Makefile to see the builds that work with this CL. [1] Setting srcs or hdrs is error-prone at best, because those files will be compiled with a different set of defines than the rest of skia_core, because they wouldn't depend on //bazel:defines_from_flags. [2] https://bazel.build/reference/be/c-cpp#cc_library.hdrs [3] https://github.com/bazelbuild/buildtools/releases Change-Id: I5e0e3ae01ad42d672506d5aad1239f2512188191 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543977 Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
2022-05-27 17:56:03 +00:00
load("//bazel:macros.bzl", "exports_files_legacy")
licenses(["notice"])
exports_files_legacy()
filegroup(
name = "public_hdrs",
srcs = [
[bazel] Add "skia_internal" target that exposes private API for tests/tools. Organization v3.5, if we are keeping track :) This splits the "srcs" filegroup into "srcs" and "private_hdrs", and renames "hdrs" to "public_hdrs". To assist with the split, I created the macro split_srcs_and_hdrs. Rather than keep two separate lists of header and source files, I figured it would be easiest, at least for the common case, to keep one list of files and then have a for loop split them apart. I've tried to be consistent with having the list of files be named with a _FILES suffix - maybe we can use this as a marker to generate .gni files in the future? Suggested review order: - //bazel/macros.bzl. Note this needs a corresponding G3 change (http://cl/452279799) as well. The exports_files_legacy change is the better approach to something I manually handled yesterday when fixing the G3 roll. - //BUILD.bazel to see the new target skia_internal and the previous skia_core renamed to skia_public. - //src/core/BUILD.bazel to see a typical usage of split_srcs_and_hdrs. - //include/... to see the change to public_hdrs and private_hdrs - //src/... to see many more usages of split_srcs_and_hdrs - //tools/... to see changes to skia_internal where appropriate. - Everything else. Note that //modules/... might also need to be built with skia_internal instead of skia_public, but we can fix that up later, if necessary. Change-Id: Ie1cc969455d97b029b2d77faa222c4a9bad70671 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/545716 Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2022-06-01 18:45:46 +00:00
"//include/android:public_hdrs",
"//include/codec:public_hdrs",
"//include/config:public_hdrs",
"//include/core:public_hdrs",
"//include/docs:public_hdrs",
"//include/effects:public_hdrs",
"//include/encode:public_hdrs",
"//include/pathops:public_hdrs",
"//include/ports:public_hdrs",
"//include/utils:public_hdrs",
[bazel] Add in hierarchical filegroup Bazel rules. The primary goal of this organization structure is to keep our top level BUILD.bazel file short, with as little logic as feasible. The logic required to control which files to include, which third_party deps are needed, what system libraries should be linked again, etc, should be in the BUILD.bazel file best should be as close to the affected files as feasible. In essence, we use filegroup() rules to bubble up the files needed to build Skia (all as one big cc_library call) and cc_library rules to bubble up the other components needed to build. For example, //src/ports/SkFontHost_FreeType.cpp needs FreeType, but only if we are compiling Skia with that type of font support. With the new organization structure in this CL, //src/ports/BUILD.bazel should have the logic that determines if the cpp file should be included in the build of Skia and if it is, that the Skia build should depend on //third_party:freetype2 Another example is //src/gpu/ganesh/BUILD.bazel, which chooses which of the dawn, gl, vulkan, etc backend sources, and the associated dependencies to include in the build. It does not specify what those are, but delegates to the BUILD.bazel files in the subdirectories housing the backend-specific code. The structure guidelines for BUILD.bazel files are as follows: - Have a filegroup() called "hdrs" (for public headers) or "srcs" (for private headers and all .cpp files) that is visible to the parent directory. This should list the files from the containing directory to include in the build. See //include/core/BUILD.bazel and //src/effects/BUILD.bazel as examples. - filegroup() rules can list a child directory's "hdrs" or "srcs" in their "srcs" attributes, but should not contain select statements pertaining to child directory files. See //include/gpu/BUILD.bazel and //src/gpu/ganesh/BUILD.bazel as examples. - May have a cc_library() called "deps". This can specify dependencies, cc_opts, and linkopts, but not srcs or hdrs. [1] See //src/codec/BUILD.bazel as an example. These should be visible to the parent directory. - "hdrs", "srcs", and "deps" for the primary Skia build (currently called "skia_core") should bubble up through //include/BUILD.bazel and //src/BUILD.bazel, one directory at a time. This CL demonstrates a very basic build of Skia with many features turned off (CPU only, no fonts, no codecs). Follow-on CLs will add to these rules as more targets are supported. See bazel/Makefile for the builds that work with just this CL. Suggested Review Order: - //BUILD.bazel to see the very small skia_core rule which delegates all the logic down stack. Note that it has a dependency on //bazel:defines_from_flags which will set all the defines listed there when compiling all the .cpp and .h files in skia_core *and* anything that depends on skia_core, but *not* //src:deps. - //include/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. Note that the filegroups in //include/private/... are called "srcs" to be similar to how Bazel wants "private headers" to be in the "srcs" of cc_library, cc_binary, etc. and only public headers are to be in "hdrs" [2]. - //src/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. //src/gpu/ganesh/... will be filled in for dawn, vulkan, and GL in the next CL. - //PRESUBMIT.py, which adds a check that runs buildifier [3] on modified BUILD.bazel files to make sure they stay consistently formatted. - //bazel/... to see the new option I added to make sksl opt-in or opt-out, so one could build Skia with sksl, but not with a gpu backend. - Misc .h and .cpp files, whose includes were removed if unnecessary or #ifdef'd out to make the minimal build work without GPU or SkSL includes. - //bazel/Makefile to see the builds that work with this CL. [1] Setting srcs or hdrs is error-prone at best, because those files will be compiled with a different set of defines than the rest of skia_core, because they wouldn't depend on //bazel:defines_from_flags. [2] https://bazel.build/reference/be/c-cpp#cc_library.hdrs [3] https://github.com/bazelbuild/buildtools/releases Change-Id: I5e0e3ae01ad42d672506d5aad1239f2512188191 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543977 Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
2022-05-27 17:56:03 +00:00
] + select({
[bazel] Add "skia_internal" target that exposes private API for tests/tools. Organization v3.5, if we are keeping track :) This splits the "srcs" filegroup into "srcs" and "private_hdrs", and renames "hdrs" to "public_hdrs". To assist with the split, I created the macro split_srcs_and_hdrs. Rather than keep two separate lists of header and source files, I figured it would be easiest, at least for the common case, to keep one list of files and then have a for loop split them apart. I've tried to be consistent with having the list of files be named with a _FILES suffix - maybe we can use this as a marker to generate .gni files in the future? Suggested review order: - //bazel/macros.bzl. Note this needs a corresponding G3 change (http://cl/452279799) as well. The exports_files_legacy change is the better approach to something I manually handled yesterday when fixing the G3 roll. - //BUILD.bazel to see the new target skia_internal and the previous skia_core renamed to skia_public. - //src/core/BUILD.bazel to see a typical usage of split_srcs_and_hdrs. - //include/... to see the change to public_hdrs and private_hdrs - //src/... to see many more usages of split_srcs_and_hdrs - //tools/... to see changes to skia_internal where appropriate. - Everything else. Note that //modules/... might also need to be built with skia_internal instead of skia_public, but we can fix that up later, if necessary. Change-Id: Ie1cc969455d97b029b2d77faa222c4a9bad70671 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/545716 Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2022-06-01 18:45:46 +00:00
"//bazel/common_config_settings:needs_sksl": ["//include/sksl:public_hdrs"],
[bazel] Add in hierarchical filegroup Bazel rules. The primary goal of this organization structure is to keep our top level BUILD.bazel file short, with as little logic as feasible. The logic required to control which files to include, which third_party deps are needed, what system libraries should be linked again, etc, should be in the BUILD.bazel file best should be as close to the affected files as feasible. In essence, we use filegroup() rules to bubble up the files needed to build Skia (all as one big cc_library call) and cc_library rules to bubble up the other components needed to build. For example, //src/ports/SkFontHost_FreeType.cpp needs FreeType, but only if we are compiling Skia with that type of font support. With the new organization structure in this CL, //src/ports/BUILD.bazel should have the logic that determines if the cpp file should be included in the build of Skia and if it is, that the Skia build should depend on //third_party:freetype2 Another example is //src/gpu/ganesh/BUILD.bazel, which chooses which of the dawn, gl, vulkan, etc backend sources, and the associated dependencies to include in the build. It does not specify what those are, but delegates to the BUILD.bazel files in the subdirectories housing the backend-specific code. The structure guidelines for BUILD.bazel files are as follows: - Have a filegroup() called "hdrs" (for public headers) or "srcs" (for private headers and all .cpp files) that is visible to the parent directory. This should list the files from the containing directory to include in the build. See //include/core/BUILD.bazel and //src/effects/BUILD.bazel as examples. - filegroup() rules can list a child directory's "hdrs" or "srcs" in their "srcs" attributes, but should not contain select statements pertaining to child directory files. See //include/gpu/BUILD.bazel and //src/gpu/ganesh/BUILD.bazel as examples. - May have a cc_library() called "deps". This can specify dependencies, cc_opts, and linkopts, but not srcs or hdrs. [1] See //src/codec/BUILD.bazel as an example. These should be visible to the parent directory. - "hdrs", "srcs", and "deps" for the primary Skia build (currently called "skia_core") should bubble up through //include/BUILD.bazel and //src/BUILD.bazel, one directory at a time. This CL demonstrates a very basic build of Skia with many features turned off (CPU only, no fonts, no codecs). Follow-on CLs will add to these rules as more targets are supported. See bazel/Makefile for the builds that work with just this CL. Suggested Review Order: - //BUILD.bazel to see the very small skia_core rule which delegates all the logic down stack. Note that it has a dependency on //bazel:defines_from_flags which will set all the defines listed there when compiling all the .cpp and .h files in skia_core *and* anything that depends on skia_core, but *not* //src:deps. - //include/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. Note that the filegroups in //include/private/... are called "srcs" to be similar to how Bazel wants "private headers" to be in the "srcs" of cc_library, cc_binary, etc. and only public headers are to be in "hdrs" [2]. - //src/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. //src/gpu/ganesh/... will be filled in for dawn, vulkan, and GL in the next CL. - //PRESUBMIT.py, which adds a check that runs buildifier [3] on modified BUILD.bazel files to make sure they stay consistently formatted. - //bazel/... to see the new option I added to make sksl opt-in or opt-out, so one could build Skia with sksl, but not with a gpu backend. - Misc .h and .cpp files, whose includes were removed if unnecessary or #ifdef'd out to make the minimal build work without GPU or SkSL includes. - //bazel/Makefile to see the builds that work with this CL. [1] Setting srcs or hdrs is error-prone at best, because those files will be compiled with a different set of defines than the rest of skia_core, because they wouldn't depend on //bazel:defines_from_flags. [2] https://bazel.build/reference/be/c-cpp#cc_library.hdrs [3] https://github.com/bazelbuild/buildtools/releases Change-Id: I5e0e3ae01ad42d672506d5aad1239f2512188191 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543977 Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
2022-05-27 17:56:03 +00:00
"//conditions:default": [],
}) + select({
[bazel] Add "skia_internal" target that exposes private API for tests/tools. Organization v3.5, if we are keeping track :) This splits the "srcs" filegroup into "srcs" and "private_hdrs", and renames "hdrs" to "public_hdrs". To assist with the split, I created the macro split_srcs_and_hdrs. Rather than keep two separate lists of header and source files, I figured it would be easiest, at least for the common case, to keep one list of files and then have a for loop split them apart. I've tried to be consistent with having the list of files be named with a _FILES suffix - maybe we can use this as a marker to generate .gni files in the future? Suggested review order: - //bazel/macros.bzl. Note this needs a corresponding G3 change (http://cl/452279799) as well. The exports_files_legacy change is the better approach to something I manually handled yesterday when fixing the G3 roll. - //BUILD.bazel to see the new target skia_internal and the previous skia_core renamed to skia_public. - //src/core/BUILD.bazel to see a typical usage of split_srcs_and_hdrs. - //include/... to see the change to public_hdrs and private_hdrs - //src/... to see many more usages of split_srcs_and_hdrs - //tools/... to see changes to skia_internal where appropriate. - Everything else. Note that //modules/... might also need to be built with skia_internal instead of skia_public, but we can fix that up later, if necessary. Change-Id: Ie1cc969455d97b029b2d77faa222c4a9bad70671 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/545716 Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2022-06-01 18:45:46 +00:00
"//bazel/common_config_settings:has_gpu_backend": ["//include/gpu:public_hdrs"],
[bazel] Add in hierarchical filegroup Bazel rules. The primary goal of this organization structure is to keep our top level BUILD.bazel file short, with as little logic as feasible. The logic required to control which files to include, which third_party deps are needed, what system libraries should be linked again, etc, should be in the BUILD.bazel file best should be as close to the affected files as feasible. In essence, we use filegroup() rules to bubble up the files needed to build Skia (all as one big cc_library call) and cc_library rules to bubble up the other components needed to build. For example, //src/ports/SkFontHost_FreeType.cpp needs FreeType, but only if we are compiling Skia with that type of font support. With the new organization structure in this CL, //src/ports/BUILD.bazel should have the logic that determines if the cpp file should be included in the build of Skia and if it is, that the Skia build should depend on //third_party:freetype2 Another example is //src/gpu/ganesh/BUILD.bazel, which chooses which of the dawn, gl, vulkan, etc backend sources, and the associated dependencies to include in the build. It does not specify what those are, but delegates to the BUILD.bazel files in the subdirectories housing the backend-specific code. The structure guidelines for BUILD.bazel files are as follows: - Have a filegroup() called "hdrs" (for public headers) or "srcs" (for private headers and all .cpp files) that is visible to the parent directory. This should list the files from the containing directory to include in the build. See //include/core/BUILD.bazel and //src/effects/BUILD.bazel as examples. - filegroup() rules can list a child directory's "hdrs" or "srcs" in their "srcs" attributes, but should not contain select statements pertaining to child directory files. See //include/gpu/BUILD.bazel and //src/gpu/ganesh/BUILD.bazel as examples. - May have a cc_library() called "deps". This can specify dependencies, cc_opts, and linkopts, but not srcs or hdrs. [1] See //src/codec/BUILD.bazel as an example. These should be visible to the parent directory. - "hdrs", "srcs", and "deps" for the primary Skia build (currently called "skia_core") should bubble up through //include/BUILD.bazel and //src/BUILD.bazel, one directory at a time. This CL demonstrates a very basic build of Skia with many features turned off (CPU only, no fonts, no codecs). Follow-on CLs will add to these rules as more targets are supported. See bazel/Makefile for the builds that work with just this CL. Suggested Review Order: - //BUILD.bazel to see the very small skia_core rule which delegates all the logic down stack. Note that it has a dependency on //bazel:defines_from_flags which will set all the defines listed there when compiling all the .cpp and .h files in skia_core *and* anything that depends on skia_core, but *not* //src:deps. - //include/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. Note that the filegroups in //include/private/... are called "srcs" to be similar to how Bazel wants "private headers" to be in the "srcs" of cc_library, cc_binary, etc. and only public headers are to be in "hdrs" [2]. - //src/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. //src/gpu/ganesh/... will be filled in for dawn, vulkan, and GL in the next CL. - //PRESUBMIT.py, which adds a check that runs buildifier [3] on modified BUILD.bazel files to make sure they stay consistently formatted. - //bazel/... to see the new option I added to make sksl opt-in or opt-out, so one could build Skia with sksl, but not with a gpu backend. - Misc .h and .cpp files, whose includes were removed if unnecessary or #ifdef'd out to make the minimal build work without GPU or SkSL includes. - //bazel/Makefile to see the builds that work with this CL. [1] Setting srcs or hdrs is error-prone at best, because those files will be compiled with a different set of defines than the rest of skia_core, because they wouldn't depend on //bazel:defines_from_flags. [2] https://bazel.build/reference/be/c-cpp#cc_library.hdrs [3] https://github.com/bazelbuild/buildtools/releases Change-Id: I5e0e3ae01ad42d672506d5aad1239f2512188191 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543977 Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
2022-05-27 17:56:03 +00:00
"//conditions:default": [],
}) + select({
"//bazel/common_config_settings:enable_svg_canvas_true": ["//include/svg:public_hdrs"],
"//conditions:default": [],
[bazel] Add in hierarchical filegroup Bazel rules. The primary goal of this organization structure is to keep our top level BUILD.bazel file short, with as little logic as feasible. The logic required to control which files to include, which third_party deps are needed, what system libraries should be linked again, etc, should be in the BUILD.bazel file best should be as close to the affected files as feasible. In essence, we use filegroup() rules to bubble up the files needed to build Skia (all as one big cc_library call) and cc_library rules to bubble up the other components needed to build. For example, //src/ports/SkFontHost_FreeType.cpp needs FreeType, but only if we are compiling Skia with that type of font support. With the new organization structure in this CL, //src/ports/BUILD.bazel should have the logic that determines if the cpp file should be included in the build of Skia and if it is, that the Skia build should depend on //third_party:freetype2 Another example is //src/gpu/ganesh/BUILD.bazel, which chooses which of the dawn, gl, vulkan, etc backend sources, and the associated dependencies to include in the build. It does not specify what those are, but delegates to the BUILD.bazel files in the subdirectories housing the backend-specific code. The structure guidelines for BUILD.bazel files are as follows: - Have a filegroup() called "hdrs" (for public headers) or "srcs" (for private headers and all .cpp files) that is visible to the parent directory. This should list the files from the containing directory to include in the build. See //include/core/BUILD.bazel and //src/effects/BUILD.bazel as examples. - filegroup() rules can list a child directory's "hdrs" or "srcs" in their "srcs" attributes, but should not contain select statements pertaining to child directory files. See //include/gpu/BUILD.bazel and //src/gpu/ganesh/BUILD.bazel as examples. - May have a cc_library() called "deps". This can specify dependencies, cc_opts, and linkopts, but not srcs or hdrs. [1] See //src/codec/BUILD.bazel as an example. These should be visible to the parent directory. - "hdrs", "srcs", and "deps" for the primary Skia build (currently called "skia_core") should bubble up through //include/BUILD.bazel and //src/BUILD.bazel, one directory at a time. This CL demonstrates a very basic build of Skia with many features turned off (CPU only, no fonts, no codecs). Follow-on CLs will add to these rules as more targets are supported. See bazel/Makefile for the builds that work with just this CL. Suggested Review Order: - //BUILD.bazel to see the very small skia_core rule which delegates all the logic down stack. Note that it has a dependency on //bazel:defines_from_flags which will set all the defines listed there when compiling all the .cpp and .h files in skia_core *and* anything that depends on skia_core, but *not* //src:deps. - //include/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. Note that the filegroups in //include/private/... are called "srcs" to be similar to how Bazel wants "private headers" to be in the "srcs" of cc_library, cc_binary, etc. and only public headers are to be in "hdrs" [2]. - //src/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. //src/gpu/ganesh/... will be filled in for dawn, vulkan, and GL in the next CL. - //PRESUBMIT.py, which adds a check that runs buildifier [3] on modified BUILD.bazel files to make sure they stay consistently formatted. - //bazel/... to see the new option I added to make sksl opt-in or opt-out, so one could build Skia with sksl, but not with a gpu backend. - Misc .h and .cpp files, whose includes were removed if unnecessary or #ifdef'd out to make the minimal build work without GPU or SkSL includes. - //bazel/Makefile to see the builds that work with this CL. [1] Setting srcs or hdrs is error-prone at best, because those files will be compiled with a different set of defines than the rest of skia_core, because they wouldn't depend on //bazel:defines_from_flags. [2] https://bazel.build/reference/be/c-cpp#cc_library.hdrs [3] https://github.com/bazelbuild/buildtools/releases Change-Id: I5e0e3ae01ad42d672506d5aad1239f2512188191 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543977 Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
2022-05-27 17:56:03 +00:00
}),
visibility = ["//:__pkg__"],
)
filegroup(
name = "private_hdrs",
srcs = [
[bazel] Add "skia_internal" target that exposes private API for tests/tools. Organization v3.5, if we are keeping track :) This splits the "srcs" filegroup into "srcs" and "private_hdrs", and renames "hdrs" to "public_hdrs". To assist with the split, I created the macro split_srcs_and_hdrs. Rather than keep two separate lists of header and source files, I figured it would be easiest, at least for the common case, to keep one list of files and then have a for loop split them apart. I've tried to be consistent with having the list of files be named with a _FILES suffix - maybe we can use this as a marker to generate .gni files in the future? Suggested review order: - //bazel/macros.bzl. Note this needs a corresponding G3 change (http://cl/452279799) as well. The exports_files_legacy change is the better approach to something I manually handled yesterday when fixing the G3 roll. - //BUILD.bazel to see the new target skia_internal and the previous skia_core renamed to skia_public. - //src/core/BUILD.bazel to see a typical usage of split_srcs_and_hdrs. - //include/... to see the change to public_hdrs and private_hdrs - //src/... to see many more usages of split_srcs_and_hdrs - //tools/... to see changes to skia_internal where appropriate. - Everything else. Note that //modules/... might also need to be built with skia_internal instead of skia_public, but we can fix that up later, if necessary. Change-Id: Ie1cc969455d97b029b2d77faa222c4a9bad70671 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/545716 Reviewed-by: Ben Wagner <bungeman@google.com> Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
2022-06-01 18:45:46 +00:00
"//include/private:private_hdrs",
[bazel] Add in hierarchical filegroup Bazel rules. The primary goal of this organization structure is to keep our top level BUILD.bazel file short, with as little logic as feasible. The logic required to control which files to include, which third_party deps are needed, what system libraries should be linked again, etc, should be in the BUILD.bazel file best should be as close to the affected files as feasible. In essence, we use filegroup() rules to bubble up the files needed to build Skia (all as one big cc_library call) and cc_library rules to bubble up the other components needed to build. For example, //src/ports/SkFontHost_FreeType.cpp needs FreeType, but only if we are compiling Skia with that type of font support. With the new organization structure in this CL, //src/ports/BUILD.bazel should have the logic that determines if the cpp file should be included in the build of Skia and if it is, that the Skia build should depend on //third_party:freetype2 Another example is //src/gpu/ganesh/BUILD.bazel, which chooses which of the dawn, gl, vulkan, etc backend sources, and the associated dependencies to include in the build. It does not specify what those are, but delegates to the BUILD.bazel files in the subdirectories housing the backend-specific code. The structure guidelines for BUILD.bazel files are as follows: - Have a filegroup() called "hdrs" (for public headers) or "srcs" (for private headers and all .cpp files) that is visible to the parent directory. This should list the files from the containing directory to include in the build. See //include/core/BUILD.bazel and //src/effects/BUILD.bazel as examples. - filegroup() rules can list a child directory's "hdrs" or "srcs" in their "srcs" attributes, but should not contain select statements pertaining to child directory files. See //include/gpu/BUILD.bazel and //src/gpu/ganesh/BUILD.bazel as examples. - May have a cc_library() called "deps". This can specify dependencies, cc_opts, and linkopts, but not srcs or hdrs. [1] See //src/codec/BUILD.bazel as an example. These should be visible to the parent directory. - "hdrs", "srcs", and "deps" for the primary Skia build (currently called "skia_core") should bubble up through //include/BUILD.bazel and //src/BUILD.bazel, one directory at a time. This CL demonstrates a very basic build of Skia with many features turned off (CPU only, no fonts, no codecs). Follow-on CLs will add to these rules as more targets are supported. See bazel/Makefile for the builds that work with just this CL. Suggested Review Order: - //BUILD.bazel to see the very small skia_core rule which delegates all the logic down stack. Note that it has a dependency on //bazel:defines_from_flags which will set all the defines listed there when compiling all the .cpp and .h files in skia_core *and* anything that depends on skia_core, but *not* //src:deps. - //include/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. Note that the filegroups in //include/private/... are called "srcs" to be similar to how Bazel wants "private headers" to be in the "srcs" of cc_library, cc_binary, etc. and only public headers are to be in "hdrs" [2]. - //src/BUILD.bazel and other BUILD.bazel files in the subdirectories of that folder. //src/gpu/ganesh/... will be filled in for dawn, vulkan, and GL in the next CL. - //PRESUBMIT.py, which adds a check that runs buildifier [3] on modified BUILD.bazel files to make sure they stay consistently formatted. - //bazel/... to see the new option I added to make sksl opt-in or opt-out, so one could build Skia with sksl, but not with a gpu backend. - Misc .h and .cpp files, whose includes were removed if unnecessary or #ifdef'd out to make the minimal build work without GPU or SkSL includes. - //bazel/Makefile to see the builds that work with this CL. [1] Setting srcs or hdrs is error-prone at best, because those files will be compiled with a different set of defines than the rest of skia_core, because they wouldn't depend on //bazel:defines_from_flags. [2] https://bazel.build/reference/be/c-cpp#cc_library.hdrs [3] https://github.com/bazelbuild/buildtools/releases Change-Id: I5e0e3ae01ad42d672506d5aad1239f2512188191 Bug: skia:12541 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543977 Reviewed-by: Leandro Lovisolo <lovisolo@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
2022-05-27 17:56:03 +00:00
],
visibility = ["//:__pkg__"],
)