You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
option( SpecUtils_USE_SIMD"Use SIMD operations; i386/x64 only right now, and very alpha, and extremely minimally used"OFF )
26
24
option( SpecUtils_ENABLE_EQUALITY_CHECKS"Enables the equal_enough(...) functions for comparing two spectrum files."OFF ) #code size is only reason to default to off, I think
27
25
option( PERFORM_DEVELOPER_CHECKS"Performs additional computationally expensive tests during execution (requires linking to boost)"OFF )
28
26
option( SpecUtils_SHARED_LIB"Whether to compile a shared, or static library"OFF )
27
+
option( SpecUtils_C_BINDINGS"Creates C bindings to the c++ code"OFF )
29
28
30
29
31
30
set( SpecUtils_FLT_PARSE_METHOD"default_value"CACHESTRING[[How to parse lists of numbers.
set( SpecUtils_USE_FAST_FLOATOFF ) # Uses https://github.com/fastfloat/fast_float . If fast_float.h isnt found, will be fetched
269
-
set( SpecUtils_USE_FROM_CHARSOFF ) # Supported by MSVC >= 2019, and gcc >= 12. Not supported by Apple clang. In MSVC, about 50% slower than boost::spirit
245
+
set( SpecUtils_USE_FROM_CHARSOFF ) # Supported by MSVC >= 2019, and gcc >= 12. Only supported by Apple if targeting macOS 10.15 or newer. In MSVC, about 50% slower than boost::spirit
270
246
set( SpecUtils_USE_BOOST_SPIRITOFF ) # Uses boost::spirit, and fasted method (maybe a hair faster than fastfloat)
271
247
set( SpecUtils_USE_STRTODOFF ) # Slowest method, but works
272
248
@@ -341,7 +317,7 @@ endif( SpecUtils_USE_BOOST_SPIRIT OR PERFORM_DEVELOPER_CHECKS )
341
317
342
318
if( SpecUtils_USE_FROM_CHARS )
343
319
if( NOT (MSVCAND (MSVC_VERSIONGREATER_EQUAL1920)) )
344
-
# MSVC >=2019 supports floating point from_chars, while Xcode 14 still doesnt (havent checked Android Studio)
320
+
# MSVC >=2019 supports floating point from_chars, while for macOS you need to target macOS 10.15 or later
345
321
message("Please double check your compiler does actually support std::from_chars for parsing floats")
Copy file name to clipboardExpand all lines: README.md
+17-4Lines changed: 17 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,9 +48,21 @@ int main() {
48
48
### Relevant CMake Build options
49
49
***SpecUtils_ENABLE_D3_CHART**[default ON]: Enabling this feature allows exporting specta to a [D3.js](https://d3js.org/) based plotting that allows viewing and interacting with the spectra in a web browser. An example can be seen [here](examples/d3_chart_example/self_contained_example.html).
50
50
* **SpecUtils_D3_SUPPORT_FILE_STATIC** [default ON]: Only relevant if *SpecUtils_ENABLE_D3_CHART* is *ON*. This option determines if all the JavaScript (including D3.js, SpectrumChartD3.js, etc) and CSS should be compiled into the library, or remain as seperate files accessed at runtime.
51
-
***SpecUtils_PYTHON_BINDINGS**[default OFF]: Determines if the Python bindings should be built. [Boost.Python](https://www.boost.org/doc/libs/1_69_0/libs/python/doc/html/index.html) is used to generate the bindings. Have a look in [test_python.py](bindings/python/test_python.py) for example use of **SpecUtils** from python.
52
-
***SpecUtils_JAVA_SWIG**[default OFF]: Determines if the Java bindings should be built. [SWIG](https://www.swig.org/) is used to generate the bindings, and an example application using them is in [bindings/swig/java_example/](bindings/swig/java_example/) directory.
53
-
***PERFORM_DEVELOPER_CHECKS**[default OFF]: Performs additional tests during program execution, with failed tests being output to a log file.
51
+
***SpecUtils_ENABLE_URI_SPECTRA**[default OFF]: Adds support for [URI-based-spectra](https://sandialabs.github.io/InterSpec/tutorials/references/spectrum_in_a_qr_code_uur_latest.pdf), such as you might find in QR-codes. Requires linking against zlib.
52
+
***SpecUtils_FLT_PARSE_METHOD** : How to parse floating point numbers from text files; options are `FastFloat`, `FromChars`, `boost`, `strtod`. `Boost` is the fastest method (but requires having boost installed), with `strtod` the slowest but most widely supported.
53
+
***PERFORM_DEVELOPER_CHECKS**[default OFF]: Performs additional tests during program execution, with failed tests being output to a log file; you normally want these off because they can be slow. Turning this option on also requires linking to `boost`.
54
+
***SpecUtils_SHARED_LIB**[default OFF]: Whether to compile a shared library, or static library.
55
+
56
+
## Bindings to other languages
57
+
`SpecUtils` has explicit bindings to `Python`, `Java`, `Node`, and `C`, with the `C` known to be used from `C`, `Fortran`, and `Rust`.
58
+
59
+
To one of these bindings:
60
+
*`Python`: The [nanobind](https://github.com/wjakob/nanobind) library is used to create these binding. To use a pre-compiled version via `pip`, see https://pypi.org/project/SandiaSpecUtils/ . If you would like to compile the bindings yourself, see [bindings/python/README.md](bindings/python/README.md). Some example uses are available in [bindings/python/examples](bindings/python/examples).
61
+
*`Node`: The [node-addon-api](https://www.npmjs.com/package/node-addon-api) and [cmake-js](https://www.npmjs.com/package/cmake-js) packages are used to create these bindings; see [bindings/node/README.md](bindings/node/README.md) for instructions on compiling. An example use is in [example.js](bindings/node/example.js).
62
+
*`Java`: The [SWIG](https://www.swig.org) package is used to create these bindings, and could likely be used for other languages. See [bindings/swig/README.md](bindings/swig/README.md) for compilation instructions. An example use of `SpecUtils` from java is included in the bindings directory.
63
+
*`C`: These bindings are hand-written, and can be included when building `SpecUtils` by specifying the `SpecUtils_C_BINDINGS` CMake option to `ON`. There is an example use of C interface in [examples/c_interface_example.c](c_interface_example.c).
64
+
65
+
54
66
55
67
## Features
56
68
* Parses >100 spectrum file format variants.
@@ -64,12 +76,13 @@ int main() {
64
76
* Tools to help rebin, re-calibrate, truncate, and combine spectra.
65
77
* And more!
66
78
79
+
67
80
## Testing
68
81
This library uses a few methods to test the code, but unfortunately still likely contains bugs or issues, especially related to specific file format variants.
69
82
70
83
The testing methods are:
71
84
* Peppered throughout the code there are `#if( PERFORM_DEVELOPER_CHECKS )` statements that perform additional tests at runtime that make sure the correct answer was computed or action taken. Most of these blocks of code will either recompute a quantity using an independent implementation, or in someway perform additional sanity checks, and when issues are found, they are logged to a file for fixing in the future. This seems to work well as the primary developer of this library uses the library heavily.
72
-
* An assortment of unit tests have been created and are occasionally run, but by no means offer anywhere near 100% coverage. Since many of the test contain proprietary data, they are not all distributed with the library.
85
+
* An assortment of unit tests are avaiable in [unit_tests](unit_tests)and are ran as part of the CI/CD, but do not offer 100% coverage.
73
86
* As the primary developer of this library comes across new file formats, or new variants of file formats, they get added to a library after manually verifying they are parsed sufficiently well. Then [regression_test/regression_test.cpp](regression_test/regression_test.cpp) is used to ensure the files continue to be parsed exactly the same as when they were manually verified. Any changes to the information extracted from these files will then be manually verified to be an improvement to the parsing (like adding the ability to extract GPS coordinates from a format), or the issue will be corrected. This helps keep regressions from occurring. A keystone piece to this testing is that all information extracted from any file format can be written out to a N42-2012 file; when this N42-2012 file is read back in, the exact same information is available as from the original file (this property is of course also tested for).
74
87
*[Fuzz testing](fuzz_test/) is periodically performed.
75
88
* Near daily use to parse a wide variety of formats by the primary developer, as well as use by users of the applications built against SpecUtils.
Copy file name to clipboardExpand all lines: bindings/node/README.md
+6-12Lines changed: 6 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,16 +7,10 @@ In order to use **SpecUtils** from **node.js**, we need to compile the C++ into
7
7
To create the add-on we use [cmake-js](https://www.npmjs.com/package/cmake-js) to build the [SpecUtils](https://github.com/sandialabs/SpecUtils) library as well as some [node-addon-api](https://www.npmjs.com/package/node-addon-api) interface code to allow accessing the C++ functions from JavaScript. Once the module is built, it should work with any **node.js** versions >=6.14.2 thanks to the ABI stability offered by [n-api](https://nodejs.org/api/n-api.html).
8
8
9
9
## Prerequisites
10
-
You will need a reasonable recent version of [CMake](https://cmake.org/) (version >=3.1) installed, a C++ compiler that can handle C++11, and the [boost](https://www.boost.org/) libraries (developed against 1.65.1 version shouldn't matter much) to link against. You will of course also need [node.js](https://nodejs.org/en/) installed.
11
-
-**Windows**: You will need the CMake and node executables in your **PATH** variable. When installing node.js there may be an option to install the MSVC command line tools through Chocolatey, otherwise you will need to have MSVS-2012 or newer installed (development done with MSVS-2017). Other compilers (clang, [MingGW](https://nuwen.net/mingw.html)) *should* work, but have not been tested. This project links against the static runtime libraries (e.g., uses the '/MT' flag), and statically links to boost, so the resulting module is self contained. When executing the steps below to compile the code you will need to open the 'x64 Native Tools Command Prompt' provided by MSVS, or execute the appropriate *vcvarsall.bat*.
12
-
- Instructions for building boost can be found [here](https://www.boost.org/doc/libs/1_65_1/more/getting_started/windows.html), but basically you want to do something like:
- **macOS**: You will need the Xcode command line tools installed, which can be done by running `xcode-select --install`. CMake, node, and boost can all be installed using [MacPorts](https://www.macports.org/), [HomeBrew](https://brew.sh/), or manually installed. Keep in mind it is best to statically link to boost (e.g., have the ".a" libraries availble).
19
-
- **Linux**: You can use your package manager to install node.js, CMake, and the C++ compiler and related tools (usually with something like `apt-get install build-essential`). However, for boost some care may be needed. The `SpecUtils` module is really a shared library that node.js loads. To avoid dependencies we will statically link to the boost libraries (e.g., copy the needed boost code into the resulting SpecUtils.module file), meaning you need the `-fPIC` C/C++ compiler flag enabled not just for building `SpecUtils` code, but for all of the static libraries you link it against, namely, boost - which isn't the default when compiling static libraries. Therefore when building boost you may need to add `-fPIC -std=c++11` to the compile flags.
10
+
You will need a reasonable recent version of [CMake](https://cmake.org/) (version >=3.5) installed, a C++ compiler that can handle C++11. You will of course also need [node.js](https://nodejs.org/en/) installed.
11
+
-**Windows**: You will need the CMake and node executables in your **PATH** variable. When installing node.js there may be an option to install the MSVC command line tools through Chocolatey, otherwise you will need to have MSVS-2012 or newer installed (development done with MSVS-2017). Other compilers (clang, [MingGW](https://nuwen.net/mingw.html)) *should* work, but have not been tested. This project links against the static runtime libraries (e.g., uses the '/MT' flag) so the resulting module is self contained. When executing the steps below to compile the code you will need to open the 'x64 Native Tools Command Prompt' provided by MSVS, or execute the appropriate *vcvarsall.bat*.
12
+
-**macOS**: You will need the Xcode command line tools installed, which can be done by running `xcode-select --install`. CMake, and node, which can be installed using [MacPorts](https://www.macports.org/), [HomeBrew](https://brew.sh/), or manually.
13
+
-**Linux**: You can use your package manager to install node.js, CMake, and the C++ compiler and related tools (usually with something like `apt-get install build-essential`). However, for boost some care may be needed. The `SpecUtils` module is really a shared library that node.js loads.
20
14
21
15
# Build Instructions
22
16
From bash or the Windows Command Prompt, run:
@@ -25,14 +19,14 @@ From bash or the Windows Command Prompt, run:
25
19
npm install -g cmake-js
26
20
27
21
# For macOS only, you may want to define a deployment target
28
-
export MACOSX_DEPLOYMENT_TARGET=10.10
22
+
export MACOSX_DEPLOYMENT_TARGET=10.15
29
23
30
24
cd /path/to/SpecUtils/bindings/node/
31
25
32
26
# Install dependency for compiling a node.js add-on
33
27
npm install --save-dev node-addon-api
34
28
35
-
# If boost is in a standard location, you can just run
29
+
#To build int the "build" directory, with default
36
30
cmake-js --CDSpecUtils_FLT_PARSE_METHOD="strtod"
37
31
38
32
# Note that the 'SpecUtils_FLT_PARSE_METHOD' options are "FastFloat", "FromChars",
0 commit comments