Standalone test (test/test_de_reader.c): generates a synthetic 12KB DE binary with known Chebyshev coefficients, exercises header parsing, polynomial evaluation at 5 domain points, Earth derivation via center=99, Moon geocentric, layout validation, range/body error paths, NAN sentinel, and garbage file rejection. 55 tests, no PG dependency. Makefile: add `make test-de-reader` target; also includes the earlier sat_code C++ -> pure C sgp4 migration that was missed from prior commits. astro_math.h: document that ecliptic_to_equatorial/equatorial_to_ecliptic are NOT safe for aliased (in-place) calls — equ[1] is written before equ[2] reads ecl[1]. The vendored sgp4/sdp4.c has separate in-place versions using a temp variable.
82 lines
3.0 KiB
Makefile
82 lines
3.0 KiB
Makefile
MODULE_big = pg_orbit
|
|
EXTENSION = pg_orbit
|
|
DATA = sql/pg_orbit--0.1.0.sql sql/pg_orbit--0.2.0.sql sql/pg_orbit--0.1.0--0.2.0.sql \
|
|
sql/pg_orbit--0.3.0.sql sql/pg_orbit--0.2.0--0.3.0.sql
|
|
|
|
# Our extension C sources
|
|
OBJS = src/pg_orbit.o src/tle_type.o src/eci_type.o src/observer_type.o \
|
|
src/sgp4_funcs.o src/coord_funcs.o src/pass_funcs.o src/gist_tle.o \
|
|
src/star_funcs.o src/kepler_funcs.o \
|
|
src/vsop87.o src/elp82b.o src/elliptic_to_rectangular.o \
|
|
src/precession.o src/sidereal_time.o src/planet_funcs.o \
|
|
src/tass17.o src/gust86.o src/marssat.o src/l12.o \
|
|
src/moon_funcs.o src/radio_funcs.o \
|
|
src/lambert.o src/transfer_funcs.o \
|
|
src/de_reader.o src/eph_provider.o src/de_funcs.o
|
|
|
|
# Vendored SGP4/SDP4 sources (pure C, from Bill Gray's sat_code, MIT license)
|
|
SGP4_DIR = src/sgp4
|
|
SGP4_SRCS = $(SGP4_DIR)/sgp4.c $(SGP4_DIR)/sdp4.c \
|
|
$(SGP4_DIR)/deep.c $(SGP4_DIR)/common.c \
|
|
$(SGP4_DIR)/basics.c $(SGP4_DIR)/get_el.c \
|
|
$(SGP4_DIR)/tle_out.c
|
|
SGP4_OBJS = $(SGP4_SRCS:.c=.o)
|
|
|
|
OBJS += $(SGP4_OBJS)
|
|
|
|
# Regression tests
|
|
REGRESS = tle_parse sgp4_propagate coord_transforms pass_prediction gist_index convenience \
|
|
star_observe kepler_comet planet_observe moon_observe lambert_transfer \
|
|
de_ephemeris vallado_518
|
|
REGRESS_OPTS = --inputdir=test
|
|
|
|
# Pure C — no C++ runtime needed
|
|
SHLIB_LINK += -lm
|
|
|
|
# Compiler flags
|
|
PG_CPPFLAGS = -I$(SGP4_DIR)
|
|
|
|
# Use PGXS
|
|
PG_CONFIG ?= pg_config
|
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
|
include $(PGXS)
|
|
|
|
# ── Standalone DE reader unit test (no PostgreSQL dependency) ──
|
|
# Generates a synthetic DE binary, exercises Chebyshev evaluation,
|
|
# header parsing, Earth derivation, error paths.
|
|
test-de-reader: test/test_de_reader.c src/de_reader.c src/de_reader.h
|
|
$(CC) -Wall -Werror -Isrc -o test/test_de_reader $< src/de_reader.c -lm
|
|
./test/test_de_reader
|
|
|
|
.PHONY: test-de-reader
|
|
|
|
# ── Docker packaging ────────────────────────────────────────
|
|
REGISTRY ?= git.supported.systems/warehack.ing
|
|
IMAGE ?= pg_orbit
|
|
PG_MAJOR ?= 17
|
|
TAG ?= pg$(PG_MAJOR)
|
|
|
|
docker-build:
|
|
docker build --build-arg PG_MAJOR=$(PG_MAJOR) \
|
|
--target artifact -t $(REGISTRY)/$(IMAGE):$(TAG)-artifact .
|
|
docker build --build-arg PG_MAJOR=$(PG_MAJOR) \
|
|
--target standalone -t $(REGISTRY)/$(IMAGE):$(TAG) .
|
|
|
|
docker-push:
|
|
docker push $(REGISTRY)/$(IMAGE):$(TAG)-artifact
|
|
docker push $(REGISTRY)/$(IMAGE):$(TAG)
|
|
|
|
docker-test:
|
|
@echo "Smoke-testing standalone image..."
|
|
docker run --rm -d --name pg_orbit_test \
|
|
-e POSTGRES_PASSWORD=test $(REGISTRY)/$(IMAGE):$(TAG)
|
|
@echo "Waiting for PostgreSQL to initialize..."
|
|
@sleep 10
|
|
docker exec pg_orbit_test psql -U postgres -tAc \
|
|
"SELECT tle_norad_id(E'1 25544U 98067A 24001.50000000 .00016717 00000-0 10270-3 0 9025\n2 25544 51.6400 208.9163 0006703 30.1694 61.7520 15.50100486 00001'::tle);" \
|
|
| grep -q 25544
|
|
@docker stop pg_orbit_test
|
|
@echo "Smoke test passed."
|
|
|
|
.PHONY: docker-build docker-push docker-test
|