build.bat 3.7 KB
Newer Older
C
chenjianping 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
@rem Copyright 2020 Huawei Technologies Co., Ltd
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem ============================================================================
C
chenjianping 已提交
15 16
@echo off
@title mindspore_build
17

C
chenjianping 已提交
18
SET BASEPATH=%CD%
19
IF NOT EXIST "%BASEPATH%/build" (
20 21
    md "build"
)
22

L
liuwenhao4 已提交
23
cd %BASEPATH%/build
24
set BUILD_PATH=%CD%
25

26
IF NOT EXIST "%BUILD_PATH%/mindspore" (
27 28
    md "mindspore"
)
29

L
liuwenhao4 已提交
30
cd %CD%/mindspore
31

32
IF "%1%" == "lite" (
33 34 35 36 37 38 39 40 41 42 43 44 45
    call :run_cmake
    IF errorlevel 1 (
        echo "cmake fail one time."
        call :gene_protobuf
        call :gene_flatbuffer
        call :run_cmake
        IF errorlevel 1 (
            echo "cmake fail."
            goto run_fail
        )
    ) ELSE (
        call :gene_protobuf
        call :gene_flatbuffer
C
chenjianping 已提交
46
    )
47

48
    cd %BUILD_PATH%/mindspore
49 50
    IF "%2%" == "" (
        cmake --build . --target package -- -j6
51
    ) ELSE (
52
        cmake --build . --target package -- -j%2%
53 54 55 56
    )
    IF errorlevel 1 (
        echo "build fail."
        goto run_fail
57
    ) ELSE (
L
liuwenhao4 已提交
58
        cd %BASEPATH%/output
59
        rd /s /q _CPack_Packages
60 61 62 63 64 65 66 67 68 69 70
    )
) ELSE (
    cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON ^
    -G "CodeBlocks - MinGW Makefiles" ../..
    IF NOT %errorlevel% == 0 (
        echo "cmake fail."
        goto run_fail
    )

    IF "%1%" == "" (
        cmake --build . --target package -- -j6
C
chenjianping 已提交
71
    ) ELSE (
72
        cmake --build . --target package -- -j%1%
C
chenjianping 已提交
73
    )
74 75 76
    IF NOT %errorlevel% == 0 (
        echo "build fail."
        goto run_fail
C
chenjianping 已提交
77
    )
78
)
C
chenjianping 已提交
79

L
liuwenhao4 已提交
80
cd %BASEPATH%
C
chenjianping 已提交
81 82 83

goto run_eof

84
:run_cmake
L
liuwenhao4 已提交
85
    cd %BUILD_PATH%/mindspore
86 87
    cmake -DBUILD_DEVICE=on -DBUILD_CONVERTER=on -DPLATFORM_ARM64=off -DSUPPORT_TRAIN=off ^
    -DCMAKE_BUILD_TYPE=Release -DSUPPORT_GPU=off -DBUILD_MINDDATA=off -DOFFLINE_COMPILE=off ^
88
    -DMS_VERSION_MAJOR=0 -DMS_VERSION_MINOR=7 -DMS_VERSION_REVISION=0 ^
89
    -G "CodeBlocks - MinGW Makefiles" "%BASEPATH%/mindspore/lite"
90 91 92
GOTO:EOF

:gene_protobuf
93
    IF NOT DEFINED MSLIBS_CACHE_PATH (
94
        cd /d %BASEPATH%/build/mindspore/_deps/protobuf-src/_build
95
    ) ELSE (
96
        cd /d %MSLIBS_CACHE_PATH%/protobuf_*/bin
97
    )
98

99 100
    SET PROTO_SRC_DIR=%BASEPATH%/mindspore/lite/tools/converter/parser/caffe
    protoc "%PROTO_SRC_DIR%/*.proto" --proto_path="%PROTO_SRC_DIR%" --cpp_out="%PROTO_SRC_DIR%"
101

102 103
    SET PROTO_SRC_DIR=%BASEPATH%/mindspore/lite/tools/converter/parser/onnx
    protoc "%PROTO_SRC_DIR%/*.proto" --proto_path="%PROTO_SRC_DIR%" --cpp_out="%PROTO_SRC_DIR%"
104
    cd /d %BUILD_PATH%/mindspore
105 106 107
GOTO:EOF

:gene_flatbuffer
108
    IF NOT DEFINED MSLIBS_CACHE_PATH (
109
        cd /d %BASEPATH%/build/mindspore/_deps/flatbuffers-src/_build
110
    ) ELSE (
111
        cd /d %MSLIBS_CACHE_PATH%/flatbuffers_*/bin
112
    )
113

114 115 116
    SET FLAT_DIR=%BASEPATH%/mindspore/lite/schema
    flatc -c -b -o "%FLAT_DIR%" "%FLAT_DIR%/*.fbs"
    flatc -c -b --reflect-types --gen-mutable --reflect-names --gen-object-api -o "%FLAT_DIR%/inner" "%FLAT_DIR%/*.fbs"
117

L
liuwenhao4 已提交
118
    SET FLAT_DIR=%BASEPATH%/mindspore/lite/tools/converter/parser/tflite
119
    flatc -c -b --reflect-types --gen-mutable --reflect-names --gen-object-api -o "%FLAT_DIR%" "%FLAT_DIR%/*.fbs"
120
    cd /d %BUILD_PATH%/mindspore
121 122
GOTO:EOF

C
chenjianping 已提交
123
:run_fail
L
liuwenhao4 已提交
124
    cd %BASEPATH%
125
    set errorlevel=1
C
chenjianping 已提交
126 127

:run_eof