colons in filenames break Makefiles
Summary
OpenFOAM sometimes uses colons in filenames (e.g. 0/jouleHeatingSource:V
). There's a number of issues due to this: #2224 (closed) #1142 (closed) #1675.
One additional problem with this is that colons (:
) in file names break Makefiles.
Consider this example:
FIELD_FILES_ORIG:=$(wildcard 0.orig/*)
FIELD_FILES:=$(foreach v,$(FIELD_FILES_ORIG),$(notdir $(v)))
FIELD_FILES_INITIAL:=$(foreach v,$(FIELD_FILES),0/$(v))
0/cellToRegion: constant/polyMesh $(FIELD_FILES_INITIAL) | 0
splitMeshRegions -cellZones -overwrite
renumberMesh -allRegions -overwrite
This code tracks changes in 0/*
files and run OpenFOAM subprograms on demand. However, it breaks when :
characters are in the names of the files.
Steps to reproduce
Execute code
git clone https://develop.openfoam.com/Development/openfoam.git --branch master
cd openfoam/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid
cat > Makefile << _EOF_
FILES:=\$(wildcard 0.orig/**/*)
all: \$(FILES)
echo success
_EOF_
make
Observe GNU Make error.
Fix file names and try again
rename 's/:/-/' 0.orig/solid/*
make
Observe output string success
.
Example case
See Steps to reproduce
What is the current bug behaviour?
OpenFOAM file names break GNU Make automation
What is the expected correct behavior?
OpenFOAM file names do not break GNU Make automation
Relevant logs and/or images
Environment information
- OpenFOAM version : v2206
- Operating system : GNU Debian bookworm
- Hardware info : x86-64
- Compiler : gcc
Possible fixes
It is clear that changing file name separator would break many existing OpenFOAM based projects. IMHO the best way to deal with this is to replace hardcoded file names with some kind of FIELD_FILE_NAME_SEPARATOR
macro and throw a deprecation warning when its value is :
. This way, people could easily roll back changes in case of problems with their projects.