Skip to content

Commit b282297

Browse files
kalmuftifacebook-github-bot
authored andcommitted
Replace whitelist with allowlist (pytorch#42067)
Summary: Fixes pytorch#41757 I've replaced all the whitelist with allowlist for this issue. Pull Request resolved: pytorch#42067 Reviewed By: pbelevich Differential Revision: D22791690 Pulled By: malfet fbshipit-source-id: 638c13cf49915f5c83bd79c7f4a39b8390cc15b4
1 parent 1a8269a commit b282297

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ enable_testing()
449449

450450
# ---[ Build variables set within the cmake tree
451451
include(cmake/BuildVariables.cmake)
452-
set(CAFFE2_WHITELIST "" CACHE STRING "A whitelist file of files that one should build.")
452+
set(CAFFE2_ALLOWLIST "" CACHE STRING "A allowlist file of files that one should build.")
453453

454454
# Set default build type
455455
if(NOT CMAKE_BUILD_TYPE)
@@ -499,8 +499,8 @@ if(USE_VULKAN_SHADERC_RUNTIME)
499499
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_VULKAN_SHADERC_RUNTIME")
500500
endif()
501501

502-
# ---[ Whitelist file if whitelist is specified
503-
include(cmake/Whitelist.cmake)
502+
# ---[ Allowlist file if allowlist is specified
503+
include(cmake/Allowlist.cmake)
504504

505505
# ---[ Set link flag, handle additional deps for gcc 4.8 and above
506506
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8.0 AND NOT ANDROID)

caffe2/CMakeLists.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ if(NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
142142
add_subdirectory(transforms)
143143
endif()
144144

145-
# Advanced: if we have white list specified, we will do intersections for all
145+
# Advanced: if we have allow list specified, we will do intersections for all
146146
# main lib srcs.
147-
if(CAFFE2_WHITELISTED_FILES)
148-
caffe2_do_whitelist(Caffe2_CPU_SRCS CAFFE2_WHITELISTED_FILES)
149-
caffe2_do_whitelist(Caffe2_GPU_SRCS CAFFE2_WHITELISTED_FILES)
150-
caffe2_do_whitelist(Caffe2_HIP_SRCS CAFFE2_WHITELISTED_FILES)
147+
if(CAFFE2_ALLOWLISTED_FILES)
148+
caffe2_do_allowlist(Caffe2_CPU_SRCS CAFFE2_ALLOWLISTED_FILES)
149+
caffe2_do_allowlist(Caffe2_GPU_SRCS CAFFE2_ALLOWLISTED_FILES)
150+
caffe2_do_allowlist(Caffe2_HIP_SRCS CAFFE2_ALLOWLISTED_FILES)
151151
endif()
152152

153153
# Debug messages - if you want to get a list of source files, enable the

cmake/Allowlist.cmake

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
if(__caffe2_allowlist_included)
3+
return()
4+
endif()
5+
6+
set(__caffe2_allowlist_included TRUE)
7+
8+
set(CAFFE2_ALLOWLISTED_FILES)
9+
if(NOT CAFFE2_ALLOWLIST)
10+
return()
11+
endif()
12+
13+
# First read the allowlist file and break it by line.
14+
file(READ "${CAFFE2_ALLOWLIST}" allowlist_content)
15+
# Convert file contents into a CMake list
16+
string(REGEX REPLACE "\n" ";" allowlist_content ${allowlist_content})
17+
18+
foreach(item ${allowlist_content})
19+
file(GLOB_RECURSE tmp ${item})
20+
set(CAFFE2_ALLOWLISTED_FILES ${CAFFE2_ALLOWLISTED_FILES} ${tmp})
21+
endforeach()
22+
23+
macro(caffe2_do_allowlist output allowlist)
24+
set(_tmp)
25+
foreach(item ${${output}})
26+
list(FIND ${allowlist} ${item} _index)
27+
if(${_index} GREATER -1)
28+
set(_tmp ${_tmp} ${item})
29+
endif()
30+
endforeach()
31+
set(${output} ${_tmp})
32+
endmacro()

cmake/Whitelist.cmake

-32
This file was deleted.

0 commit comments

Comments
 (0)