tweak tools/check-typo and break more overlong lines

master
Damien Doligez 2016-02-19 12:16:21 +01:00
parent 57620a7afd
commit d5f61a4e54
17 changed files with 121 additions and 73 deletions

View File

@ -240,11 +240,10 @@ install:
for i in $(OTHERLIBRARIES); do \
(cd otherlibs/$$i; $(MAKE) install) || exit $$?; \
done
if test -n "$(WITH_OCAMLDOC)"; then (cd ocamldoc; $(MAKE) install); else :; fi
if test -n "$(WITH_DEBUGGER)"; then (cd debugger; $(MAKE) install); \
else :; fi
if test -n "$(WITH_OCAMLDOC)"; then (cd ocamldoc; $(MAKE) install); fi
if test -n "$(WITH_DEBUGGER)"; then (cd debugger; $(MAKE) install); fi
cp config/Makefile $(INSTALL_LIBDIR)/Makefile.config
if test -f ocamlopt; then $(MAKE) installopt; else :; fi
if test -f ocamlopt; then $(MAKE) installopt; fi
# Installation of the native-code compiler
installopt:
@ -279,10 +278,11 @@ installoptopt:
if test -f ocamlnat ; then \
cp ocamlnat $(INSTALL_BINDIR)/ocamlnat$(EXE); \
cp toplevel/opttopdirs.cmi $(INSTALL_LIBDIR); \
cp compilerlibs/ocamlopttoplevel.cmxa compilerlibs/ocamlopttoplevel.a \
$(OPTTOPLEVELSTART:.cmo=.cmx) $(OPTTOPLEVELSTART:.cmo=.o) \
$(INSTALL_COMPLIBDIR); \
else :; fi
cp compilerlibs/ocamlopttoplevel.cmxa \
compilerlibs/ocamlopttoplevel.a \
$(OPTTOPLEVELSTART:.cmo=.cmx) $(OPTTOPLEVELSTART:.cmo=.o) \
$(INSTALL_COMPLIBDIR); \
fi
cd $(INSTALL_COMPLIBDIR) && $(RANLIB) ocamlcommon.a ocamlbytecomp.a \
ocamloptcomp.a
@ -311,7 +311,8 @@ partialclean::
ocamlc: compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma $(BYTESTART)
$(CAMLC) $(LINKFLAGS) -compat-32 -o ocamlc \
compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma $(BYTESTART)
compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma \
$(BYTESTART)
# The native-code compiler
@ -505,11 +506,11 @@ byterun/primitives:
bytecomp/runtimedef.ml: byterun/primitives byterun/caml/fail.h
(echo 'let builtin_exceptions = [|'; \
sed -n -e 's|.*/\* \("[A-Za-z_]*"\) \*/$$| \1;|p' byterun/caml/fail.h | \
sed -e '$$s/;$$//'; \
sed -n -e 's|.*/\* \("[A-Za-z_]*"\) \*/$$| \1;|p' \
byterun/caml/fail.h; \
echo '|]'; \
echo 'let builtin_primitives = [|'; \
sed -e 's/.*/ "&";/' -e '$$s/;$$//' byterun/primitives; \
sed -e 's/.*/ "&";/' byterun/primitives; \
echo '|]') > bytecomp/runtimedef.ml
partialclean::
@ -571,7 +572,7 @@ beforedepend:: asmcomp/scheduling.ml
asmcomp/emit.ml: asmcomp/$(ARCH)/emit.mlp tools/cvt_emit
echo \# 1 \"$(ARCH)/emit.mlp\" > asmcomp/emit.ml
$(CAMLRUN) tools/cvt_emit < asmcomp/$(ARCH)/emit.mlp >> asmcomp/emit.ml \
$(CAMLRUN) tools/cvt_emit <asmcomp/$(ARCH)/emit.mlp >>asmcomp/emit.ml \
|| { rm -f asmcomp/emit.ml; exit 2; }
partialclean::

View File

@ -225,12 +225,15 @@ installbyt:
for i in $(OTHERLIBRARIES); do \
$(MAKEREC) -C otherlibs/$$i install || exit $$?; \
done
if test -n "$(WITH_OCAMLDOC)"; then (cd ocamldoc; $(MAKEREC) install); \
else :; fi
if test -n "$(WITH_DEBUGGER)"; then (cd debugger; $(MAKEREC) install); \
else :; fi
if test -n "$(FLEXDLL_SUBMODULE_PRESENT)"; then $(MAKEREC) install-flexdll; \
else :; fi
if test -n "$(WITH_OCAMLDOC)"; then \
(cd ocamldoc; $(MAKEREC) install); \
fi
if test -n "$(WITH_DEBUGGER)"; then \
(cd debugger; $(MAKEREC) install); \
fi
if test -n "$(FLEXDLL_SUBMODULE_PRESENT)"; then \
$(MAKEREC) install-flexdll; \
fi
cp config/Makefile "$(INSTALL_LIBDIR)/Makefile.config"
cp README.adoc "$(INSTALL_DISTRIB)/Readme.general.txt"
cp README.win32.adoc "$(INSTALL_DISTRIB)/Readme.windows.txt"
@ -307,7 +310,8 @@ partialclean::
rm -f compilerlibs/ocamlbytecomp.cma
ocamlc: compilerlibs/ocamlcommon.cma compilerlibs/ocamlbytecomp.cma $(BYTESTART)
$(CAMLC) $(LINKFLAGS) -compat-32 -o ocamlc compilerlibs/ocamlcommon.cma \
$(CAMLC) $(LINKFLAGS) -compat-32 -o ocamlc \
compilerlibs/ocamlcommon.cma \
compilerlibs/ocamlbytecomp.cma $(BYTESTART)
partialclean::
@ -480,11 +484,11 @@ byterun/primitives:
bytecomp/runtimedef.ml: byterun/primitives byterun/caml/fail.h
(echo 'let builtin_exceptions = [|'; \
sed -n -e 's|.*/\* \("[A-Za-z_]*"\) \*/$$| \1;|p' byterun/caml/fail.h | \
sed -e '$$s/;$$//'; \
sed -n -e 's|.*/\* \("[A-Za-z_]*"\) \*/$$| \1;|p' \
byterun/caml/fail.h; \
echo '|]'; \
echo 'let builtin_primitives = [|'; \
sed -e 's/.*/ "&";/' -e '$$s/;$$//' byterun/primitives; \
sed -e 's/.*/ "&";/' byterun/primitives; \
echo '|]') > bytecomp/runtimedef.ml
partialclean::
@ -596,15 +600,16 @@ alldepend::
# The library
library:
cd stdlib ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) all
cd stdlib && $(MAKEREC) $(BOOT_FLEXLINK_CMD) all
library-cross:
cd stdlib ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) CAMLRUN=../byterun/ocamlrun all
cd stdlib \
&& $(MAKEREC) $(BOOT_FLEXLINK_CMD) CAMLRUN=../byterun/ocamlrun all
libraryopt:
cd stdlib ; $(MAKEREC) $(BOOT_FLEXLINK_CMD) allopt
cd stdlib && $(MAKEREC) $(BOOT_FLEXLINK_CMD) allopt
partialclean::
cd stdlib ; $(MAKEREC) clean
cd stdlib && $(MAKEREC) clean
alldepend::
cd stdlib ; $(MAKEREC) depend
cd stdlib && $(MAKEREC) depend
# The lexer and parser generators

View File

@ -70,7 +70,8 @@ $(LINKEDFILES): %.c: ../byterun/%.c
# Need special compilation rule so as not to do -I../byterun
win32.$(O): ../byterun/win32.c
$(CC) -c $(NATIVECCCOMPOPTS) -DNATIVE_CODE $(IFLEXDIR) ../byterun/win32.c
$(CC) -c $(NATIVECCCOMPOPTS) -DNATIVE_CODE $(IFLEXDIR) \
../byterun/win32.c
%.$(O): %.c
$(CC) $(CFLAGS) -c $<

View File

@ -71,7 +71,8 @@ install::
if test -d "$(INSTALL_LIBDIR)/caml"; then : ; \
else mkdir "$(INSTALL_LIBDIR)/caml"; fi
for i in $(PUBLIC_INCLUDES); do \
sed -f ../tools/cleanup-header caml/$$i > "$(INSTALL_LIBDIR)/caml/$$i"; \
sed -f ../tools/cleanup-header caml/$$i \
> "$(INSTALL_LIBDIR)/caml/$$i"; \
done
cp ld.conf "$(INSTALL_LIBDIR)/ld.conf"
.PHONY: install

View File

@ -100,8 +100,9 @@ install:
installopt:
cp libthreadsnat.a $(INSTALL_LIBDIR)/libthreadsnat.a
cd $(INSTALL_LIBDIR); $(RANLIB) libthreadsnat.a
cp $(THREAD_OBJS:.cmo=.cmx) threads.cmxa threads.a $(INSTALL_LIBDIR)/threads
cd $(INSTALL_LIBDIR)/threads; $(RANLIB) threads.a
cp $(THREAD_OBJS:.cmo=.cmx) threads.cmxa threads.a \
$(INSTALL_LIBDIR)/threads
cd $(INSTALL_LIBDIR)/threads && $(RANLIB) threads.a
.SUFFIXES: .ml .mli .cmo .cmi .cmx

View File

@ -108,7 +108,9 @@ INSTALL_LIBDIR=$(DESTDIR)$(LIBDIR)
INSTALL_STUBLIBDIR=$(DESTDIR)$(STUBLIBDIR)
install:
if test -f dllvmthreads.so; then cp dllvmthreads.so $(INSTALL_STUBLIBDIR)/.; fi
if test -f dllvmthreads.so; then \
cp dllvmthreads.so $(INSTALL_STUBLIBDIR)/.; \
fi
mkdir -p $(INSTALL_LIBDIR)/vmthreads
cp libvmthreads.a $(INSTALL_LIBDIR)/vmthreads/libvmthreads.a
cd $(INSTALL_LIBDIR)/vmthreads; $(RANLIB) libvmthreads.a

View File

@ -55,7 +55,7 @@ camlheaderi target_camlheaderi: \
if $(SHARPBANGSCRIPTS); then \
for suff in '' d i; do \
echo '#!$(BINDIR)/ocamlrun'$$suff > camlheader$$suff && \
echo '#!$(TARGET_BINDIR)/ocamlrun'$$suff > target_camlheader$$suff; \
echo '#!$(TARGET_BINDIR)/ocamlrun'$$suff >target_camlheader$$suff; \
done && \
echo '#!' | tr -d '\012' > camlheader_ur; \
else \

View File

@ -103,7 +103,8 @@ clean::
$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) `./Compflags $@` -c $<
.ml.p.cmx:
$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) `./Compflags $@` -p -c -o $*.p.cmx $<
$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) `./Compflags $@` \
-p -c -o $*.p.cmx $<
# Dependencies on the compiler
$(OBJS) std_exit.cmo: $(COMPILER)

View File

@ -82,17 +82,17 @@ all-%: lib
.PHONY: parallel-%
parallel-%: lib
@echo | parallel >/dev/null 2>/dev/null \
|| (echo "Unable to run the GNU parallel tool;";\
echo "You should install it before using the parallel* targets.";\
exit 1)
|| (echo "Unable to run the GNU parallel tool;";\
echo "You should install it before using the parallel* targets.";\
exit 1)
@echo | parallel --gnu --no-notice >/dev/null 2>/dev/null \
|| (echo "Your 'parallel' tool seems incompatible with GNU parallel;";\
echo "This target requires GNU parallel.";\
exit 1)
|| (echo "Your 'parallel' tool seems incompatible with GNU parallel.";\
echo "This target requires GNU parallel.";\
exit 1)
@for dir in tests/$**; do echo $$dir; done \
| parallel --gnu --no-notice --keep-order \
"$(MAKE) $(NO_PRINT) exec-one DIR={} 2>&1" \
| tee _log
| parallel --gnu --no-notice --keep-order \
"$(MAKE) $(NO_PRINT) exec-one DIR={} 2>&1" \
| tee _log
@$(MAKE) $(NO_PRINT) retries
@$(MAKE) report

View File

@ -85,10 +85,10 @@ OCAMLOPT=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/ocamlopt $(OCFLAGS) \
OCAMLDOC=$(OCAMLRUN) $(OTOPDIR)/ocamldoc/ocamldoc
OCAMLLEX=$(OCAMLRUN) $(OTOPDIR)/lex/ocamllex
OCAMLMKLIB=$(FLEXLINK_PREFIX)$(OCAMLRUN) $(OTOPDIR)/tools/ocamlmklib \
-ocamlc "$(OTOPDIR)/byterun/ocamlrun$(USE_RUNTIME)$(EXE) \
$(OTOPDIR)/ocamlc $(OCFLAGS) $(RUNTIME_VARIANT)" \
-ocamlopt "$(OTOPDIR)/byterun/ocamlrun$(USE_RUNTIME)$(EXE) \
$(OTOPDIR)/ocamlopt $(OCFLAGS) $(RUNTIME_VARIANT)"
-ocamlc "$(OTOPDIR)/byterun/ocamlrun$(USE_RUNTIME)$(EXE) \
$(OTOPDIR)/ocamlc $(OCFLAGS) $(RUNTIME_VARIANT)" \
-ocamlopt "$(OTOPDIR)/byterun/ocamlrun$(USE_RUNTIME)$(EXE) \
$(OTOPDIR)/ocamlopt $(OCFLAGS) $(RUNTIME_VARIANT)"
OCAMLYACC=$(TOPDIR)/yacc/ocamlyacc$(EXE)
DUMPOBJ=$(OCAMLRUN) $(OTOPDIR)/tools/dumpobj
OBJINFO=$(OCAMLRUN) $(OTOPDIR)/tools/objinfo

View File

@ -20,7 +20,8 @@
default:
@for file in *.ml; do \
$(OCAMLC) -dlambda -c $$file 2>&1 | \
sed -e "s|\\([A-Za-z_][A-Za-z_']*\)/[0-9][0-9]*|\\1|g" > $$file.result; \
sed -e "s|\\([A-Za-z_][A-Za-z_']*\)/[0-9][0-9]*|\\1|g" \
> $$file.result; \
done
@for file in *.reference; do \
printf " ... testing '$$file':"; \

View File

@ -37,8 +37,9 @@ C_INCLUDES+=-I $(CTOPDIR)/byterun
.PHONY: default
default:
@$(MAKE) compile
@$(NATIVECODE_ONLY) && $(BYTECODE_ONLY) && echo " ... testing => skipped" || \
$(SET_LD_PATH) $(MAKE) run
@$(NATIVECODE_ONLY) && $(BYTECODE_ONLY) \
&& echo " ... testing => skipped" \
|| (SET_LD_PATH) $(MAKE) run
.PHONY: compile
compile: $(ML_FILES)
@ -68,7 +69,8 @@ run:
printf " ocamlc"; \
$(MYRUNTIME) ./program.byte$(EXE) $(EXEC_ARGS) \
>$(MAIN_MODULE).result \
&& $(DIFF) $(MAIN_MODULE).reference $(MAIN_MODULE).result >/dev/null; \
&& $(DIFF) $(MAIN_MODULE).reference $(MAIN_MODULE).result \
>/dev/null; \
fi \
&& if $(BYTECODE_ONLY); then : ; else \
printf " ocamlopt"; \

View File

@ -72,7 +72,7 @@ native:
rm -f program program.exe; \
$(OCAMLOPT) -g -o $(EXECNAME) $$file; \
for arg in a b c d ''; do \
printf " ... testing '$$file' with ocamlopt and argument '$$arg':"; \
printf " ... testing '$$file' with ocamlopt and argument '$$arg':";\
F="`basename $$file .ml`"; \
(OCAMLRUNPARAM=$$OCAMLRUNPARAM,b=1 \
./$(EXECNAME) $$arg || true) \

View File

@ -25,8 +25,10 @@ default:
skip:
@echo " ... testing 'test' with ordinary compilation => skipped"
@echo " ... testing 'test' with change to opaque interface => skipped"
@echo " ... testing 'test' with change to opaque implementation => skipped"
@echo " ... testing 'test' with change to non-opaque implementation => skipped"
@echo " ... testing 'test' with change to opaque implementation \
=> skipped"
@echo " ... testing 'test' with change to non-opaque implementation \
=> skipped"
.PHONY: compile
compile:
@ -55,7 +57,7 @@ compile:
$(OCAMLOPT) fst/opaque_intf.cmx snd/opaque_impl.cmx \
fst/regular.cmx test.cmx 2>/dev/null \
&& echo " => passed" || echo " => failed"; \
printf " ... testing 'test' with change to non-opaque implementation"; \
printf " ... testing 'test' with change to non-opaque implementation";\
$(OCAMLOPT) fst/opaque_intf.cmx fst/opaque_impl.cmx \
snd/regular.cmx test.cmx 2>/dev/null \
&& echo " => failed" || echo " => passed"; \

View File

@ -40,7 +40,8 @@ run-all:
if $(BYTECODE_ONLY); then echo " => skipped"; else \
F="`basename $$file .ml`"; \
$(OCAMLOPT) $(FLAGS) -c $$file 2>$$F.$(BACKEND).opt_result; \
$(DIFF) $$F.$(BACKEND).opt_reference $$F.$(BACKEND).opt_result >/dev/null \
$(DIFF) $$F.$(BACKEND).opt_reference $$F.$(BACKEND).opt_result \
>/dev/null \
&& echo " => passed" || echo " => failed"; \
fi \
done;

View File

@ -21,7 +21,8 @@ CAMLC=$(CAMLRUN) ../boot/ocamlc -nostdlib -I ../boot
CAMLOPT=$(CAMLRUN) ../ocamlopt -nostdlib -I ../stdlib
CAMLLEX=$(CAMLRUN) ../boot/ocamllex
INCLUDES=-I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../asmcomp \
-I ../middle_end -I ../middle_end/base_types -I ../driver -I ../toplevel
-I ../middle_end -I ../middle_end/base_types -I ../driver \
-I ../toplevel
COMPFLAGS= -strict-sequence -w +27+32..39 -warn-error A -safe-string $(INCLUDES)
LINKFLAGS=$(INCLUDES)
@ -47,7 +48,8 @@ CAMLDEP_IMPORTS=timings.cmo misc.cmo config.cmo identifiable.cmo numbers.cmo \
builtin_attributes.cmo
ocamldep: depend.cmi $(CAMLDEP_OBJ)
$(CAMLC) $(LINKFLAGS) -compat-32 -o ocamldep $(CAMLDEP_IMPORTS) $(CAMLDEP_OBJ)
$(CAMLC) $(LINKFLAGS) -compat-32 -o ocamldep $(CAMLDEP_IMPORTS) \
$(CAMLDEP_OBJ)
ocamldep.opt: depend.cmi $(CAMLDEP_OBJ:.cmo=.cmx)
$(CAMLOPT) $(LINKFLAGS) -o ocamldep.opt $(CAMLDEP_IMPORTS:.cmo=.cmx) \

View File

@ -168,6 +168,7 @@ IGNORE_DIRS="
&& counts[name] <= 10){
printf ("%s:%d.%d:", file, NR, RSTART + RLENGTH);
printf (" [%s] %s\n", name, msg);
got_errors = 1;
if (counts[name] == 10){
printf ("WARNING: too many [%s] in this file.", name);
printf (" Others will not be reported.\n");
@ -175,8 +176,32 @@ IGNORE_DIRS="
}
}
function more_columns(str, limit, c){
c = 0;
for (i = 1; i <= length(str); i++){
if (substr(str, i, 1) == "\t"){
c = int((c + 8) / 8) * 8;
}else{
++ c;
}
}
return c > limit;
}
BEGIN { state = "(first line)"; }
match($0, /\t/) {
err("tab", "TAB character(s)");
if (more_columns($0, 80)){
RSTART=81;
RLENGTH = 0;
err("long-line", "line is over 80 columns");
}
if (more_columns($0, 132)){
RSTART=133;
RLENGTH = 0;
err("very-long-line", "line is over 132 columns");
}
}
match($0, /[\200-\377]/) {
@ -195,37 +220,39 @@ IGNORE_DIRS="
err("svn-keyword", "SVN keyword marker");
}
length($0) > 80 {
$0 !~ /\t/ && length($0) > 80 {
RSTART = 81;
RLENGTH = 0;
err("long-line", "line is over 80 characters");
err("long-line", "line is over 80 columns");
}
length($0) > 132 {
$0 !~ /\t/ && length($0) > 132 {
RSTART = 133;
RLENGTH = 0;
err("very-long-line", "line is over 132 characters");
err("very-long-line", "line is over 132 columns");
}
# Header-recognition automaton. Read this from bottom to top.
state == "close" && $0 ~ /\*{74}/ { state = "OK"; }
state == "close" { state = "error"; }
state == "close" { state = "(last line)"; }
state == "blurb" && $0 ~ /\* {72}\*/ { state = "close"; }
state == "blurb1" && $0 ~ /\* All rights reserved. / \
state == "blurb1" && $0 ~ /\* All rights reserved. .{47} \*/ \
{ state = "blurb"; }
state == "blurb1" { state = "error"; }
state == "blurb1" { state = "(blurb line 1)"; }
state == "copyright" && $0 ~ /\* {72}\*/ { state = "blurb1"; }
state == "copyright" && $0 !~ /\* Copyright [0-9]{4}/ \
&& $0 !~ /\* / { state = "error"; }
state == "copyright" && $0 !~ /\* Copyright [0-9]{4}.{54} \*/ \
&& $0 !~ /\* .{66} \*/ \
{ state = "(copyright lines)"; }
state == "authors" && $0 ~ /\* {72}\*/ { state = "copyright"; }
state == "authors" && $0 !~ /\* .{70} \*/ { state = "(authors)"; }
state == "blank2" && $0 ~ /\* {72}\*/ { state = "authors"; }
state == "blank2" { state = "error"; }
state == "blank2" { state = "(blank line 2)"; }
state == "title" && $0 ~ /\* {33}OCaml {34}\*/ { state = "blank2"; }
state == "title" { state = "error"; }
state == "title" { state = "(title line)"; }
state == "blank1" && $0 ~ /\* {72}\*/ { state = "title"; }
state == "blank1" { state = "error"; }
state == "" && NR < 4 && $0 ~ /\*{74}/ { state = "blank1"; }
state == "blank1" { state = "(blank line 1)"; }
state == "(first line)" && NR < 4 && $0 ~ /\*{74}/ { state = "blank1"; }
{
prev_line = last_line;
@ -249,7 +276,7 @@ IGNORE_DIRS="
NR = 1;
RSTART = 1;
RLENGTH = 0;
err("missing-header", "missing copyright header");
err("missing-header", sprintf("bad copyright header %s", state));
}else{
counts["missing-header"] = 1;
}
@ -264,6 +291,7 @@ IGNORE_DIRS="
err("unused-prop", sprintf("unused [%s] in ocaml-typo", name));
}
}
exit got_errors;
}
'
done