Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / infra / packaging / preset / 20200616_windows
1 #!/bin/bash
2
3 function preset_configure()
4 {
5   REQUIRED_UNITS=()
6   # Common Libraries
7   REQUIRED_UNITS+=("angkor" "cwrap" "foder" "oops" "pepper-assert")
8   REQUIRED_UNITS+=("pepper-str" "pepper-strcast" "pp" "safemain" "stdex")
9   # Hermes Logging Framework
10   REQUIRED_UNITS+=("hermes" "hermes-std")
11   # loco IR and related utilities
12   REQUIRED_UNITS+=("loco" "locop" "locomotiv" "logo-core" "logo")
13   # TensorFlow GraphDef I/O
14   REQUIRED_UNITS+=("mio-tflite" "mio-circle")
15   # Circle compiler library (.circle -> .circle)
16   REQUIRED_UNITS+=("luci")
17   # Tools
18   REQUIRED_UNITS+=("circlechef" "circle2circle" "circle-verify")
19   REQUIRED_UNITS+=("luci-interpreter" "record-minmax" "tflchef")
20   REQUIRED_UNITS+=("tflite2circle" "tf2tfliteV2")
21
22   NPROC=$(cat /proc/cpuinfo | grep -c processor)
23
24   # TODO Use "nncc configure" and "nncc build"
25   cmake \
26     -G "MSYS Makefiles" \
27     -DTF2NNPKG_FOR_WINDOWS=ON \
28     -DUSE_PROTOBUF_LEGACY_IMPORT=ON \
29     -DCMAKE_EXE_LINKER_FLAGS="-Wl,--allow-multiple-definition" \
30     -DCMAKE_SHARED_LINKER_FLAGS="-Wl,--allow-multiple-definition" \
31     -DENABLE_TEST=OFF \
32     -DDOWNLOAD_GTEST=OFF \
33     -DBUILD_GTEST=OFF \
34     -DCMAKE_C_COMPILER=gcc \
35     -DCMAKE_CXX_COMPILER=g++ \
36     -DCMAKE_INSTALL_PREFIX="${NNCC_INSTALL_PREFIX}" \
37     -DCMAKE_BUILD_TYPE=release \
38     -DBUILD_WHITELIST=$(join_by ";" "${REQUIRED_UNITS[@]}") \
39     -DEXTERNALS_BUILD_THREADS=$((NPROC/2)) \
40     ${EXTRA_OPTIONS[@]} \
41     "${NNAS_PROJECT_PATH}/infra/nncc"
42 }
43
44 function preset_install()
45 {
46   # Install libraries to bin/ for Windows release
47   mv ${NNCC_INSTALL_PREFIX}/lib/*.dll ${NNCC_INSTALL_PREFIX}/bin
48   rm -rf ${NNCC_INSTALL_PREFIX}/lib
49
50   install -t "${NNPKG_INSTALL_PREFIX}/bin" -D \
51     "${NNAS_PROJECT_PATH}/tools/nnpackage_tool/model2nnpkg/model2nnpkg.sh"
52
53   # Install tf2nnpkg
54   install -T -m 755 -D "${SCRIPT_PATH}/res/tf2nnpkg.${PRESET}" "${NNAS_INSTALL_PREFIX}/bin/tf2nnpkg"
55
56   # Though you have to install tensorflow to run 'tf2tfliteV2',
57   # tensorflow can't be installed in mingw. First, You can install tensorflow 
58   # from Window native CMD(run as administrator) with python virtual environment.
59   # And, you must copy it to "${NNAS_INSTALL_PREFIX}/bin/venv"
60 }