]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/ukstore: Re-use `libraries.in` from `lib/uklibid`
authorSimon Kuenzer <simon@unikraft.io>
Fri, 2 Jun 2023 00:21:25 +0000 (02:21 +0200)
committerUnikraft <monkey@unikraft.io>
Wed, 9 Aug 2023 10:27:40 +0000 (10:27 +0000)
Instead of generating own library identifiers, this commit adopts
`lib/ukstore` to use the same library catalog from `lib/uklibid`. At the
same time, this commit adopt `Makefile.uk` to make use of the `SUBBUILD`
feature of the build system. This is done for simplifying Makefile.uk and
to let the build system natively generate each dynamic headers of
`lib/ukstore`.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #938

lib/ukstore/Config.uk
lib/ukstore/Makefile.uk
lib/ukstore/gen_array.h.awk [deleted file]
lib/ukstore/gen_libs.h.awk [deleted file]
lib/ukstore/gen_libs.ld.awk [deleted file]
lib/ukstore/store_array.awk [new file with mode: 0644]
lib/ukstore/store_ld.awk [new file with mode: 0644]
lib/ukstore/store_libs.awk [new file with mode: 0644]

index 1786441992ece53c70ac75dfd275de1f13bee5f4..d3560b5c989800598ea857749b4f8d7eb2efee28 100644 (file)
@@ -2,4 +2,5 @@ config LIBUKSTORE
        bool "ukstore: Run-time configuring and monitoring"
        select LIBNOLIBC if !HAVE_LIBC
        select LIBUKDEBUG
+       select LIBUKLIBID
        default n
index a0e752a2d07690fc70521b8c52db53662947a83e..772992082c8a9c3ba5be32a4f48c5363b486e461 100644 (file)
@@ -1,53 +1,23 @@
 $(eval $(call addlib_s,libukstore,$(CONFIG_LIBUKSTORE)))
 
-$(call mk_sub_libbuild_dir,libukstore,include/uk/bits)
-
-LIBUKSTORE_GEN_INCLUDES_PATH := $(call sub_libbuild_dir,libukstore,include)
-
 CINCLUDES-y                    += -I$(LIBUKSTORE_BASE)/include
-CINCLUDES-$(CONFIG_LIBUKSTORE) += -I$(LIBUKSTORE_GEN_INCLUDES_PATH)
+CINCLUDES-$(CONFIG_LIBUKSTORE) += -I$(LIBUKSTORE_BUILD)/include
 CXXINCLUDES-y                    += -I$(LIBUKSTORE_BASE)/include
-CXXINCLUDES-$(CONFIG_LIBUKSTORE) += -I$(LIBUKSTORE_GEN_INCLUDES_PATH)
-
-LIBUKSTORE_PHONY_SRC     := $(LIBUKSTORE_BUILD)/uk_libs.in
-LIBUKSTORE_PHONY_SRC_NEW := $(addsuffix .new, $(LIBUKSTORE_PHONY_SRC))
-
-LIBUKSTORE_GEN_SRC := $(LIBUKSTORE_GEN_INCLUDES_PATH)/uk/bits/store_libs.h
-LIBUKSTORE_GEN_ARR := $(LIBUKSTORE_GEN_INCLUDES_PATH)/uk/bits/store_array.h
-LIBUKSTORE_GEN_LD  := $(LIBUKSTORE_BUILD)/store_libs.lds.S
-
-UK_PREPROCESS-$(CONFIG_LIBUKSTORE) += $(LIBUKSTORE_PHONY_SRC) $(LIBUKSTORE_GEN_SRC) $(LIBUKSTORE_GEN_LD) $(LIBUKSTORE_GEN_ARR)
-
-$(LIBUKSTORE_PHONY_SRC): %: %.new
-       @cmp -s $^ $@; if [ $$? -ne 0 ]; then cp $^ $@; fi
-
-$(LIBUKSTORE_BUILD)/uk_libs.in.new:
-       $(call build_cmd,GEN,libukstore,$(notdir $@), \
-               echo $(foreach P,$(UK_PLATS) $(UK_PLATS-y),\
-                    $(if $(call qstrip,$($(call uc,$(P))_LIBS) $($(call uc,$(P))_LIBS-y)),\
-                    $(foreach L,$($(call uc,$(P))_LIBS) $($(call uc,$(P))_LIBS-y), \
-                    $(if $(call qstrip,$($(call vprefix_lib,$(L),SRCS)) $($(call vprefix_lib,$(L),SRCS-y))), \
-                    $(L) \
-                    )))) \
-                    $(UK_LIBS) $(UK_LIBS-y) \
-               | tr ' ' '\n' > $@)
-
-$(LIBUKSTORE_GEN_INCLUDES_PATH)/uk/bits/store_libs.h: $(LIBUKSTORE_BASE)/gen_libs.h.awk $(LIBUKSTORE_BUILD)/uk_libs.in
-       $(call build_cmd,AWK,libukstore,$(notdir $@), \
-               $(AWK) -F '-' -f $(LIBUKSTORE_BASE)/gen_libs.h.awk \
-               $(LIBUKSTORE_BUILD)/uk_libs.in > $@)
-
-$(LIBUKSTORE_BUILD)/store_libs.lds.S: $(LIBUKSTORE_BASE)/gen_libs.ld.awk $(LIBUKSTORE_BUILD)/uk_libs.in
-       $(call build_cmd,AWK,libukstore,$(notdir $@), \
-               $(AWK) -F '-' -f $(LIBUKSTORE_BASE)/gen_libs.ld.awk \
-               $(LIBUKSTORE_BUILD)/uk_libs.in > $@)
-
-$(LIBUKSTORE_GEN_INCLUDES_PATH)/uk/bits/store_array.h: $(LIBUKSTORE_BASE)/gen_array.h.awk $(LIBUKSTORE_BUILD)/uk_libs.in
-       $(call build_cmd,AWK,libukstore,$(notdir $@), \
-               $(AWK) -F '-' -f $(LIBUKSTORE_BASE)/gen_array.h.awk \
-               $(LIBUKSTORE_BUILD)/uk_libs.in > $@)
-
+CXXINCLUDES-$(CONFIG_LIBUKSTORE) += -I$(LIBUKSTORE_BUILD)/include
+
+# Cross-reference libraries catalog generated by lib/uklibid
+# NOTE: Normally, we do not consider such cross-referencing a good practice,
+#       since libraries.in is in a way internal to lib/uklibid.
+#       On the other hand, it somehow doesn't make sense to create the same file
+#       again for this library, so we opt for deduplication here.
+LIBUKSTORE_LIBRARIES_IN = $(call sub_build_dir,libuklibid)/libraries.in
+
+LIBUKSTORE_SRCS-y += $(LIBUKSTORE_BASE)/store_libs.awk>.h
+LIBUKSTORE_STORE_LIBS_SUBBUILD = include/uk/bits
+LIBUKSTORE_STORE_LIBS_AWKINCLUDES-y += $(LIBUKSTORE_LIBRARIES_IN)
+LIBUKSTORE_SRCS-y += $(LIBUKSTORE_BASE)/store_array.awk>.h
+LIBUKSTORE_STORE_ARRAY_SUBBUILD = include/uk/bits
+LIBUKSTORE_STORE_ARRAY_AWKINCLUDES-y += $(LIBUKSTORE_LIBRARIES_IN)
+LIBUKSTORE_SRCS-y += $(LIBUKSTORE_BASE)/store_ld.awk>.lds.S
+LIBUKSTORE_STORE_LD_AWKINCLUDES-y += $(LIBUKSTORE_LIBRARIES_IN)
 LIBUKSTORE_SRCS-y += $(LIBUKSTORE_BASE)/store.c
-LIBUKSTORE_SRCS-y += $(LIBUKSTORE_BUILD)/store_libs.lds.S
-
-LIBUKSTORE_CLEAN = $(LIBUKSTORE_PHONY_SRC) $(LIBUKSTORE_PHONY_SRC_NEW)
diff --git a/lib/ukstore/gen_array.h.awk b/lib/ukstore/gen_array.h.awk
deleted file mode 100644 (file)
index 04202b8..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-BEGIN {
-       print "/* Automatically generated file; DO NOT EDIT */"
-       print ""
-       print "static struct uk_store_entry *static_entries[2 * __UK_STORE_COUNT] = {"
-}
-
-/[a-zA-Z0-9]+/{
-       printf "\t\t(struct uk_store_entry *) &uk_store_lib_%s_start,\n", $1;
-       printf "\t\t(struct uk_store_entry *) &uk_store_lib_%s_end,\n", $1;
-}
-
-END {
-       print "\t};"
-       print ""
-}
diff --git a/lib/ukstore/gen_libs.h.awk b/lib/ukstore/gen_libs.h.awk
deleted file mode 100644 (file)
index 2d00ef2..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-BEGIN {
-       print "/* Automatically generated file; DO NOT EDIT */"
-       print ""
-       print "#ifndef __UK_STORE_H__"
-       print "#error Do not include this header directly"
-       print "#endif /* __UK_STORE_H__ */\n"
-       print "\nstruct uk_store_entry;\n"
-
-       entries = 0
-}
-
-/[a-zA-Z0-9]+/{
-       printf "#define __UK_STORE_HAVE_%s 1\n", $1;
-       printf "#define __UK_STORE_%s (%d)\n", $1, (entries++);
-       printf "extern struct uk_store_entry *uk_store_lib_%s_start;\n", $1;
-       printf "extern struct uk_store_entry *uk_store_lib_%s_end;\n\n", $1;
-}
-
-END {
-       printf "#define __UK_STORE_COUNT (%d)\n", entries;
-}
diff --git a/lib/ukstore/gen_libs.ld.awk b/lib/ukstore/gen_libs.ld.awk
deleted file mode 100644 (file)
index b2873e8..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-BEGIN {
-       print "/* Automatically generated file; DO NOT EDIT */"
-       print ""
-       print "SECTIONS"
-       print ""
-       print "{"
-}
-
-/[a-zA-Z0-9]+/{
-       printf "\t.uk_store_lib_%s : {\n", $1;
-       printf "\t\tPROVIDE(uk_store_lib_%s_start = .);\n", $1;
-       printf "\t\tKEEP(*(.uk_store_lib_%s));\n", $1;
-       printf "\t\tKEEP(*(.uk_store_lib_%s.*));\n", $1;
-       printf "\t\tPROVIDE(uk_store_lib_%s_end = .);\n", $1;
-       print  "\t}"
-       print  ""
-}
-
-END {
-       print "}"
-       print "INSERT AFTER .rodata"
-       print ""
-}
diff --git a/lib/ukstore/store_array.awk b/lib/ukstore/store_array.awk
new file mode 100644 (file)
index 0000000..04202b8
--- /dev/null
@@ -0,0 +1,15 @@
+BEGIN {
+       print "/* Automatically generated file; DO NOT EDIT */"
+       print ""
+       print "static struct uk_store_entry *static_entries[2 * __UK_STORE_COUNT] = {"
+}
+
+/[a-zA-Z0-9]+/{
+       printf "\t\t(struct uk_store_entry *) &uk_store_lib_%s_start,\n", $1;
+       printf "\t\t(struct uk_store_entry *) &uk_store_lib_%s_end,\n", $1;
+}
+
+END {
+       print "\t};"
+       print ""
+}
diff --git a/lib/ukstore/store_ld.awk b/lib/ukstore/store_ld.awk
new file mode 100644 (file)
index 0000000..b2873e8
--- /dev/null
@@ -0,0 +1,23 @@
+BEGIN {
+       print "/* Automatically generated file; DO NOT EDIT */"
+       print ""
+       print "SECTIONS"
+       print ""
+       print "{"
+}
+
+/[a-zA-Z0-9]+/{
+       printf "\t.uk_store_lib_%s : {\n", $1;
+       printf "\t\tPROVIDE(uk_store_lib_%s_start = .);\n", $1;
+       printf "\t\tKEEP(*(.uk_store_lib_%s));\n", $1;
+       printf "\t\tKEEP(*(.uk_store_lib_%s.*));\n", $1;
+       printf "\t\tPROVIDE(uk_store_lib_%s_end = .);\n", $1;
+       print  "\t}"
+       print  ""
+}
+
+END {
+       print "}"
+       print "INSERT AFTER .rodata"
+       print ""
+}
diff --git a/lib/ukstore/store_libs.awk b/lib/ukstore/store_libs.awk
new file mode 100644 (file)
index 0000000..2d00ef2
--- /dev/null
@@ -0,0 +1,21 @@
+BEGIN {
+       print "/* Automatically generated file; DO NOT EDIT */"
+       print ""
+       print "#ifndef __UK_STORE_H__"
+       print "#error Do not include this header directly"
+       print "#endif /* __UK_STORE_H__ */\n"
+       print "\nstruct uk_store_entry;\n"
+
+       entries = 0
+}
+
+/[a-zA-Z0-9]+/{
+       printf "#define __UK_STORE_HAVE_%s 1\n", $1;
+       printf "#define __UK_STORE_%s (%d)\n", $1, (entries++);
+       printf "extern struct uk_store_entry *uk_store_lib_%s_start;\n", $1;
+       printf "extern struct uk_store_entry *uk_store_lib_%s_end;\n\n", $1;
+}
+
+END {
+       printf "#define __UK_STORE_COUNT (%d)\n", entries;
+}