Skip to content
Snippets Groups Projects
Commit e82a0294 authored by mark's avatar mark
Browse files

ENH: add help/usage for dirToString, wmkdep. Add dirToString -strip option.

- The dirToString -strip option is simple, but reduces effort for the caller.
parent 46ecad8f
No related merge requests found
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
if [ -r Make/files ] if [ -r Make/files ]
then then
echo "Error: Make/files already exists - exiting" echo "Error: Make/files already exists - exiting" 1>&2
exit 1 exit 1
fi fi
...@@ -43,38 +43,32 @@ dirToString=$WM_DIR/platforms/$WM_ARCH$WM_COMPILER/dirToString ...@@ -43,38 +43,32 @@ dirToString=$WM_DIR/platforms/$WM_ARCH$WM_COMPILER/dirToString
[ -d Make ] || mkdir Make [ -d Make ] || mkdir Make
rm -f Make/files rm -f Make/files
for dir in `find . -type d -print` for dir in $(find . -mindepth 1 -type d -print)
do do
case "$dir" in case "$dir" in
. | ./Make | ./lnInclude ) . | ./Make | ./lnInclude )
# Skip special directories # Skip special directories
;; ;;
*) *)
baseDir=`echo $dir | sed 's%^\./%%'` echo "$(echo $dir | $dirToString -strip) = ${dir#./}"
baseDirName=`echo $baseDir | $dirToString`
echo $baseDirName " = " $baseDir >> Make/files
;; ;;
esac esac
done done >> Make/files
[ -s Make/files ] && echo >> Make/files
echo >> Make/files
for file in `find . -name "*.[cCylLfF]" -type f -print` for file in $(find . -type f -name "*.[cCylLfF]" -print)
do do
fileName=${file##*/} pathName=$(echo ${file%/*} | $dirToString -strip)
pathName=`echo ${file%/*} | sed -e 's%^\.%%' -e 's%^/%%' | $dirToString`
if [ -n "$pathName" ] if [ -n "$pathName" ]
then then
echo '$('$pathName')/'$fileName >> Make/files echo '$('$pathName')/'"${file##*/}"
else else
echo $fileName >> Make/files echo "${file##*/}"
fi fi
done done >> Make/files
echo >> Make/files echo >> Make/files
echo 'EXE = $(FOAM_APPBIN)/'"${PWD##*/}" >> Make/files
echo 'EXE = $(FOAM_APPBIN)/'${PWD##*/} >> Make/files
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
if [ -r Make/options ] if [ -r Make/options ]
then then
echo "Error: Make/options already exists - exiting" echo "Error: Make/options already exists - exiting" 1>&2
exit 1 exit 1
fi fi
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -33,22 +33,61 @@ Usage ...@@ -33,22 +33,61 @@ Usage
e.g. e.g.
using sh using sh
baseDirName=`echo $dir | sed 's%^\./%%' | $bin/dirToString` baseDirName=$(echo $dir | $bin/dirToString -strip)
using csh using csh
set baseDirName=`echo $dir | sed 's%^\./%%' | $bin/dirToString` set baseDirName=`echo $dir | $bin/dirToString -strip`
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <ctype.h> #include <ctype.h>
int main() int main(int argc, char* argv[])
{ {
int c; int c;
int nextupper = 0; int nextupper = 0;
if (argc > 1)
{
if (!strncmp(argv[1], "-h", 2)) /* -h, -help */
{
fprintf
(
stderr,
"\nUsage: %s [-strip]\n\n",
"dirToString"
);
fprintf
(
stderr,
" -strip ignore leading [./] characters.\n\n"
"Transform dir1/dir2 to camel-case dir1Dir2\n\n"
);
return 0;
}
if (!strcmp(argv[1], "-s") || !strcmp(argv[1], "-strip")) /* -s, -strip */
{
while ((c=getchar()) != EOF && (c == '.' || c == '/'))
{
/* nop */
}
if (c == EOF)
{
return 0;
}
putchar(c);
}
}
while ((c=getchar()) != EOF) while ((c=getchar()) != EOF)
{ {
if (c == '/') if (c == '/')
...@@ -60,13 +99,12 @@ int main() ...@@ -60,13 +99,12 @@ int main()
if (nextupper) if (nextupper)
{ {
putchar(toupper(c)); putchar(toupper(c));
nextupper = 0;
} }
else else
{ {
putchar(c); putchar(c);
} }
nextupper = 0;
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -147,10 +147,29 @@ int main(int argc, char* argv[]) ...@@ -147,10 +147,29 @@ int main(int argc, char* argv[])
char *basePos, *dotPos; char *basePos, *dotPos;
int i, silent; int i, silent;
if (argc == 1) if (argc < 2)
{ {
fprintf(stderr, "input file not supplied\n"); fprintf(stderr, "input file not supplied\n");
exit(1); return 1;
}
else if (!strncmp(argv[1], "-h", 2)) /* -h, -help */
{
fprintf
(
stderr,
"\nUsage: %s [-Idir ... -Idir] [-iheader .. -iheader] filename\n\n",
"wmkdep"
);
fprintf
(
stderr,
" -Idir Directories to be searched for headers.\n"
" -iheader Headers to be ignored.\n\n"
"Dependency list generator, similar to 'cpp -M'\n\n"
);
return 0;
} }
sourceFile = strdup(argv[argc-1]); sourceFile = strdup(argv[argc-1]);
...@@ -161,7 +180,7 @@ int main(int argc, char* argv[]) ...@@ -161,7 +180,7 @@ int main(int argc, char* argv[])
} }
else else
{ {
basePos++; ++basePos;
} }
if if
...@@ -176,18 +195,18 @@ int main(int argc, char* argv[]) ...@@ -176,18 +195,18 @@ int main(int argc, char* argv[])
"cannot find extension in source file name %s\n", "cannot find extension in source file name %s\n",
sourceFile sourceFile
); );
exit(1); return 1;
} }
/* count number of -I directories */ /* count number of -I directories */
nDirectories = 0; nDirectories = 0;
for (i = 1; i < argc; i++) for (i = 1; i < argc; ++i)
{ {
if (strncmp(argv[i], "-I", 2) == 0) if (strncmp(argv[i], "-I", 2) == 0)
{ {
if (strlen(argv[i]) > 2) if (strlen(argv[i]) > 2)
{ {
nDirectories++; ++nDirectories;
} }
} }
} }
...@@ -196,7 +215,7 @@ int main(int argc, char* argv[]) ...@@ -196,7 +215,7 @@ int main(int argc, char* argv[])
/* build list of -I directories and add -i ignores */ /* build list of -I directories and add -i ignores */
nDirectories = 0; nDirectories = 0;
for (i = 1; i < argc; i++) for (i = 1; i < argc; ++i)
{ {
if (strncmp(argv[i], "-I", 2) == 0) if (strncmp(argv[i], "-I", 2) == 0)
{ {
...@@ -240,7 +259,7 @@ int main(int argc, char* argv[]) ...@@ -240,7 +259,7 @@ int main(int argc, char* argv[])
puts("\n"); puts("\n");
for (i = 0; i < nDirectories; i++) for (i = 0; i < nDirectories; ++i)
{ {
free(directories[i]); free(directories[i]);
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment