config system: Support Windows when CRLFs used for eol markers

Includes a test in test_build_system.sh to prevent regressions w/
CRLFs in text files.

Fixes Github #10
This commit is contained in:
Angus Gratton 2016-09-16 17:56:50 +10:00
parent 567cabb3f5
commit cdd1b95b6e
3 changed files with 25 additions and 8 deletions

View File

@ -80,6 +80,22 @@ function run_tests()
failure "Files weren't cleaned: ${ALL_BUILD_FILES}"
fi
print_status "Can still clean build if all text files are CRLFs"
make clean
find . -exec unix2dos {} \; # CRLFify template dir
# make a copy of esp-idf and CRLFify it
CRLF_ESPIDF=${TESTDIR}/esp-idf-crlf
mkdir -p ${CRLF_ESPIDF}
cp -rv ${IDF_PATH}/* ${CRLF_ESPIDF}
# don't CRLFify executable files, as Linux will fail to execute them
find ${CRLF_ESPIDF} -type f ! -perm 755 -exec unix2dos {} \;
make IDF_PATH=${CRLF_ESPIDF}
# do the same checks we do for the clean build
assert_built ${APP_BINS} ${BOOTLOADER_BINS} partitions_singleapp.bin
[ -f ${BUILD}/partition*.bin ] || failure "A partition table should have been built in CRLF mode"
# NOTE: If adding new tests, add them above this CRLF test...
print_status "All tests completed"
if [ -n "${FAILURES}" ]; then
echo "Some failures were detected:"

View File

@ -301,7 +301,8 @@ zconf.lex.c: zconf.l
flex -L -P zconf -o zconf.lex.c zconf.l
zconf.hash.c: zconf.gperf
gperf -t --output-file zconf.hash.c -a -C -E -g -k '1,3,$$' -p -t zconf.gperf
# strip CRs on Windows systems where gperf will otherwise barf on them
sed -E "s/\r//" zconf.gperf | gperf -t --output-file zconf.hash.c -a -C -E -g -k '1,3,$$' -p -t
zconf.tab.c: zconf.y
bison -t -l -p zconf -o zconf.tab.c zconf.y

View File

@ -114,8 +114,8 @@ n [A-Za-z0-9_-]
zconflval.string = text;
return T_WORD;
}
. warn_ignored_character(*yytext);
\n {
[^\r\n] warn_ignored_character(*yytext);
\r?\n {
BEGIN(INITIAL);
current_file->lineno++;
return T_EOL;
@ -139,7 +139,7 @@ n [A-Za-z0-9_-]
new_string();
BEGIN(STRING);
}
\n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
\r?\n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
({n}|[/.])+ {
const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
if (id && id->flags & TF_PARAM) {
@ -184,7 +184,7 @@ n [A-Za-z0-9_-]
} else
append_string(yytext, 1);
}
\n {
\r?\n {
printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno());
current_file->lineno++;
BEGIN(INITIAL);
@ -218,16 +218,16 @@ n [A-Za-z0-9_-]
append_string(" ", ts);
}
}
[ \t]*\n/[^ \t\n] {
[ \t]*\r?\n/[^ \t\r\n] {
current_file->lineno++;
zconf_endhelp();
return T_HELPTEXT;
}
[ \t]*\n {
[ \t]*\r?\n {
current_file->lineno++;
append_string("\n", 1);
}
[^ \t\n].* {
[^ \t\r?\n].* {
while (yyleng) {
if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t'))
break;