Skip to content
Snippets Groups Projects
Commit cc9db3ea authored by Mark OLESEN's avatar Mark OLESEN
Browse files

BACKPORT: relocate wmake binaries into project platforms/tools (#1647)

- can aid when creating source-only or binary-only packages

- replace dirToString binary with shell/awk equivalent for simpler
  maintenance. The utility is very rarely used (auto scanning to
  create Make/files) so there is no performance difference.
parent fbbff15e
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ GLIB_LIBS =
COMPILER_TYPE = $(shell echo $(WM_COMPILER) | tr -d [:digit:])
DEFAULT_RULES = $(WM_DIR)/rules/$(WM_ARCH)$(COMPILER_TYPE)
RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER)
WMAKE_BIN = $(WM_DIR)/platforms/$(WM_ARCH)$(WM_COMPILER)
WMAKE_BIN = $(WM_PROJECT_DIR)/platforms/tools/$(WM_ARCH)$(WM_COMPILER)
ifeq ($(WM_SCHEDULER),)
AND = &&
......
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# Script
# dirToString
#
# Usage
# dirToString path/to/file
#
# Description
# Converts a directory path into a camelCase string.
# Leading [./] characters are stripped by default.
#
# For example,
# input: dir1/dir2/dir3
# output: dir1Dir2Dir3
#
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: ${0##*/} [OPTION] dir
options:
-no-strip Do not ignore leading [./] characters
-strip Ignore leading [./] characters (default)
-h, -help Print the usage
Converts a directory path into a camelCase string
USAGE
exit 1
}
#------------------------------------------------------------------------------
# Parse arguments and options
#------------------------------------------------------------------------------
optStrip=true
while [ "$#" -gt 0 ]
do
case "$1" in
# Print help
(-h | -help*)
usage
;;
(-s | -strip)
optStrip=true
;;
(-no-strip)
unset optStrip
;;
(--)
shift
break
;;
(*)
break
;;
esac
shift
done
if [ -z "$optStrip" ]
then
dirName="$1"
else
# Ignore any leading ./ characters
dirName="$(echo ""$1"" | sed -e 's@^[./]*@@')"
fi
dirName=$(echo "$dirName" | \
awk 'BEGIN{FS="";RS="/";ORS=""} {if (FNR>1) {$0=toupper(substr($0,1,1))substr($0,2)}} 1')
echo "$dirName"
#------------------------------------------------------------------------------
......@@ -3,9 +3,11 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
......
......@@ -3,9 +3,11 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
......@@ -31,7 +33,7 @@
# Usage : makeFiles
#
#------------------------------------------------------------------------------
dirToString="$WM_DIR/platforms/$WM_ARCH$WM_COMPILER"/dirToString
dirToString="$WM_DIR/scripts/dirToString"
if [ -r Make/files ]
then
......@@ -46,8 +48,10 @@ fi
[ -d Make ] || mkdir Make
rm -f Make/files
#------------------------------------------------------------------------------
echo "Creating Make/files"
echo "Creating Make/files ..."
for dir in $(find . -mindepth 1 -type d -print)
do
......@@ -56,7 +60,7 @@ do
# Skip special directories
;;
*)
echo "$(echo $dir | $dirToString -strip) = ${dir#./}"
echo "$($dirToString "$dir") = ${dir#./}"
;;
esac
done > Make/files
......@@ -64,11 +68,11 @@ done > Make/files
for file in $(find . -name "*.[cCylLfF]" -type f -print)
do
pathName=$(echo ${file%/*} | $dirToString -strip)
pathName="$($dirToString "${file%/*}")"
if [ -n "$pathName" ]
then
echo '$('$pathName')/'"${file##*/}"
echo '$('"$pathName"')/'"${file##*/}"
else
echo "${file##*/}"
fi
......
......@@ -3,9 +3,11 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
......@@ -40,7 +42,9 @@ fi
[ -d Make ] || mkdir Make
rm -f Make/options
#------------------------------------------------------------------------------
echo "Creating Make/options"
echo 'EXE_INC = \
......
......@@ -3,9 +3,11 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
......
#!/bin/sh
cd "${0%/*}" || exit 1 # Run from this directory
cd "${0%/*}" || exit # This directory (/path/project/wmake/src)
if [ -z "$WM_DIR" ] # Require WM_DIR
if [ -z "$WM_DIR" ] # Require WM_DIR (/path/project/wmake)
then
WM_DIR="$(\cd $(dirname $0)/.. && \pwd -L)"
WM_DIR="$(dirname "$(pwd -L)")"
export WM_DIR
fi
make # Compile tools for wmake
if [ -z "$WM_PROJECT_DIR" ] # Expect WM_PROJECT_DIR (/path/project)
then
echo "Warning (${0##*/}) : No WM_PROJECT_DIR set" 1>&2
WM_PROJECT_DIR="${WM_DIR%/*}"
export WM_PROJECT_DIR
fi
if [ -z "$WM_ARCH" ] || [ -z "$WM_COMPILER" ]
then
echo "Error (${0##*/}) : No WM_ARCH or WM_COMPILER set"
echo " Check your OpenFOAM environment and installation"
exit 1
fi
case "$WM_COMPILER" in
Mingw*)
# Host wmake toolchain with system gcc (when cross-compiling)
make \
WM_COMPILER=Gcc WM_COMPILER_TYPE=system \
WMAKE_BIN="${WM_PROJECT_DIR}/platforms/tools/${WM_ARCH}${WM_COMPILER}" \
"$@"
;;
*)
# Regular wmake toolchain
make "$@"
;;
esac
#------------------------------------------------------------------------------
......@@ -2,9 +2,12 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
......@@ -30,13 +33,13 @@
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# The Makefile use a POSIX shell
# Use POSIX shell
#------------------------------------------------------------------------------
SHELL = /bin/sh
SHELL = /bin/sh
#------------------------------------------------------------------------------
# Unset suffices list (suffix rules are not used)
# No default suffix rules used
#------------------------------------------------------------------------------
.SUFFIXES:
......@@ -52,41 +55,44 @@ WM_COMPILE_OPTION = Opt
GENERAL_RULES = $(WM_DIR)/rules/General
include $(GENERAL_RULES)/general
archHost := $(WM_ARCH)$(WM_COMPILER)
archTarget := $(shell basename $(WMAKE_BIN))
#------------------------------------------------------------------------------
# Targets
#------------------------------------------------------------------------------
.PHONY: all clean
.PHONY: all clean message old
all: $(WMAKE_BIN)/wmkdepend message
all: $(WMAKE_BIN)/dirToString $(WMAKE_BIN)/wmkdep $(WMAKE_BIN)/wmkdepend
@echo built wmake-bin for $(WM_ARCH)$(WM_COMPILER)
# Flex-based processing
old: $(WMAKE_BIN)/wmkdep
message:
@echo "built wmake-bin ($(archTarget))"
clean:
@echo clean wmake-bin for $(WM_ARCH)$(WM_COMPILER)
@rm -rf $(WMAKE_BIN) 2>/dev/null
@echo "clean wmake-bin ($(archTarget))"
@rm -rf $(WMAKE_BIN)
@rmdir $(shell dirname $(WMAKE_BIN)) 2>/dev/null || true
$(WMAKE_BIN)/dirToString: dirToString.c
@mkdir -p $(WMAKE_BIN)
$(call QUIET_MESSAGE,compile,$(<F))
$E $(cc) $(cFLAGS) $(<F) -o $@
$(WMAKE_BIN)/wmkdep: wmkdep.l
@mkdir -p $(WMAKE_BIN)
$(call QUIET_MESSAGE,flex,$(<F))
$E flex -o $@.c $(<F) && $(cc) $(cFLAGS) $@.c -o $@
@rm -f $@.c 2>/dev/null
@rm -f $@.c
$(WMAKE_BIN)/wmkdepend: wmkdepend.cpp
@mkdir -p $(WMAKE_BIN)
$(call QUIET_MESSAGE,wmkdepend,$(<F))
$E $(CC) $(c++FLAGS) $(c++LESSWARN) $(<F) -o $@
# $(WMAKE_BIN)/wmkdepend: wmkdepend.rl
# @mkdir -p $(WMAKE_BIN)
# $(call QUIET_MESSAGE,ragel,$(<F))
# $E ragel -G2 -o $@.cpp $(<F) && $(CC) $(c++FLAGS) $(c++LESSWARN) $@.cpp -o $@
# @rm -f $@.cpp 2>/dev/null
#$(WMAKE_BIN)/wmkdepend: wmkdepend.rl
# @mkdir -p $(WMAKE_BIN)
# $(call QUIET_MESSAGE,ragel,$(<F))
# $E ragel -G2 -o $@.cpp $(<F) && $(CC) $(c++FLAGS) $@.cpp -o $@
# @rm -f $@.cpp
#------------------------------------------------------------------------------
/*----------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
dirToString
Description
Converts a directory path into a camelCase string.
e.g. dir1/dir2/dir3 becomes dir1Dir2Dir3
Usage
echo dirName | dirToString
e.g.
using sh
baseDirName=$(echo $dir | $bin/dirToString -strip)
using csh
set baseDirName=`echo $dir | $bin/dirToString -strip`
\*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* The executable name (for messages), without requiring access to argv[] */
#define EXENAME "dirToString"
int main(int argc, char* argv[])
{
int c;
if (argc > 1)
{
if (!strncmp(argv[1], "-h", 2))
{
/* Option: -h, -help */
fputs
(
"\nUsage: " EXENAME
" [-strip]\n\n"
" -strip ignore leading [./] characters.\n\n"
"Converts a directory path into a camelCase string\n\n",
stderr
);
return 0;
}
if (!strcmp(argv[1], "-s") || !strcmp(argv[1], "-strip"))
{
/* Option: -s, -strip */
while ((c=getchar()) != EOF && (c == '.' || c == '/'))
{
/* nop */
}
if (c == EOF)
{
return 0;
}
putchar(c);
}
}
int nextUpper = 0;
while ((c = getchar()) != EOF)
{
if (c == '/')
{
nextUpper = 1;
}
else if (nextUpper)
{
putchar(toupper(c));
nextUpper = 0;
}
else
{
putchar(c);
}
}
return 0;
}
/*****************************************************************************/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment