-
Notifications
You must be signed in to change notification settings - Fork 0
/
blade_build.sh
executable file
·84 lines (52 loc) · 1.56 KB
/
blade_build.sh
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
#!/bin/bash
IN_FILE_NAME=`echo "$(pwd)/$1"`
OUT_FILE_NAME=$2
#DOTNET_VERSION=`dotnet --version`
DOTNET_PATH='/usr/share/dotnet'
#FS_PATH="$DOTNET_PATH/sdk/$DOTNET_VERSION/FSharp/"
#echo "F\# Path: $FS_PATH"
# need these for NetCDF compatability
NC_LIBS="-L/usr/local/lib/ -lnetcdf"
NC_INCLUDES="-I/usr/include/"
BLADE_ROOT=`pwd`
mkdir exec
# Step 1: compile nested_funcs.c
pushd $BLADE_ROOT/src
gcc nested_funcs.c -o $BLADE_ROOT/exec/nested_funcs.so --std=c11 -fPIC -shared $NC_INCLUDES $NC_LIBS
popd
# Step 2: compile parser.fsx and run parser on user file
pushd $BLADE_ROOT/exec
$DOTNET_PATH/dotnet new console -lang F# -n execFS
cp $BLADE_ROOT/src/parser.fs $BLADE_ROOT/exec/execFS
pushd $BLADE_ROOT/exec/execFS
##### hack alert!
rm Program.fs
cat << EOF > Program.fsx
open Parser
let iFileName = @"$IN_FILE_NAME"
let oFileName = @"$BLADE_ROOT/exec/blade.cpp"
Parser.compile iFileName oFileName
EOF
rm execFS.fsproj
cat << EOF > execFS.fsproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="parser.fs" />
<Compile Include="Program.fsx" />
</ItemGroup>
</Project>
EOF
$DOTNET_PATH/dotnet build
$DOTNET_PATH/dotnet run
popd
# Step 3: compile intermediate file with nested_array_utilities.cpp
cp $BLADE_ROOT/src/nested_array_utilities.cpp .
g++ nested_array_utilities.cpp blade.cpp -fopenmp -std=c++17 -O3 -o $OUT_FILE_NAME $NC_INCLUDES $NC_LIBS
cp $OUT_FILE_NAME $BLADE_ROOT
popd
# Step 4: run executable
# ./$OUT_FILE_NAME