From f07efb4a1dfebf4f9d55308785e65c74b68de269 Mon Sep 17 00:00:00 2001 From: Hleb Valoshka <375gnu@gmail.com> Date: Thu, 21 Nov 2019 01:04:54 +0300 Subject: [PATCH] NASA C SPICE toolkit (#8859) --- ports/cspice/CMakeLists.txt | 41 +++++++++++++++++++++++++ ports/cspice/CONTROL | 3 ++ ports/cspice/License.txt | 16 ++++++++++ ports/cspice/isatty.patch | 19 ++++++++++++ ports/cspice/mktemp.patch | 11 +++++++ ports/cspice/portfile.cmake | 60 +++++++++++++++++++++++++++++++++++++ 6 files changed, 150 insertions(+) create mode 100644 ports/cspice/CMakeLists.txt create mode 100644 ports/cspice/CONTROL create mode 100644 ports/cspice/License.txt create mode 100644 ports/cspice/isatty.patch create mode 100644 ports/cspice/mktemp.patch create mode 100644 ports/cspice/portfile.cmake diff --git a/ports/cspice/CMakeLists.txt b/ports/cspice/CMakeLists.txt new file mode 100644 index 00000000000..e82b3a2804a --- /dev/null +++ b/ports/cspice/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required(VERSION 3.1) +project(cspice LANGUAGES C) + +set(SOVERSION 66) + +# Include all *.c files from the library +file(GLOB CSPICE_SOURCE ${PROJECT_SOURCE_DIR}/cspice/src/cspice/*.c) +set(INCLUDE_PATH "${PROJECT_SOURCE_DIR}/cspice/include") + +if (_STATIC_BUILD) + add_library(cspice STATIC ${CSPICE_SOURCE}) +else() + add_library(cspice SHARED ${CSPICE_SOURCE}) +endif() +target_include_directories(cspice PUBLIC "${INCLUDE_PATH}") + +if (WIN32) + target_compile_definitions(cspice PUBLIC "_COMPLEX_DEFINED;MSDOS;OMIT_BLANK_CC;NON_ANSI_STDIO") + set_target_properties(cspice PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) +elseif (UNIX) + target_compile_definitions(cspice PUBLIC "NON_ANSI_STDIO") + target_compile_options(cspice PUBLIC -m64 -ansi -fPIC) +endif () + +if (NOT _SKIP_HEADERS) + file(GLOB SPICE_HEADERS ${INCLUDE_PATH}/*.h) + install(FILES ${SPICE_HEADERS} DESTINATION include/cspice) +endif() + +set_target_properties( + cspice + PROPERTIES SOVERSION ${SOVERSION} +) + +install( + TARGETS cspice + EXPORT cspice + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) diff --git a/ports/cspice/CONTROL b/ports/cspice/CONTROL new file mode 100644 index 00000000000..670f75a3ae1 --- /dev/null +++ b/ports/cspice/CONTROL @@ -0,0 +1,3 @@ +Source: cspice +Version: 66-1 +Description: NASA C SPICE toolkit diff --git a/ports/cspice/License.txt b/ports/cspice/License.txt new file mode 100644 index 00000000000..dcec937a117 --- /dev/null +++ b/ports/cspice/License.txt @@ -0,0 +1,16 @@ +This software and any related materials were created by the California +Institute of Technology (Caltech) under U.S. government contract with the +National Aeronautics and Space Administration (NASA). The software is +Technology and Software Publicly Available under U.S. export laws and is +provided "as-is" to the recipient without warranty of any kind, including any +warranties of performance or merchantability or fitness for particular use or +purpose (as set forth in United States UCC§2312-§2313) or for any purpose +whatsoever, for the software and related materials, however used. In no event +shall Caltech, its Jet Propulsion Laboratory, or NASA be liable for any damages +and/or costs, including, but not limited to, incidental or consequential +damages of any kind, including economic damage or injury to property and lost +profits, regardless of whether Caltech, JPL, or NASA be advised, have reason to +know, or, in fact, shall know of the possibility. Recipient bears all risk +relating to quality and performance of the software and any related materials, +and agrees to indemnify Caltech and NASA for all third-party claims resulting +from the actions of recipient in the use of the software. diff --git a/ports/cspice/isatty.patch b/ports/cspice/isatty.patch new file mode 100644 index 00000000000..a6d201d7754 --- /dev/null +++ b/ports/cspice/isatty.patch @@ -0,0 +1,19 @@ +--- a/cspice/src/cspice/fio.h 2019-11-01 20:51:53.198400000 +0300 ++++ b/cspice/src/cspice/fio.h 2019-11-01 21:19:58.123200000 +0300 +@@ -1,3 +1,6 @@ ++#ifdef _WIN32 ++#include /* for isatty() */ ++#endif + #include "stdio.h" + #include "errno.h" + #ifndef NULL +@@ -75,7 +76,9 @@ + extern int (*f__donewrec)(void), t_putc(int), x_wSL(void); + extern void b_char(char*,char*,ftnlen), g_char(char*,ftnlen,char*); + extern int c_sfe(cilist*), z_rnew(void); ++#ifndef _WIN32 + extern int isatty(int); ++#endif + extern int err__fl(int,int,char*); + extern int xrd_SL(void); + extern int f__putbuf(int); diff --git a/ports/cspice/mktemp.patch b/ports/cspice/mktemp.patch new file mode 100644 index 00000000000..5a7cc0ee004 --- /dev/null +++ b/ports/cspice/mktemp.patch @@ -0,0 +1,11 @@ +--- a/cspice/src/cspice/open.c 2019-11-02 10:57:10.073886963 +0300 ++++ b/cspice/src/cspice/open.c 2019-11-02 10:57:49.230398941 +0300 +@@ -324,7 +324,7 @@ + #ifdef NON_ANSI_STDIO + + (void) strcpy(buf,"tmp.FXXXXXX"); +- (void) mktemp(buf); ++ fclose(mktemp(buf)); + goto replace; + + #else diff --git a/ports/cspice/portfile.cmake b/ports/cspice/portfile.cmake new file mode 100644 index 00000000000..7c52772f355 --- /dev/null +++ b/ports/cspice/portfile.cmake @@ -0,0 +1,60 @@ +include(vcpkg_common_functions) + +if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + message(FATAL_ERROR "${PORT} does not currently support UWP") +endif() + +if (WIN32) + vcpkg_download_distfile(ARCHIVE + URLS "https://naif.jpl.nasa.gov/pub/naif/toolkit/C/PC_Windows_VisualC_32bit/packages/cspice.zip" + FILENAME "cspice.zip" + SHA512 4f6129b26543729f4eb4f8240b43ca87530db9c6d9a5c0e3f43faf30561eaad95dcf507e3fecfd1c3d4388ccaa4e22a76df7bf7945b6ce9a68eb3b4893885992 + ) +elseif (APPLE) + vcpkg_download_distfile(ARCHIVE + URLS "https://naif.jpl.nasa.gov/pub/naif/toolkit//C/MacIntel_OSX_AppleC_32bit/packages/cspice.tar.Z" + FILENAME "cspice.tar.Z" + SHA512 bd5cc20206e48b3712c5077a2beb05c98cd58a25ce374ed363699a04998eb8ba93e42b5f7c2104c5296db95b3bccdc7cc9b6a2ba45875454d0c3914834aa4c42 + ) +else () + vcpkg_download_distfile(ARCHIVE + URLS "https://naif.jpl.nasa.gov/pub/naif/toolkit/C/PC_Linux_GCC_32bit/packages/cspice.tar.Z" + FILENAME "cspice.tar.Z" + SHA512 b387bc2cfca4deccc451d198af49564ea0b19cf665ba143d39196ed532639cbc11aad7e1d63f71f1bb88d72c0e6ac30757b6e1babca9e0ee3b92f9c205c1b908 + ) +endif() + +set(PATCHES isatty.patch) +if (NOT WIN32) + set(PATCHES ${PATCHES} mktemp.patch) +endif() + +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + NO_REMOVE_ONE_LEVEL + PATCHES ${PATCHES} +) + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) + +if (VCPKG_LIBRARY_LINKAGE STREQUAL static) + set(_STATIC_BUILD ON) +endif() + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS -D_STATIC_BUILD=${_STATIC_BUILD} + OPTIONS_DEBUG -D_SKIP_HEADERS=ON +) + +vcpkg_install_cmake() + +vcpkg_copy_pdbs() + +file( + INSTALL ${CMAKE_CURRENT_LIST_DIR}/License.txt + DESTINATION ${CURRENT_PACKAGES_DIR}/share/cspice + RENAME copyright +)