Skip to content

Commit a25210e

Browse files
authored
Merge pull request #697 from SpaceIm/add-cspice-0066
add cspice/0066
2 parents 7c37e8a + b07a3fe commit a25210e

10 files changed

+752
-0
lines changed

recipes/cspice/all/CMakeLists.txt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
project(cspice C)
3+
4+
include(conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
file(GLOB SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/src/cspice/*.c)
8+
add_library(cspice ${SRC_FILES})
9+
10+
if(WIN32)
11+
target_compile_definitions(cspice PRIVATE "_COMPLEX_DEFINED;MSDOS;OMIT_BLANK_CC;NON_ANSI_STDIO")
12+
set_target_properties(cspice PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
13+
elseif(UNIX)
14+
target_compile_definitions(cspice PRIVATE "NON_UNIX_STDIO")
15+
target_compile_options(cspice PRIVATE -ansi)
16+
endif()
17+
18+
install(
19+
TARGETS cspice
20+
EXPORT cspice
21+
RUNTIME DESTINATION bin
22+
LIBRARY DESTINATION lib
23+
ARCHIVE DESTINATION lib
24+
)
25+
26+
file(GLOB INCLUDE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/source_subfolder/include/*.h)
27+
install(FILES ${INCLUDE_FILES} DESTINATION include)

recipes/cspice/all/TSPA.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
2+
CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
3+
GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
4+
ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
5+
PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" TO
6+
THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
7+
WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
8+
PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES
9+
UCC§2312-§2313) OR FOR ANY PURPOSE WHATSOEVER,
10+
FOR THE SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
11+
12+
IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA BE
13+
LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT LIMITED TO,
14+
INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING
15+
ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
16+
REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
17+
REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
18+
19+
RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF THE
20+
SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
21+
CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
22+
ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE

recipes/cspice/all/conandata.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
sources:
2+
"0066":
3+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/MacIntel_OSX_AppleC_32bit/packages/cspice.tar.Z"
4+
sha256: "9a4b5f674ea76821c43aa9140829da4091de646ef3ce40fd5be1d09d7c37b6b3"
5+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/MacIntel_OSX_AppleC_64bit/packages/cspice.tar.Z"
6+
sha256: "f5d48c4b0d558c5d71e8bf6fcdf135b0943210c1ff91f8191dfc447419a6b12e"
7+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Linux_GCC_32bit/packages/cspice.tar.Z"
8+
sha256: "59f5a2e865ff8dee3e415477fe55cf366bad5498948bf7b034ee00b46ec80720"
9+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Linux_GCC_64bit/packages/cspice.tar.Z"
10+
sha256: "93cd4fbce5818f8b7fecf3914c5756b8d41fd5bdaaeac1f4037b5a5410bc4768"
11+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Windows_VisualC_32bit/packages/cspice.zip"
12+
sha256: "db48e5beddc0e50f7a0224bb2c6f2b39fc38f84628ad5cd455e847fc70aa5e75"
13+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Windows_VisualC_64bit/packages/cspice.zip"
14+
sha256: "b29dfb0b41ae8322c60ee9d162beb97433d21e12843ecbe03d819e5edef45920"
15+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Cygwin_GCC_32bit/packages/cspice.tar.gz"
16+
sha256: "fae1e81f2b120801078415ddc78069543792b2ecf6f01e2ddd4f9d1fdff6d705"
17+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/PC_Cygwin_GCC_64bit/packages/cspice.tar.gz"
18+
sha256: "bc41bd496c98b5b26c03e2eb1235a2ab3ee3d6b54452155722c0163ebec52c09"
19+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunIntel_Solaris_SunC_32bit/packages/cspice.tar.Z"
20+
sha256: "2779be0a8cce3a342fd77d118c53689344979de01a4185f8ff727f85502f116e"
21+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunIntel_Solaris_SunC_64bit/packages/cspice.tar.Z"
22+
sha256: "b221eb598e4397acf957b0464694a62c92871671be9fe9c32ac64d621b1eb29d"
23+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_GCC_32bit/packages/cspice.tar.Z"
24+
sha256: "463c93a54f432fa41e1733bc4ec0e584f1017f48f84e0e9fafe4adc4163064c9"
25+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_SunC_32bit/packages/cspice.tar.Z"
26+
sha256: "1432f49f628930b48197bcf4e9234ed7a340732302c82fd6d0650d15fe8503f8"
27+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_GCC_64bit/packages/cspice.tar.Z"
28+
sha256: "4e86fad7e8fa947abddd3d78174efc65476a3f54627747ffc2027ee572af48b3"
29+
- url: "https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066/C/SunSPARC_Solaris_SunC_64bit/packages/cspice.tar.Z"
30+
sha256: "be27fa91fefa9f54e90578a7c84e9e16d19b0ce6420eb346340ecf8d26db1b5f"
31+
patches:
32+
"0066":
33+
- patch_file: "patches/isatty.patch"
34+
base_path: "source_subfolder"
35+
- patch_file: "patches/patches20171106.patch" # from https://naif.jpl.nasa.gov/pub/naif/misc/toolkit_N0066_patches
36+
base_path: "source_subfolder"

recipes/cspice/all/conanfile.py

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import os
2+
3+
from conans import ConanFile, CMake, tools
4+
from conans.errors import ConanInvalidConfiguration
5+
6+
class CspiceConan(ConanFile):
7+
name = "cspice"
8+
description = "NASA C SPICE library"
9+
license = "TSPA"
10+
topics = ("conan", "spice", "naif", "kernels", "space", "nasa", "jpl", "spacecraft", "planet", "robotics")
11+
homepage = "https://naif.jpl.nasa.gov/naif/toolkit.html"
12+
url = "https://github.com/conan-io/conan-center-index"
13+
exports_sources = ["CMakeLists.txt", "patches/**"]
14+
exports = ["TSPA.txt"]
15+
generators = "cmake"
16+
settings = "os", "arch", "compiler", "build_type"
17+
options = {"shared": [True, False], "fPIC": [True, False]}
18+
default_options = {"shared": False, "fPIC": True}
19+
20+
_cmake = None
21+
22+
@property
23+
def _source_subfolder(self):
24+
return "source_subfolder"
25+
26+
@property
27+
def _build_subfolder(self):
28+
return "build_subfolder"
29+
30+
@property
31+
def _sources_idx_per_triplet(self):
32+
# Index of source code per triplet in conadata's "sources" field.
33+
return {
34+
"Macos": {
35+
"x86": {"apple-clang": 0},
36+
"x86_64": {"apple-clang": 1}
37+
},
38+
"Linux": {
39+
"x86": {"gcc": 2},
40+
"x86_64": {"gcc": 3}
41+
},
42+
"Windows": {
43+
"x86": {"Visual Studio": 4},
44+
"x86_64": {"Visual Studio": 5}
45+
},
46+
"cygwin": {
47+
"x86": {"gcc": 6},
48+
"x86_64": {"gcc": 7}
49+
},
50+
"SunOs": {
51+
"x86": {"sun-cc": 8},
52+
"x86_64": {"sun-cc": 9},
53+
"sparc": {"gcc": 10, "sun-cc": 11},
54+
"sparcv9": {"gcc": 12, "sun-cc": 13}
55+
}
56+
}
57+
58+
def config_options(self):
59+
if self.settings.os == "Windows":
60+
del self.options.fPIC
61+
62+
def configure(self):
63+
del self.settings.compiler.libcxx
64+
del self.settings.compiler.cppstd
65+
66+
self._raise_if_not_supported_triplet()
67+
68+
def _raise_if_not_supported_triplet(self):
69+
the_os = self._get_os_or_subsystem()
70+
arch = str(self.settings.arch)
71+
compiler = str(self.settings.compiler)
72+
if the_os not in self._sources_idx_per_triplet:
73+
raise ConanInvalidConfiguration("cspice does not support {0}".format(the_os))
74+
if arch not in self._sources_idx_per_triplet[the_os]:
75+
raise ConanInvalidConfiguration("cspice does not support {0} {1}".format(the_os, arch))
76+
if compiler not in self._sources_idx_per_triplet[the_os][arch]:
77+
raise ConanInvalidConfiguration("cspice does not support {0} on {1} {2}".format(compiler, the_os, arch))
78+
79+
def _get_os_or_subsystem(self):
80+
if self.settings.os == "Windows" and self.settings.os.subsystem != "None":
81+
os_or_subsystem = str(self.settings.os.subsystem)
82+
else:
83+
os_or_subsystem = str(self.settings.os)
84+
return os_or_subsystem
85+
86+
def source(self):
87+
pass
88+
89+
def build(self):
90+
self._get_sources()
91+
os.rename(self.name, self._source_subfolder)
92+
for patch in self.conan_data["patches"][self.version]:
93+
tools.patch(**patch)
94+
cmake = self._configure_cmake()
95+
cmake.build()
96+
97+
def _get_sources(self):
98+
the_os = self._get_os_or_subsystem()
99+
arch = str(self.settings.arch)
100+
compiler = str(self.settings.compiler)
101+
source_idx = self._sources_idx_per_triplet[the_os][arch][compiler]
102+
source = self.conan_data["sources"][self.version][source_idx]
103+
url = source["url"]
104+
if url.endswith(".tar.Z"): # Python doesn't have any module to uncompress .Z files
105+
filename = os.path.basename(url)
106+
tools.download(url, filename, sha256=source["sha256"])
107+
command = "zcat {} | tar -xf -".format(filename)
108+
self.run(command=command)
109+
os.remove(filename)
110+
else:
111+
tools.get(**source)
112+
113+
def _configure_cmake(self):
114+
if self._cmake:
115+
return self._cmake
116+
self._cmake = CMake(self)
117+
self._cmake.configure(build_folder=self._build_subfolder)
118+
return self._cmake
119+
120+
def package(self):
121+
self.copy("TSPA.txt", dst="licenses")
122+
cmake = self._configure_cmake()
123+
cmake.install()
124+
125+
def package_info(self):
126+
self.cpp_info.libs = tools.collect_libs(self)
127+
if self.settings.os == "Linux":
128+
self.cpp_info.system_libs.append("m")
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--- a/src/cspice/fio.h
2+
+++ b/src/cspice/fio.h
3+
@@ -1,3 +1,6 @@
4+
+#ifdef _WIN32
5+
+#include <io.h> /* for isatty() */
6+
+#endif
7+
#include "stdio.h"
8+
#include "errno.h"
9+
#ifndef NULL
10+
@@ -73,7 +76,9 @@ extern void f_init(void);
11+
extern int (*f__donewrec)(void), t_putc(int), x_wSL(void);
12+
extern void b_char(char*,char*,ftnlen), g_char(char*,ftnlen,char*);
13+
extern int c_sfe(cilist*), z_rnew(void);
14+
+#ifndef _WIN32
15+
extern int isatty(int);
16+
+#endif
17+
extern int err__fl(int,int,char*);
18+
extern int xrd_SL(void);
19+
extern int f__putbuf(int);

0 commit comments

Comments
 (0)