Issue 116349 - certain SOURCE_ROOT patterns break the build on Windows/cygwin
Summary: certain SOURCE_ROOT patterns break the build on Windows/cygwin
Status: CLOSED FIXED
Alias: None
Product: Build Tools
Classification: Code
Component: GNU make (show other issues)
Version: DEV300m96
Hardware: PC All
: P1 (highest) Blocker (vote)
Target Milestone: ---
Assignee: Frank Schönheit
QA Contact: issues@tools
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-24 14:01 UTC by hans_werner67
Modified: 2012-03-03 11:11 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
My proposed fix for this issue (1.94 KB, text/plain)
2011-01-19 12:44 UTC, clippka
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Frank Schönheit 2011-01-07 13:07:39 UTC
If your SOURCE_ROOT points to a location so that the cygwin-notation of the path
is actually a sub string of its Windows-notation (with \ replaced by /), then
the GNU make build system breaks.

To reproduce:
- Use a CWS located at, say, C:\cws\mycws
- mount C:\cws to /cws
- export SOURCE_ROOT=c:/cws/mycws
- cd /cws/mycws/DEV300/ooo/tools
- make -r
=> the build breaks with an error message talking about a path "C:C:/cws/mycws/..."

The problem here is that some makefile magic attemps to replace cygwin path
notations with their respective Windows-compliant counterpart. This is done by
substituting "/cws/mycws" with "C:/cws/mycws", which unfortunately also hits if
the string already contains C:/cws/mycws.
Comment 1 clippka 2011-01-19 10:01:36 UTC
cl: The problem is definitly in file solenv/gbuild/platform/windows.mk in 

define gb_Helper_abbreviate_dirs_native

My source_root is e:/cws/cws_name

and cygpath -m gives "E:/cws/cws_name"

watch the capital E here.

So everywhere $(1) contains "e:/cws/cws_name" it will not be replaced by R since
gb_Helper_REPODIR_NATIVE is "E:/cws/cws_name" and subst works case sensitive.
But subst will find $(REPODIR) which is /cws/cws_name in "e:/cws/cws_name" and
replace it with $R so we get "e:$R/".

Raising priority as this makes the build system unusable on windows systems.
Comment 2 clippka 2011-01-19 10:05:59 UTC
As a quick fix I tried to set my source_root to "E:/cws/cws_name" which does not
fix the issue entirely.
Comment 3 clippka 2011-01-19 10:41:16 UTC
this

# Helper class

lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst
F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst
L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst
R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst
X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))

gb_Helper_SRCDIR_NATIVE := $(call lc,$(shell cygpath -m $(SRCDIR)))
gb_Helper_WORKDIR_NATIVE := $(call lc,$(shell cygpath -m $(WORKDIR)))
gb_Helper_OUTDIR_NATIVE := $(call lc,$(shell cygpath -m $(OUTDIR)))
gb_Helper_REPODIR_NATIVE := $(call lc,$(shell cygpath -m $(REPODIR)))

define gb_Helper_abbreviate_dirs_native
R=$(gb_Helper_REPODIR_NATIVE) && $(subst $(REPODIR),$$R,$(subst
$(gb_Helper_REPODIR_NATIVE),$$R,$1 ))
endef

Kind of fixes it for me but I still get some -IE:/cws/cws_name/ooo/solenv/inc
Comment 4 bjoern.michaelsen 2011-01-19 10:54:25 UTC
The root cause are the replacements at gb_Helper_abbreviate_dirs_native:
>
http://hg.services.openoffice.org/DEV300/file/6a873085545b/solenv/gbuild/platform/windows.mk#l202
and that with your setup have $(WORKDIR) being a substring of
$(gb_Helper_WORKDIR_NATIVE) etc.

Probable solution:
Replace (from innermost/first):
- gb_Helper_WORKDIR_NATIVE (cannot be a substring of WORKDIR)
- gb_Helper_OUTDIR_NATIVE (cannot be a substring of OUTDIR)
- gb_Helper_SRCDIR_NATIVE (cannot be a substring of SRCDIR)
- WORKDIR
- OUTDIR
- SRCDIR
- REPODIR
on line 202 instead of the current substitutions.

Comment 5 clippka 2011-01-19 11:03:40 UTC
Thanks to ause, this works at least for tools

lc = $(patsubst A:%,a:%,$(patsubst B:%,b:%,$(patsubst C:%,c:%,$(patsubst
D:%,d:%,$(patsubst E:%,e:%,$(patsubst F:%,f:%,$(patsubst G:%,g:%,$(patsubst
H:%,h:%,$(patsubst I:%,i:%,$(patsubst J:%,j:%,$(patsubst K:%,k:%,$(patsubst
L:%,l:%,$(patsubst M:%,m:%,$(patsubst N:%,n:%,$(patsubst O:%,o:%,$(patsubst
P:%,p:%,$(patsubst Q:%,q:%,$(patsubst R:%,r:%,$(patsubst S:%,s:%,$(patsubst
T:%,t:%,$(patsubst U:%,u:%,$(patsubst V:%,v:%,$(patsubst W:%,w:%,$(patsubst
X:%,x:%,$(patsubst Y:%,y:%,$(patsubst Z:%,z:%,$1))))))))))))))))))))))))))

gb_Helper_SRCDIR_NATIVE := $(call lc,$(shell cygpath -m $(SRCDIR)))
gb_Helper_WORKDIR_NATIVE := $(call lc,$(shell cygpath -m $(WORKDIR)))
gb_Helper_OUTDIR_NATIVE := $(call lc,$(shell cygpath -m $(OUTDIR)))
gb_Helper_REPODIR_NATIVE := $(call lc,$(shell cygpath -m $(REPODIR)))
$(info $(gb_Helper_REPODIR_NATIVE))

define gb_Helper_abbreviate_dirs_native
R=$(gb_Helper_REPODIR_NATIVE) && $(subst $(REPODIR),$$R,$(subst
$(gb_Helper_REPODIR_NATIVE),$$R,$1 ))
endef
Comment 6 bjoern.michaelsen 2011-01-19 11:17:47 UTC
please use:
gb_Helper_SRCDIR_NATIVE := $(shell cygpath -m $(SRCDIR) |$(gb_AWK) -- '{ print
tolower(substr($$0,1,1)) substr($$0,2) }'))
...

instead.
Comment 7 clippka 2011-01-19 11:27:05 UTC
this still works but has a much shorter command line, like the original version

# Helper class

lc = $(patsubst A:%,a:%,$(patsubst B:%,b:%,$(patsubst C:%,c:%,$(patsubst
D:%,d:%,$(patsubst E:%,e:%,$(patsubst F:%,f:%,$(patsubst G:%,g:%,$(patsubst
H:%,h:%,$(patsubst I:%,i:%,$(patsubst J:%,j:%,$(patsubst K:%,k:%,$(patsubst
L:%,l:%,$(patsubst M:%,m:%,$(patsubst N:%,n:%,$(patsubst O:%,o:%,$(patsubst
P:%,p:%,$(patsubst Q:%,q:%,$(patsubst R:%,r:%,$(patsubst S:%,s:%,$(patsubst
T:%,t:%,$(patsubst U:%,u:%,$(patsubst V:%,v:%,$(patsubst W:%,w:%,$(patsubst
X:%,x:%,$(patsubst Y:%,y:%,$(patsubst Z:%,z:%,$1))))))))))))))))))))))))))

gb_Helper_SRCDIR_NATIVE := $(call lc,$(shell cygpath -m $(SRCDIR)))
gb_Helper_WORKDIR_NATIVE := $(call lc,$(shell cygpath -m $(WORKDIR)))
gb_Helper_OUTDIR_NATIVE := $(call lc,$(shell cygpath -m $(OUTDIR)))
gb_Helper_REPODIR_NATIVE := $(call lc,$(shell cygpath -m $(REPODIR)))

define gb_Helper_abbreviate_dirs_native
R=$(gb_Helper_REPODIR_NATIVE) && $(subst $(REPODIR)/,$$R/,$(subst
$(gb_Helper_REPODIR_NATIVE)/,$$R/,O=$(gb_Helper_OUTDIR_NATIVE) &&
W=$(gb_Helper_WORKDIR_NATIVE) && S=$(gb_Helper_SRCDIR_NATIVE))) && \
$(subst $(REPODIR)/,$$R/,$(subst $(SRCDIR)/,$$S/,$(subst $(OUTDIR)/,$$O/,$(subst
$(WORKDIR)/,$$W/,$(subst $(gb_Helper_REPODIR_NATIVE)/,$$R/,$(subst
$(gb_Helper_SRCDIR_NATIVE)/,$$S/,$(subst
$(gb_Helper_OUTDIR_NATIVE)/,$$O/,$(subst
$(gb_Helper_WORKDIR_NATIVE)/,$$W/,($1)))))))))
endef
Comment 8 clippka 2011-01-19 11:32:52 UTC
thanks björn. So Frank & Ause, can you please review if the following works in
your environment?

# Helper class
gb_Helper_SRCDIR_NATIVE := $(shell cygpath -m $(SRCDIR) | $(gb_AWK) -- '{ print
tolower(substr($$0,1,1)) substr($$0,2) }')
gb_Helper_WORKDIR_NATIVE := $(shell cygpath -m $(WORKDIR) | $(gb_AWK) -- '{
print tolower(substr($$0,1,1)) substr($$0,2) }')
gb_Helper_OUTDIR_NATIVE := $(shell cygpath -m $(OUTDIR) | $(gb_AWK) -- '{ print
tolower(substr($$0,1,1)) substr($$0,2) }')
gb_Helper_REPODIR_NATIVE := $(shell cygpath -m $(REPODIR) | $(gb_AWK) -- '{
print tolower(substr($$0,1,1)) substr($$0,2) }')

define gb_Helper_abbreviate_dirs_native
R=$(gb_Helper_REPODIR_NATIVE) && $(subst $(REPODIR)/,$$R/,$(subst
$(gb_Helper_REPODIR_NATIVE)/,$$R/,O=$(gb_Helper_OUTDIR_NATIVE) &&
W=$(gb_Helper_WORKDIR_NATIVE) && S=$(gb_Helper_SRCDIR_NATIVE))) && \
$(subst $(REPODIR)/,$$R/,$(subst $(SRCDIR)/,$$S/,$(subst $(OUTDIR)/,$$O/,$(subst
$(WORKDIR)/,$$W/,$(subst $(gb_Helper_REPODIR_NATIVE)/,$$R/,$(subst
$(gb_Helper_SRCDIR_NATIVE)/,$$S/,$(subst
$(gb_Helper_OUTDIR_NATIVE)/,$$O/,$(subst
$(gb_Helper_WORKDIR_NATIVE)/,$$W/,($1)))))))))
endef
Comment 9 Frank Schönheit 2011-01-19 12:18:43 UTC
fs->cl: If you attach this as patch file, so it doesn't have the line breaks,
and I know where to apply it exactly, I am willing to give it a try.
Comment 10 clippka 2011-01-19 12:44:30 UTC
Created attachment 75590 [details]
My proposed fix for this issue
Comment 11 hjs 2011-01-19 16:59:32 UTC
there is a typo at the end of the patch that ends up all test quick:
probably should be $(1) instead of ($1)
Comment 12 clippka 2011-01-31 11:17:56 UTC
cl->hjs: please integrate after testing
Comment 13 hjs 2011-01-31 11:42:01 UTC
added in gnumake3

http://hg.services.openoffice.org/cws/gnumake3/rev/f495584800da
Comment 14 bjoern.michaelsen 2011-02-02 09:36:55 UTC
@fs: please verify