Skip to content

Commit

Permalink
New wrap: cfitsio-4.5.0
Browse files Browse the repository at this point in the history
This is a file wrap with a patch. It is mostly based on the
CMakeLists.txt provided in the source. But there were a few defines
in the autotolls version that werent in the cmake that I also added.
  • Loading branch information
kjmeagher committed Nov 1, 2024
1 parent 0150cf0 commit 1760daa
Show file tree
Hide file tree
Showing 7 changed files with 379 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ci_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
"cexception:werror=false"
]
},
"cfitsio": {
"alpine_packages": [
"gfortran",
"libcurl"
],
"debian_packages": [
"gfortran"
]
},
"cglm": {
"build_options": [
"cglm:build_tests=true"
Expand Down
6 changes: 6 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@
"1.3.3-1"
]
},
"cfitsio":{
"dependency_names": [
"cfitsio"
],
"versions":["4.5.0-1"]
},
"cglm": {
"dependency_names": [
"cglm"
Expand Down
9 changes: 9 additions & 0 deletions subprojects/cfitsio.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[wrap-file]
directory = cfitsio-4.5.0
source_url = https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.5.0.tar.gz
source_filename = cfitsio-4.5.0.tar.gz
source_hash = e4854fc3365c1462e493aa586bfaa2f3d0bb8c20b75a524955db64c27427ce09
patch_directory = cfitsio

[provide]
cfitsio = cfitsio_dep
277 changes: 277 additions & 0 deletions subprojects/packagefiles/cfitsio/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
project(
'cfitsio',
'c',
version: '4.5.0',
meson_version: '>=1.1.0',
license: 'CFITSIO',
license_files: ['licenses/License.txt'],
)
has_fortran = add_languages(
'fortran',
native: false,
required: get_option('fortran'),
)
SOVERSION = 10

cc = meson.get_compiler('c')
deps = []
libm = cc.find_library('m', required: false)
if not libm.found()
libm = dependency('', required: false)
endif
deps += libm

threads = dependency('threads', required: get_option('reentrant'))
if threads.found()
add_project_arguments('-D_REENTRANT', language: 'c')
deps += threads
endif

deps += dependency('zlib', method: 'pkg-config', required:true, fallback: ['zlib', 'zlib_dep'])

if target_machine.system() != 'windows'

bzip2 = dependency(
'bzip2',
method: 'pkg-config',
required: get_option('bzip2'),
fallback: ['bzip2', 'bzip2_dep'],
)
if bzip2.found()
add_project_arguments('-DHAVE_BZIP2=1', language: 'c')
deps += bzip2
endif

curl = dependency(
'libcurl',
method: 'pkg-config',
required: get_option('curl'),
)
if curl.found()
add_project_arguments('-DCFITSIO_HAVE_CURL', language: 'c')
deps += curl
endif
endif

if get_option('hera')
add_project_arguments('-DBUILD_HERA=1', language: 'c')
endif

if cc.get_id() != 'msvc' and cc.has_function('gethostbyname') and cc.has_function(
'connect',
)
add_project_arguments('-DHAVE_NET_SERVICES', language: 'c')
if cc.has_header_symbol('stdio.h', 'fmemopen')
add_project_arguments('-DHAVE_FMEMOPEN', language: 'c')
endif
endif

if get_option('sse2')
if cc.has_argument('-msse2')
add_project_arguments('-msse2', language: 'c')
elif cc.get_id() == 'msvc'
add_project_arguments('-D__SSE2__=1')
endif
endif

if get_option('ssse3')
if cc.has_argument('-mssse3')
add_project_arguments('-mssse3', language: 'c')
elif cc.get_id() == 'msvc'
add_project_arguments('-D__SSE2__=1', '-D__SSSE3__=1', language: 'c')
endif
endif

if cc.has_header_symbol('unistd.h', 'ftruncate')
add_project_arguments('-DHAVE_UNISTD_H', '-DHAVE_FTRUNCATE', language: 'c')
endif

shmem_prefix = [
'#include <sys/ipc.h>',
'#include <sys/shm.h>',
'#include <sys/sem.h>',
]
flock_prefix = ['#include <sys/flock.h>']

have_shmem_services = true
foreach func : ['shmat', 'shmdt', 'shmget', 'semget']
have_shmem_services = have_shmem_services and cc.has_function(
func,
prefix: shmem_prefix,
)
endforeach
if have_shmem_services
add_project_arguments('-DHAVE_SHMEM_SERVICES', language: 'c')
if cc.has_type('flock_t', prefix: flock_prefix)
add_project_arguments('-DHAVE_FLOCK_T', language: 'c')
endif
if cc.has_type('union semun', prefix: shmem_prefix)
add_project_arguments('-DHAVE_UNION_SEMUN', language: 'c')
endif
endif

if cc.has_type('long long')
add_project_arguments('-DHAVE_LONGLONG', language: 'c')
endif

install_headers('fitsio.h', 'fitsio2.h', 'longnam.h')

libcfitsio_la_SOURCES = [
'buffers.c',
'cfileio.c',
'checksum.c',
'drvrfile.c',
'drvrmem.c',
'drvrnet.c',
'drvrsmem.c',
'editcol.c',
'edithdu.c',
'eval_l.c',
'eval_y.c',
'eval_f.c',
'fitscore.c',
'getcol.c',
'getcolb.c',
'getcold.c',
'getcole.c',
'getcoli.c',
'getcolj.c',
'getcolk.c',
'getcoll.c',
'getcols.c',
'getcolsb.c',
'getcoluk.c',
'getcolui.c',
'getcoluj.c',
'getkey.c',
'group.c',
'grparser.c',
'histo.c',
'iraffits.c',
'modkey.c',
'putcol.c',
'putcolb.c',
'putcold.c',
'putcole.c',
'putcoli.c',
'putcolj.c',
'putcolk.c',
'putcoluk.c',
'putcoll.c',
'putcols.c',
'putcolsb.c',
'putcolu.c',
'putcolui.c',
'putcoluj.c',
'putkey.c',
'region.c',
'scalnull.c',
'swapproc.c',
'wcssub.c',
'wcsutil.c',
'imcompress.c',
'quantize.c',
'ricecomp.c',
'pliocomp.c',
'fits_hcompress.c',
'fits_hdecompress.c',
'simplerng.c',
'zcompress.c',
'zuncompress.c',
]

if has_fortran
libcfitsio_la_SOURCES += [
'f77_wrap1.c',
'f77_wrap2.c',
'f77_wrap3.c',
'f77_wrap4.c',
]
endif

libcfitsio = shared_library(
'cfitsio',
libcfitsio_la_SOURCES,
dependencies: deps,
version: meson.project_version(),
soversion: SOVERSION,
install: true,
)

cfitsio_dep = declare_dependency(
include_directories: include_directories('.'),
link_with: libcfitsio,
)

pkg = import('pkgconfig')
pkg.generate(
libraries: libcfitsio,
version: meson.project_version(),
name: 'cifitsio',
description: 'FITS File Subroutine Library',
url: 'https://heasarc.gsfc.nasa.gov/fitsio/',
)

executable(
'fitscopy',
'utilities/fitscopy.c',
dependencies: cfitsio_dep,
install: get_option('utils'),
)
executable(
'fitsverify',
'utilities/ftverify.c',
'utilities/fvrf_data.c',
'utilities/fvrf_file.c',
'utilities/fvrf_head.c',
'utilities/fvrf_key.c',
'utilities/fvrf_misc.c',
c_args: '-DSTANDALONE',
dependencies: cfitsio_dep,
install: get_option('utils'),
)
executable(
'fpack',
'utilities/fpack.c',
'utilities/fpackutil.c',
dependencies: [libm, cfitsio_dep],
install: get_option('utils'),
)
executable(
'funpack',
'utilities/funpack.c',
'utilities/fpackutil.c',
dependencies: [libm, cfitsio_dep],
link_with: libcfitsio,
install: get_option('utils'),
)

executable('executimcopy', 'utilities/imcopy.c', dependencies: cfitsio_dep)
if have_shmem_services
executable('smem', 'utilities/smem.c', dependencies: cfitsio_dep)
endif

test(
'cookbook',
executable('cookbook', 'utilities/cookbook.c', dependencies: cfitsio_dep),
)
cmp = find_program('test_compare.py')
testprog = executable(
'testprog',
'utilities/testprog.c',
dependencies: cfitsio_dep,
)
test('testprog', cmp, args: [testprog, meson.current_source_dir()])
if has_fortran
testf77 = executable(
'testf77',
'utilities/testf77.f',
dependencies: cfitsio_dep,
)
test('testf77', cmp, args: [testf77, meson.current_source_dir()])
endif

benchmark(
'speed',
executable('speed', 'utilities/speed.c', dependencies: cfitsio_dep),
)
38 changes: 38 additions & 0 deletions subprojects/packagefiles/cfitsio/meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
option(
'curl',
type: 'feature',
description: 'Enable linking with the curl library. Enables remote file i/o support',
)
option(
'reentrant',
type: 'feature',
description: 'Enable reentrant multithreading',
)
option(
'utils',
type: 'boolean',
description: 'Build fpack, funpack, fitscopy, and fitsverify executables',
)
option(
'sse2',
type: 'boolean',
description: 'Enable use of instructions in the SSE2 extended instruction set',
)
option(
'ssse3',
type: 'boolean',
description: 'Enable use of instructions in the SSSE3 extended instruction set',
)
option('hera', type: 'boolean', description: 'Build for HERA (ASD use only)')
option(
'bzip2',
type: 'feature',
description: 'Enable bzip2 support. Optional path to the location of include/bzlib.h and lib/libbz2',
)
# option('gsiftp',type:'feature', description: 'Enable Globus Toolkit gsiftp protocol support')
# option('gsiftp-flavour','Define Globus Toolkit gsiftp protocol flavour')
option(
'fortran',
type: 'feature',
description: 'Build package with Fortran support',
)
37 changes: 37 additions & 0 deletions subprojects/packagefiles/cfitsio/test_compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3

"""
cfitsio instructs the user build test executeables, run them, and then compare
the output to provided reference files. This python file does that in a
portable way integrated into meson's test framework
"""

import sys
from pathlib import Path
import subprocess

test_exe = Path(sys.argv[1])
src_dir = Path(sys.argv[2])
name = test_exe.name.split('.')[0]

input_name = src_dir / (name + ".tpt")
output_ref = src_dir / (name + ".out")
fits_ref = src_dir / (name + ".std")

print(f"input file: {input_name} found : {input_name.is_file()}")
print(f"output reference: {output_ref} found : {output_ref.is_file()}")
print(f"fits reference: {fits_ref} found : {fits_ref.is_file()}")

r = subprocess.run(test_exe.absolute(), cwd=src_dir, capture_output=True)
if r.returncode:
print(r"test returned non zero: {r.returncode}")
exit(r.returncode)

out_are_same = r.stdout.splitlines() == open(output_ref, "rb").read().splitlines()
print(f"Outputs are the same: {out_are_same}")
fits_are_same = (
open(fits_ref, "rb").read() == open(src_dir / (name + ".std"), "rb").read()
)
print(f"Fits are the same: {fits_are_same}")

exit(int(not fits_are_same) * 2 + int(not out_are_same))
Loading

0 comments on commit 1760daa

Please sign in to comment.