diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index c7c602a..2c02472 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -28,9 +28,9 @@ jobs: - name: Get cfitsio run: | - wget "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.47.tar.gz" -O cfitsio.tar.gz; + wget "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-3.48.tar.gz" -O cfitsio.tar.gz; tar -xvf cfitsio.tar.gz; - cd cfitsio-3.47 + cd cfitsio-3.48 ./configure --prefix=/usr/local --enable-reentrant; make clean && make; sudo make install; diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b57ef1..e9b3c54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log Changes in each release are listed below. +## 0.3.2 25-June-2020 (Pre-release) +* libmwalib.so now has statically linked libcfitsio library as cfitsio's ABI keeps changing making linking difficult for users. + ## 0.3.1 08-June-2020 (Pre-release) * Bugfix: Fixed panic when all 24 coarse channels are using receiver channel numbers >128. * Added more inline documentation for mwalib.h. diff --git a/Cargo.toml b/Cargo.toml index 1ee3352..be31fd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mwalib" -version = "0.3.0" +version = "0.3.2" homepage = "https://github.com/MWATelescope/mwalib" authors = ["Greg Sleap ", "Christopher H. Jordan "] @@ -19,21 +19,21 @@ codegen-units = 1 # Set this to 1 in Cargo.toml to allow for maximum size redu crate-type = ["rlib", "staticlib", "cdylib"] [dependencies] -anyhow = "1.0.28" -chrono = "0.4.11" -fitsio = "0.15.0" -fitsio-sys = "0.3.0" -lazy_static = "1.4.0" -libc = "0.2.69" -rayon = "1.3.0" -regex = "1.3.7" +anyhow = "1.0.*" +chrono = "0.4.*" +fitsio = "0.15.*" +fitsio-sys = "0.3.*" +lazy_static = "1.4.*" +libc = "0.2.*" +rayon = "1.3.*" +regex = "1.3.*" [dev-dependencies] -criterion = "0.3.2" -csv = "1.1.3" -float-cmp = "0.7.0" -structopt = "0.3.14" -tempdir = "0.3.7" +criterion = "0.3.*" +csv = "1.1.*" +float-cmp = "0.7.*" +structopt = "0.3.*" +tempdir = "0.3.*" [[bench]] name = "bench" diff --git a/LICENSE-cfitsio b/LICENSE-cfitsio new file mode 100644 index 0000000..2d051ec --- /dev/null +++ b/LICENSE-cfitsio @@ -0,0 +1,24 @@ +CFITSIO (See: https://heasarc.gsfc.nasa.gov/fitsio/) + +Copyright (Unpublished--all rights reserved under the copyright laws of +the United States), U.S. Government as represented by the Administrator +of the National Aeronautics and Space Administration. No copyright is +claimed in the United States under Title 17, U.S. Code. +Permission to freely use, copy, modify, and distribute this software +and its documentation without fee is hereby granted, provided that this +copyright notice and disclaimer of warranty appears in all copies. +DISCLAIMER: +THE SOFTWARE IS PROVIDED 'AS IS' WITHOUT ANY WARRANTY OF ANY KIND, +EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, +ANY WARRANTY THAT THE SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY +IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE, AND FREEDOM FROM INFRINGEMENT, AND ANY WARRANTY THAT THE +DOCUMENTATION WILL CONFORM TO THE SOFTWARE, OR ANY WARRANTY THAT THE +SOFTWARE WILL BE ERROR FREE. IN NO EVENT SHALL NASA BE LIABLE FOR ANY +DAMAGES, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL OR +CONSEQUENTIAL DAMAGES, ARISING OUT OF, RESULTING FROM, OR IN ANY WAY +CONNECTED WITH THIS SOFTWARE, WHETHER OR NOT BASED UPON WARRANTY, +CONTRACT, TORT , OR OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY +PERSONS OR PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED +FROM, OR AROSE OUT OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR +SERVICES PROVIDED HEREUNDER. \ No newline at end of file diff --git a/README.md b/README.md index f947bcb..c4cd1f1 100644 --- a/README.md +++ b/README.md @@ -62,10 +62,8 @@ the rendered documentation. presented in the data is calculated as `n/2 * (n+1)` (where `n` is the number of antennas). -## Installation -It is possible that a dynamic-shared and/or static objects can be provided on -GitHub in the future, but for now, `mwalib` should be compiled from source. - +## Building From Source +You can build mwalib from source: - Install rust `https://www.rust-lang.org/tools/install` @@ -96,6 +94,28 @@ GitHub in the future, but for now, `mwalib` should be compiled from source. Install `cbindgen` with your package manager or via `cargo` with `cargo install cbindgen`. +## Installation +As an alternative to building from source, we produce github releases whenever features or bug fixes are completed as tarballs. In the release you will find everything you need to use mwalib from C/C++/Python or any other language that can utilise shared libraries: +* lib/libmwalib.a (Statically compiled library) +* lib/libmwalib.so (Dynamic library) +* include/mwalib.h (C Header file) +* CHANGELOG.md (Change log for this and previous relases) +* LICENSE (License for using mwalib in your projects) +* LICENSE-cfitsio (Since libcfitsio is statically compiled into our static and dynamic libraries, we also include it's license) + +To install on a regular linux x86/64 distribution, the following would be all that is needed: +- Download release from mwalib [github releases](https://github.com/MWATelescope/mwalib/releases). + `wget "https://github.com/MWATelescope/mwalib/releases/download/v0.3.1/libmwalib-0.3.1-linux_x86_64.tar.gz" -O mwalib.tar.gz` + +- Untar the tarball + `mkdir mwalib; tar xvf mwalib.tar.gz -C mwalib` + +- Install + `sudo cp mwalib/lib/libmwalib.* /usr/local/lib` + `sudo cp mwalib/include/libmwalib.h /usr/local/include` + +- Register the library with ldconfig + 'sudo ldconfig' ## Consistency checks (TODO: This is non-exhaustive!) diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..56254a4 --- /dev/null +++ b/build.rs @@ -0,0 +1,28 @@ +use std::env; + +fn main() { + // + // Link to shared or static CFITSIO + // + // Check if we have this environment variable + // If we do, then we will link to cfitsio statically + // But if so, you need to have: + // 1. libcfitsio.a in your LD_LIBRARY_PATH or PATH + // AND + // 2. libcfitsio.a needs to have been built with the following ./configure statement: + // ./configure --disable-curl --prefix=/usr/local --enable-reentrant + match env::var("MWALIB_LINK_STATIC_CFITSIO") { + Ok(val) => { + match val.as_str() { + "0" => { + println!("cargo:warning=rustc will link with the shared libcfitsio.so library. Set MWALIB_LINK_STATIC_CFITSIO=1 in your environment to link statically.") + }, + _ => { + println!("cargo:rustc-link-lib=static=cfitsio"); + println!("cargo:warning=rustc will link with the static libcfitsio.a library. Remove MWALIB_LINK_STATIC_CFITSIO from your environment (or set to 0) to link dynamically."); + } + } + }, + Err(_) => println!("cargo:warning=rustc will link with the shared libcfitsio.so library. Set MWALIB_LINK_STATIC_CFITSIO=1 in your environment to link statically."), + } +} diff --git a/tools/make_release.sh b/tools/make_release.sh new file mode 100755 index 0000000..26dee4b --- /dev/null +++ b/tools/make_release.sh @@ -0,0 +1,22 @@ +echo "Making release..." +echo "Cleaning up previous release files..." +rm -rf ../target +rm -rf release +echo "Building mwalib..." +cargo build --release -v +cbindgen -l c .. > ../include/mwalib.h +echo "mwalib.h has been regenerated in ../include/mwalib.h" +echo "Packaging up mwalib..." +mkdir -p release +mkdir -p release/lib +mkdir -p release/include +cp ../target/release/libmwalib.a release/lib/. +cp ../target/release/libmwalib.so release/lib/. +cp ../LICENSE release/. +cp ../LICENSE-cfitsio release/. +cp ../CHANGELOG.md release/. +cp ../include/mwalib.h release/include/. +cd release +echo "Taring files..." +tar -czvf libmwalib-0.3.2-linux_x86_64.tar.gz lib/libmwalib.a lib/libmwalib.so include/mwalib.h LICENSE LICENSE-cfitsio CHANGELOG.md +echo "Release complete!"