Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: pylib/gyp/generator/make.py

Issue 113463003: Use gyp.common.EnsureDirExists() in more places. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pylib/gyp/generator/eclipse.py ('k') | pylib/gyp/generator/msvs.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 Google Inc. All rights reserved. 1 # Copyright (c) 2013 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Notes: 5 # Notes:
6 # 6 #
7 # This is all roughly based on the Makefile system used by the Linux 7 # This is all roughly based on the Makefile system used by the Linux
8 # kernel, but is a non-recursive make -- we put the entire dependency 8 # kernel, but is a non-recursive make -- we put the entire dependency
9 # graph in front of make and let it figure it out. 9 # graph in front of make and let it figure it out.
10 # 10 #
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 qualified_out_dir = os.path.normpath(os.path.join( 110 qualified_out_dir = os.path.normpath(os.path.join(
111 output_dir, builddir_name, 'gypfiles')) 111 output_dir, builddir_name, 'gypfiles'))
112 112
113 global generator_filelist_paths 113 global generator_filelist_paths
114 generator_filelist_paths = { 114 generator_filelist_paths = {
115 'toplevel': params['options'].toplevel_dir, 115 'toplevel': params['options'].toplevel_dir,
116 'qualified_out_dir': qualified_out_dir, 116 'qualified_out_dir': qualified_out_dir,
117 } 117 }
118 118
119 119
120 def ensure_directory_exists(path):
121 dir = os.path.dirname(path)
122 if dir and not os.path.exists(dir):
123 os.makedirs(dir)
124
125
126 # The .d checking code below uses these functions: 120 # The .d checking code below uses these functions:
127 # wildcard, sort, foreach, shell, wordlist 121 # wildcard, sort, foreach, shell, wordlist
128 # wildcard can handle spaces, the rest can't. 122 # wildcard can handle spaces, the rest can't.
129 # Since I could find no way to make foreach work with spaces in filenames 123 # Since I could find no way to make foreach work with spaces in filenames
130 # correctly, the .d files have spaces replaced with another character. The .d 124 # correctly, the .d files have spaces replaced with another character. The .d
131 # file for 125 # file for
132 # Chromium\ Framework.framework/foo 126 # Chromium\ Framework.framework/foo
133 # is for example 127 # is for example
134 # out/Release/.deps/out/Release/Chromium?Framework.framework/foo 128 # out/Release/.deps/out/Release/Chromium?Framework.framework/foo
135 # This is the replacement character. 129 # This is the replacement character.
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 """The main entry point: writes a .mk file for a single target. 678 """The main entry point: writes a .mk file for a single target.
685 679
686 Arguments: 680 Arguments:
687 qualified_target: target we're generating 681 qualified_target: target we're generating
688 base_path: path relative to source root we're building in, used to resolve 682 base_path: path relative to source root we're building in, used to resolve
689 target-relative paths 683 target-relative paths
690 output_filename: output .mk file name to write 684 output_filename: output .mk file name to write
691 spec, configs: gyp info 685 spec, configs: gyp info
692 part_of_all: flag indicating this target is part of 'all' 686 part_of_all: flag indicating this target is part of 'all'
693 """ 687 """
694 ensure_directory_exists(output_filename) 688 gyp.common.EnsureDirExists(output_filename)
695 689
696 self.fp = open(output_filename, 'w') 690 self.fp = open(output_filename, 'w')
697 691
698 self.fp.write(header) 692 self.fp.write(header)
699 693
700 self.qualified_target = qualified_target 694 self.qualified_target = qualified_target
701 self.path = base_path 695 self.path = base_path
702 self.target = spec['target_name'] 696 self.target = spec['target_name']
703 self.type = spec['type'] 697 self.type = spec['type']
704 self.toolset = spec['toolset'] 698 self.toolset = spec['toolset']
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 807
814 This is a small, wrapper Makefile that calls the top-level Makefile to build 808 This is a small, wrapper Makefile that calls the top-level Makefile to build
815 the targets from a single gyp file (i.e. a sub-project). 809 the targets from a single gyp file (i.e. a sub-project).
816 810
817 Arguments: 811 Arguments:
818 output_filename: sub-project Makefile name to write 812 output_filename: sub-project Makefile name to write
819 makefile_path: path to the top-level Makefile 813 makefile_path: path to the top-level Makefile
820 targets: list of "all" targets for this sub-project 814 targets: list of "all" targets for this sub-project
821 build_dir: build output directory, relative to the sub-project 815 build_dir: build output directory, relative to the sub-project
822 """ 816 """
823 ensure_directory_exists(output_filename) 817 gyp.common.EnsureDirExists(output_filename)
824 self.fp = open(output_filename, 'w') 818 self.fp = open(output_filename, 'w')
825 self.fp.write(header) 819 self.fp.write(header)
826 # For consistency with other builders, put sub-project build output in the 820 # For consistency with other builders, put sub-project build output in the
827 # sub-project dir (see test/subdirectory/gyptest-subdir-all.py). 821 # sub-project dir (see test/subdirectory/gyptest-subdir-all.py).
828 self.WriteLn('export builddir_name ?= %s' % 822 self.WriteLn('export builddir_name ?= %s' %
829 os.path.join(os.path.dirname(output_filename), build_dir)) 823 os.path.join(os.path.dirname(output_filename), build_dir))
830 self.WriteLn('.PHONY: all') 824 self.WriteLn('.PHONY: all')
831 self.WriteLn('all:') 825 self.WriteLn('all:')
832 if makefile_path: 826 if makefile_path:
833 makefile_path = ' -C ' + makefile_path 827 makefile_path = ' -C ' + makefile_path
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 value = os.environ[key] 2054 value = os.environ[key]
2061 make_global_settings += ' %s = %s\n' % (key, value) 2055 make_global_settings += ' %s = %s\n' % (key, value)
2062 make_global_settings += 'endif\n' 2056 make_global_settings += 'endif\n'
2063 else: 2057 else:
2064 make_global_settings += '%s ?= %s\n' % (key, value) 2058 make_global_settings += '%s ?= %s\n' % (key, value)
2065 # TODO(ukai): define cmd when only wrapper is specified in 2059 # TODO(ukai): define cmd when only wrapper is specified in
2066 # make_global_settings. 2060 # make_global_settings.
2067 2061
2068 header_params['make_global_settings'] = make_global_settings 2062 header_params['make_global_settings'] = make_global_settings
2069 2063
2070 ensure_directory_exists(makefile_path) 2064 gyp.common.EnsureDirExists(makefile_path)
2071 root_makefile = open(makefile_path, 'w') 2065 root_makefile = open(makefile_path, 'w')
2072 root_makefile.write(SHARED_HEADER % header_params) 2066 root_makefile.write(SHARED_HEADER % header_params)
2073 # Currently any versions have the same effect, but in future the behavior 2067 # Currently any versions have the same effect, but in future the behavior
2074 # could be different. 2068 # could be different.
2075 if android_ndk_version: 2069 if android_ndk_version:
2076 root_makefile.write( 2070 root_makefile.write(
2077 '# Define LOCAL_PATH for build of Android applications.\n' 2071 '# Define LOCAL_PATH for build of Android applications.\n'
2078 'LOCAL_PATH := $(call my-dir)\n' 2072 'LOCAL_PATH := $(call my-dir)\n'
2079 '\n') 2073 '\n')
2080 for toolset in toolsets: 2074 for toolset in toolsets:
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 root_makefile.write("endif\n") 2168 root_makefile.write("endif\n")
2175 root_makefile.write('\n') 2169 root_makefile.write('\n')
2176 2170
2177 if (not generator_flags.get('standalone') 2171 if (not generator_flags.get('standalone')
2178 and generator_flags.get('auto_regeneration', True)): 2172 and generator_flags.get('auto_regeneration', True)):
2179 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) 2173 WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files)
2180 2174
2181 root_makefile.write(SHARED_FOOTER) 2175 root_makefile.write(SHARED_FOOTER)
2182 2176
2183 root_makefile.close() 2177 root_makefile.close()
OLDNEW
« no previous file with comments | « pylib/gyp/generator/eclipse.py ('k') | pylib/gyp/generator/msvs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698