msvs_emulation.py destroy relative path

35 views
Skip to first unread message

KOBAYASHI Koji

unread,
Sep 15, 2018, 8:47:25 PM9/15/18
to gyp-developer
Dear all.

I find that gyp erase some argument when gyp invoke python script in Windows 10.

Following is excerption from error code.
# I'm trying to update gyp revision in mozc project.

https://github.com/google/mozc/blob/master/src/data_manager/data_manager_base.gypi
_________________________________________________________
# mozc_dir: ../..
# platform_data_dir: '<(mozc_dir)/data/dictionary_oss'

    ......
    {
      'target_name': 'gen_separate_user_pos_data_for_<(dataset_tag)',
    ......
      'actions': [
        {
          'action_name': 'gen_separate_user_pos_data_for_<(dataset_tag)',
          'variables': {
            'id_def': '<(platform_data_dir)/id.def',
          ......
          'action': [
            'python', '<(mozc_dir)/dictionary/gen_user_pos_data.py',
            '--id_file=<(id_def)',
          ......
_________________________________________________________
GYP previous revision (before ae76d91) can keep id_file argument,
but current revision (after b62d04f) cannot.

So we would like to ignore path normalization in msvs_emulation.py.
_________________________________________________________
Index: pylib/gyp/msvs_emulation.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- pylib/gyp/msvs_emulation.py    (revision 81286d388abf5c8f946f3f4be274bd987a690952)
+++ pylib/gyp/msvs_emulation.py    (date 1537055731000)
@@ -31,8 +31,8 @@
   # use that function to handle command line arguments.
 
   # Use a heuristic to try to find args that are paths, and normalize them
-  if arg.find('/') > 0 or arg.count('/') > 1:
-    arg = os.path.normpath(arg)
+  # if arg.find('/') > 0 or arg.count('/') > 1:
+  #   arg = os.path.normpath(arg)
 
   # For a literal quote, CommandLineToArgvW requires 2n+1 backslashes
   # preceding it, and results in n backslashes + the quote. So we substitute

_________________________________________________________

Thanks,
Koji

Scott Graham

unread,
Sep 17, 2018, 1:44:27 PM9/17/18
to coooo...@gmail.com, gyp-developer
Yeah, that part of that change https://chromium-review.googlesource.com/c/external/gyp/+/482580 was problematic for other people too. I thought it had been reverted, but I guess not. I think it should be still.

--

---
You received this message because you are subscribed to the Google Groups "gyp-developer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gyp-develope...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

coooo...@gmail.com

unread,
Sep 18, 2018, 10:02:16 AM9/18/18
to Scott Graham, gyp-developer
convenientDear Scott.

Thank you for your comment.
Yes, the problem is same as my problem.

It is troublesome problem because;
- it is difficult to find bug because "arg" become None object
and cause error with meaningless message.
# especially it is difficult for python novice programmer (like me).
- it cause different behavior between Windows and other OS.

Actually, I update master branch of GYP
https://chromium.googlesource.com/external/gyp/+/master/pylib/gyp/msvs_emulation.py
in mozc and I get in trouble for meaningless error messsage.


Of cause, current code is also convenient many cases, but I also think
that it is necessary to treat raw argument strings to avoid unexpected
behavior.
So I think that some flags that force "treat argument as raw string" is
necessary. What do you think about this?

Regards.
KOBAYASHI Koji


_______________________________________
> <mailto:gyp-develope...@googlegroups.com>.

鈴見咲 君高Suzumizaki-Kimitaka

unread,
Jan 3, 2019, 1:33:13 AM1/3/19
to gyp-developer
At the project "mozc" case, there are 2 kinds of problematic arguments at least. 

One is Python's optparse style as KOBAYASHI said:
'--input=../../data/dictionary_oss/dictionary00.txt'

Another one is mozc specific argument style:
'pos_matcher:32:..\..\out_win\Debug\gen\data_manager\chromeos\pos_matcher.data'

The returned values of os.path.normpath() as the arguments above are:
'data\dictionary_oss\dictionary00.txt'
'out_win\Debug\gen\data_manager\chromeos\pos_matcher.data'

'--input=' and 'pos_matcher:32:..\..\' are lost.

I think the caller of os.path.normpath(arg) should assume the given arg is the path on the local machines.
But the GYP cannot do without additional informations.
I don't know why os.path.normpath is REQUIRED here, but I guess that's logically wrong.

2018年9月18日火曜日 2時44分27秒 UTC+9 Scott Graham:

鈴見咲 君高Suzumizaki-Kimitaka

unread,
Jan 3, 2019, 7:50:05 PM1/3/19
to gyp-developer
I reported as the new issue at:
https://bugs.chromium.org/p/gyp/issues/detail?id=543

2019年1月3日木曜日 15時33分13秒 UTC+9 鈴見咲 君高Suzumizaki-Kimitaka:
Reply all
Reply to author
Forward
0 new messages