summaryrefslogtreecommitdiffstats
path: root/windows/hdf5bt.BAT
blob: ea8f6d5d7c5511806175fea17fc2dd35be79d915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
@echo OFF
rem Copyright by The HDF Group.

rem Copyright by the Board of Trustees of the University of Illinois.

rem All rights reserved.

rem

rem This file is part of HDF5.  The full HDF5 copyright notice, including

rem terms governing use, modification, and redistribution, is contained in

rem the files COPYING and Copyright.html.  COPYING can be found at the root

rem of the source code distribution tree; Copyright.html can be found at the

rem root level of an installed copy of the electronic HDF5 document set and

rem is linked from the top-level documents page.  It can also be found at

rem http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have

rem access to either file, you may request a copy from help@hdfgroup.org.



rem File Name: hdf5bt.bat

rem This batch file is used to build and test HDF5 Libraries and Tools.

rem This batch file takes the following options:

rem .  /fort             Build and test HDF5 with Fortran libraries

rem .  /useenv           Build HDF5 using compiler settings defined

rem .                    in the environment, rather than the IDE.

rem .  /log               Log the build and test results in files defined by

rem .                      environment variables HDF5BUILD_LOG and

rem .                      HDF5CHECK_LOG

rem .  /?                Help information

rem By Xuan Bai

rem Created: Aug. 16, 2004

rem Last Updated: Scott Wegner, 10/1/07


rem This batch file makes the following assumptions:

rem    - The appropriate version of Visual Studio is installed and setup

rem    - The directory structure is setup from a fresh source copy

rem    - copy_hdf.bat has already been run from the ./windows directory

rem    - Visual Studio already contains the required paths for external libraries

rem    - szip and zlib DLLs are already placed in an accessible directory

rem    - hdf5_ext_szip or hdf5_ext_zlib have been set accordingly

rem    - if building with the /useenv option, szip and zlib paths have been added

rem      to %include% and %libpath% as necessary.

rem    - if using the /log option, hdf5build_log and hdf5_check log should be defined

rem    - in the environment.


rem By default, only C and C++ libraries are built and tested.


setlocal enabledelayedexpansion
pushd %~dp0

set nerrors=0
goto main

rem Print a help message

:help

    echo.Builds and tests HDF5 Libraries and Tools.
    echo.
    echo Usage: %~nx0 [OPTION]
    echo.
    echo.   /fort             Build and test HDF5 with Fortran libraries
    echo.   /useenv           Build HDF5 using compiler settings defined
    echo.                     in the environment, rather than the IDE.
    echo.   /?                Help information

    exit /b 0


rem Parse through the parameters sent to file, and set appropriate variables

:parse_params

    for %%a in (%*) do (
        if "%%a"=="/fort" (

            rem Enable Fortran

            set hdf5_enablefortran=true

            

        ) else if "%%a"=="/useenv" (
            rem Pass /useenv flag to devenv
            set hdf5_useenv=true
            
        ) else if "%%a"=="/log" (

            rem Log our results to files defined in environment

            set hdf5_logresults=true

                        

        ) else if "%%a"=="/?" (
            rem Set errorlevel 1 and send to help
            call :help
            exit /b 1
            
        ) else (
            rem Set errorlevel 2 to send to help if we receive a bad parameter
            echo.Unknown option: %%a
            call :help
            exit /b 2
        )
    )
    
    exit /b 0

    
rem Setup our environment

:setup

    rem All we need to do here is setup the parameters that will be sent to
    rem hdf5build and hdf5check.
    set hdf5build_params=
    set hdf5check_params=enablecpp
    
    if defined hdf5_enablefortran (
        set hdf5build_params=%hdf5build_params% /fort
        set hdf5check_params=enableall
    )
    
    if defined hdf5_useenv (
        set hdf5build_params=%hdf5build_params% /useenv
    )
    
    rem Clear out our log files if they will be used
    if defined hdf5_logresults (
        if not defined hdf5build_log (
            echo.Error: HDF5BUILD_LOG not defined in environment!
            exit /b 1
        ) else (
            type nul > !hdf5build_log!
        )
        
        if not defined hdf5check_log (
            echo.Error: HDF5CHECK_LOG not defined in environment!
            exit /b 1
        ) else (
            type nul > !hdf5check_log!
        )
    )
    
    exit /b 0


rem Build HDF5 libraries and tools

:build

    if defined hdf5_logresults (
        echo.Calling hdf5bbuild.bat %hdf5build_params%
        echo.Results logged in %hdf5build_log%
        call hdf5build.bat %hdf5build_params% > !hdf5build_log! 2>&1
    ) else (
        call hdf5build.bat %hdf5build_params%
    )

    exit /b


rem Test our libraries and tools

:test
    if defined hdf5_logresults (
        echo.Calling hdf5check.bat %hdf5check_params%
        echo.Results logged in %hdf5check_log%
        call hdf5check %hdf5check_params% > !hdf5check_log! 2>&1
    ) else (
        call hdf5check %hdf5check_params%
    )

    exit /b


rem Handle errors

:error

    rem For now, our error handling consists of setting nerrors and quitting
    echo.HDF5 build-test failed.
    set /a nerrors=%nerrors%+1
    goto end
    
    rem We'll never really get here, but we keep this line for consistency.
    exit /b


rem This is where the magic happens

:main

    call :parse_params %*
    if %errorlevel% neq 0 (
        if !errorlevel! equ 1 (
            rem This isn't an error case-- this means /? was specified.  Simply
            rem quit.
            goto end
            
        ) else (
            rem Error case.
            echo.Error parsing parameters!
            goto error
        )
    )

    call :setup
    if %errorlevel% neq 0 (
        echo.Error setting up hdf5bt environment!
        goto error
    )

    echo.*****************************************************************************
    echo.                        Build and Test HDF5 Library and Tools
    echo.*****************************************************************************
    echo.

    call :build
    if %errorlevel% neq 0 (
        echo.Error building HDF5 libraries!
        goto error
    )

    call :test
    if %errorlevel% neq 0 (
        echo.Error testing HDF5 libraries!
        goto error
    )

    if "%nerrors%"=="0" (

        echo. All HDF5 libraries and tools build and tested successfully!

    )

    rem Fall through to end



:end

    popd

    endlocal & exit /b %nerrors%