Skip to content

Commit

Permalink
Replace whitelist with allowlist (pytorch#42067)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kalmufti authored and facebook-github-bot committed Jul 28, 2020
1 parent 1a8269a commit b282297
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ enable_testing()

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

# Set default build type
if(NOT CMAKE_BUILD_TYPE)
Expand Down Expand Up @@ -499,8 +499,8 @@ if(USE_VULKAN_SHADERC_RUNTIME)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_VULKAN_SHADERC_RUNTIME")
endif()

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

# ---[ Set link flag, handle additional deps for gcc 4.8 and above
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8.0 AND NOT ANDROID)
Expand Down
10 changes: 5 additions & 5 deletions caffe2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ if(NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
add_subdirectory(transforms)
endif()

# Advanced: if we have white list specified, we will do intersections for all
# Advanced: if we have allow list specified, we will do intersections for all
# main lib srcs.
if(CAFFE2_WHITELISTED_FILES)
caffe2_do_whitelist(Caffe2_CPU_SRCS CAFFE2_WHITELISTED_FILES)
caffe2_do_whitelist(Caffe2_GPU_SRCS CAFFE2_WHITELISTED_FILES)
caffe2_do_whitelist(Caffe2_HIP_SRCS CAFFE2_WHITELISTED_FILES)
if(CAFFE2_ALLOWLISTED_FILES)
caffe2_do_allowlist(Caffe2_CPU_SRCS CAFFE2_ALLOWLISTED_FILES)
caffe2_do_allowlist(Caffe2_GPU_SRCS CAFFE2_ALLOWLISTED_FILES)
caffe2_do_allowlist(Caffe2_HIP_SRCS CAFFE2_ALLOWLISTED_FILES)
endif()

# Debug messages - if you want to get a list of source files, enable the
Expand Down
32 changes: 32 additions & 0 deletions cmake/Allowlist.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

if(__caffe2_allowlist_included)
return()
endif()

set(__caffe2_allowlist_included TRUE)

set(CAFFE2_ALLOWLISTED_FILES)
if(NOT CAFFE2_ALLOWLIST)
return()
endif()

# First read the allowlist file and break it by line.
file(READ "${CAFFE2_ALLOWLIST}" allowlist_content)
# Convert file contents into a CMake list
string(REGEX REPLACE "\n" ";" allowlist_content ${allowlist_content})

foreach(item ${allowlist_content})
file(GLOB_RECURSE tmp ${item})
set(CAFFE2_ALLOWLISTED_FILES ${CAFFE2_ALLOWLISTED_FILES} ${tmp})
endforeach()

macro(caffe2_do_allowlist output allowlist)
set(_tmp)
foreach(item ${${output}})
list(FIND ${allowlist} ${item} _index)
if(${_index} GREATER -1)
set(_tmp ${_tmp} ${item})
endif()
endforeach()
set(${output} ${_tmp})
endmacro()
32 changes: 0 additions & 32 deletions cmake/Whitelist.cmake

This file was deleted.

0 comments on commit b282297

Please sign in to comment.