Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/openvinotoolkit/master' into ng…
Browse files Browse the repository at this point in the history
…raph_static_lib
  • Loading branch information
emmanuelattia committed Oct 30, 2020
2 parents 49c2903 + ce037da commit 97c5879
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ function(_ie_add_api_validator_post_build_step)
set(UWP_API_VALIDATOR_APIS "${PROGRAMFILES}/Windows Kits/10/build/universalDDIs/x64/UniversalDDIs.xml")
set(UWP_API_VALIDATOR_EXCLUSION "${UWP_SDK_PATH}/BinaryExclusionlist.xml")

if(NOT UWP_API_VALIDATOR OR (WINDOWS_STORE OR WINDOWS_PHONE) OR
NOT EXISTS UWP_API_VALIDATOR_APIS OR NOT EXISTS UWP_API_VALIDATOR_EXCLUSION)
if((NOT UWP_API_VALIDATOR) OR (WINDOWS_STORE OR WINDOWS_PHONE))
return()
endif()

Expand Down Expand Up @@ -85,24 +84,35 @@ function(_ie_add_api_validator_post_build_step)
return()
endif()

# generate rules
# apply check

macro(api_validator_get_target_name)
get_target_property(IS_IMPORTED ${target} IMPORTED)
if(IS_IMPORTED)
get_target_property(target_location ${target} LOCATION)
get_filename_component(target_name "${target_location}" NAME_WE)
else()
set(target_name ${target})
endif()
endmacro()

foreach(target IN LISTS API_VALIDATOR_TARGETS)
list(APPEND commands
COMMAND "${UWP_API_VALIDATOR}"
-SupportedApiXmlFiles:${UWP_API_VALIDATOR_APIS}
-BinaryExclusionListXmlFile:${UWP_API_VALIDATOR_EXCLUSION}
-StrictCompliance:TRUE
-DriverPackagePath:$<TARGET_FILE:${target}>)
api_validator_get_target_name()
set(output_file "${CMAKE_BINARY_DIR}/api_validator/${target_name}.txt")

add_custom_command(TARGET ${API_VALIDATOR_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND}
-D UWP_API_VALIDATOR=${UWP_API_VALIDATOR}
-D UWP_API_VALIDATOR_TARGET=$<TARGET_FILE:${target}>
-D UWP_API_VALIDATOR_APIS=${UWP_API_VALIDATOR_APIS}
-D UWP_API_VALIDATOR_EXCLUSION=${UWP_API_VALIDATOR_EXCLUSION}
-D UWP_API_VALIDATOR_OUTPUT=${output_file}
-P "${OpenVINO_MAIN_SOURCE_DIR}/cmake/api_validator/api_validator_run.cmake"
BYPRODUCTS ${output_file}
COMMENT "[apiValidator] Check ${target_name} for OneCore compliance"
VERBATIM)
endforeach()

# apply rules

add_custom_command(TARGET ${API_VALIDATOR_TARGET} POST_BUILD
${commands}
COMMENT "[apiValidator] Check ${API_VALIDATOR_TARGET} and its dependencies for WCOS compatibility"
VERBATIM)

# update list of validated libraries

list(APPEND VALIDATED_LIBRARIES ${API_VALIDATOR_TARGETS})
Expand Down
69 changes: 69 additions & 0 deletions cmake/api_validator/api_validator_run.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright (C) 2018-2020 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

cmake_policy(SET CMP0012 NEW)

foreach(var UWP_API_VALIDATOR UWP_API_VALIDATOR_TARGET
UWP_API_VALIDATOR_APIS UWP_API_VALIDATOR_EXCLUSION
UWP_API_VALIDATOR_OUTPUT)
if(NOT DEFINED ${var})
message(FATAL_ERROR "Variable ${var} is not defined")
endif()
endforeach()

# create command

if(NOT EXISTS "${UWP_API_VALIDATOR_APIS}")
message(FATAL_ERROR "${UWP_API_VALIDATOR_APIS} does not exist")
endif()

set(command "${UWP_API_VALIDATOR}"
-SupportedApiXmlFiles:${UWP_API_VALIDATOR_APIS}
-DriverPackagePath:${UWP_API_VALIDATOR_TARGET})
if(EXISTS "${UWP_API_VALIDATOR_EXCLUSION}")
list(APPEND command
-BinaryExclusionListXmlFile:${UWP_API_VALIDATOR_EXCLUSION}
-StrictCompliance:TRUE)
set(UWP_HAS_BINARY_EXCLUSION ON)
endif()

# execute

execute_process(COMMAND ${command}
OUTPUT_VARIABLE output_message
ERROR_VARIABLE error_message
RESULT_VARIABLE exit_code
OUTPUT_STRIP_TRAILING_WHITESPACE)

file(WRITE "${UWP_API_VALIDATOR_OUTPUT}" "${output_message}\n\n\n${error_message}")

# post-process output

get_filename_component(name "${UWP_API_VALIDATOR_TARGET}" NAME)

if(NOT UWP_HAS_BINARY_EXCLUSION)
set(exclusion_dlls "msvcp140.dll" "vcruntime140.dll")

# remove exclusions from error_message

foreach(dll IN LISTS exclusion_dlls)
string(REGEX REPLACE
"ApiValidation: Error: ${name} has unsupported API call to \"${dll}![^\"]+\"\n"
"" error_message "${error_message}")
endforeach()

# throw error if error_message still contains any errors

if(error_message)
message(FATAL_ERROR "${error_message}")
endif()
endif()

# write output

if(UWP_HAS_BINARY_EXCLUSION AND NOT exit_code EQUAL 0)
message(FATAL_ERROR "${error_message}")
endif()

message("ApiValidator: ${name} has passed the OneCore compliance")
4 changes: 3 additions & 1 deletion cmake/developer_package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,13 @@ include(os_flags)
include(sanitizer)
include(cross_compiled_func)
include(faster_build)
include(api_validator)
include(api_validator/api_validator)

function(set_ci_build_number)
set(OpenVINO_MAIN_SOURCE_DIR "${CMAKE_SOURCE_DIR}")
include(version)
set(CI_BUILD_NUMBER "${CI_BUILD_NUMBER}" PARENT_SCOPE)
endfunction()
set_ci_build_number()

set(CMAKE_VERBOSE_MAKEFILE ON)
10 changes: 7 additions & 3 deletions cmake/uwp.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
set(CMAKE_SYSTEM_NAME WindowsStore)

if(NOT DEFINED CMAKE_SYSTEM_VERSION)
set(CMAKE_SYSTEM_VERSION 10.0)
# Sometimes CMAKE_HOST_SYSTEM_VERSION has form 10.x.y while we need
# form 10.x.y.z Adding .0 at the end fixes the issue
if(CMAKE_HOST_SYSTEM_VERSION MATCHES "^10\.0.[0-9]+$")
set(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}.0")
else()
set(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
endif()
endif()

if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
Expand All @@ -21,6 +27,4 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/src/uwp.hpp"
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FI\"${CMAKE_CURRENT_BINARY_DIR}/src/uwp.hpp\"")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /FI\"${CMAKE_CURRENT_BINARY_DIR}/src/uwp.hpp\"")

# UWP setting for package isolation
# set(CMAKE_VS_GLOBALS "AppContainerApplication=true")
set(CMAKE_VS_GLOBALS "WindowsTargetPlatformMinVersion=${CMAKE_SYSTEM_VERSION}")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "functional_test_utils/plugin_config.hpp"
#include "functional_test_utils/blob_utils.hpp"
#include "legacy/ie_ngraph_utils.hpp"
#include <ie_ngraph_utils.hpp>

void PreparePluginConfiguration(LayerTestsUtils::LayerTestsCommon* test) {
const float MAX_VAL_2B_FEAT = 16384.0f;
Expand Down

0 comments on commit 97c5879

Please sign in to comment.