forked from Open-Systems-Pharmacology/OSPSuite.SimModel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildNix.sh
More file actions
executable file
·92 lines (80 loc) · 4.23 KB
/
Copy pathbuildNix.sh
File metadata and controls
executable file
·92 lines (80 loc) · 4.23 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
#! /bin/sh
# Build the native library and run the native C++ and .NET tests on Linux or macOS.
#
# Usage: buildNix.sh distributionName
# e.g. buildNix.sh Linux
#
# distributionName is only used to name the test log files (testLog_$1.html for
# the .NET tests and testLogCpp_$1.xml for the C++ tests).
# Packing the unified multi-RID NuGet package is done in the dedicated CI
# pack-and-publish job, not here, because it requires natives from all three
# platforms to be present under runtimes/.
#
# The OSP-GitHub-Packages NuGet source must be configured before running this
# script (CI does this; for local runs add it via `nuget sources add` with a
# personal access token that has read:packages scope).
set -e
if [ -z "$1" ]; then
echo "Usage: $0 <distributionName> e.g. $0 Linux | $0 MacOS" >&2
exit 1
fi
UNAME_S="$(uname)"
UNAME_M="$(uname -m)"
# OSP supports macOS Arm64 and Linux x86_64. Intel macOS and Linux Arm64 are
# explicitly out of scope - fail fast so a misconfigured local run does not
# silently stage a wrong-arch binary under the wrong runtime folder.
if [ "$UNAME_S" = 'Darwin' ]; then
if [ "$UNAME_M" != 'arm64' ]; then
echo "Unsupported macOS architecture: $UNAME_M (only arm64 is supported; Intel macOS was dropped in #198)" >&2
exit 1
fi
ARCH=Arm64
RID=osx-arm64
EXT=dylib
NATIVE_FILE=libOSPSuite.SimModelNative.dylib
elif [ "$UNAME_M" = 'x86_64' ]; then
ARCH=x64
RID=linux-x64
EXT=so
NATIVE_FILE=libOSPSuite.SimModelNative.so
else
echo "Unsupported architecture: $UNAME_S/$UNAME_M" >&2
exit 1
fi
git submodule update --init --recursive
# Restore native upstream packages (FuncParser + CVODES solver) so the C++
# build can find headers and the FuncParser .so/.dylib it links against.
nuget install packages.config -OutputDirectory packages -ExcludeVersion
# Build native (Release only - the runtimes/<rid>/native/ NuGet convention has
# no Debug/Release axis; consumers needing native debugging build from the
# source shipped in the package under OSPSuite.SimModelNative/src/ and
# include/).
cmake -BBuild/Release/$ARCH/ -Hsrc/OSPSuite.SimModelNative/ -DCMAKE_BUILD_TYPE=Release -DRID=$RID -DEXT=$EXT
make -C Build/Release/$ARCH/
# Stage the native binary at runtimes/<rid>/native/ - the canonical location
# read by both OSPSuite.SimModel.csproj (for in-repo tests) and the unified
# nuspec (for packing). FuncParser and CVODES natives don't need staging here;
# the .NET SDK auto-copies them to the test bin output via PackageReference
# RID-based asset resolution, and SimModelNative finds them at runtime via
# RPATH=$ORIGIN (Linux) / @rpath (macOS).
mkdir -p runtimes/$RID/native
cp Build/Release/$ARCH/$NATIVE_FILE runtimes/$RID/native/
# Build and run the native C++ unit tests (OSPSuite.SimModelNative.Tests). The
# tests link against the SimModelNative shared library just built above and
# fetch GoogleTest via CMake, mirroring the Windows vcxproj that uses the
# Microsoft.googletest NuGet. SIMMODEL_NATIVE_DIR points at the freshly built
# native binary so the tests exercise the exact same artifact that ships.
cmake -BBuild/Release/$ARCH/Tests/ -Htests/OSPSuite.SimModelNative.Tests/ -DCMAKE_BUILD_TYPE=Release -DRID=$RID -DEXT=$EXT -DSIMMODEL_NATIVE_DIR="$(pwd)/Build/Release/$ARCH"
make -C Build/Release/$ARCH/Tests/
Build/Release/$ARCH/Tests/OSPSuite.SimModelNative.Tests --gtest_output="xml:testLogCpp_$1.xml"
# Build managed projects via a .NET-only solution (the C++ vcxprojs are not
# buildable with `dotnet`).
rm -f OSPSuite.SimModel.NetOnly.sln
cp -p -f OSPSuite.SimModel.sln OSPSuite.SimModel.NetOnly.sln
dotnet sln OSPSuite.SimModel.NetOnly.sln remove src/OSPSuite.SimModelNative/OSPSuite.SimModelNative.vcxproj
dotnet sln OSPSuite.SimModel.NetOnly.sln remove src/OSPSuite.SysTool/OSPSuite.SysTool.vcxproj
dotnet sln OSPSuite.SimModel.NetOnly.sln remove src/OSPSuite.XMLWrapper/OSPSuite.XMLWrapper.vcxproj
dotnet sln OSPSuite.SimModel.NetOnly.sln remove tests/OSPSuite.SimModelNative.Tests/OSPSuite.SimModelNative.Tests.vcxproj
dotnet restore OSPSuite.SimModel.NetOnly.sln
dotnet build OSPSuite.SimModel.NetOnly.sln --configuration Release --no-restore
dotnet test tests/OSPSuite.SimModel.Tests/OSPSuite.SimModel.Tests.csproj --no-build --no-restore --configuration Release --logger:"html;LogFileName=../../../testLog_$1.html"