Skip to content

Commit

Permalink
Merge pull request #350 from ICESat2-SlideRule/tidy
Browse files Browse the repository at this point in the history
Tidy
  • Loading branch information
jpswinski authored Oct 25, 2023
2 parents d64c54c + bb62c52 commit 47e1ec7
Show file tree
Hide file tree
Showing 289 changed files with 5,400 additions and 7,610 deletions.
111 changes: 3 additions & 108 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,66 +1,8 @@
# SlideRule top-level CMake build script

project (SLIDERULE LANGUAGES CXX)

#################
# CMake Options #
#################

set (CMAKE_LEGACY_CYGWIN_WIN32 0) # Squelch a warning when building on Win32/Cygwin
cmake_minimum_required (VERSION 3.13.0) # The minimum CMake version is chosen to enable policy CMP0079
cmake_policy(SET CMP0079 NEW) # add link library to target which is not built in this directory
cmake_policy(SET CMP0053 NEW) # simplified variable escape processing (recommended by cmake)

# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(default_build_type "Debug")
endif()
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
endif()

# Set a default platform
if(NOT CMAKE_BUILD_PLATFORM)
set(CMAKE_BUILD_PLATFORM "Linux" CACHE STRING "Choose the target platform." FORCE)
endif()

###################
# Project Options #
###################

# Project Options #

option (PYTHON_BINDINGS "Create Python bindings, including h5lite module" OFF)
option (SHARED_LIBRARY "Create shared library instead of sliderule binary" OFF)
option (SERVER_APP "Create sliderule server binary" ON)

# Library Options #

option (ENABLE_COMPAT "Use C++11 for compatibility with older compilers" OFF)
option (ENABLE_ADDRESS_SANITIZER "Instrument code with AddressSanitizer for memory error detection" OFF)
option (ENABLE_TIME_HEARTBEAT "Instruct TimeLib to use a 1KHz heart beat timer to set millisecond time resolution" OFF)
option (ENABLE_CUSTOM_ALLOCATOR "Override new and delete operators globally for debug purposes" OFF)
option (ENABLE_H5CORO_ATTRIBUTE_SUPPORT "H5Coro will read and process attribute messages" OFF)
option (ENABLE_APACHE_ARROW_10_COMPAT "Use Apache Arrow 11 interface" OFF)
option (ENABLE_BEST_EFFORT_CONDA_ENV "Attempt to alleviate some issues with running in a conda environment")

# Package Options #

option (USE_ARROW_PACKAGE "Include the Apache Arrow package" OFF)
option (USE_AWS_PACKAGE "Include the AWS package" OFF)
option (USE_CCSDS_PACKAGE "Include the CCSDS package" ON)
option (USE_GEO_PACKAGE "Include the GEO package" OFF)
option (USE_H5_PACKAGE "Include the HDF5 package" ON)
option (USE_LEGACY_PACKAGE "Include the Legacy package" ON)
option (USE_NETSVC_PACKAGE "Include the Network Services package" OFF)
option (USE_PISTACHE_PACKAGE "Include the Pistache package" OFF)

# Platform Options #

option (ENABLE_TRACING "Instantiate trace points" OFF)
option (ENABLE_TERMINAL "Instantiate terminal messages" ON)
include(${CMAKE_CURRENT_SOURCE_DIR}/project-config.cmake)

#####################
# Target: SlideRule #
Expand All @@ -74,47 +16,12 @@ else()
add_library(slideruleLib STATIC "")
endif()

# Version Information #

file(STRINGS ${PROJECT_SOURCE_DIR}/version.txt TGTVER)
string(REPLACE "v" "" LIBVER ${TGTVER})

# C++ Version #

if(${ENABLE_COMPAT})
set(CXX_VERSION 11)
else()
set(CXX_VERSION 17) # required if using pistache package
endif()

# Platform #

set_property(GLOBAL PROPERTY platform "")
# Platform Config #

if(CMAKE_BUILD_PLATFORM MATCHES "Linux")

# Prefer libraries installed in /usr/local
INCLUDE_DIRECTORIES(/usr/local/include)
LINK_DIRECTORIES(/usr/local/lib)

# Set Environment Variables
set (INSTALLDIR /usr/local CACHE STRING "Installation directory for library and executables")
set (CONFDIR ${INSTALLDIR}/etc/sliderule)
set (INCDIR ${INSTALLDIR}/include/sliderule)

# Include Linux Platform #
add_subdirectory (platforms/linux)

elseif(CMAKE_BUILD_PLATFORM MATCHES "Windows")

# Set Environment Variables
set (INSTALLDIR "C:\\Program Files\\SlideRule" CACHE STRING "Installation directory for library and executables")
set (CONFDIR ${INSTALLDIR}\etc\sliderule)
set (INCDIR ${INSTALLDIR}\include\sliderule)

# Include Windows Platform #
add_subdirectory (platforms/windows)

endif()

# Target Properties #
Expand All @@ -124,14 +31,8 @@ set_target_properties (slideruleLib PROPERTIES OUTPUT_NAME sliderule)
set_target_properties (slideruleLib PROPERTIES ENABLE_EXPORTS true)
set_target_properties (slideruleLib PROPERTIES CXX_STANDARD ${CXX_VERSION})

if(${PYTHON_BINDINGS})
set_target_properties (slideruleLib PROPERTIES POSITION_INDEPENDENT_CODE 1)
endif()

# Compile Definitions #

set (RUNTIMEDIR ${CONFDIR} CACHE STRING "Runtime directory for plugins and configuration scripts")

if (${ENABLE_TIME_HEARTBEAT})
message (STATUS "Enabling time heartbeat")
target_compile_definitions (slideruleLib PUBLIC TIME_HEARTBEAT)
Expand Down Expand Up @@ -248,12 +149,6 @@ add_subdirectory (scripts)

install (TARGETS slideruleLib DESTINATION ${INSTALLDIR}/lib)

if(${PYTHON_BINDINGS})

add_subdirectory (targets/binding-python)

elseif(${SERVER_APP} AND (CMAKE_BUILD_PLATFORM MATCHES "Linux"))

if(${SERVER_APP} AND (CMAKE_BUILD_PLATFORM MATCHES "Linux"))
add_subdirectory (targets/server-linux)

endif()
28 changes: 5 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ USGS3DEP_BUILD = $(BUILD)/usgs3dep
OPENDATA_BUILD = $(BUILD)/opendata
SWOT_BUILD = $(BUILD)/swot

# when using the llvm toolchain to build the source
CLANG_OPT = -DCMAKE_USER_MAKE_RULES_OVERRIDE=$(ROOT)/platforms/linux/ClangOverrides.txt -D_CMAKE_TOOLCHAIN_PREFIX=llvm-

# for a MacOSX host to have this ip command you must install homebrew(see https://brew.sh/) then run 'brew install iproute2mac' on your mac host
MYIP ?= $(shell (ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$$/\1/p'))

########################
# Core Framework Targets
########################
Expand Down Expand Up @@ -223,19 +217,6 @@ uninstall-swot: ## uninstall most recent install of icesat2 plugin from system
# Development Targets
########################

scan: prep ## perform static analysis
cd $(SLIDERULE_BUILD); export CC=clang; export CXX=clang++; scan-build cmake $(CLANG_OPT) $(DEVCFG) $(ROOT)
cd $(SLIDERULE_BUILD); scan-build -o scan-results make

asan: prep ## build address sanitizer debug version of sliderule binary
cd $(SLIDERULE_BUILD); export CC=clang; export CXX=clang++; cmake $(CLANG_OPT) $(DEVCFG) -DCMAKE_BUILD_TYPE=Debug -DENABLE_ADDRESS_SANITIZER=ON $(ROOT)
cd $(SLIDERULE_BUILD); make

ctags: ## generate ctags
if [ -d ".clangd/index/" ]; then rm -f .clangd/index/*; fi ## clear clagnd index (before clangd-11)
if [ -d ".cache/clangd/index/" ]; then rm -f .cache/clangd/index/*; fi ## clear clagnd index (clangd-11)
/usr/bin/jq -s 'add' $(SLIDERULE_BUILD)/compile_commands.json $(PGC_BUILD)/compile_commands.json $(ICESAT2_BUILD)/compile_commands.json $(GEDI_BUILD)/compile_commands.json $(LANDSAT_BUILD)/compile_commands.json $(USGS3DEP_BUILD)/compile_commands.json $(OPENDATA_BUILD)/compile_commands.json $(SWOT_BUILD)/compile_commands.json > compile_commands.json

testmem: ## run memory test on sliderule
valgrind --leak-check=full --track-origins=yes --track-fds=yes sliderule $(testcase)

Expand All @@ -256,14 +237,15 @@ testcov: ## analyze results of test coverage report
genhtml $(SLIDERULE_BUILD)/coverage.info --output-directory $(SLIDERULE_BUILD)/coverage_html
# firefox $(SLIDERULE_BUILD)/coverage_html/index.html

testpy: ## run python binding test
cp scripts/systests/coro.py $(SLIDERULE_BUILD)
cd $(SLIDERULE_BUILD); /usr/bin/python3 coro.py

########################
# Global Targets
########################

ctags: ## generate ctags
if [ -d ".clangd/index/" ]; then rm -f .clangd/index/*; fi ## clear clagnd index (before clangd-11)
if [ -d ".cache/clangd/index/" ]; then rm -f .cache/clangd/index/*; fi ## clear clagnd index (clangd-11)
/usr/bin/jq -s 'add' $(SLIDERULE_BUILD)/compile_commands.json $(PGC_BUILD)/compile_commands.json $(ICESAT2_BUILD)/compile_commands.json $(GEDI_BUILD)/compile_commands.json $(LANDSAT_BUILD)/compile_commands.json $(USGS3DEP_BUILD)/compile_commands.json $(OPENDATA_BUILD)/compile_commands.json $(SWOT_BUILD)/compile_commands.json > compile_commands.json

prep: ## create necessary build directories
mkdir -p $(SLIDERULE_BUILD)
mkdir -p $(PGC_BUILD)
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ Options include:
-DRUNTIMEDIR=[directory] location for run-time files like plugins, configuration files, and lua scripts
default: /usr/local/etc/sliderule
-DPYTHON_BINDINGS=[ON|OFF] build python bindings instead of sliderule executable (overrides all other targets)
default: OFF
-DSHARED_LIBRARY=[ON|OFF] build sliderule as a shared library (overrides all other targets except for PYTHON_BINDINGS)
-DSHARED_LIBRARY=[ON|OFF] build sliderule as a shared library (overrides all other targets)
default: OFF
-DENABLE_COMPAT=[ON|OFF] configure build for older tool chains (needed to build on CentOS 7)
Expand Down
5 changes: 4 additions & 1 deletion clients/nodejs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ publish: ## publish package to npm registry
login: ## login to npm registry
npm login --scope sliderule --auth-type legacy

install: ## install project (installs dependencies in package.json file)
update: ## update project (updates dependencies in package-lock.json file)
cd sliderule; npm install

install: ## install project (installs dependencies in package-lock.json file)
cd sliderule; npm install

init: ## initialize project
Expand Down
Loading

0 comments on commit 47e1ec7

Please sign in to comment.