Skip to content

Commit 5a585ed

Browse files
authored
Add recipe for GMAT (#1523)
* Add recipe for GMAT * Address review comments * Do not link Ws2 * Separate patches and add boost dependency for Mac * Add header list for CMake * Patch install calls * Move cmake folder * Make boost a build dependency * Fix plugin headers * Fix paths * Try building all platforms * Add FreeBSD patch * Flatten includes
1 parent c6f35d1 commit 5a585ed

11 files changed

+1602
-0
lines changed

G/GMAT/build_tarballs.jl

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Note that this script can accept some limited command-line arguments, run
2+
# `julia build_tarballs.jl --help` to see a usage message.
3+
using BinaryBuilder, Pkg
4+
5+
name = "GMAT"
6+
version = v"2020.0.0"
7+
8+
# Collection of sources required to complete build
9+
sources = [
10+
ArchiveSource("https://downloads.sourceforge.net/project/gmat/GMAT/GMAT-R2020a/GMAT-src-R2020a.zip", "943f403ac04d958b313b1d99d64fd09e3fa8e4c65363809d5bb88dd8c66e43e4"),
11+
DirectorySource("./bundled"),
12+
]
13+
14+
# Bash recipe for building across all platforms
15+
script = raw"""
16+
cd $WORKSPACE/srcdir
17+
apk add --upgrade cmake --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
18+
cd GMAT-R2020a/
19+
cp -r $WORKSPACE/srcdir/patches/cmake .
20+
dos2unix plugins/EstimationPlugin/src/base/measurement/Ionosphere/Ionosphere.hpp
21+
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/0001-Remove-hard-coded-CSPICE-paths.patch"
22+
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/0002-Remove-MSVC-flags.patch"
23+
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/0003-Fix-non-portable-cast.patch"
24+
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/0004-Use-std-chrono-on-all-platforms.patch"
25+
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/0005-Use-Linux-typedefs-for-cross-compile.patch"
26+
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/0006-Use-standard-CMake-boost-module.patch"
27+
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/0007-Remove-explicit-Ws2_32-linking.patch"
28+
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/0008-Use-standard-install-locations.patch"
29+
atomic_patch -p1 "${WORKSPACE}/srcdir/patches/0009-FreeBSD-compat.patch"
30+
mkdir builddir
31+
cd builddir/
32+
cmake -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} -DCMAKE_BUILD_TYPE=Release \
33+
-DGMAT_INCLUDE_GUI=OFF \
34+
-DCSPICE_LIB=${libdir}/libcspice.${dlext} -DCSPICE_DIR=${prefix} -DCSPICE_INCLUDE_DIR=${includedir} \
35+
-DF2C_DIR=${includedir} \
36+
..
37+
make -j${nproc}
38+
make install
39+
"""
40+
41+
# These are the platforms we will build for by default, unless further
42+
# platforms are passed in on the command line
43+
platforms = expand_cxxstring_abis(supported_platforms())
44+
45+
# The products that we will ensure are always built
46+
products = [
47+
LibraryProduct("libGmatFunction", :libgmatfunction, "plugins"),
48+
LibraryProduct("libGmatUtil", :libgmatutil),
49+
LibraryProduct("libScriptTools", :libgmatscripttools, "plugins"),
50+
LibraryProduct("libCInterface", :libgmatcinterface),
51+
LibraryProduct("libGmatBase", :libgmatbase),
52+
# FIXME: Enable once Python_jll is available for Windows
53+
# LibraryProduct("libPythonInterface", :libgmatpythoninterface, "plugins"),
54+
LibraryProduct("libGmatEstimation", :libgmatestimation, "plugins"),
55+
LibraryProduct("libDataInterface", :libgmatdatainterface, "plugins"),
56+
LibraryProduct("libYukonOptimizer", :libgmatyukonoptimizer, "plugins"),
57+
LibraryProduct("libThrustFile", :libgmatthrustfile, "plugins"),
58+
LibraryProduct("libEphemPropagator", :libgmatephempropagator, "plugins"),
59+
LibraryProduct("libExtraPropagators", :libgmatextrapropagators, "plugins"),
60+
LibraryProduct("libNewParameters", :libgmatnewparameters, "plugins"),
61+
LibraryProduct("libFormation", :libgmatformation, "plugins"),
62+
LibraryProduct("libPolyhedronGravity", :libgmatpolyhedrongravity, "plugins"),
63+
LibraryProduct("libStation", :libgmatstation, "plugins"),
64+
LibraryProduct("libSaveCommand", :libgmatsavecommand, "plugins"),
65+
LibraryProduct("libEventLocator", :libgmateventlocator, "plugins"),
66+
LibraryProduct("libProductionPropagators", :libgmatproductionpropagators, "plugins"),
67+
LibraryProduct("libEKF", :libgmatekf, "plugins"),
68+
ExecutableProduct("GmatConsole", :gmatconsole)
69+
]
70+
71+
# Dependencies that must be installed before this package can be built
72+
dependencies = [
73+
Dependency(PackageSpec(name="CSPICE_jll", uuid="07f52509-e9d9-513c-a20d-3b911885bf96"))
74+
Dependency(PackageSpec(name="Python_jll", uuid="93d3a430-8e7c-50da-8e8d-3dfcfb3baf05"))
75+
Dependency(PackageSpec(name="Xerces_jll", uuid="637d83c4-b86a-5d90-b82d-5cf0573a8cfc"))
76+
BuildDependency(PackageSpec(name="boost_jll", uuid="28df3c45-c428-5900-9ff8-a3135698ca75"))
77+
]
78+
79+
# Build the tarballs, and possibly a `build.jl` as well.
80+
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version = v"7.1.0")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From 86892ab9877ad123f27ee75a8d5fff348227ae07 Mon Sep 17 00:00:00 2001
2+
From: Helge Eichhorn <[email protected]>
3+
Date: Mon, 24 Aug 2020 08:38:05 +0200
4+
Subject: [PATCH 1/8] Remove hard-coded CSPICE paths
5+
6+
---
7+
CMakeLists.txt | 3 ---
8+
1 file changed, 3 deletions(-)
9+
10+
diff --git a/CMakeLists.txt b/CMakeLists.txt
11+
index fb51077..49d72ab 100644
12+
--- a/CMakeLists.txt
13+
+++ b/CMakeLists.txt
14+
@@ -210,9 +210,6 @@ if(CSPICE_DIR)
15+
else()
16+
SET(CSPICE_EXT "a")
17+
endif()
18+
- SET(CSPICE_LIB "${CSPICE_DIR}/lib/cspice.${CSPICE_EXT}")
19+
- SET(CSPICE_LIB_DEBUG "${CSPICE_DIR}/lib/cspiced.${CSPICE_EXT}")
20+
- SET(CSPICE_INCLUDE_DIR "${CSPICE_DIR}/include")
21+
if(NOT EXISTS ${CSPICE_LIB_DEBUG})
22+
SET(CSPICE_LIB_DEBUG ${CSPICE_LIB})
23+
endif()
24+
--
25+
2.24.3 (Apple Git-128)
26+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
From 5a7ec1e197c39450ad1c8e39b1dd72ff8390d0c0 Mon Sep 17 00:00:00 2001
2+
From: Helge Eichhorn <[email protected]>
3+
Date: Mon, 24 Aug 2020 08:41:59 +0200
4+
Subject: [PATCH 2/8] Remove MSVC flags
5+
6+
---
7+
CMakeLists.txt | 10 ----------
8+
plugins/CMakeLists.txt | 5 -----
9+
src/base/CMakeLists.txt | 4 ----
10+
src/gmatutil/CMakeLists.txt | 4 ----
11+
4 files changed, 23 deletions(-)
12+
13+
diff --git a/CMakeLists.txt b/CMakeLists.txt
14+
index 49d72ab..c71e9af 100644
15+
--- a/CMakeLists.txt
16+
+++ b/CMakeLists.txt
17+
@@ -365,10 +365,6 @@ endif()
18+
# ====================================================================
19+
# Common build options
20+
21+
-if(WIN32)
22+
- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W2")
23+
-endif()
24+
-
25+
# Enable parallel builds on VisualStudio
26+
if(MSVC)
27+
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
28+
@@ -405,12 +401,6 @@ endif()
29+
# Mark debug libraries with a "d" suffix
30+
SET(CMAKE_DEBUG_POSTFIX "d")
31+
32+
-# Warning suppression definitions
33+
-# Note that warning C4430 presents as an error in the MatlabInterface plugin
34+
-if(WIN32)
35+
- ADD_DEFINITIONS("/wd4430 /wd4251 /wd4231 /wd4996 /nologo")
36+
-endif()
37+
-
38+
# Set 32/64-bit specific definitions and directories
39+
if(GMAT_64_BIT)
40+
ADD_DEFINITIONS("-DUSE_64_BIT_LONGS")
41+
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
42+
index 6544dc2..1fcbb29 100644
43+
--- a/plugins/CMakeLists.txt
44+
+++ b/plugins/CMakeLists.txt
45+
@@ -22,8 +22,6 @@
46+
# INSTALL_DIR: Directory to install plugin (plugins, bin, etc.)
47+
# Note that all paths should be relative to the plugin's CMakeLists.txt
48+
MACRO(_SETUPPLUGIN TargetName PLUGIN_DIRS PLUGIN_SRCS INSTALL_DIR)
49+
- # Add Preproccessor Definitions
50+
- ADD_DEFINITIONS("-D_DYNAMICLINK")
51+
52+
# ====================================================================
53+
# Recursively find all include files in specified directories
54+
@@ -430,7 +428,4 @@ if(PluginTargets)
55+
SET_TARGET_PROPERTIES(${PluginTargets} PROPERTIES VERSION ${GMAT_VERSION})
56+
57+
# Specify link flags for Win32 targets
58+
- if(WIN32)
59+
- SET_TARGET_PROPERTIES(${PluginTargets} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:\"libcmt.lib\"")
60+
- endif()
61+
endif()
62+
diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt
63+
index 5e19462..03f1e66 100644
64+
--- a/src/base/CMakeLists.txt
65+
+++ b/src/base/CMakeLists.txt
66+
@@ -17,7 +17,6 @@ MESSAGE("GMAT base setup " ${VERSION})
67+
SET(TargetName GmatBase)
68+
69+
# Add preprocessor definitions
70+
-ADD_DEFINITIONS("-D_DYNAMICLINK")
71+
ADD_DEFINITIONS("-DEXP_STL")
72+
73+
SET(SPICE_SRCS
74+
@@ -543,9 +542,6 @@ SET_TARGET_PROPERTIES(${TargetName} PROPERTIES PREFIX "lib")
75+
_ADDSOURCEGROUPS("${BASE_DIRS}")
76+
77+
# Windows-specific link flags
78+
-if(WIN32)
79+
- SET_TARGET_PROPERTIES(${TargetName} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:\"libcmt.lib\" /INCREMENTAL:NO")
80+
-endif()
81+
82+
# Create build products in bin directory
83+
_SETOUTPUTDIRECTORY(${TargetName} bin)
84+
diff --git a/src/gmatutil/CMakeLists.txt b/src/gmatutil/CMakeLists.txt
85+
index 18a35ef..37b6d7e 100644
86+
--- a/src/gmatutil/CMakeLists.txt
87+
+++ b/src/gmatutil/CMakeLists.txt
88+
@@ -16,7 +16,6 @@ MESSAGE("GMAT util setup " ${VERSION})
89+
SET(TargetName GmatUtil)
90+
91+
# Add preprocessor definitions
92+
-ADD_DEFINITIONS("-D_DYNAMICLINK")
93+
ADD_DEFINITIONS("-DEXP_STL")
94+
95+
# ====================================================================
96+
@@ -142,9 +141,6 @@ SET_TARGET_PROPERTIES(${TargetName} PROPERTIES PREFIX "lib")
97+
_ADDSOURCEGROUPS("${UTIL_DIRS}")
98+
99+
# Windows-specific link flags
100+
-if(WIN32)
101+
- SET_TARGET_PROPERTIES(${TargetName} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:\"libcmt.lib\" /INCREMENTAL:NO")
102+
-endif()
103+
104+
# Create build products in bin directory
105+
_SETOUTPUTDIRECTORY(${TargetName} bin)
106+
--
107+
2.24.3 (Apple Git-128)
108+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From b4636edc3463a9263b6e5ad978e1e93cd4e7e9df Mon Sep 17 00:00:00 2001
2+
From: Helge Eichhorn <[email protected]>
3+
Date: Mon, 24 Aug 2020 08:43:23 +0200
4+
Subject: [PATCH 3/8] Fix non-portable cast
5+
6+
---
7+
src/base/forcemodel/ODEModel.cpp | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/src/base/forcemodel/ODEModel.cpp b/src/base/forcemodel/ODEModel.cpp
11+
index be4e2a5..bbe9bdf 100644
12+
--- a/src/base/forcemodel/ODEModel.cpp
13+
+++ b/src/base/forcemodel/ODEModel.cpp
14+
@@ -2680,7 +2680,7 @@ Integer ODEModel::SetupSpacecraftData(ObjectArray *sats, Integer i, bool updateE
15+
if (!cs)
16+
{
17+
char sataddr[20];
18+
- std::sprintf(sataddr, "%lx", (unsigned long)sat);
19+
+ std::sprintf(sataddr, "%lx", (uintptr_t)sat);
20+
throw ODEModelException(
21+
"CoordinateSystem is NULL on Spacecraft " + sat->GetName() +
22+
" at address " + sataddr);
23+
--
24+
2.24.3 (Apple Git-128)
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
From 36d88c5b8753e3a4cd91663a43db4506f57bfbd3 Mon Sep 17 00:00:00 2001
2+
From: Helge Eichhorn <[email protected]>
3+
Date: Mon, 24 Aug 2020 08:44:35 +0200
4+
Subject: [PATCH 4/8] Use std::chrono on all platforms
5+
6+
---
7+
src/base/function/SystemTime.cpp | 60 +++++++++++++-------------------
8+
1 file changed, 24 insertions(+), 36 deletions(-)
9+
10+
diff --git a/src/base/function/SystemTime.cpp b/src/base/function/SystemTime.cpp
11+
index d936c14..287d300 100644
12+
--- a/src/base/function/SystemTime.cpp
13+
+++ b/src/base/function/SystemTime.cpp
14+
@@ -335,46 +335,34 @@ bool SystemTime::Execute(ObjectInitializer *objInit, bool reinitialize)
15+
Integer year, month, day, hour, min, sec;
16+
Real msec;
17+
18+
- #ifdef _WIN32
19+
- SYSTEMTIME theTime;
20+
- GetSystemTime(&theTime);
21+
-
22+
- year = theTime.wYear;
23+
- month = theTime.wMonth;
24+
- day = theTime.wDay;
25+
- hour = theTime.wHour;
26+
- min = theTime.wMinute;
27+
- msec = theTime.wSecond + theTime.wMilliseconds / 1000.0;
28+
- #else
29+
- //Retrieve the system time. This result is UTCGregorian, but not in the accepted
30+
- //GMAT format.
31+
- std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
32+
- std::time_t now_t = std::chrono::system_clock::to_time_t(now);
33+
-
34+
- long int millis =
35+
- std::chrono::duration_cast<std::chrono::milliseconds>
36+
- (now.time_since_epoch()).count();
37+
-
38+
- #ifdef DEBUG_TIME_SYSTEM
39+
- // What is the epoch time?
40+
- std::chrono::time_point<std::chrono::system_clock> p1;
41+
- std::time_t epoch_time = std::chrono::system_clock::to_time_t(p1);
42+
- std::string epstr = std::ctime(&epoch_time);
43+
- #endif
44+
-
45+
- msec = millis / 1000.0 - (Integer)(millis / 1000);
46+
+ //Retrieve the system time. This result is UTCGregorian, but not in the accepted
47+
+ //GMAT format.
48+
+ std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
49+
+ std::time_t now_t = std::chrono::system_clock::to_time_t(now);
50+
51+
- //Convert the retrieved system time to a proper formatted UTCModJulian time.
52+
- struct tm *now_struct = gmtime(&now_t);
53+
+ long int millis =
54+
+ std::chrono::duration_cast<std::chrono::milliseconds>
55+
+ (now.time_since_epoch()).count();
56+
57+
- year = now_struct->tm_year + 1900;
58+
- month = now_struct->tm_mon + 1;
59+
- day = now_struct->tm_mday;
60+
- hour = now_struct->tm_hour;
61+
- min = now_struct->tm_min;
62+
- msec = now_struct->tm_sec + msec;
63+
+ #ifdef DEBUG_TIME_SYSTEM
64+
+ // What is the epoch time?
65+
+ std::chrono::time_point<std::chrono::system_clock> p1;
66+
+ std::time_t epoch_time = std::chrono::system_clock::to_time_t(p1);
67+
+ std::string epstr = std::ctime(&epoch_time);
68+
#endif
69+
70+
+ msec = millis / 1000.0 - (Integer)(millis / 1000);
71+
+
72+
+ //Convert the retrieved system time to a proper formatted UTCModJulian time.
73+
+ struct tm *now_struct = gmtime(&now_t);
74+
+
75+
+ year = now_struct->tm_year + 1900;
76+
+ month = now_struct->tm_mon + 1;
77+
+ day = now_struct->tm_mday;
78+
+ hour = now_struct->tm_hour;
79+
+ min = now_struct->tm_min;
80+
+ msec = now_struct->tm_sec + msec;
81+
+
82+
#ifdef DEBUG_SYSTEM_TIME
83+
MessageInterface::ShowMessage("SystemTime is %02d:%02d:%02d.%03d\n",
84+
hour, min, sec, msec);
85+
--
86+
2.24.3 (Apple Git-128)
87+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
From a0f58f1581c3dddedd593b08fa627b11d045e749 Mon Sep 17 00:00:00 2001
2+
From: Helge Eichhorn <[email protected]>
3+
Date: Mon, 24 Aug 2020 08:46:14 +0200
4+
Subject: [PATCH 5/8] Use Linux typedefs for cross-compile
5+
6+
---
7+
.../measurement/Ionosphere/Ionosphere.hpp | 29 -------------------
8+
1 file changed, 29 deletions(-)
9+
10+
diff --git a/plugins/EstimationPlugin/src/base/measurement/Ionosphere/Ionosphere.hpp b/plugins/EstimationPlugin/src/base/measurement/Ionosphere/Ionosphere.hpp
11+
index 038be61..e8e3e58 100644
12+
--- a/plugins/EstimationPlugin/src/base/measurement/Ionosphere/Ionosphere.hpp
13+
+++ b/plugins/EstimationPlugin/src/base/measurement/Ionosphere/Ionosphere.hpp
14+
@@ -34,8 +34,6 @@
15+
16+
#include "f2c.h"
17+
18+
-#ifdef __linux__
19+
-
20+
#ifndef integer
21+
typedef int integer;
22+
#endif
23+
@@ -53,33 +51,6 @@ typedef int ftnlen;
24+
#undef max
25+
#endif
26+
27+
-#endif
28+
-
29+
-#ifdef __APPLE__
30+
-
31+
-//#undef abs // to work on Mac - the macro for abs confuses the Mac C++ code
32+
-
33+
-#ifndef integer
34+
-typedef int integer;
35+
-#endif
36+
-
37+
-#ifndef logical
38+
-typedef int logical;
39+
-#endif
40+
-
41+
-#ifndef ftnlen
42+
-typedef int ftnlen;
43+
-#endif
44+
-
45+
-#endif
46+
-
47+
-#ifdef _MSC_VER
48+
-//#else
49+
-typedef long int integer;
50+
-typedef long int logical;
51+
-typedef long int ftnlen;
52+
-#endif
53+
-
54+
typedef float real;
55+
typedef double doublereal;
56+
57+
--
58+
2.24.3 (Apple Git-128)
59+

0 commit comments

Comments
 (0)