Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6ab2e83

Browse files
committed
Put genbki.pl output into src/include/catalog/ directly
With the makefile rules, the output of genbki.pl was written to src/backend/catalog/, and then the header files were linked to src/include/catalog/. This changes it so that the output files are written directly to src/include/catalog/. This makes the logic simpler, and it also makes the behavior consistent with the meson build system. Also, the list of catalog files is now kept in parallel in src/include/catalog/{meson.build,Makefile}, while before the makefiles had it in src/backend/catalog/Makefile. Reviewed-by: Andreas Karlsson <andreas@proxel.se> Discussion: https://www.postgresql.org/message-id/flat/21b74bdc-183d-4dd5-9c27-9378d178f459@eisentraut.org
1 parent 6cb1b63 commit 6ab2e83

File tree

8 files changed

+163
-155
lines changed

8 files changed

+163
-155
lines changed

src/backend/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl u
118118

119119
# run this unconditionally to avoid needing to know its dependencies here:
120120
submake-catalog-headers:
121-
$(MAKE) -C catalog generated-header-symlinks
121+
$(MAKE) -C ../include/catalog generated-headers
122122

123123
# run this unconditionally to avoid needing to know its dependencies here:
124124
submake-nodes-headers:

src/backend/catalog/.gitignore

-8
This file was deleted.

src/backend/catalog/Makefile

+2-138
Original file line numberDiff line numberDiff line change
@@ -50,141 +50,8 @@ OBJS = \
5050

5151
include $(top_srcdir)/src/backend/common.mk
5252

53-
# Note: the order of this list determines the order in which the catalog
54-
# header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs
55-
# must appear first, and pg_statistic before pg_statistic_ext_data, and
56-
# there are reputedly other, undocumented ordering dependencies.
57-
CATALOG_HEADERS := \
58-
pg_proc.h \
59-
pg_type.h \
60-
pg_attribute.h \
61-
pg_class.h \
62-
pg_attrdef.h \
63-
pg_constraint.h \
64-
pg_inherits.h \
65-
pg_index.h \
66-
pg_operator.h \
67-
pg_opfamily.h \
68-
pg_opclass.h \
69-
pg_am.h \
70-
pg_amop.h \
71-
pg_amproc.h \
72-
pg_language.h \
73-
pg_largeobject_metadata.h \
74-
pg_largeobject.h \
75-
pg_aggregate.h \
76-
pg_statistic.h \
77-
pg_statistic_ext.h \
78-
pg_statistic_ext_data.h \
79-
pg_rewrite.h \
80-
pg_trigger.h \
81-
pg_event_trigger.h \
82-
pg_description.h \
83-
pg_cast.h \
84-
pg_enum.h \
85-
pg_namespace.h \
86-
pg_conversion.h \
87-
pg_depend.h \
88-
pg_database.h \
89-
pg_db_role_setting.h \
90-
pg_tablespace.h \
91-
pg_authid.h \
92-
pg_auth_members.h \
93-
pg_shdepend.h \
94-
pg_shdescription.h \
95-
pg_ts_config.h \
96-
pg_ts_config_map.h \
97-
pg_ts_dict.h \
98-
pg_ts_parser.h \
99-
pg_ts_template.h \
100-
pg_extension.h \
101-
pg_foreign_data_wrapper.h \
102-
pg_foreign_server.h \
103-
pg_user_mapping.h \
104-
pg_foreign_table.h \
105-
pg_policy.h \
106-
pg_replication_origin.h \
107-
pg_default_acl.h \
108-
pg_init_privs.h \
109-
pg_seclabel.h \
110-
pg_shseclabel.h \
111-
pg_collation.h \
112-
pg_parameter_acl.h \
113-
pg_partitioned_table.h \
114-
pg_range.h \
115-
pg_transform.h \
116-
pg_sequence.h \
117-
pg_publication.h \
118-
pg_publication_namespace.h \
119-
pg_publication_rel.h \
120-
pg_subscription.h \
121-
pg_subscription_rel.h
122-
123-
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h) schemapg.h syscache_ids.h syscache_info.h system_fk_info.h
124-
125-
POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
126-
127-
# The .dat files we need can just be listed alphabetically.
128-
POSTGRES_BKI_DATA = $(addprefix $(top_srcdir)/src/include/catalog/,\
129-
pg_aggregate.dat \
130-
pg_am.dat \
131-
pg_amop.dat \
132-
pg_amproc.dat \
133-
pg_authid.dat \
134-
pg_cast.dat \
135-
pg_class.dat \
136-
pg_collation.dat \
137-
pg_conversion.dat \
138-
pg_database.dat \
139-
pg_language.dat \
140-
pg_namespace.dat \
141-
pg_opclass.dat \
142-
pg_operator.dat \
143-
pg_opfamily.dat \
144-
pg_proc.dat \
145-
pg_range.dat \
146-
pg_tablespace.dat \
147-
pg_ts_config.dat \
148-
pg_ts_config_map.dat \
149-
pg_ts_dict.dat \
150-
pg_ts_parser.dat \
151-
pg_ts_template.dat \
152-
pg_type.dat \
153-
)
154-
155-
all: generated-header-symlinks
156-
157-
.PHONY: generated-header-symlinks
158-
159-
generated-header-symlinks: $(top_builddir)/src/include/catalog/header-stamp
160-
161-
# bki-stamp records the last time we ran genbki.pl. We don't rely on
162-
# the timestamps of the individual output files, because the Perl script
163-
# won't update them if they didn't change (to avoid unnecessary recompiles).
164-
# Technically, this should depend on Makefile.global which supplies
165-
# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
166-
# configure run, even in distribution tarballs. So depending on configure.ac
167-
# instead is cheating a bit, but it will achieve the goal of updating the
168-
# version number when it changes.
169-
bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_srcdir)/configure.ac $(top_srcdir)/src/include/access/transam.h
170-
$(PERL) $< --include-path=$(top_srcdir)/src/include/ \
171-
--set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
172-
touch $@
173-
174-
# The generated headers must all be symlinked into src/include/.
175-
# We use header-stamp to record that we've done this because the symlinks
176-
# themselves may appear older than bki-stamp.
177-
$(top_builddir)/src/include/catalog/header-stamp: bki-stamp
178-
cd '$(dir $@)' && for file in $(GENERATED_HEADERS); do \
179-
rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
180-
done
181-
touch $@
182-
183-
# Note: installation of generated headers is handled elsewhere
18453
.PHONY: install-data
185-
install-data: bki-stamp installdirs
186-
$(INSTALL_DATA) postgres.bki '$(DESTDIR)$(datadir)/postgres.bki'
187-
$(INSTALL_DATA) system_constraints.sql '$(DESTDIR)$(datadir)/system_constraints.sql'
54+
install-data: installdirs
18855
$(INSTALL_DATA) $(srcdir)/system_functions.sql '$(DESTDIR)$(datadir)/system_functions.sql'
18956
$(INSTALL_DATA) $(srcdir)/system_views.sql '$(DESTDIR)$(datadir)/system_views.sql'
19057
$(INSTALL_DATA) $(srcdir)/information_schema.sql '$(DESTDIR)$(datadir)/information_schema.sql'
@@ -195,7 +62,4 @@ installdirs:
19562

19663
.PHONY: uninstall-data
19764
uninstall-data:
198-
rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql sql_features.txt)
199-
200-
clean:
201-
rm -f bki-stamp postgres.bki system_constraints.sql $(GENERATED_HEADERS)
65+
rm -f $(addprefix '$(DESTDIR)$(datadir)'/, system_functions.sql system_views.sql information_schema.sql sql_features.txt)

src/include/Makefile

+4-3
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ install: all installdirs
5454
$(INSTALL_DATA) $(srcdir)/$$dir/*.h '$(DESTDIR)$(includedir_server)'/$$dir || exit; \
5555
done
5656
ifeq ($(vpath_build),yes)
57-
for file in catalog/schemapg.h catalog/syscache_ids.h catalog/system_fk_info.h catalog/pg_*_d.h storage/lwlocknames.h utils/probes.h utils/wait_event_types.h; do \
57+
for file in storage/lwlocknames.h utils/probes.h utils/wait_event_types.h; do \
5858
$(INSTALL_DATA) $$file '$(DESTDIR)$(includedir_server)'/$$file || exit; \
5959
done
6060
endif
61+
$(MAKE) -C catalog install
6162

6263
installdirs:
6364
$(MKDIR_P) '$(DESTDIR)$(includedir)/libpq' '$(DESTDIR)$(includedir_internal)/libpq'
@@ -69,14 +70,14 @@ uninstall:
6970
rm -f $(addprefix '$(DESTDIR)$(includedir_internal)'/, c.h port.h postgres_fe.h libpq/pqcomm.h libpq/protocol.h)
7071
# heuristic...
7172
rm -rf $(addprefix '$(DESTDIR)$(includedir_server)'/, $(SUBDIRS) *.h)
73+
$(MAKE) -C catalog uninstall
7274

7375

7476
clean:
7577
rm -f utils/fmgroids.h utils/fmgrprotos.h utils/errcodes.h utils/header-stamp
7678
rm -f storage/lwlocknames.h utils/probes.h utils/wait_event_types.h
77-
rm -f catalog/schemapg.h catalog/syscache_ids.h catalog/syscache_info.h catalog/system_fk_info.h
78-
rm -f catalog/pg_*_d.h catalog/header-stamp
7979
rm -f nodes/nodetags.h nodes/header-stamp
80+
$(MAKE) -C catalog clean
8081

8182
distclean: clean
8283
rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h

src/include/catalog/.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
/postgres.bki
12
/schemapg.h
23
/syscache_ids.h
34
/syscache_info.h
45
/system_fk_info.h
6+
/system_constraints.sql
57
/pg_*_d.h
6-
/header-stamp
8+
/bki-stamp

src/include/catalog/Makefile

+152
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,158 @@ subdir = src/include/catalog
1313
top_builddir = ../../..
1414
include $(top_builddir)/src/Makefile.global
1515

16+
# Note: the order of this list determines the order in which the catalog
17+
# header files are assembled into postgres.bki. BKI_BOOTSTRAP catalogs
18+
# must appear first, and pg_statistic before pg_statistic_ext_data, and
19+
# there are reputedly other, undocumented ordering dependencies.
20+
CATALOG_HEADERS := \
21+
pg_proc.h \
22+
pg_type.h \
23+
pg_attribute.h \
24+
pg_class.h \
25+
pg_attrdef.h \
26+
pg_constraint.h \
27+
pg_inherits.h \
28+
pg_index.h \
29+
pg_operator.h \
30+
pg_opfamily.h \
31+
pg_opclass.h \
32+
pg_am.h \
33+
pg_amop.h \
34+
pg_amproc.h \
35+
pg_language.h \
36+
pg_largeobject_metadata.h \
37+
pg_largeobject.h \
38+
pg_aggregate.h \
39+
pg_statistic.h \
40+
pg_statistic_ext.h \
41+
pg_statistic_ext_data.h \
42+
pg_rewrite.h \
43+
pg_trigger.h \
44+
pg_event_trigger.h \
45+
pg_description.h \
46+
pg_cast.h \
47+
pg_enum.h \
48+
pg_namespace.h \
49+
pg_conversion.h \
50+
pg_depend.h \
51+
pg_database.h \
52+
pg_db_role_setting.h \
53+
pg_tablespace.h \
54+
pg_authid.h \
55+
pg_auth_members.h \
56+
pg_shdepend.h \
57+
pg_shdescription.h \
58+
pg_ts_config.h \
59+
pg_ts_config_map.h \
60+
pg_ts_dict.h \
61+
pg_ts_parser.h \
62+
pg_ts_template.h \
63+
pg_extension.h \
64+
pg_foreign_data_wrapper.h \
65+
pg_foreign_server.h \
66+
pg_user_mapping.h \
67+
pg_foreign_table.h \
68+
pg_policy.h \
69+
pg_replication_origin.h \
70+
pg_default_acl.h \
71+
pg_init_privs.h \
72+
pg_seclabel.h \
73+
pg_shseclabel.h \
74+
pg_collation.h \
75+
pg_parameter_acl.h \
76+
pg_partitioned_table.h \
77+
pg_range.h \
78+
pg_transform.h \
79+
pg_sequence.h \
80+
pg_publication.h \
81+
pg_publication_namespace.h \
82+
pg_publication_rel.h \
83+
pg_subscription.h \
84+
pg_subscription_rel.h
85+
86+
GENERATED_HEADERS := $(CATALOG_HEADERS:%.h=%_d.h)
87+
88+
POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/, $(CATALOG_HEADERS))
89+
90+
# The .dat files we need can just be listed alphabetically.
91+
POSTGRES_BKI_DATA = \
92+
pg_aggregate.dat \
93+
pg_am.dat \
94+
pg_amop.dat \
95+
pg_amproc.dat \
96+
pg_authid.dat \
97+
pg_cast.dat \
98+
pg_class.dat \
99+
pg_collation.dat \
100+
pg_conversion.dat \
101+
pg_database.dat \
102+
pg_language.dat \
103+
pg_namespace.dat \
104+
pg_opclass.dat \
105+
pg_operator.dat \
106+
pg_opfamily.dat \
107+
pg_proc.dat \
108+
pg_range.dat \
109+
pg_tablespace.dat \
110+
pg_ts_config.dat \
111+
pg_ts_config_map.dat \
112+
pg_ts_dict.dat \
113+
pg_ts_parser.dat \
114+
pg_ts_template.dat \
115+
pg_type.dat
116+
117+
GENBKI_OUTPUT_FILES = \
118+
$(GENERATED_HEADERS) \
119+
postgres.bki \
120+
system_constraints.sql \
121+
schemapg.h \
122+
syscache_ids.h \
123+
syscache_info.h \
124+
system_fk_info.h
125+
126+
all: generated-headers
127+
128+
.PHONY: generated-headers
129+
130+
generated-headers: bki-stamp
131+
132+
# bki-stamp records the last time we ran genbki.pl. We don't rely on
133+
# the timestamps of the individual output files, because the Perl script
134+
# won't update them if they didn't change (to avoid unnecessary recompiles).
135+
# Technically, this should depend on Makefile.global which supplies
136+
# $(MAJORVERSION); but then genbki.pl would need to be re-run after every
137+
# configure run, even in distribution tarballs. So depending on configure.ac
138+
# instead is cheating a bit, but it will achieve the goal of updating the
139+
# version number when it changes.
140+
bki-stamp: $(top_srcdir)/src/backend/catalog/genbki.pl $(top_srcdir)/src/backend/catalog/Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_srcdir)/configure.ac $(top_srcdir)/src/include/access/transam.h
141+
$(PERL) $< --include-path=$(top_srcdir)/src/include/ \
142+
--set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
143+
touch $@
144+
145+
install: all installdirs
146+
$(INSTALL_DATA) postgres.bki '$(DESTDIR)$(datadir)/postgres.bki'
147+
$(INSTALL_DATA) system_constraints.sql '$(DESTDIR)$(datadir)/system_constraints.sql'
148+
# In non-vpath builds, src/include/Makefile already installs all headers.
149+
ifeq ($(vpath_build),yes)
150+
$(INSTALL_DATA) schemapg.h '$(DESTDIR)$(includedir_server)'/catalog/schemapg.h
151+
$(INSTALL_DATA) syscache_ids.h '$(DESTDIR)$(includedir_server)'/catalog/syscache_ids.h
152+
$(INSTALL_DATA) system_fk_info.h '$(DESTDIR)$(includedir_server)'/catalog/system_fk_info.h
153+
for file in $(GENERATED_HEADERS); do \
154+
$(INSTALL_DATA) $$file '$(DESTDIR)$(includedir_server)'/catalog/$$file || exit; \
155+
done
156+
endif
157+
158+
installdirs:
159+
$(MKDIR_P) '$(DESTDIR)$(datadir)' '$(DESTDIR)$(includedir_server)'
160+
161+
uninstall:
162+
rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql)
163+
rm -f $(addprefix '$(DESTDIR)$(includedir_server)'/catalog/, schemapg.h syscache_ids.h system_fk_info.h $(GENERATED_HEADERS))
164+
165+
clean:
166+
rm -f bki-stamp $(GENBKI_OUTPUT_FILES)
167+
16168
# 'make reformat-dat-files' is a convenience target for rewriting the
17169
# catalog data files in our standard format. This includes collapsing
18170
# out any entries that are redundant with a BKI_DEFAULT annotation.

src/include/catalog/meson.build

+1-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ generated_catalog_headers = custom_target('generated_catalog_headers',
145145
generated_headers += generated_catalog_headers.to_list()
146146

147147
# autoconf generates the file there, ensure we get a conflict
148-
generated_sources_ac += {'src/backend/catalog': output_files + ['bki-stamp']}
149-
generated_sources_ac += {'src/include/catalog': ['header-stamp']}
148+
generated_sources_ac += {'src/include/catalog': output_files + ['bki-stamp']}
150149

151150
# 'reformat-dat-files' is a convenience target for rewriting the
152151
# catalog data files in our standard format. This includes collapsing

src/tools/pginclude/headerscheck

-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ do
142142
test "$f" = src/include/common/unicode_nonspacing_table.h && continue
143143
test "$f" = src/include/common/unicode_east_asian_fw_table.h && continue
144144

145-
test "$f" = src/backend/catalog/syscache_ids.h && continue
146-
test "$f" = src/backend/catalog/syscache_info.h && continue
147145
test "$f" = src/include/catalog/syscache_ids.h && continue
148146
test "$f" = src/include/catalog/syscache_info.h && continue
149147

0 commit comments

Comments
 (0)