build: winpack_dldt with dldt 2020.4.0
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Sun, 5 Jul 2020 22:16:46 +0000 (22:16 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Mon, 6 Jul 2020 14:08:54 +0000 (14:08 +0000)
platforms/winpack_dldt/2020.4/20200413-dldt-pdb.patch [new file with mode: 0644]
platforms/winpack_dldt/2020.4/20200604-dldt-disable-multidevice.patch [new file with mode: 0644]
platforms/winpack_dldt/2020.4/20200701-dldt-disable-unused-targets.patch [new file with mode: 0644]
platforms/winpack_dldt/2020.4/patch.config.py [new file with mode: 0644]
platforms/winpack_dldt/2020.4/sysroot.config.py [new file with mode: 0644]
platforms/winpack_dldt/build_package.py

diff --git a/platforms/winpack_dldt/2020.4/20200413-dldt-pdb.patch b/platforms/winpack_dldt/2020.4/20200413-dldt-pdb.patch
new file mode 100644 (file)
index 0000000..081c3c0
--- /dev/null
@@ -0,0 +1,14 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 1f981ed2..90eb500a 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -22,6 +22,9 @@ endif()
+ project(OpenVINO)
++set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /FS")
++set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
++
+ set(OpenVINO_MAIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+ set(IE_MAIN_SOURCE_DIR ${OpenVINO_MAIN_SOURCE_DIR}/inference-engine)
+ list(APPEND CMAKE_MODULE_PATH "${OpenVINO_MAIN_SOURCE_DIR}/cmake")
diff --git a/platforms/winpack_dldt/2020.4/20200604-dldt-disable-multidevice.patch b/platforms/winpack_dldt/2020.4/20200604-dldt-disable-multidevice.patch
new file mode 100644 (file)
index 0000000..b4d1ef9
--- /dev/null
@@ -0,0 +1,13 @@
+diff --git a/inference-engine/src/CMakeLists.txt b/inference-engine/src/CMakeLists.txt
+index 0ba0dd78..7d34e7cb 100644
+--- a/inference-engine/src/CMakeLists.txt
++++ b/inference-engine/src/CMakeLists.txt
+@@ -26,7 +26,7 @@ endif()
+ add_subdirectory(hetero_plugin)
+-add_subdirectory(multi_device)
++#add_subdirectory(multi_device)
+ add_subdirectory(transformations)
diff --git a/platforms/winpack_dldt/2020.4/20200701-dldt-disable-unused-targets.patch b/platforms/winpack_dldt/2020.4/20200701-dldt-disable-unused-targets.patch
new file mode 100644 (file)
index 0000000..bce5ccb
--- /dev/null
@@ -0,0 +1,173 @@
+diff --git a/inference-engine/CMakeLists.txt b/inference-engine/CMakeLists.txt
+index 39ff413b..df4e89c7 100644
+--- a/inference-engine/CMakeLists.txt
++++ b/inference-engine/CMakeLists.txt
+@@ -66,7 +66,7 @@ if(ENABLE_TESTS)
+     add_subdirectory(tests)
+ endif()
+-add_subdirectory(tools)
++#add_subdirectory(tools)
+ function(ie_build_samples)
+     # samples should be build with the same flags as from OpenVINO package,
+@@ -85,7 +85,7 @@ endfunction()
+ # gflags and format_reader targets are kept inside of samples directory and
+ # they must be built even if samples build is disabled (required for tests and tools).
+-ie_build_samples()
++#ie_build_samples()
+ file(GLOB_RECURSE SAMPLES_SOURCES samples/*.cpp samples/*.hpp samples/*.h)
+ add_cpplint_target(sample_cpplint
+@@ -174,10 +174,10 @@ endif()
+ # Developer package
+ #
+-ie_developer_export_targets(format_reader)
++#ie_developer_export_targets(format_reader)
+ ie_developer_export_targets(${NGRAPH_LIBRARIES})
+-ie_developer_export()
++#ie_developer_export()
+ configure_file(
+     "${IE_MAIN_SOURCE_DIR}/cmake/developer_package_config.cmake.in"
+diff --git a/inference-engine/src/inference_engine/CMakeLists.txt b/inference-engine/src/inference_engine/CMakeLists.txt
+index 4ae0d560..e37acbe0 100644
+--- a/inference-engine/src/inference_engine/CMakeLists.txt
++++ b/inference-engine/src/inference_engine/CMakeLists.txt
+@@ -99,7 +99,7 @@ add_cpplint_target(${TARGET_NAME}_plugin_api_cpplint FOR_SOURCES ${plugin_api_sr
+ # Create common base object library
+-add_library(${TARGET_NAME}_common_obj OBJECT
++add_library(${TARGET_NAME}_common_obj OBJECT EXCLUDE_FROM_ALL
+             ${IE_BASE_SOURCE_FILES})
+ target_compile_definitions(${TARGET_NAME}_common_obj PRIVATE IMPLEMENT_INFERENCE_ENGINE_API)
+@@ -112,7 +112,7 @@ target_include_directories(${TARGET_NAME}_common_obj SYSTEM PRIVATE
+ # Create object library
+-add_library(${TARGET_NAME}_obj OBJECT
++add_library(${TARGET_NAME}_obj OBJECT EXCLUDE_FROM_ALL
+             ${LIBRARY_SRC}
+             ${LIBRARY_HEADERS}
+             ${PUBLIC_HEADERS})
+@@ -177,7 +177,7 @@ ie_register_plugins(MAIN_TARGET ${TARGET_NAME}
+ # Static library used for unit tests which are always built
+-add_library(${TARGET_NAME}_s STATIC
++add_library(${TARGET_NAME}_s STATIC EXCLUDE_FROM_ALL
+             $<TARGET_OBJECTS:${TARGET_NAME}_obj>
+             $<TARGET_OBJECTS:${TARGET_NAME}_common_obj>
+             $<TARGET_OBJECTS:${TARGET_NAME}_legacy_obj>
+diff --git a/inference-engine/src/legacy_api/CMakeLists.txt b/inference-engine/src/legacy_api/CMakeLists.txt
+index 85524310..ed27e058 100644
+--- a/inference-engine/src/legacy_api/CMakeLists.txt
++++ b/inference-engine/src/legacy_api/CMakeLists.txt
+@@ -21,7 +21,7 @@ source_group("include" FILES ${PUBLIC_HEADERS})
+ # Create object library
+-add_library(${TARGET_NAME}_obj OBJECT
++add_library(${TARGET_NAME}_obj OBJECT EXCLUDE_FROM_ALL
+             ${LIBRARY_SRC}
+             ${PUBLIC_HEADERS})
+diff --git a/inference-engine/src/mkldnn_plugin/CMakeLists.txt b/inference-engine/src/mkldnn_plugin/CMakeLists.txt
+index 297783da..06da35c3 100644
+--- a/inference-engine/src/mkldnn_plugin/CMakeLists.txt
++++ b/inference-engine/src/mkldnn_plugin/CMakeLists.txt
+@@ -192,7 +192,7 @@ cross_compiled_file(${TARGET_NAME}
+ #  add test object library
+-add_library(${TARGET_NAME}_obj OBJECT ${SOURCES} ${HEADERS})
++add_library(${TARGET_NAME}_obj OBJECT EXCLUDE_FROM_ALL ${SOURCES} ${HEADERS})
+ target_include_directories(${TARGET_NAME}_obj PRIVATE $<TARGET_PROPERTY:inference_engine_preproc_s,INTERFACE_INCLUDE_DIRECTORIES>
+                                                       $<TARGET_PROPERTY:inference_engine_lp_transformations,INTERFACE_INCLUDE_DIRECTORIES>
+diff --git a/inference-engine/src/preprocessing/CMakeLists.txt b/inference-engine/src/preprocessing/CMakeLists.txt
+index adc52f06..6b7d0ffe 100644
+--- a/inference-engine/src/preprocessing/CMakeLists.txt
++++ b/inference-engine/src/preprocessing/CMakeLists.txt
+@@ -124,7 +124,7 @@ endif()
+ # Create object library
+-add_library(${TARGET_NAME}_obj OBJECT
++add_library(${TARGET_NAME}_obj OBJECT EXCLUDE_FROM_ALL
+             ${LIBRARY_SRC}
+             ${LIBRARY_HEADERS})
+@@ -183,7 +183,7 @@ add_cpplint_target(${TARGET_NAME}_cpplint FOR_TARGETS ${TARGET_NAME}
+ # Static library used for unit tests which are always built
+-add_library(${TARGET_NAME}_s STATIC
++add_library(${TARGET_NAME}_s STATIC EXCLUDE_FROM_ALL
+             $<TARGET_OBJECTS:${TARGET_NAME}_obj>)
+ set_ie_threading_interface_for(${TARGET_NAME}_s)
+diff --git a/inference-engine/src/vpu/common/CMakeLists.txt b/inference-engine/src/vpu/common/CMakeLists.txt
+index 43e9308f..2e40dd31 100644
+--- a/inference-engine/src/vpu/common/CMakeLists.txt
++++ b/inference-engine/src/vpu/common/CMakeLists.txt
+@@ -55,7 +55,7 @@ add_common_target("vpu_common_lib" FALSE)
+ # Unit tests support for graph transformer
+ if(WIN32)
+-    add_common_target("vpu_common_lib_test_static" TRUE)
++    #add_common_target("vpu_common_lib_test_static" TRUE)
+ else()
+     add_library("vpu_common_lib_test_static" ALIAS "vpu_common_lib")
+ endif()
+diff --git a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt
+index 982d3c7f..15fcf3e8 100644
+--- a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt
++++ b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt
+@@ -64,7 +64,7 @@ add_graph_transformer_target("vpu_graph_transformer" FALSE)
+ # Unit tests support for graph transformer
+ if(WIN32)
+-    add_graph_transformer_target("vpu_graph_transformer_test_static" TRUE)
++    #add_graph_transformer_target("vpu_graph_transformer_test_static" TRUE)
+ else()
+     add_library("vpu_graph_transformer_test_static" ALIAS "vpu_graph_transformer")
+ endif()
+diff --git a/inference-engine/thirdparty/CMakeLists.txt b/inference-engine/thirdparty/CMakeLists.txt
+index f94453e0..c80e75c5 100644
+--- a/inference-engine/thirdparty/CMakeLists.txt
++++ b/inference-engine/thirdparty/CMakeLists.txt
+@@ -43,13 +43,13 @@ function(build_with_lto)
+     endfunction()
+     ie_build_pugixml()
+-    add_subdirectory(stb_lib)
++    #add_subdirectory(stb_lib)
+     add_subdirectory(ade)
+     add_subdirectory(fluid/modules/gapi)
+     target_include_directories(pugixml INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/pugixml/src>")
+-    set_target_properties(pugixml ade fluid stb_image
++    set_target_properties(pugixml ade fluid
+                           PROPERTIES FOLDER thirdparty)
+     # developer package
+diff --git a/inference-engine/thirdparty/pugixml/CMakeLists.txt b/inference-engine/thirdparty/pugixml/CMakeLists.txt
+index 8bcb2801..380fb468 100644
+--- a/inference-engine/thirdparty/pugixml/CMakeLists.txt
++++ b/inference-engine/thirdparty/pugixml/CMakeLists.txt
+@@ -41,7 +41,7 @@ if(BUILD_SHARED_LIBS)
+ else()
+       add_library(pugixml STATIC ${SOURCES})
+       if (MSVC)
+-              add_library(pugixml_mt STATIC ${SOURCES})
++               #add_library(pugixml_mt STATIC ${SOURCES})
+               #if (WIN32)
+               #       set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
+               #       set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
diff --git a/platforms/winpack_dldt/2020.4/patch.config.py b/platforms/winpack_dldt/2020.4/patch.config.py
new file mode 100644 (file)
index 0000000..496f383
--- /dev/null
@@ -0,0 +1,3 @@
+applyPatch('20200701-dldt-disable-unused-targets.patch')
+applyPatch('20200413-dldt-pdb.patch')
+applyPatch('20200604-dldt-disable-multidevice.patch')
diff --git a/platforms/winpack_dldt/2020.4/sysroot.config.py b/platforms/winpack_dldt/2020.4/sysroot.config.py
new file mode 100644 (file)
index 0000000..fc8dffd
--- /dev/null
@@ -0,0 +1,56 @@
+sysroot_bin_dir = prepare_dir(self.sysrootdir / 'bin')
+copytree(self.build_dir / 'install', self.sysrootdir / 'ngraph')
+#rm_one(self.sysrootdir / 'ngraph' / 'lib' / 'ngraph.dll')
+
+build_config = 'Release' if not self.config.build_debug else 'Debug'
+build_bin_dir = self.build_dir / 'bin' / 'intel64' / build_config
+
+def copy_bin(name):
+    global build_bin_dir, sysroot_bin_dir
+    copytree(build_bin_dir / name, sysroot_bin_dir / name)
+
+dll_suffix = 'd' if self.config.build_debug else ''
+def copy_dll(name):
+    global copy_bin, dll_suffix
+    copy_bin(name + dll_suffix + '.dll')
+    copy_bin(name + dll_suffix + '.pdb')
+
+copy_bin('cache.json')
+copy_dll('clDNNPlugin')
+copy_dll('HeteroPlugin')
+copy_dll('inference_engine')
+copy_dll('inference_engine_ir_reader')
+copy_dll('inference_engine_legacy')
+copy_dll('inference_engine_transformations')  # runtime
+copy_dll('inference_engine_lp_transformations')  # runtime
+copy_dll('MKLDNNPlugin')  # runtime
+copy_dll('myriadPlugin')  # runtime
+#copy_dll('MultiDevicePlugin')  # runtime, not used
+copy_dll('ngraph')
+copy_bin('plugins.xml')
+copytree(self.build_dir / 'bin' / 'intel64' / 'pcie-ma248x.elf', sysroot_bin_dir / 'pcie-ma248x.elf')
+copytree(self.build_dir / 'bin' / 'intel64' / 'usb-ma2x8x.mvcmd', sysroot_bin_dir / 'usb-ma2x8x.mvcmd')
+copytree(self.build_dir / 'bin' / 'intel64' / 'usb-ma2450.mvcmd', sysroot_bin_dir / 'usb-ma2450.mvcmd')
+
+copytree(self.srcdir / 'inference-engine' / 'temp' / 'tbb' / 'bin', sysroot_bin_dir)
+copytree(self.srcdir / 'inference-engine' / 'temp' / 'tbb', self.sysrootdir / 'tbb')
+
+sysroot_ie_dir = prepare_dir(self.sysrootdir / 'deployment_tools' / 'inference_engine')
+sysroot_ie_lib_dir = prepare_dir(sysroot_ie_dir / 'lib' / 'intel64')
+
+copytree(self.srcdir / 'inference-engine' / 'include', sysroot_ie_dir / 'include')
+if not self.config.build_debug:
+    copytree(self.build_dir / 'install' / 'lib' / 'ngraph.lib', sysroot_ie_lib_dir / 'ngraph.lib')
+    copytree(build_bin_dir / 'inference_engine.lib', sysroot_ie_lib_dir / 'inference_engine.lib')
+    copytree(build_bin_dir / 'inference_engine_ir_reader.lib', sysroot_ie_lib_dir / 'inference_engine_ir_reader.lib')
+    copytree(build_bin_dir / 'inference_engine_legacy.lib', sysroot_ie_lib_dir / 'inference_engine_legacy.lib')
+else:
+    copytree(self.build_dir / 'install' / 'lib' / 'ngraphd.lib', sysroot_ie_lib_dir / 'ngraphd.lib')
+    copytree(build_bin_dir / 'inference_engined.lib', sysroot_ie_lib_dir / 'inference_engined.lib')
+    copytree(build_bin_dir / 'inference_engine_ir_readerd.lib', sysroot_ie_lib_dir / 'inference_engine_ir_readerd.lib')
+    copytree(build_bin_dir / 'inference_engine_legacyd.lib', sysroot_ie_lib_dir / 'inference_engine_legacyd.lib')
+
+sysroot_license_dir = prepare_dir(self.sysrootdir / 'etc' / 'licenses')
+copytree(self.srcdir / 'LICENSE', sysroot_license_dir / 'dldt-LICENSE')
+copytree(self.srcdir / 'ngraph/LICENSE', sysroot_license_dir / 'ngraph-LICENSE')
+copytree(self.sysrootdir / 'tbb/LICENSE', sysroot_license_dir / 'tbb-LICENSE')
index 07ad96b..8f37241 100644 (file)
@@ -133,9 +133,10 @@ def git_checkout(dst, url, branch, revision, clone_extra_args, noFetch=False):
                 (['-b', branch] if branch else []) +
                 clone_extra_args + [url, '.'], cwd=dst)
     else:
-        execute(cmd=['git', 'fetch', 'origin'] + ([branch] if branch else []), cwd=dst)
+        execute(cmd=['git', 'fetch', 'origin'] + ([branch + ':' + branch] if branch else []), cwd=dst)
     execute(cmd=['git', 'reset', '--hard'], cwd=dst)
-    execute(cmd=['git', 'checkout', '-B', 'winpack_dldt', revision], cwd=dst)
+    execute(cmd=['git', 'clean', '-f', '-d'], cwd=dst)
+    execute(cmd=['git', 'checkout', '--force', '-B', 'winpack_dldt', revision], cwd=dst)
     execute(cmd=['git', 'clean', '-f', '-d'], cwd=dst)
     execute(cmd=['git', 'submodule', 'init'], cwd=dst)
     execute(cmd=['git', 'submodule', 'update', '--force', '--depth=1000'], cwd=dst)
@@ -149,6 +150,7 @@ def git_apply_patch(src_dir, patch_file):
     patch_file = str(patch_file)  # Python 3.5 may not handle Path
     assert os.path.exists(patch_file), patch_file
     execute(cmd=['git', 'apply', '--3way', '-v', '--ignore-space-change', str(patch_file)], cwd=src_dir)
+    execute(cmd=['git', 'diff', 'HEAD'], cwd=src_dir)
 
 
 #===================================================================================================
@@ -186,6 +188,17 @@ class BuilderDLDT:
         self.build_dir = prepare_dir(self.outdir / 'build', clean=self.config.clean_dldt)
         self.sysrootdir = prepare_dir(self.outdir / 'sysroot', clean=self.config.clean_dldt)
 
+        if self.config.build_subst_drive:
+            if os.path.exists(self.config.build_subst_drive + ':\\'):
+                execute(['subst', self.config.build_subst_drive + ':', '/D'])
+            execute(['subst', self.config.build_subst_drive + ':', str(self.outdir)])
+            def fix_path(p):
+                return str(p).replace(str(self.outdir), self.config.build_subst_drive + ':')
+            self.srcdir = Path(fix_path(self.srcdir))
+            self.build_dir = Path(fix_path(self.build_dir))
+            self.sysrootdir = Path(fix_path(self.sysrootdir))
+
+
     def init_patchset(self):
         cpath = self.cpath
         self.patch_file = str(cpath / 'patch.config.py')  # Python 3.5 may not handle Path
@@ -255,12 +268,14 @@ class BuilderDLDT:
             BUILD_TESTS='OFF',
             ENABLE_OPENCV='OFF',
             ENABLE_GNA='OFF',
+            ENABLE_SPEECH_DEMO='OFF',  # 2020.4+
             NGRAPH_DOC_BUILD_ENABLE='OFF',
             NGRAPH_UNIT_TEST_ENABLE='OFF',
             NGRAPH_UNIT_TEST_OPENVINO_ENABLE='OFF',
             NGRAPH_TEST_UTIL_ENABLE='OFF',
             NGRAPH_ONNX_IMPORT_ENABLE='OFF',
             CMAKE_INSTALL_PREFIX=str(self.build_dir / 'install'),
+            OUTPUT_ROOT=str(self.build_dir),  # 2020.4+
         )
 
         cmd += [ '-D%s=%s' % (k, v) for (k, v) in cmake_vars.items() if v is not None]
@@ -270,14 +285,6 @@ class BuilderDLDT:
         cmd.append(str(self.srcdir))
 
         build_dir = self.build_dir
-        if self.config.build_subst_drive:
-            if os.path.exists(self.config.build_subst_drive + ':\\'):
-                execute(['subst', self.config.build_subst_drive + ':', '/D'])
-            def fix_path(p):
-                return str(p).replace(str(self.outdir), self.config.build_subst_drive + ':')
-            execute(['subst', self.config.build_subst_drive + ':', str(self.outdir)])
-            cmd = [fix_path(c) for c in cmd]
-            build_dir = Path(fix_path(build_dir))
         try:
             execute(cmd, cwd=build_dir)
 
@@ -291,8 +298,6 @@ class BuilderDLDT:
             cmd = [self.cmake_path, '-DBUILD_TYPE=' + build_config, '-P', 'cmake_install.cmake']
             execute(cmd, cwd=build_dir / 'ngraph')
         except:
-            if self.config.build_subst_drive:
-                execute(['subst', self.config.build_subst_drive + ':', '/D'])
             raise
 
         log.info('DLDT build completed')
@@ -307,6 +312,11 @@ class BuilderDLDT:
         log.info('DLDT sysroot preparation completed')
 
 
+    def cleanup(self):
+        if self.config.build_subst_drive:
+            execute(['subst', self.config.build_subst_drive + ':', '/D'])
+
+
 #===================================================================================================
 
 class Builder:
@@ -466,7 +476,7 @@ def main():
     parser.add_argument('--dldt_reference_dir', help='DLDT reference git repository (optional)')
     parser.add_argument('--dldt_src_dir', help='DLDT custom source repository (skip git checkout and patching, use for TESTING only)')
 
-    parser.add_argument('--dldt_config', help='Specify DLDT build configuration (defaults to DLDT commit)')
+    parser.add_argument('--dldt_config', help='Specify DLDT build configuration (defaults to evaluate from DLDT commit/branch)')
 
     args = parser.parse_args()
 
@@ -492,7 +502,10 @@ def main():
         args.opencv_dir = os.path.abspath(args.opencv_dir)
 
     if not args.dldt_config:
-        args.dldt_config = args.dldt_src_commit
+        if args.dldt_src_commit == 'releases/2020/4' or args.dldt_src_branch == 'releases/2020/4':
+            args.dldt_config = '2020.4'
+        else:
+            args.dldt_config = args.dldt_src_commit
 
     _opencv_dir = check_dir(args.opencv_dir)
     _outdir = prepare_dir(args.output_dir)
@@ -504,14 +517,18 @@ def main():
 
     builder_dldt = BuilderDLDT(args)
 
-    builder_dldt.prepare_sources()
-    builder_dldt.build()
-    builder_dldt.make_sysroot()
-
-    builder_opencv = Builder(args)
-    builder_opencv.build(builder_dldt)
-    builder_opencv.copy_sysroot(builder_dldt)
-    builder_opencv.package_sources()
+    try:
+        builder_dldt.prepare_sources()
+        builder_dldt.build()
+        builder_dldt.make_sysroot()
+
+        builder_opencv = Builder(args)
+        builder_opencv.build(builder_dldt)
+        builder_opencv.copy_sysroot(builder_dldt)
+        builder_opencv.package_sources()
+    except:
+        builder_dldt.cleanup()
+        raise
 
     log.info("=====")
     log.info("===== Build finished")