2323from __future__ import print_function
2424
2525import os
26+ import posixpath as path
2627import re
2728import subprocess
2829import gyp
@@ -221,7 +222,7 @@ def WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files,
221222
222223 gyp_binary = gyp .common .FixIfRelativePath (params ['gyp_binary' ], options .toplevel_dir )
223224 if not gyp_binary .startswith (os .sep ):
224- gyp_binary = os . path .join ('.' , gyp_binary )
225+ gyp_binary = path .join ('.' , gyp_binary )
225226
226227 root_makefile .write (
227228 "quiet_cmd_regen_makefile = ACTION Regenerating $@\n "
@@ -261,12 +262,12 @@ def CalculateMakefilePath(build_file_arg, base_name):
261262 # paths relative to the source root for the master makefile. Grab
262263 # the path of the .gyp file as the base to relativize against.
263264 # E.g. "foo/bar" when we're constructing targets for "foo/bar/baz.gyp".
264- base_makefile_path = gyp .common .RelativePath (os . path .dirname (build_file_arg ), options .depth )
265+ base_makefile_path = gyp .common .RelativePath (path .dirname (build_file_arg ), options .depth )
265266 # We write the file in the base_makefile_path directory.
266- output_makefile = os . path .join (options .depth , base_makefile_path , base_name )
267+ output_makefile = path .join (options .depth , base_makefile_path , base_name )
267268 if options .generator_output :
268- output_makefile = os . path .join (options .depth , options .generator_output , base_makefile_path , base_name )
269- base_makefile_path = gyp .common .RelativePath (os . path .dirname (build_file_arg ), options .toplevel_dir )
269+ output_makefile = path .join (options .depth , options .generator_output , base_makefile_path , base_name )
270+ base_makefile_path = gyp .common .RelativePath (path .dirname (build_file_arg ), options .toplevel_dir )
270271 return base_makefile_path , output_makefile
271272
272273 # TODO: search for the first non-'Default' target. This can go
@@ -284,9 +285,9 @@ def CalculateMakefilePath(build_file_arg, base_name):
284285
285286 srcdir = '.'
286287 makefile_name = 'Makefile' + options .suffix
287- makefile_path = os . path .join (options .toplevel_dir , makefile_name )
288+ makefile_path = path .join (options .toplevel_dir , makefile_name )
288289 if options .generator_output :
289- makefile_path = os . path .join (options .toplevel_dir , options .generator_output , makefile_name )
290+ makefile_path = path .join (options .toplevel_dir , options .generator_output , makefile_name )
290291 srcdir = gyp .common .RelativePath (srcdir , options .generator_output )
291292 Sourceify .srcdir_prefix = '$(srcdir)/'
292293
@@ -407,7 +408,7 @@ def CalculateMakefilePath(build_file_arg, base_name):
407408 WriteRootHeaderSuffixRules (root_makefile )
408409
409410 # Put build-time support tools next to the root Makefile.
410- dest_path = os . path .dirname (makefile_path )
411+ dest_path = path .dirname (makefile_path )
411412 gyp .common .CopyTool (flavor , dest_path )
412413
413414 # Find the list of targets that derive from the gyp file(s) being built.
@@ -437,7 +438,7 @@ def CalculateMakefilePath(build_file_arg, base_name):
437438 gyp .common .UnrelativePath (included_file , build_file ),
438439 options .toplevel_dir
439440 )
440- abs_include_file = os . path .abspath (relative_include_file )
441+ abs_include_file = path .abspath (relative_include_file )
441442 # If the include file is from the ~/.gyp dir, we should use absolute path
442443 # so that relocating the src dir doesn't break the path.
443444 if params ['home_dot_gyp' ] and abs_include_file .startswith (params ['home_dot_gyp' ]):
@@ -458,7 +459,7 @@ def CalculateMakefilePath(build_file_arg, base_name):
458459
459460 # Our root_makefile lives at the source root. Compute the relative path
460461 # from there to the output_file for including.
461- mkfile_rel_path = gyp .common .RelativePath (output_file , os . path .dirname (makefile_path ))
462+ mkfile_rel_path = gyp .common .RelativePath (output_file , path .dirname (makefile_path ))
462463 include_list .add (mkfile_rel_path )
463464
464465 assert writer
@@ -468,14 +469,14 @@ def CalculateMakefilePath(build_file_arg, base_name):
468469 # The paths in build_files were relativized above, so undo that before
469470 # testing against the non-relativized items in target_list and before
470471 # calculating the Makefile path.
471- build_file_path = os . path .join (depth_rel_path , build_file )
472+ build_file_path = path .join (depth_rel_path , build_file )
472473 related_gyp_targets = [t for t in target_list if t .startswith (build_file ) and t in needed_targets ]
473474 # Only generate Makefiles for gyp files with targets.
474475 if not related_gyp_targets :
475476 continue
476- build_file_name = "%s.Makefile" % os . path .splitext (os . path .basename (build_file ))[0 ]
477+ build_file_name = "%s.Makefile" % path .splitext (path .basename (build_file ))[0 ]
477478 _ , submake_output_file = CalculateMakefilePath (build_file_path , build_file_name )
478- makefile_rel_path = gyp .common .RelativePath (os . path .dirname (makefile_path ), os . path .dirname (submake_output_file ))
479+ makefile_rel_path = gyp .common .RelativePath (path .dirname (makefile_path ), path .dirname (submake_output_file ))
479480 gyp_targets_names = [target_dicts [t ]['target_name' ] for t in related_gyp_targets ]
480481 writer .WriteSubMake (submake_output_file , makefile_rel_path , gyp_targets_names , builddir_name )
481482
@@ -547,7 +548,7 @@ def CalculateGeneratorInputInfo(params):
547548 output_dir = params ['options' ].generator_output or \
548549 params ['options' ].toplevel_dir
549550 builddir_name = generator_flags .get ('output_dir' , 'out' )
550- qualified_out_dir = os . path .normpath (os . path .join (
551+ qualified_out_dir = path .normpath (path .join (
551552 output_dir , builddir_name , 'gypfiles' ))
552553
553554 global generator_filelist_paths
0 commit comments