Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to a new layout #5

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ jobs:

- name: Build extension package
run: |
make -j8 PYTHON=$EDBDIR/python3 EDBFLAGS=--no-devmode PG_CONFIG=/usr/bin/pg_config
unzip -l postgis--3.4.3.zip
mkdir -p target
make -j8 PYTHON=$EDBDIR/python3 EDBFLAGS=--no-devmode PG_CONFIG=/usr/bin/pg_config zip
unzip -l postgis--*.zip

- name: Install extension package
run: |
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ include $(MKS)
$(SQL_BUILD_STAMP): MANIFEST.toml postgis/NEWS Makefile
cd postgis && sh autogen.sh
cd postgis && ./configure "--with-pgconfig=$(PG_CONFIG)" --without-raster
$(MAKE) -C postgis
$(MAKE) -C postgis comments
$(MAKE) -C postgis DESTDIR=$(PWD)/build/out PG_CONFIG=$(PG_DIR)/bin/pg_config install
env PG_CONFIG=$(PG_CONFIG) $(MAKE) -C postgis
env PG_CONFIG=$(PG_CONFIG) $(MAKE) -C postgis comments
env PG_CONFIG=$(PG_CONFIG) $(MAKE) -C postgis DESTDIR=$(PWD)/build/out install
touch $(SQL_BUILD_STAMP)
43 changes: 30 additions & 13 deletions exts.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ PYTHON ?= python3
EXT_NAME := $(shell $(PYTHON) -c 'import tomllib; f = tomllib.load(open("MANIFEST.toml", "rb")); print(f["name"])')
EXT_VERSION := $(shell $(PYTHON) -c 'import tomllib; f = tomllib.load(open("MANIFEST.toml", "rb")); print(f["version"])')
EDGEQL_SRCS := $(shell $(PYTHON) -c 'import tomllib; f = tomllib.load(open("MANIFEST.toml", "rb")); print(" ".join(f["files"]))')
SQL_DIR := $(shell $(PYTHON) -c 'import tomllib; f = tomllib.load(open("MANIFEST.toml", "rb")); print(f["postgres_files"])')
EXT_FNAME := $(EXT_NAME)--$(EXT_VERSION)

.DEFAULT_GOAL := $(EXT_FNAME).zip
.PHONY: clean install
.DEFAULT_GOAL := build
.PHONY: build clean install zip

#

Expand All @@ -19,31 +18,45 @@ SQL_DEPS := $(call rwildcard,$(SQL_MODULE),*.c *.h *.sql *.control Makefile)
SQL_BUILD_STAMP := build/.sql_build_stamp
SQL_INSTALL_STAMP := build/.sql_install_stamp
EDGEQL_INSTALL_STAMP := build/.edgeql_install_stamp
INSTALLABLES := MANIFEST.toml

ifeq ($(strip $(WITH_SQL)),yes)

INSTALLABLES += lib/ share/

ifeq ($(origin PG_CONFIG), undefined)
EDB := $(PYTHON) -m edb.tools $(EDBFLAGS)
PG_CONFIG := $(shell $(EDB) config --pg-config)

ifeq ($(PG_CONFIG),)
$(error cannot find pg_config, please set PG_CONFIG explicitly)
endif
endif

ifneq ($(strip $(CUSTOM_SQL_BUILD)),1)

$(SQL_BUILD_STAMP): MANIFEST.toml $(SQL_DEPS) $(EXTRA_DEPS) Makefile
$(MAKE) -C $(SQL_MODULE) DESTDIR=$(PWD)/build/out PG_CONFIG=$(PG_CONFIG) install
env PG_CONFIG=$(PG_CONFIG) $(MAKE) -C $(SQL_MODULE) DESTDIR=$(PWD)/build/out install
touch $(SQL_BUILD_STAMP)
endif

$(SQL_INSTALL_STAMP): $(SQL_BUILD_STAMP)
mkdir -p build/$(SQL_DIR)
cp -r $(PWD)/build/out/$(shell $(PG_CONFIG) --pkglibdir) build/$(SQL_DIR)/lib
cp -r $(PWD)/build/out/$(shell $(PG_CONFIG) --sharedir) build/$(SQL_DIR)/share
cp -r build/$(SQL_DIR) build/$(EXT_FNAME)/$(SQL_DIR)
rm -rf build/$(EXT_FNAME)/lib
mkdir -p build/$(EXT_FNAME)/lib
rm -rf build/$(EXT_FNAME)/share/postgresql
mkdir -p build/$(EXT_FNAME)/share/postgresql
cp -r $(PWD)/build/out/$(shell $(PG_CONFIG) --pkglibdir) build/$(EXT_FNAME)/lib/postgresql
cp -r $(PWD)/build/out/$(shell $(PG_CONFIG) --sharedir)/contrib build/$(EXT_FNAME)/share/postgresql/contrib
cp -r $(PWD)/build/out/$(shell $(PG_CONFIG) --sharedir)/extension build/$(EXT_FNAME)/share/postgresql/extension
touch $(SQL_INSTALL_STAMP)
else
$(SQL_INSTALL_STAMP):
mkdir -p build
touch $(SQL_INSTALL_STAMP)
endif
ifeq ($(strip $(WITH_EDGEQL)),yes)
INSTALLABLES += $(EDGEQL_SRCS) $(EXTRA_FILES)

$(EDGEQL_INSTALL_STAMP): MANIFEST.toml $(EDGEQL_SRCS) $(EXTRA_FILES) Makefile
mkdir -p build/$(EXT_FNAME)
cp $(EDGEQL_SRCS) build/$(EXT_FNAME)
Expand All @@ -56,14 +69,18 @@ EDGEQL:
touch $(EDGEQL_INSTALL_STAMP)
endif

$(EXT_FNAME).zip: $(EDGEQL_INSTALL_STAMP) $(SQL_INSTALL_STAMP)
rm -f $(EXT_FNAME).zip
cd build/$(EXT_FNAME)/ && zip -r ../../$(EXT_FNAME).zip *
build: $(EDGEQL_INSTALL_STAMP) $(SQL_INSTALL_STAMP)

install: $(EXT_FNAME).zip
install: build
if [ -z "$(DESTDIR)" ]; then echo "DESTDIR must be set" >&2; exit 1; fi
mkdir -p "$(DESTDIR)"
cp $(EXT_FNAME).zip "$(DESTDIR)/"
cd "build/$(EXT_FNAME)" && cp -r $(INSTALLABLES) "${DESTDIR}/"

$(EXT_FNAME).zip: build
rm -f $(EXT_FNAME).zip
cd build/$(EXT_FNAME)/ && zip -r ../../$(EXT_FNAME).zip *

zip: $(EXT_FNAME).zip

clean:
rm -rf build $(EXT_FNAME).zip
Loading