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

Fix undefined variable warning for $( ) in Makefiles #10270

Merged
merged 6 commits into from Mar 4, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Changes
Expand Up @@ -99,8 +99,8 @@ Working version
- #9582: Add Array.{find_opt,find_map,split,combine}.
(Nicolás Ojeda Bär, review by Daniel Bünzli and Gabriel Scherer)

* #10169: Use capitalized module names in the Standard Library prefixing scheme
to match Dune, e.g. Stdlib__String instead of Stdlib__string. This is a
* #10169, #10270: Use capitalized module names in the Standard Library prefixing
scheme to match Dune, e.g. Stdlib__String instead of Stdlib__string. This is a
breaking change only to code which attempted to use the internal names before.
The Standard Library generated by the Dune rules is now equivalent to the main
build (the Dune rules still do not generate a distributable compiler).
Expand Down
5 changes: 5 additions & 0 deletions Makefile.common
Expand Up @@ -23,6 +23,11 @@ DEPDIR=.dep
D=d
MKDIR=mkdir -p

# $(EMPTY) is defined in Makefile.config, but may not have been loaded
EMPTY :=
# $(SPACE) contains a single space
SPACE := $(EMPTY) $(EMPTY)

DESTDIR ?=
INSTALL_BINDIR := $(DESTDIR)$(BINDIR)
INSTALL_LIBDIR := $(DESTDIR)$(LIBDIR)
Expand Down
3 changes: 0 additions & 3 deletions stdlib/Makefile
Expand Up @@ -239,9 +239,6 @@ clean::

include .depend

EMPTY :=
SPACE := $(EMPTY) $(EMPTY)

STDLIB_NAMESPACE_MODULES = $(subst $(SPACE),|,$(STDLIB_PREFIXED_MODULES))

.PHONY: depend
Expand Down
9 changes: 7 additions & 2 deletions stdlib/StdlibModules
Expand Up @@ -15,6 +15,8 @@
#* *
#**************************************************************************

# This file must be self-contained.

# This file lists all standard library modules. It is used by:
# 1. stdlib/Makefile when building stdlib.cma
# 2. Makefile to expunge the toplevels
Expand Down Expand Up @@ -45,12 +47,15 @@ STDLIB_MODULE_BASENAMES=\
STDLIB_PREFIXED_MODULES=\
$(filter-out stdlib camlinternal%, $(STDLIB_MODULE_BASENAMES))

define add_stdlib_prefix_first
$(shell echo $1 | cut -c1 | tr '[:lower:]' '[:upper:]')
endef

# add stdlib__ as prefix to a module except for internal modules
# and the stdlib module itself
define add_stdlib_prefix
$(or $(filter-out $(STDLIB_PREFIXED_MODULES), $1), \
stdlib__$(shell echo $1 | cut -c1 | tr '[:lower:]' '[:upper:]')$\
$(shell echo $1 | cut -c2-))
stdlib__$(call add_stdlib_prefix_first,$1)$(shell echo $1 | cut -c2-))
endef

STDLIB_MODULES:=\
Expand Down
16 changes: 14 additions & 2 deletions tools/ci/actions/runner.sh
Expand Up @@ -21,6 +21,8 @@ PREFIX=~/local
MAKE="make $MAKE_ARG"
SHELL=dash

MAKE_WARN="$MAKE --warn-undefined-variables"

export PATH=$PREFIX/bin:$PATH

Configure () {
Expand Down Expand Up @@ -61,8 +63,8 @@ EOF
}

Build () {
$MAKE world.opt
$MAKE ocamlnat
script --return --command "$MAKE_WARN world.opt" build.log
script --return --append --command "$MAKE_WARN ocamlnat" build.log
echo Ensuring that all names are prefixed in the runtime
./tools/check-symbol-names runtime/*.a
}
Expand All @@ -86,6 +88,15 @@ Install () {
}

Checks () {
set +x
STATUS=0
if grep -Fq ' warning: undefined variable ' build.log; then
echo -e '\e[31mERROR\e[0m Undefined Makefile variables detected!'
grep -F ' warning: undefined variable ' build.log | sort | uniq
STATUS=1
fi
rm build.log
set -x
if fgrep 'SUPPORTS_SHARED_LIBRARIES=true' Makefile.config &>/dev/null ; then
echo Check the code examples in the manual
$MAKE manual-pregen
Expand All @@ -106,6 +117,7 @@ Checks () {
test -z "$(git status --porcelain)"
# Check that there are no ignored files
test -z "$(git ls-files --others -i --exclude-standard)"
exit $STATUS
}

CheckManual () {
Expand Down