-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel2exe.bat
More file actions
126 lines (89 loc) · 3.54 KB
/
model2exe.bat
File metadata and controls
126 lines (89 loc) · 3.54 KB
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
@setlocal enabledelayedexpansion
@set rootdir=%~dp0
@set target=%~1
@set GCC=
@set GSL_VER=
@set platform=32
@if exist "%SystemDrive%\rtools42\x86_64-w64-mingw%platform%.static.posix\bin\gcc.exe" (
@set "PATH=%PATH%;%SystemDrive%\rtools42\x86_64-w64-mingw%platform%.static.posix\bin"
@set "GCC=gcc.exe"
@set "GSL_VER=2.7"
goto use_gcc
)
@if exist "%SystemDrive%\rtools40\mingw%platform%\bin\gcc.exe" (
@set "GCC=%SystemDrive%\rtools40\mingw%platform%\bin\gcc.exe"
@set "GSL_VER=2.6"
goto use_gcc
)
@if exist "%SystemDrive%\Rtools\mingw_%platform%\bin\gcc.exe" (
@set "GCC=%SystemDrive%\Rtools\mingw_%platform%\bin\gcc.exe"
@set "GSL_VER=2.6"
goto use_gcc
)
@echo.
@echo Failed to find compiler in Rtools
@exit /b 1
:use_gcc
@set "MOD=%rootdir%mod\mod.exe"
@if not exist "%MOD%" (
@echo.
@echo Building mod...
"%GCC%" -o %MOD% %rootdir%mod\getopt.c %rootdir%mod\lex.c %rootdir%mod\lexerr.c %rootdir%mod\lexfn.c %rootdir%mod\mod.c %rootdir%mod\modd.c %rootdir%mod\modi.c %rootdir%mod\modiSBML.c %rootdir%mod\modiSBML2.c %rootdir%mod\modo.c %rootdir%mod\strutil.c
@if %ERRORLEVEL% neq 0 (
@pause
@exit /b 1
)
@echo ...done
)
@if "%target%" NEQ "" (
@for %%i in ("%target%") do @(
@set targetName=%%~ni
@set targetDir=%%~dpi
)
@if exist "!targetDir!!targetName!.c" (
@del "!targetDir!!targetName!.c"
)
"%MOD%" "%target%" "!targetDir!!targetName!.c"
@if not exist "!targetDir!!targetName!.c" (
@exit /b 1
)
@if exist "!targetDir!!targetName!.exe" (
@del "!targetDir!!targetName!.exe"
)
"%GCC%" -O3 -I%rootdir%sim -I%rootdir%sim\gsl-%GSL_VER% -o "!targetDir!!targetName!.exe" "!targetDir!!targetName!.c" %rootdir%sim\delays.c %rootdir%sim\getopt.c %rootdir%sim\lex.c %rootdir%sim\lexerr.c %rootdir%sim\lexfn.c %rootdir%sim\list.c %rootdir%sim\lsodes1.c %rootdir%sim\lsodes2.c %rootdir%sim\matutil.c %rootdir%sim\matutilo.c %rootdir%sim\mh.c %rootdir%sim\modelu.c %rootdir%sim\optdsign.c %rootdir%sim\random.c %rootdir%sim\sim.c %rootdir%sim\simi.c %rootdir%sim\siminit.c %rootdir%sim\simmonte.c %rootdir%sim\simo.c %rootdir%sim\strutil.c %rootdir%sim\yourcode.c -lm -L%rootdir%sim\gsl-%GSL_VER%\.libs -lgsl
@if not exist "!targetDir!!targetName!.exe" (
@exit /b 1
)
@echo Created !targetDir!!targetName!.exe
@exit /b 0
)
@if not exist "%rootdir%out" (
mkdir "%rootdir%out"
)
@for /f %%M in ("%rootdir%target\*.model") do @(
@echo.
@echo Building sim for %%~nM...
@set "target_c=%rootdir%out\%%~nM.c"
@set "target_exe=%rootdir%out\%%~nM.exe"
@if exist "!target_c!" (
@del "!target_c!"
)
"%MOD%" "%rootdir%target\%%~nM.model" "!target_c!"
@if not exist "!target_c!" (
@echo.
@echo Failed to generate .c file for %%~nM
@exit /b 1
)
@echo ...compiling...
@if exist "!target_exe!" (
@del "!target_exe!"
)
"%GCC%" -O3 -I%rootdir%sim -I%rootdir%sim\gsl-%GSL_VER% -o "!target_exe!" "!target_c!" %rootdir%sim\delays.c %rootdir%sim\getopt.c %rootdir%sim\lex.c %rootdir%sim\lexerr.c %rootdir%sim\lexfn.c %rootdir%sim\list.c %rootdir%sim\lsodes1.c %rootdir%sim\lsodes2.c %rootdir%sim\matutil.c %rootdir%sim\matutilo.c %rootdir%sim\mh.c %rootdir%sim\modelu.c %rootdir%sim\optdsign.c %rootdir%sim\random.c %rootdir%sim\sim.c %rootdir%sim\simi.c %rootdir%sim\siminit.c %rootdir%sim\simmonte.c %rootdir%sim\simo.c %rootdir%sim\strutil.c %rootdir%sim\yourcode.c -lm -L%rootdir%sim\gsl-%GSL_VER%\.libs -lgsl
@if not exist "!target_exe!" (
@echo.
@echo Failed to compile/link .c file for %%~nM
@exit /b 1
)
@echo.
@echo ...done...created %%~nM.exe
)