
    Kbi                       d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dlm
Z
 d dlZddddddd	d
dddddddZdZdag ag ag adad Zd ZdZdZdZdZdZdZdez   dz   ez   dz   ez   dz   ez   d z   ez   d!z   Zd"Zd# Zd$Zd%Zd&Z d'Z!d(d)d)d)d(d(d*Z"d+ Z#d, Z$d- Z%d. Z&d/ Z'd0 Z(d1 Z)d2 Z*da+d3 Z,d<d5Z-d6 Z.i Z/i Z0 G d7 d8e1          Z2d9 Z3d: Z4d; Z5dS )=    )print_functionN)GetEnvironFallback)GypError lib.az $(obj).$(TOOLSET)/$(TARGET)/geniz
$(obj)/gen$(builddir)%(INPUT_ROOT)s%(INPUT_DIRNAME)sz$(abspath $<)z$(suffix $<)z$(notdir $<)$(BUILDTYPE))EXECUTABLE_PREFIXEXECUTABLE_SUFFIXSTATIC_LIB_PREFIXSHARED_LIB_PREFIXSTATIC_LIB_SUFFIXINTERMEDIATE_DIRSHARED_INTERMEDIATE_DIRPRODUCT_DIRRULE_INPUT_ROOTRULE_INPUT_DIRNAMERULE_INPUT_PATHRULE_INPUT_EXTRULE_INPUT_NAMECONFIGURATION_NAMETFc                    t           j                            |          }|dk    r|                     dd           |                     dd           |                     dt          d                    |                     dt          d                    dd	lmc m} t          |d
g           a	t          |dg           a
t          |dg           at                              ddd           d	S |}|dk    rd}|                     d|           |dk    r|                     dd           n|                     dd           |                     dd           |                     dd           d	S )zDCalculate additional variables for use in the build (called by gyp).macOSSHARED_LIB_SUFFIXz.dylibSHARED_LIB_DIRr   LIB_DIRr   N+generator_additional_non_configuration_keys"generator_additional_path_sections!generator_extra_sources_for_rulesobjcobjcxx).m.mmandroidlinuxaixr   .soz$(builddir)/lib.$(TOOLSET)z$(obj).$(TOOLSET))gypcommon	GetFlavor
setdefaultgenerator_default_variablesgyp.generator.xcode	generatorxcodegetattrr!   r"   r#   COMPILABLE_EXTENSIONSupdate)default_variablesparamsflavorxcode_generatoroperating_systems        4/usr/lib/python3/dist-packages/gyp/generator/make.pyCalculateVariablesr=   D   s   :''&u__  u---  !4h???  !1!<]!KM M M  !<]!KM M M
 21111111129/5r3; 3;/ *1,b*2 *2& )0+R)1 )1%  !A!ABBBBB   '7888""#6====""#6>>>  !12NOOO  ,?@@@@@    c                 b   |                      di           }|                     dd          }|rda| d         j        p| d         j        }|                     dd          }t          j                            t          j                            ||d                    }| d         j        |d	adS )
zOCalculate the generator specific info that gets fed to input (called by
  gyp).generator_flagsandroid_ndk_versionNToptions
output_diroutgypfiles)toplevelqualified_out_dir)	get#generator_wants_sorted_dependenciesgenerator_outputtoplevel_dirospathnormpathjoingenerator_filelist_paths)r8   r@   rA   rC   builddir_namerG   s         r<   CalculateGeneratorInputInforR   i   s     JJ0"55/'++,A4HH /*.'i 1 .i - !%%lE::-g&&rw||z(+ (+ , ,
 y!.* r>   ?a  quiet_cmd_alink = AR($(TOOLSET)) $@
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)

quiet_cmd_alink_thin = AR($(TOOLSET)) $@
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)

# Due to circular dependencies between libraries :(, we wrap the
# special "figure out circular dependencies" flags around the entire
# input list during linking.
quiet_cmd_link = LINK($(TOOLSET)) $@
cmd_link = $(LINK.$(TOOLSET)) -o $@ $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,--start-group $(LD_INPUTS) $(LIBS) -Wl,--end-group

# We support two kinds of shared objects (.so):
# 1) shared_library, which is just bundling together many dependent libraries
# into a link line.
# 2) loadable_module, which is generating a module intended for dlopen().
#
# They differ only slightly:
# In the former case, we want to package all dependent code into the .so.
# In the latter case, we want to package just the API exposed by the
# outermost module.
# This means shared_library uses --whole-archive, while loadable_module doesn't.
# (Note that --whole-archive is incompatible with the --start-group used in
# normal linking.)

# Other shared-object link notes:
# - Set SONAME to the library filename so our binaries don't reference
# the local, absolute paths used on the link command-line.
quiet_cmd_solink = SOLINK($(TOOLSET)) $@
cmd_solink = $(LINK.$(TOOLSET)) -o $@ -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS)

quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -o $@ -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
ah  quiet_cmd_alink = LIBTOOL-STATIC $@
cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^)

quiet_cmd_link = LINK($(TOOLSET)) $@
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)

quiet_cmd_solink = SOLINK($(TOOLSET)) $@
cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)

quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
a  quiet_cmd_alink = AR($(TOOLSET)) $@
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)

quiet_cmd_alink_thin = AR($(TOOLSET)) $@
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)

# Due to circular dependencies between libraries :(, we wrap the
# special "figure out circular dependencies" flags around the entire
# input list during linking.
quiet_cmd_link = LINK($(TOOLSET)) $@
quiet_cmd_link_host = LINK($(TOOLSET)) $@
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS)
cmd_link_host = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)

# Other shared-object link notes:
# - Set SONAME to the library filename so our binaries don't reference
# the local, absolute paths used on the link command-line.
quiet_cmd_solink = SOLINK($(TOOLSET)) $@
cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS)

quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
quiet_cmd_solink_module_host = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module_host = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
a  quiet_cmd_alink = AR($(TOOLSET)) $@
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) -X32_64 crs $@ $(filter %.o,$^)

quiet_cmd_alink_thin = AR($(TOOLSET)) $@
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) -X32_64 crs $@ $(filter %.o,$^)

quiet_cmd_link = LINK($(TOOLSET)) $@
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)

quiet_cmd_solink = SOLINK($(TOOLSET)) $@
cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)

quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
a  quiet_cmd_alink = AR($(TOOLSET)) $@
cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^)

quiet_cmd_alink_thin = AR($(TOOLSET)) $@
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)

quiet_cmd_link = LINK($(TOOLSET)) $@
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS)

quiet_cmd_solink = SOLINK($(TOOLSET)) $@
cmd_solink = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(LD_INPUTS) $(LIBS) -Wl,DLL

quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) -Wl,DLL
a.	  # We borrow heavily from the kernel build setup, though we are simpler since
# we don't have Kconfig tweaking settings on us.

# The implicit make rules have it looking for RCS files, among other things.
# We instead explicitly write all the rules we care about.
# It's even quicker (saves ~200ms) to pass -r on the command line.
MAKEFLAGS=-r

# The source directory tree.
srcdir := %(srcdir)s
abs_srcdir := $(abspath $(srcdir))

# The name of the builddir.
builddir_name ?= %(builddir)s

# The V=1 flag on command line makes us verbosely print command lines.
ifdef V
  quiet=
else
  quiet=quiet_
endif

# Specify BUILDTYPE=Release on the command line for a release build.
BUILDTYPE ?= %(default_configuration)s

# Directory all our build output goes into.
# Note that this must be two directories beneath src/ for unit tests to pass,
# as they reach into the src/ directory for data with relative paths.
builddir ?= $(builddir_name)/$(BUILDTYPE)
abs_builddir := $(abspath $(builddir))
depsdir := $(builddir)/.deps

# Object output directory.
obj := $(builddir)/obj
abs_obj := $(abspath $(obj))

# We build up a list of every single one of the targets so we can slurp in the
# generated dependency rule Makefiles in one pass.
all_deps :=

%(make_global_settings)s

CC.target ?= %(CC.target)s
CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS)
CXX.target ?= %(CXX.target)s
CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS)
LINK.target ?= %(LINK.target)s
LDFLAGS.target ?= $(LDFLAGS)
AR.target ?= $(AR)

# C++ apps need to be linked with g++.
LINK ?= $(CXX.target)

# TODO(evan): move all cross-compilation logic to gyp-time so we don't need
# to replicate this environment fallback in make as well.
CC.host ?= %(CC.host)s
CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host)
CXX.host ?= %(CXX.host)s
CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host)
LINK.host ?= %(LINK.host)s
LDFLAGS.host ?= $(LDFLAGS_host)
AR.host ?= %(AR.host)s

# Define a dir function that can handle spaces.
# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
# "leading spaces cannot appear in the text of the first argument as written.
# These characters can be put into the argument value by variable substitution."
empty :=
space := $(empty) $(empty)

# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces
replace_spaces = $(subst $(space),z ,$1)
unreplace_spaces = $(subst a  ,$(space),$1)
dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1)))

# Flags to make gcc output dependency info.  Note that you need to be
# careful here to use the flags that ccache and distcc can understand.
# We write to a dep file on the side first and then rename at the end
# so we can't end up with a broken dep file.
depfile = $(depsdir)/$(call replace_spaces,$@).d
DEPFLAGS = %(makedep_args)s -MF $(depfile).raw

# We have to fixup the deps output in a few ways.
# (1) the file output should mention the proper .o file.
# ccache or distcc lose the path to the target, so we convert a rule of
# the form:
#   foobar.o: DEP1 DEP2
# into
#   path/to/foobar.o: DEP1 DEP2
# (2) we want missing files not to cause us to fail to build.
# We want to rewrite
#   foobar.o: DEP1 DEP2 \
#               DEP3
# to
#   DEP1:
#   DEP2:
#   DEP3:
# so if the files are missing, they're just considered phony rules.
# We have to do some pretty insane escaping to get those backslashes
# and dollar signs past make, the shell, and sed at the same time.
# Doesn't work with spaces, but that's fine: .d files have spaces in
# their names replaced with other characters.
define fixup_dep
# The depfile may not exist if the input file didn't have any #includes.
touch $(depfile).raw
# Fixup path as in (1).
sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
# Add extra rules as in (2).
# We remove slashes and replace spaces with new lines;
# remove blank lines;
# delete the first line and append a colon to the remaining lines.
sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
  grep -v '^$$'                             |\
  sed -e 1d -e 's|$$|:|'                     \
    >> $(depfile)
rm $(depfile).raw
endef

# Command definitions:
# - cmd_foo is the actual command to run;
# - quiet_cmd_foo is the brief-output summary of the command.

quiet_cmd_cc = CC($(TOOLSET)) $@
cmd_cc = $(CC.$(TOOLSET)) -o $@ $< $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c

quiet_cmd_cxx = CXX($(TOOLSET)) $@
cmd_cxx = $(CXX.$(TOOLSET)) -o $@ $< $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c
%(extra_commands)s
quiet_cmd_touch = TOUCH $@
cmd_touch = touch $@

quiet_cmd_copy = COPY $@
# send stderr to /dev/null to ignore messages when linking directories.
cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp %(copy_archive_args)s "$<" "$@")

%(link_commands)s

# Define an escape_quotes function to escape single quotes.
# This allows us to handle quotes properly as long as we always use
# use single quotes and escape_quotes.
escape_quotes = $(subst ','\'',$(1))
# This comment is here just to include a ' to unconfuse syntax highlighting.
# Define an escape_vars function to escape '$' variable syntax.
# This allows us to read/write command lines with shell variables (e.g.
# $LD_LIBRARY_PATH), without triggering make substitution.
escape_vars = $(subst $$,$$$$,$(1))
# Helper that expands to a shell command to echo a string exactly as it is in
# make. This uses printf instead of echo because printf's behaviour with respect
# to escape sequences is more portable than echo's across different shells
# (e.g., dash, bash).
exact_echo = printf '%%s\n' '$(call escape_quotes,$(1))'

# Helper to compare the command we're about to run against the command
# we logged the last time we ran the command.  Produces an empty
# string (false) when the commands match.
# Tricky point: Make has no string-equality test function.
# The kernel uses the following, but it seems like it would have false
# positives, where one string reordered its arguments.
#   arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
#                       $(filter-out $(cmd_$@), $(cmd_$(1))))
# We instead substitute each for the empty string into the other, and
# say they're equal if both substitutions produce the empty string.
# .d files contain aa   instead of spaces, take that into account.
command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\
                       $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1))))

# Helper that is non-empty when a prerequisite changes.
# Normally make does this implicitly, but we force rules to always run
# so we can check their command lines.
#   $? -- new prerequisites
#   $| -- order-only dependencies
prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?))

# Helper that executes all postbuilds until one fails.
define do_postbuilds
  @E=0;\
  for p in $(POSTBUILDS); do\
    eval $$p;\
    E=$$?;\
    if [ $$E -ne 0 ]; then\
      break;\
    fi;\
  done;\
  if [ $$E -ne 0 ]; then\
    rm -rf "$@";\
    exit $$E;\
  fi
endef

# do_cmd: run a command via the above cmd_foo names, if necessary.
# Should always run for a given target to handle command-line changes.
# Second argument, if non-zero, makes it do asm/C/C++ dependency munging.
# Third argument, if non-zero, makes it do POSTBUILDS processing.
# Note: We intentionally do NOT call dirx for depfile, since it contains z* for
# spaces already and dirx strips the a   characters.
define do_cmd
$(if $(or $(command_changed),$(prereq_changed)),
  @$(call exact_echo,  $($(quiet)cmd_$(1)))
  @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))"
  $(if $(findstring flock,$(word %(flock_index)d,$(cmd_$1))),
    @$(cmd_$(1))
    @echo "  $(quiet_cmd_$(1)): Finished",
    @$(cmd_$(1))
  )
  @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile)
  @$(if $(2),$(fixup_dep))
  $(if $(and $(3), $(POSTBUILDS)),
    $(call do_postbuilds)
  )
)
endef

# Declare the "%(default_target)s" target first so it is the default,
# even though we don't have the deps yet.
.PHONY: %(default_target)s
%(default_target)s:

# make looks for ways to re-generate included makefiles, but in our case, we
# don't have a direct way. Explicitly telling make that it has nothing to do
# for them makes it go faster.
%%.d: ;

# Use FORCE_DO_CMD to force a target to run.  Should be coupled with
# do_cmd.
.PHONY: FORCE_DO_CMD
FORCE_DO_CMD:

a  
quiet_cmd_objc = CXX($(TOOLSET)) $@
cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<

quiet_cmd_objcxx = CXX($(TOOLSET)) $@
cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $<

# Commands for precompiled header files.
quiet_cmd_pch_c = CXX($(TOOLSET)) $@
cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
quiet_cmd_pch_cc = CXX($(TOOLSET)) $@
cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
quiet_cmd_pch_m = CXX($(TOOLSET)) $@
cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<
quiet_cmd_pch_mm = CXX($(TOOLSET)) $@
cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $<

# gyp-mac-tool is written next to the root Makefile by gyp.
# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd
# already.
quiet_cmd_mac_tool = MACTOOL $(4) $<
cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@"

quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@
cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4)

quiet_cmd_infoplist = INFOPLIST $@
cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@"
c                    t          t                                          t          j                  }|                     d           |D ]=}|                     d|z             |                     dt          |         z             >|                     d           |D ]=}|                     d|z             |                     dt          |         z             >|                     d           |D ]=}|                     d|z             |                     dt          |         z             >|                     d           d S )	N)key1# Suffix rules, putting all outputs into $(obj).
z4$(obj).$(TOOLSET)/%%.o: $(srcdir)/%%%s FORCE_DO_CMD
z	@$(call do_cmd,%s,1)
z,
# Try building from generated source, too.
z<$(obj).$(TOOLSET)/%%.o: $(obj).$(TOOLSET)/%%%s FORCE_DO_CMD

z1$(obj).$(TOOLSET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
)sortedr5   keysstrlowerwrite)writer
extensionsexts      r<   WriteRootHeaderSuffixRulesr`     sZ   +0022	BBB*,,CDDD J Jc
LLH3NOOO
LL+.CC.HHIIII,,?@@@ J Jc
LLG#MO O O
LL+.CC.HHIIII,,t J Jc
LLEKLLL
LL+.CC.HHIIII,,tr>   rV   z+# Try building from generated source, too.
a  # "all" is a concatenation of the "all" targets from all the included
# sub-makefiles. This is just here to clarify.
all:

# Add in dependency-tracking rules.  $(all_deps) is the list of every single
# target in our tree. Only consider the ones with .d (dependency) info:
d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d))
ifneq ($(d_files),)
  include $(d_files)
endif
z/# This file is generated by gyp; do not edit.

cccxx).c.cc.cpp.cxx.s.Sc                 >      fdt           D             D ]}|r dS dS )z:Return true if the file is compilable (should be in OBJS).c              3   B   K   | ]}                     |          V  d S Nendswith).0efilenames     r<   	<genexpr>zCompilable.<locals>.<genexpr>J  s1      BBqh""BBBBBBr>   TF)r5   )rp   ress   ` r<   
Compilablers   H  s@    BBBB,ABBB  c
 TT	r>   c                 ,    |                      d          S )zAReturn true if the file is linkable (should be on the link line)..orl   rp   s    r<   Linkablerw   P  s    			4	 	  r>   c                 R    t           j                            |           d         dz   S )z1Translate a compilable filename to its .o target.r   ru   rL   rM   splitextrv   s    r<   Targetr{   U  s"    			(	#	#A	&	--r>   c                 :    d|                      dd          z   dz   S )zQuotes an argument so that it will be interpreted literally by a POSIX
     shell. Taken from
     http://stackoverflow.com/questions/35817/whats-the-best-way-to-escape-ossystem-calls-in-python
     'z'\''replacess    r<   EscapeShellArgumentr   Z  s"    
 
qyyg&&	&	,,r>   c                 .    |                      dd          S )zrMake has its own variable expansion syntax using $. We must escape it for
     string to be interpreted literally.$z$$r~   r   s    r<   EscapeMakeVariableExpansionr   b  s     
3		r>   c                 j    t          |           } t          |           } |                     dd          S )zBEscapes a CPP define so that it will reach the compiler unaltered.#z\#)r   r   r   r   s    r<   EscapeCppDefiner   h  s2    !!!!$$! 
3		r>   c                 F    d| v rd|                      dd          z   dz   } | S )zSTODO: Should this ideally be replaced with one or more of the above
     functions?"z\"r~   strings    r<   QuoteIfNecessaryr   q  s/     	F]]6>>#u---3F	-r>   c                 .    t          j        dd|           S )zGConvert a string to a value that is acceptable as a make variable name.z[^a-zA-Z0-9_]_)resubr   s    r<   StringToMakefileVariabler   y  s    	f	-	--r>   c                 d    d| v r| S t           j                            |           r| S t          | z   S )z,Convert a path to its source directory form.$()rL   rM   isabssrcdir_prefix)rM   s    r<   	Sourceifyr     s6    	T\\KW]]4 K		r>   \ c                 .    |                      d|          S )N r~   )r   quotes     r<   QuoteSpacesr     s    	
3		r>   c                 .   |                      dd          dk    rdS i }|D ]s}t          j                            |          \  }}|dv }|s+t          j                            |          }|                    |g                               |           td}|                                D ]7\  }}	t          |	          dk    r|d|dd		                    |	          d
z  }8|r0t          d| d         z  |z   dz   dz              t          d          dS )zMakes sure if duplicate basenames are not specified in the source list.

  Arguments:
    spec: The target dictionary containing the properties of the target.
  typeNstatic_library)rc   rd   re   rf   r&   r'   rg   rh   r        : r   rW   z<static library %s has several files with the same basename:
target_namezlibtool on OS X will generatez warnings for them.z6Duplicate basenames in sources section, see list above)rH   rL   rM   rz   basenamer/   appenditemslenrO   printr   )
specall_sources	basenamessourcenamer_   is_compiled_filer   errorfiless
             r<   _ValidateSourcesForOSXr     s]    
XXfd///
F) 6 6f  ((ID# > > w%%H2&&--f5555
%"** : :oh
5zzA~~exxx%99e
 M	
I
}
 %&(GH
  ! ! ! K
L
LL	M Mr>   c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd ZddefdZ	 	 d$dZ	 	 d%dZd Zd&dZd'dZd Zd Zd Zd  Z d! Z!d" Z"d# Z#dS )(MakefileWriterzMakefileWriter packages up the writing of one target-specific foobar.mk.

  Its only real entry point is Write(), and is mostly used for namespacing.
  c           	         || _         || _        i | _        i | _        i | _        t
                                          D ]}| j                            |d|dt
          |         di           | j                            |d|dt
          |         di           | j                            |d|dt
          |         di           d S )Nz,$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%z FORCE_DO_CMD
	@$(call do_cmd,z,1)
z4$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%z)$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%)r@   r9   suffix_rules_srcdirsuffix_rules_objdir1suffix_rules_objdir2r5   rY   r6   )selfr@   r9   r_   s       r<   __init__zMakefileWriter.__init__  s   *DDK!D "D "D %))++ + +
%%ss ss!#&&&.( '* + + + && ss!#&&&/( (* + + + && ss!#&&&/( (* + + + ++ +r>   c                 .
    t           j                            |           t          |d           _         j                            t                     | _        | _        |d          _	        |d          _
        |d          _        t           j                             j        |           _         j        dk    r%t           j                            |           _        nd _                             |          \  }}g }	g }
g }g }g } j        r5                     |           _                             |           _        n!                     |          x _         _        t1          |                    dd                     _        d	 _         j        s j
         j        v r>t8          j                             j                   _                                         }n j         _         j        }                      d
 j        z                                    d j	        z              d|v r !                    |d         |
|	||           d|v r "                    |d         |
|	||           d|v r #                    |d         |	|            j        rD|                    dg           |z   } $                    ||            %                    |           |                    dg           |
z   }|r~ j        dk    rtM          ||            '                    ||||	||t           j        (                     j         fd j)                             d |D             }|r                      tT                     tW          d |D                       }|D ]+}| j,        v r                        j,        |                    ,                      tZ                     |D ]+}| j.        v r                        j.        |                    ,|D ]+}| j/        v r                        j/        |                    ,                      d            j        r|0                     j                    1                    |||||z   ||	|           |td          |<    j
        dv r j        tf          |<    j4                            dd          r 5                     j	        ||            j        6                                 dS )a  The main entry point: writes a .mk file for a single target.

    Arguments:
      qualified_target: target we're generating
      base_path: path relative to source root we're building in, used to resolve
                 target-relative paths
      output_filename: output .mk file name to write
      spec, configs: gyp info
      part_of_all: flag indicating this target is part of 'all'
    wr   r   toolsetr   Nstandalone_static_libraryr   )
executableloadable_moduleshared_libraryzTOOLSET := z
TARGET := actionsrulescopiesmac_bundle_resourcessourcesc                 H    t                              |                     S rk   r   
Absolutifypr   s    r<   <lambda>z&MakefileWriter.Write.<locals>.<lambda>3  s    Ytq7I7I-J-J r>   c                 0    g | ]}t          |          |S  )rs   )rn   xs     r<   
<listcomp>z(MakefileWriter.Write.<locals>.<listcomp>5  s#    999q:a==9999r>   c                 X    g | ]'}t           j                            |          d          (S )r   ry   )rn   r   s     r<   r   z(MakefileWriter.Write.<locals>.<listcomp>8  s-    BBBQ"'**1--a0BBBr>   z!# End of this set of suffix rules)r   r   rA   )7r,   r-   EnsureDirExistsopenfpr\   headerqualified_targetrM   targetr   r   xcode_emulationIsMacBundler9   is_mac_bundleXcodeSettingsxcode_settingsComputeDepsComputeMacBundleOutputoutputComputeMacBundleBinaryOutputoutput_binaryComputeOutputboolrH   is_standalone_static_library_INSTALLABLE_TARGETSrL   r   alias_InstallableTargetInstallPathWriteLnWriteActions
WriteRulesWriteCopiesWriteMacBundleResourcesWriteMacInfoPlistr   WriteSourcesMacPrefixHeaderPchify#SHARED_HEADER_SUFFIX_RULES_COMMENT1setr   #SHARED_HEADER_SUFFIX_RULES_COMMENT2r   r   r   WriteTargettarget_outputstarget_link_depsr@   WriteAndroidNdkModuleRuleclose)r   r   	base_pathoutput_filenamer   configspart_of_alldeps	link_depsextra_outputsextra_sourcesextra_link_depsextra_mac_bundle_resourcesmac_bundle_depsinstall_pathall_mac_bundle_resourcesr   r   r^   r_   s   `                   r<   WritezMakefileWriter.Write  s^    J///?C((DGGMM&,DDI}%DKVDI	?DL,88dKKD{e/==dCCd d&&t,,OD)
 MMO!#O B//55dk<<TBBd)-););D)A)AAdkD&(,,a00)2 )2D%!3D) !	T...7##DK00dj7799ll;dj[lLL-...LL+,,, D
Y2KA A A $
ood7m]M0+? ? ? 4
tH~}kBBB  .
(()2
.
.1K
K 
""#;_MMM
_--- ((9b))M9K 5			 	t[111

4m
;


-
-!#J#J#J#Jk    :9K999g	 58999BB'BBBCC
 	8 	8CD,,,LL1#67778999 	9 	9CD---LL237888 	9 	9CD---LL2378888999  	5

 
 !3
4
4
4T7D/I*E$m[B B B (4N#$ y888+/+='(  5t<< J
$$T[+yIIIGMMOOOOOr>   c                 B   t           j                            |           t          |d          | _        | j                            t                     |                     dt          j	        
                    t          j	                            |          |          z             |                     d           |                     d           |rd|z   }|                     d|dd
                    |                     | j                                         dS )	a  Write a "sub-project" Makefile.

    This is a small, wrapper Makefile that calls the top-level Makefile to build
    the targets from a single gyp file (i.e. a sub-project).

    Arguments:
      output_filename: sub-project Makefile name to write
      makefile_path: path to the top-level Makefile
      targets: list of "all" targets for this sub-project
      build_dir: build output directory, relative to the sub-project
    r   zexport builddir_name ?= %sz.PHONY: allzall:z -C z	$(MAKE)r   N)r,   r-   r   r   r   r\   r   r   rL   rM   rO   dirnamer   )r   r   makefile_pathtargets	build_dirs        r<   WriteSubMakezMakefileWriter.WriteSubMake[  s     J///?C((DGGMM& 	LL-bgooo>>	JJK L L LLLLL -},mLLL]]]CHHW4E4E4EFGGGGMMOOOOOr>   c                                                       |D ]}t           j        d|d                   }                     d|d         z             |d         }|d         }	t	                      }
|	D ]>}t
          j                            |          d         }|r|
                    |           ?t          |
                    dd                    r||	z  }t          |
                    d	d                    r||	z  }|d
         } j        dk    rfd|D             }t          j                            |          }d|v r#                     d|d|d         d           n                     d|d|d           t          |
          dk    rdd                    |
          z  dz   |z   }dt#           j        pd          z  }|                    d j                  }|                    d j                  }                     d|d||                                              fd|	D             }	                     dt)          |	d                   z                                  dt)          |	d                   z                                  |	d                                                      |D ]}d|vsJ d|z              |	D ]}d|vsJ d|z              fd|	D             }	fd|D             }                     |	t/          t"          t/           j        |                    ||            d!|z  }                     |d"d                    |	                     |                    d#|z                                                                                 d$S )%a  Write Makefile code for any 'actions' from the gyp input.

    extra_sources: a list that will be filled in with newly generated source
                   files, if any
    extra_outputs: a list that will be filled in with any outputs of these
                   actions (used to make other pieces dependent on these
                   actions)
    part_of_all: flag indicating this target is part of 'all'
    r   action_namez### Rules for action "%s":inputsoutputsr   process_outputs_as_sourcesF'process_outputs_as_mac_bundle_resourcesactionr   c                 P    g | ]"}t           j                            |          #S r   r,   r   ExpandEnvVarsrn   commandenvs     r<   r   z/MakefileWriter.WriteActions.<locals>.<listcomp>  s<     : : :% .<<WcJJ : : :r>   message
quiet_cmd_z
 = ACTION z $@zmkdir -p %sr   z; cd %s; .	$(TARGET)cmd_zj = LD_LIBRARY_PATH=$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; c                 :    g | ]}                     |          S r   r   rn   or   s     r<   r   z/MakefileWriter.WriteActions.<locals>.<listcomp>  s%    555##555r>   %s: obj := $(abs_obj)%s: builddir := $(abs_builddir)z3Spaces in action input filenames not supported (%s)z4Spaces in action output filenames not supported (%s)c                 P    g | ]"}t           j                            |          #S r   r  rn   r"  r  s     r<   r   z/MakefileWriter.WriteActions.<locals>.<listcomp>  s,    LLLq$221c::LLLr>   c                 P    g | ]"}t           j                            |          #S r   r  rn   ir  s     r<   r   z/MakefileWriter.WriteActions.<locals>.<listcomp>  s,    JJJa#11!S99JJJr>   )r   r  zaction_%s_outputs := $(%s)N)GetSortedXcodeEnvr   r   r   r   rL   rM   splitaddintrH   r9   r,   r-   EncodePOSIXShellListr   rO   r   r   r   r   WriteSortedXcodeEnv
WriteDoCmdmapr   r   )r   r   r   r   r  r   r  r   r  r  dirsrD   diraction_commandsr  	cd_actioninputr   outputs_variabler  s   `                  @r<   r   zMakefileWriter.WriteActionsv  sY    
 
 
"
"C S S%1F1F1F171F1F'H I Id
ll/&2GGHHHhfy!g UUd  #gmmC  # 	
((3---	VZZ4e<<	=	= ! 	VZZA5II	J	J ."g-" x(o			: : : :)8: : :
//@@g	f		dddF9<M<M<MNOOOOdddDDDABBB	TQ#((4..047'Ai	(8S999i
 T[99g##K==i lll ddIIww	0 1 1 1
 llnnn5555W555g ll*[-D-DDEEE
ll4{71:7N7NNOOO
wqz4+A+A+C+CDDD L L%%AUJ   N N&&   BfL !    MLLLGLLLgJJJJ6JJJf
oogs9c$/6.J.JKK"-t  = = = -t3
ll!1!1!1388G3D3D3DEFFF7%55666
llnnnnLLNNNNNr>   c                                                       |D ]*}t           j        d|d                   }d}                     d|z             g }	|                    dg           D ]u}
t                      }t          j                            |
          \  }t          j        	                    |          \  } fd|d         D             }|D ]8}t          j        
                    |          }|r|                    |           9t          |                    dd	                    r||z  }t          |                    d
d	                    r||z  }t          t          t           j        |
g|                    dg           z                       }d||fz  g}|dk    r|dgz  }fd|D             }fd|D             } fd|D             }|	|z  }	                     d|d         z                                  d|d         z                                  |||d||fz             t#          j        d          }|D ])}t#          j        |d|          }d|vsJ d|z              *                     dd                    |          z              fd|d         D             }d}t+          |          dk    rdd                    |          z  }dt           j        pd          z  } j        d k    rfd!|D             }t.          j                            |          }|                    d" j                  }|                    d" j                  }|                    d" j                  }                     d#|||||d$z                                  d%||d&z                                               |d'z  }wd(|z  }                     |	|           |                    d)|z                                  d*|z                                               ,                     d+                                d           d,S )-a  Write Makefile code for any 'rules' from the gyp input.

    extra_sources: a list that will be filled in with newly generated source
                   files, if any
    extra_outputs: a list that will be filled in with any outputs of these
                   rules (used to make other pieces dependent on these rules)
    part_of_all: flag indicating this target is part of 'all'
    r   	rule_namer   z### Generated for rule %s:rule_sourcesc                 >    g | ]}                     |          S r   ExpandInputRoot)rn   rD   rule_source_dirnamerule_source_rootr   s     r<   r   z-MakefileWriter.WriteRules.<locals>.<listcomp>  sA     / / / ''-=(;= = / / /r>   r  r  Fr  r  z$(call do_cmd,%s_%d)resources_gritz@touch --no-create $@c                 P    g | ]"}t           j                            |          #S r   r  r&  s     r<   r   z-MakefileWriter.WriteRules.<locals>.<listcomp>  s,    NNN3&44Q<<NNNr>   c                 P    g | ]"}t           j                            |          #S r   r  r(  s     r<   r   z-MakefileWriter.WriteRules.<locals>.<listcomp>  s,    LLL#%33As;;LLLr>   c                 :    g | ]}                     |          S r   r   r!  s     r<   r   z-MakefileWriter.WriteRules.<locals>.<listcomp>  s%    777!4??1%%777r>   r#  r$  z%s_%d)r  z\$\([^ ]* \$<\)r   r   z/Spaces in rule filenames not yet supported (%s)all_deps += %sc                 >    g | ]}                     |          S r   r>  )rn   acr@  rA  r   s     r<   r   z-MakefileWriter.WriteRules.<locals>.<listcomp>$  sA     , , , &&r+;':< < , , ,r>   r  zmkdir -p %s; r  r  r   c                 P    g | ]"}t           j                            |          #S r   r  r  s     r<   r   z-MakefileWriter.WriteRules.<locals>.<listcomp>0  s<     + + + '55gsCC + + +r>   r  zcmd_%(name)s_%(count)d = LD_LIBRARY_PATH=$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; %(cd_action)s%(mkdirs)s%(action)s)r  r7  countmkdirsr   z9quiet_cmd_%(name)s_%(count)d = RULE %(name)s_%(count)d $@)rJ  r   r   zrule_%s_outputsr+  z$### Finished generating for rule: %sz%### Finished generating for all rulesN)r,  r   r   r   rH   r   rL   rM   r-  rz   r  r.  r/  r3  r   r   WriteMakeRuler   compiler   rO   r   r9   r,   r-   r0  r   r   	WriteListr   )r   r   r   r   r  r   ruler   rJ  all_outputsrule_sourcer4  rule_source_basenamerule_source_extr  rD   r5  r  r   variables_with_spacesr   r  rK  r7  r9  r  r@  rA  s   `                        @@@r<   r   zMakefileWriter.WriteRules  sb    
 
 
"
"C p p%1F1F1F15k1B1B'D E Ede
ll/$6777k."55 a a+uu68gmmK6P6P3	2G122 	,	?/ / / / / /"9o/ / /  	 	C$$# HHSMMMtxx4e<<== 	#
7
"-txxA5IIJJ 	0
$
/
$YDOk]$(HHXr$:$:6; !< !< = =)T5M9:### -.
.' ONNNgNNNLLLLVLLL7777w777w 	,wqz9:::6CDDD7FG#*dE]#: 	 	< 	< 	< !#
+= > > 	K 	KF6/V<<&F"""?6I #"""%(9(99:::, , , , , , N, , , t99q=="SXXd^^3&	$)*:s ; ;;	
 ;%+ + + +#)+ + +&0088T[99%%k4;??	T[99 	2  5
 5
	

	 
	 
	 	GK
 K
 
	 	 	
 	
*T1
nn["23337%55666
ll9D@AAA
llnnnnLL8999LLr>   c           
         |                      d           t          | j        dz             }g }|D ] }|d         D ]}t          |                     |                    }t
          j                            |          d         }t          |                     t
          j                            |d         |                              }	| 	                                }
t          j                            |	|
          }	t          j                            ||
          }|                     |	g|gd|           |                    |	           "|                      |dd                    t          t           |                               |                    d	|z             |                                   d
S )a  Write Makefile code for any 'copies' from the gyp input.

    extra_outputs: a list that will be filled in with any outputs of this action
                   (used to make other pieces dependent on this action)
    part_of_all: flag indicating this target is part of 'all'
    z### Generated for copy rule._copiesr   r   destinationcopy = r   r+  N)r   r   r   r   r   rL   rM   r-  rO   r,  r,   r   r  r2  r   r3  r   )r   r   r   r   variabler  rX  rM   rp   r   r  s              r<   r   zMakefileWriter.WriteCopiesZ  s    	LL/000'(=	(IJJHG  w-  $..//7==&&q)4??27<<]8K8@,B ,B C C D D $$&&$2263??"00s;;4&&+>>>v)* 	LLhhh['1J1J(K(K(KLMMM8+,,,LLNNNNNr>   c                    |                      d           t          j                            t          d         | j        t          t          t          | j        |                              D ]]\  }}t          j
                            |          \  }}|dk    r0|                     |g|gdd           |                    |           ^dS )z0Writes Makefile code for 'mac_bundle_resources'.z&### Generated for mac_bundle_resourcesr   z	.xcassetszmac_tool,,,copy-bundle-resourceTr   N)r   r,   r   GetMacBundleResourcesr0   r   r3  r   r   rL   rM   rz   r2  r   )r   	resourcesbundle_depsr   rr   r   r_   s          r<   r   z&MakefileWriter.WriteMacBundleResources  s    LL9:::*@@#M2D4GIs4?I66779 9 # # w''fa			3%)J$( 	 	* 	* 	*6"""# #r>   c                     t           j                            t          d          j         fd          \  }}}}|sdS |r`dt
          j                            |          z   }                     ||dz   dt                      
                    |g|gdd	g           |}                     |                     |
                                          |g|gdd           |                    |           dS )z0Write Makefile code for bundle Info.plist files.r   c                 H    t                              |                     S rk   r   r   s    r<   r   z2MakefileWriter.WriteMacInfoPlist.<locals>.<lambda>  s    )DOOA..// r>   Nz$(obj).$(TOOLSET)/$(TARGET)/z: INFOPLIST_DEFINES-D)quoterz$(call do_cmd,infoplist)z@plutil -convert xml1 $@ $@additional_settingszmac_tool,,,copy-info-plistTr\  )r,   r   GetMacInfoPlistr0   r   rL   rM   r   rN  r   rL  r1  r,  r2  r   )r   r_  
info_plistrD   defines	extra_envintermediate_plists   `      r<   r   z MakefileWriter.WriteMacInfoPlist  sG   *-*=*M*M#M2D4G////+1 +1'JWi  f &:
'

:
&
&'
nnW03HH$   " " "
,-
|% )*+ + +
 &jT##	#BBD D DOOSEJ<)E $  & & &sr>   c                 	    t          |                                          D ]=}||         }	                     |	                    d          d|z  dt                      j        dk    r j                            |          }
 j                            |          } j        	                    |          } j        
                    |          } j                            |          }n?|	                    d          }
|	                    d          }|	                    d          }                     d	                                |
d
|z                                  d                                |d|z                                  d                                |d|z              j        dk    r\                     d                                |d|z                                  d                                |d|z             |	                    d          }|r fd|D             }                     |d|z  d           ?t          t          |          } fd|D             }                     |d           |D ]}d|vsJ d|z                                   d                                d                                             |r                     dg|dd !           |r                     dg|d"d !           |                    ||          }|rM                     d#           |D ] \  }}}                     |d$|           !                     d%           |r|                    d                                d&                                d'                                d(|                    d)          z  d*z                                   d+|                    d,          z  d-z               j        dk    r\                     d.|                    d/          z  d0z                                   d1|                    d2          z  d3z                                   |                                           |d4 |D             z  }                                  d5S )6a  Write Makefile code for any 'sources' from the gyp input.
    These are source files necessary to build the current target.

    configs, deps, sources: input from gyp.
    extra_outputs: a list of extra outputs this action should be dependent on;
                   used to serialize action/rules before compilation
    extra_link_deps: a list that will be filled in with any outputs of
                     compilation (to be used in link lines)
    part_of_all: flag indicating this target is part of 'all'
    rh  zDEFS_%srb  )prefixrc  r   cflagscflags_c	cflags_ccz## Flags passed to all source files.z	CFLAGS_%sz# Flags passed to only C files.zCFLAGS_C_%sz!# Flags passed to only C++ files.zCFLAGS_CC_%sz"# Flags passed to only ObjC files.zCFLAGS_OBJC_%sz$# Flags passed to only ObjC++ files.zCFLAGS_OBJCC_%sinclude_dirsc                 T    g | ]$}t                              |                    %S r   r   )rn   includer   s     r<   r   z/MakefileWriter.WriteSources.<locals>.<listcomp>  s-    PPPGIdoog6677PPPr>   zINCS_%sz-I)rl  c           	      z    g | ]7}                                         t          |                              8S r   )	Objectifyr   r{   )rn   r   r   s     r<   r   z/MakefileWriter.WriteSources.<locals>.<listcomp>  s7    KKK1DNN4??6!995566KKKr>   OBJSr   z-Spaces in object filenames not supported (%s)z?# Add to the list of files we specially track dependencies for.zall_deps += $(OBJS)z$(OBJS)z6Make sure our dependencies are built before any of us.Tcomment
order_onlyz1Make sure our actions/rules run before any of us.z:# Dependencies from obj files to their precompiled headersr   z%# End precompiled header dependencieszn# CFLAGS et al overrides must be target-local.
# See "Target-specific Variable Values" in the GNU Make manual.z$(OBJS): TOOLSET := $(TOOLSET)zD$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) %s cz/$(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))zF$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) %s ra   z0$(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))zG$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) %s mzK$(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))zI$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) %s mmzM$(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))c                 0    g | ]}t          |          |S r   )rw   )rn   r   s     r<   r   z/MakefileWriter.WriteSources.<locals>.<listcomp>"  s%    III68H8HIIIIr>   N)rX   rY   rN  rH   r   r9   r   	GetCflags
GetCflagsCGetCflagsCCGetCflagsObjCGetCflagsObjCCr   filterrs   rL  GetObjDependenciesr   
GetIncludeWritePchTargetsGetPchBuildCommands)r   r   r   r   r   r   r   precompiled_header
confignameconfigrm  rn  ro  cflags_objccflags_objccincludes
compilableobjsobjpchdepsr   gchs   `                     r<   r   zMakefileWriter.WriteSources  s    W\\^^,, D D
z"f
nnVZZ	**I
,B4   " " " 
		$..z::&11*=='33J??	)77
CC*99*EEH%%::j))JJ{++	
ll8999
nnV[:5666
ll4555
nnX}z9:::
ll6777
nnY ;<<<			9:::{$4z$ABBB;<<<|%6%CDDDN++h	 QPPPPxPPP
nnXy:5dnCCCC
G,,JKKKK
KKKDNN4    B B^^^
9S
@ ^^^LL % & & &LL&'''LLNNN  ,
)d$7&*  , , ,  ,
)m$7&*  , , ,
 !33JFFG <
llOPPP% , ,
&#scc*++++
ll:;;;  5Y'''
ll C D D D ll3444
ll  .88==>.	. / / / ll  .88>>?/	/ 0 0 0 
		  0::3??@3	3 	4 	4 	4 	  0::4@@A4	4 	5 	5 	5 	+??AABBB IIWIIIIOLLNNNNNr>   c           	         |sdS |D ]\  }}}}ddddd|         }ddd	d
d|         }|                      |d|d|ddz   |z              |                      |d|d           |                      d|z             |                      d           d|vsJ d|z              |                      d|z             |                      d           dS )z,Writes make rules to compile prefix headers.Nz$(CFLAGS_C_$(BUILDTYPE))z$(CFLAGS_CC_$(BUILDTYPE))z4$(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))z6$(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)))ry  ra   rz  r{  GYP_PCH_CFLAGSGYP_PCH_CXXFLAGSGYP_PCH_OBJCFLAGSGYP_PCH_OBJCXXFLAGSr   r*  r   zA$(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE))  FORCE_DO_CMDz	@$(call do_cmd,pch_%s,1)r   z*Spaces in gch filenames not supported (%s)rF  )r   )r   pch_commandsr  	lang_flaglangr8  extra_flagsvar_names           r<   r  zMakefileWriter.WritePchTargets&  sL    f'3  #Ye')CF	 
 	k   #	 
 	h llccc888YYY?-- 	       llCCC7888
ll/$6777
ll2^^^
6#
= ^^
ll#c)***
ll23 r>   c                 H   | j         rJ | j        dk    r"| j        dv r| j                                        S |d         }d}d}| j        dk    r|dd         dk    r
|dd         }d}d	}ni| j        d
v r+|dd         dk    r
|dd         }d}| j        dk    rd	}n8d}n5| j        dk    rd|z  }n$| j        dk    rt          dd| j        d|f           |                    d|          }|                    d|          }|                    d          }|rd|z   }||z   |z   S )zReturn the 'output basename' of a gyp spec.

    E.g., the loadable module 'foobar' in directory 'baz' will produce
      'libfoobar.so'
    r   r   r   r   r   r   r   r   N   r   r   )r   r   r*   r+   nonez%s.stampr   z,ERROR: What output file should be generated?r   r   product_prefixproduct_nameproduct_extensionr  )r   r9   r   r   GetExecutablePathr   rH   )r   r   r   target_prefix
target_extproduct_exts         r<   ComputeOutputBasenamez$MakefileWriter.ComputeOutputBasenameG  s    !!!!{e	 .M !M !M 22444- FMJy$$$	u		mjj	;	;	;	u		m			



	f		F"ff	l	"	";TY&2 3 3 3 HH-}==MXXnf--F((.//K %$j6!J..r>   c                 @    | j         dk    o| j        dk    o| j        dv S )Nr   r   r  )r   r9   r   r   s    r<   _InstallImmediatelyz"MakefileWriter._InstallImmediatelyr  s9    <8# Ou(< O OO BO Or>   c                 B   | j         rJ t          j                            d| j        z   | j                  }| j        dk    s|                                 rd}|                    d|          }t          j                            ||                     |                    S )zReturn the 'output' (full output path) of a gyp spec.

    E.g., the loadable module 'foobar' in directory 'baz' will produce
      '$(obj)/baz/libfoobar.so'
    $(obj).r   r	   product_dir)	r   rL   rM   rO   r   r   r  rH   r  r   r   rM   s      r<   r   zMakefileWriter.ComputeOutputw  s     !!!!7<<	DL0$)<<DyL  D$<$<$>$> d88M4((D7<<d88>>???r>   c                     | j         sJ t          d         }t          j                            || j                                                  S )zDReturn the 'output' (full output path) to a bundle output directory.r   )r   r0   rL   rM   rO   r   GetWrapperNamer  s      r<   r   z%MakefileWriter.ComputeMacBundleOutput  s@    &}5D7<<d1@@BBCCCr>   c                     t           d         }t          j                            || j                                                  S )zAReturn the 'output' (full output path) to the binary in a bundle.r   )r0   rL   rM   rO   r   r  r  s      r<   r   z+MakefileWriter.ComputeMacBundleBinaryOutput  s1    &}5D7<<d1CCEEFFFr>   c                 j   g }g }d|v rn|                     d |d         D                        |d         D ]+}|t          v r |                    t          |                    ,|                     |           t          j                            |          t          j                            |          fS )zCompute the dependencies of a gyp spec.

    Returns a tuple (deps, link_deps), where each is a list of
    filenames that will need to be put in front of make for either
    building (deps) or linking (link_deps).
    dependenciesc                 B    g | ]}t           |         t           |         S r   )r   rn   deps     r<   r   z.MakefileWriter.ComputeDeps.<locals>.<listcomp>  s6     + + +3$S)+>#& + + +r>   )extendr   r   r,   r-   uniquer)r   r   r   r   r  s        r<   r   zMakefileWriter.ComputeDeps  s     DI
kk + +$~2F + + + , , ,n% 2 2#"""


+C0
1
1
1
kk) Jt$$cj&8&8&C&CDDr>   c                 D    |                      | j        g|dd           d S )Nz Build our special outputs first.Trv  )rL  r   )r   r   r   s      r<   WriteDependencyOnExtraOutputsz,MakefileWriter.WriteDependencyOnExtraOutputs  s9    *+]!C$(  * * * * *r>   c                 8                          d           |r4                      j        |                                ||dd           i } j        dk    r#t          |                                          D ]}	||	         }
 j        dk    r j        	                    |	t          d          fd          }t          j                             j                  } j                            |	t!          t"          j                            t"          j                            | j                                      t!          t"          j                            t"          j                            | j                                                }|r|||	<   ni|
                    d	g           }t-          d
 |D                       r:|                    d j        z             |                    d j        z             |
                    dg           }|d |D             z  }                     |d|	z              j        dk    r1                      j                            |	          d|	z             |                    d          }|rDt          j                            |          } j        dk    r j                            |          }                     |d                                 dt!           j                  z                                   dt!           j                  z              j        dk    r*                      dt!           j                  z             g } j        dk    rI|r|                    d           |                    t          j                            |                     |rc                       j         !                                           |D ]T}	                      t!           j                  d|	dt          j        "                    ||	                              U|#                    dt          j        "                    d j        g                     tI          |          D ],\  }}|%                    d          stM          |          ||<   -                      dt!           j                  z                                   t!           j                  dd                    |                      j'        r                      j        |                                tQ          t           |          d                                 d t!           j                  z              j        d!v r/                      d" j        )                                z             |r                      d#           g }                      d$                                 d%t!           j                  z             |r' j'        rJ d& j*        z              d'|vs
J d(             j        d)k    r                      t!           j                  d*d                    tQ          t           |                                j        d+k    r- j        d,k    r" +                     j        g|d-||.           nՉ +                     j        g|d/||.           n j        d0k    rj|D ]}d|vsJ d1|z               j        d2vr) j,        s" +                     j        g|d3||.           n` +                     j        g|d4||.           n> j        d5k    rs                      t!           j                  d*d                    tQ          t           |                                +                     j        g|d6||.           n j        d7k    rn|D ]}d|vsJ d8|z               j        d+k    r, j        d,k    r! +                     j        g|d9||.           nh +                     j        g|d:||.           nG j        dk    r! +                     j        g|d;||.           nt[          d< j         j*                    j        re j         j*        k    rU j         j.        vrG                      j*        g j        gd=d>           |r                      d?g j*        gd@d>            j         j.        v s j,        rD j        d5k    rdA}n j        d0k    rdB}nd)} /                                } j        g} j        dk    r.d'|vr* j        dCk    r| j        k    sJ |dD j                                          j*        g|gd=d>           | j        k    rB j'        rJ  +                    |g j        gdEdF|z  |G           |                    |            j         j0        k    r2 j0         j*        k    r"                      j0        g|dH|z  d>           |r"                     d?g|gdI|z  d>           dJS dJS dJS )Ka&  Write Makefile code to produce the final target of the gyp spec.

    spec, configs: input from gyp.
    deps, link_deps: dependency lists; see ComputeDeps()
    extra_outputs: any extra outputs that our target should depend on
    part_of_all: flag indicating this target is part of 'all'
    z### Rules for final target.z4Preserve order dependency of special output on deps.Trv  r  r   r   c                 H    t                              |                     S rk   r   r   s    r<   r   z,MakefileWriter.WriteTarget.<locals>.<lambda>  s    	$//!"4"455 r>   ldflagsc              3   H   K   | ]}|                     d           pd|v V  dS )r+   z.so.Nrl   r  s     r<   rq   z-MakefileWriter.WriteTarget.<locals>.<genexpr>  s7      FF#e$$5#FFFFFFr>   z-Wl,-rpath=\$$ORIGIN/lib.%s/z$-Wl,-rpath-link=\$(builddir)/lib.%s/library_dirsc                     g | ]}d |z  S )z-L%sr   )rn   library_dirs     r<   r   z.MakefileWriter.WriteTarget.<locals>.<listcomp>  s    KKK{Vk)KKKr>   z
LDFLAGS_%szLIBTOOLFLAGS_%s	librariesLIBSz*%s: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))z%s: LIBS := $(LIBS)z4%s: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))z!$(TARGET_POSTBUILDS_$(BUILDTYPE))z: TARGET_POSTBUILDS_r*  r   cdr   r$  z: POSTBUILDS := r   BUNDLE_DEPSz%s: $(BUNDLE_DEPS))r   r   z+	@$(call do_cmd,mac_package_framework,,,%s)z	@$(call do_postbuilds)z	@true  # No-op, used by testsz	@touch -c %szQPostbuilds for bundles should be done on the bundle, not the binary (target '%s')r  z.Postbuilds do not work with custom product_dirr   z: LD_INPUTS := hostr(   	link_host)
postbuildslinkr   z2Spaces in alink input filenames not supported (%s))r   openbsdnetbsdwin
alink_thinalinkr   solinkr   z3Spaces in module input filenames not supported (%s)solink_module_hostsolink_moduletouchzWARNING: no output forzAdd target alias)rw  phonyallz!Add target alias to "all" target.zshared libraryzstatic libraryr   z != rX  z Copy this to the %s output path.)rw  r   z!Short alias for building this %s.zAdd %s to "all" target.N)1r   r  r   rL  r   rX   rY   r9   r   
GetLdflagsr0   r,   r-   InvertRelativePathrM   AddImplicitPostbuildsr   rL   rN   rO   r   rH   anyr   r   rN  GetLibtoolflagsr  AdjustLibrariesr  r   GetSpecPostbuildCommandsr1  GetSortedXcodePostbuildEnvr0  insert	enumerate
startswithr   r   r3  GetFrameworkVersionr   r2  r   r   r   r   r   )r   r   r   r   r   r_  r   r   target_postbuildsr  r  r  gyp_to_buildtarget_postbuildr  r  r  r)  	postbuildlink_dep	file_descr  installable_depss   `                      r<   r   zMakefileWriter.WriteTarget  s}    	LL./// ,
(();]KKK
#<&*  , , ,
 yFw||~~.. 9 9*$;%'22:)-855557 7'
 66tyAA,!0FF"'**27<<8<,E ,E F F G G"'**27<<8<8J,L ,L M M N N	O O
  =,<j)JJy"--'FFFFFFF ) NN:T\IJJJNNB<( ) ) )zz."55KKlKKKKwz 9:::;%
..,<<ZHH*Z79 9 9((;''i	 EJ&&y11	;%)99)DD)
nnY'''
ll?
d(
)
)* + + +
ll(;t7I+J+JJKKK			K*++, 	- 	- 	-
 J{e	 ?=>>>


6
6t
<
<> > >  ; t{D,K,K,M,MNNN) N N*%%%%ZZZ,,->z-JKKKM 	N 	N 	N 	N 3:::D$);LMMNNN#J// 9 9,!Y##C(( 	9-i88*Q-
ll4{4;7O7OOPPP
ll
dk
"
"
"
"CHHZ$8$8$8: ; ; ;  @ ((mDDD nnSk22MBBB
ll'+dk*B*BBCCC 
;	;	;C33556 	7 	7 	7
 
 1/000j ll4555 ll#k$+&>&>>???  # I I ':<@K'H I I I$&&& *&&& yL  
ll
d(
)
)
)
)
((3{I..
/
/
/1 2 2 2 
		DK9$<$<+,i#
 	 	< 	< 	< 	< 	+,i#- 	 	/ 	/ 	/ 	/ 
&	&	& N N(("""@HL #"""
+@
@
@

+ A+,i#
 	 	< 	< 	< 	< 	+,i+#- 	 	/ 	/ 	/ 	/	&	&	&
ll*++++HHSi001113 4 4 4 oot)*Ix!+  - - - -	'	'	' O O(("""AXM #"""			DK9$<$<+,i9M#
 	 	< 	< 	< 	< 	 )_k! 	 	# 	# 	# 	# 
f		
oot)*D';!+  - - - - $di=== 
 )33	$3	3	3
$+!3T  C C C	 )E7T[M%H#' 	 	) 	) 	) 		T...) 	/	&	&	&$		9((($		 	7799l+
+

}'<'<
,(
"
"t{***LL$++-'*** $+!3T  C C C		$	$%%%%v"D!#"/: 	 	< 	< 	< 	---	
	"	"tzT['@'@DJ<)9%H$&%.2 	 	4 	4 	4 
 )E7\N%>%J#' 	 	) 	) 	) 	) 	)= 	/.:) )r>   Nr   c                     d}|r'fd|D             }dd                     |          z   }| j                            |d|d           dS )zWrite a variable definition that is a list of values.

    E.g. WriteList(['a','b'], 'foo', prefix='blah') writes out
         foo = blaha blahb
    but in a pretty-printed style.
    r   c                 ,    g | ]} |z             S r   r   )rn   lrl  rc  s     r<   r   z,MakefileWriter.WriteList.<locals>.<listcomp>  s'    ;;;1FF6A:&&;;;r>   z \
	z :=z

N)rO   r   r\   )r   
value_listrZ  rl  rc  valuess      `` r<   rN  zMakefileWriter.WriteList  sl     F 6;;;;;
;;;j9>>*555fGMM888VVV455555r>   Fc                     d}|rd|vsJ d}|                      ||d||dg||d           d |D             }|                     d	d
                    |          z             dS )zWrite a Makefile rule that uses do_cmd.

    This makes the outputs dependent on the command line that was run,
    as well as support the V= make command line flag.
    r   ,z,,1z$(call do_cmd,)T)r   rw  r  forcec                 8    g | ]}t          |t                    S r   )r   SPACE_REPLACEMENTrn   r"  s     r<   r   z-MakefileWriter.WriteDoCmd.<locals>.<listcomp>  s#    BBBQ{1/00BBBr>   rF  r   N)rL  r   rO   )r   r  r  r  r   rw  r  suffixs           r<   r2  zMakefileWriter.WriteDoCmd  s     F fw;B7FFF"K!L!(!(#	  % % % CB'BBBGLL!CHHW$5$5566666r>   c	                    d |D             }t          t          |          }|r|                     d|z              |r+|                     dd                    |          z              |r|                     d|d         z             |rdnd}	|rD|                     d                    |          d	d                    |          |	           n6t	          |          d
k    r6|                     |d         dd                    |          |	           n|r|n| j                            d          }
t          j        |
          	                                }d|z  }|                     d                    |          d|           |                     ddz             |                     dd|           |                     |dd                    |          |	           |
                    dd           |r|D ]}|                     d|z             |                                  dS )a  Write a Makefile rule, with some extra tricks.

    outputs: a list of outputs for the rule (note: this is not directly
             supported by make; see comments below)
    inputs: a list of inputs for the rule
    actions: a list of shell commands to run for the rule
    comment: a comment to put in the Makefile above the rule (also useful
             for making this Python script's code self-documenting)
    order_only: if true, makes the dependency order-only
    force: if true, include FORCE_DO_CMD as an order-only dep
    phony: if true, the rule does not actually generate the named output, the
           output is just a name to run the rule
    command: (optional) command name to generate unambiguous labels
    c                 ,    g | ]}t          |          S r   )r   r  s     r<   r   z0MakefileWriter.WriteMakeRule.<locals>.<listcomp>  s    ///!{1~~///r>   z# z.PHONY: r   z%s: TOOLSET := $(TOOLSET)r   r  r   z: | r   r   zutf-8z%s.intermediatez	%sz@:z.INTERMEDIATEz$(call do_cmd,touch)N)r3  r   r   rO   r   r   encodehashlibsha1	hexdigestr  )r   r  r  r   rw  rx  r  r  r  force_append	cmdstring	cmddigestintermediater  s                 r<   rL  zMakefileWriter.WriteMakeRule  st     0/w///Gf%%F #
ll4'>""" 3
ll: 1 11222 =
ll.;<<<&+3??L 0 llHHW%%%%sxx'7'7'7G H H H H	W		
llSXXf-=-=-=||LMMMM &6774;>>wGGi,y))3355i&)4l
llsxx0000,,?@@@
ll6D=!!!
ll=>>>
ll LL#((6"2"2"2LLB C C CnnQ./// & & &&Vf_%%%%LLNNNNNr>   c           	         | j         dvrdS |                     d           |                     d           |                     d|z              |                     d           |                     d           |                     d           |                     d	           d
d
d
d}d}|D ]O}t          j                            |          d         }||v r$||xx         dz  cc<   ||         ||         k    r|}P|                     d|z              |                     t          | j        t          t          |                    d           d }ddi}	i }
t          |
|	           |                      ||t          d         |
d                   d           |                      ||t          d         t          d                   d           | j         dk    r|                     d           nA| j         dk    r|                     d           n | j         dk    r|                     d           |                                  dS )a  Write a set of LOCAL_XXX definitions for Android NDK.

    These variable definitions will be used by Android NDK but do nothing for
    non-Android applications.

    Arguments:
      module_name: Android NDK module name, which must be unique among all
          module names.
      all_sources: A list of source files (will be filtered by Compilable).
      link_deps: A list of link dependencies, which must be sorted in
          the order from dependencies to dependents.
    )r   r   r   Nz/# Variable definitions for Android applicationszinclude $(CLEAR_VARS)zLOCAL_MODULE := ziLOCAL_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))z+LOCAL_CPPFLAGS := $(CFLAGS_CC_$(BUILDTYPE))zLOCAL_C_INCLUDES :=z/LOCAL_LDLIBS := $(LDFLAGS_$(BUILDTYPE)) $(LIBS)r   )rd   re   rf   re   r   zLOCAL_CPP_EXTENSION := LOCAL_SRC_FILESc                    g }| D ]}t           j                            |          }|                    |          rM|                    |          r8|                    |t          |          t          |                               |S rk   )rL   rM   r   r  rm   r   r   )r   rl  r  modulesfilepathrp   s         r<   DepsToModulesz?MakefileWriter.WriteAndroidNdkModuleRule.<locals>.DepsToModules2  s    g = =(7##H--v&& 	=8+<+<V+D+D 	=
..#f++s6{{l":;
<
<
<nr>   r9   r)   r   r   LOCAL_SHARED_LIBRARIESr   r   LOCAL_STATIC_LIBRARIESr   zinclude $(BUILD_EXECUTABLE)r   zinclude $(BUILD_SHARED_LIBRARY)r   zinclude $(BUILD_STATIC_LIBRARY))r   r   rL   rM   rz   rN  r3  r   r  rs   r=   r0   )r   module_namer   r   cpp_extdefault_cpp_extrp   r_   r  r8   r7   s              r<   r   z(MakefileWriter.WriteAndroidNdkModuleRule   s    yJJJfLLBCCCLL()))LL#k1222LL 	( 	) 	) 	) 	LL>???LL&'''LLBCCC A..GO    GX&&q)c	3<'/222/LL*_<===NN3tz;(G(GHH$& & &
    F(&111NNi12EF'(;<	> 	> 	!	" " "
 	NNi12EF12EF	H 	H 	!	" " " yL  
ll01111	&	&	&
ll45555	&	&	&
ll4555LLNNNNNr>   c                 @    | j                             |dz              d S )NrW   )r   r\   )r   texts     r<   r   zMakefileWriter.WriteLnS  s     GMM$+r>   c                     t           j                            | j        dt          j                            d| j                  d|          S )Nz$(abs_builddir)z$(abs_srcdir)r   )r,   r   r,  r   rL   rM   rO   )r   re  s     r<   r,  z MakefileWriter.GetSortedXcodeEnvW  s@    00.
_di00.  r>   c                 h    | j                             dd          }|                     d|i          S )NCHROMIUM_STRIP_SAVE_FILEr   rd  )r   GetPerTargetSettingr,  )r   strip_save_files     r<   r  z)MakefileWriter.GetSortedXcodePostbuildEnv^  sK     )=="B( (O !!7I " K K Kr>   c                 j    |D ]/\  }}|                      t          |          d|d|           0d S )Nz	: export r*  )r   r   )r   r   r  kvs        r<   r1  z"MakefileWriter.WriteSortedXcodeEnvi  sU     H H1 llK,?,?,?,?AAFGGGGH Hr>   c                 l    d|v r|                     dd| j        z            }d|vrd| j        d|}|S )z,Convert a path to its output directory form.r   $(obj)/z$(obj).%s/$(TARGET)/z$(obj)r  z/$(TARGET)/)r   r   r   rM   s     r<   rt  zMakefileWriter.Objectifyt  sK    t||\\)%;dl%JKKdt)-tt<dKr>   c                     |                      |          }d|v r#|                    dd| j        d|          }|S d| j        d|d|S )z:Convert a prefix header path to its output directory form.r   r  r  z/$(TARGET)/pch-/)r   r   r   )r   rM   r  s      r<   r   zMakefileWriter.Pchify}  sj    ??4  Dt||\\))<<<&/ 0 0dk  /3lllDDD$$GGr>   c                     d|v r|                     d          S t          j                            t          j                            | j        |                    S )zlConvert a subdirectory-relative path into a base-relative path.
    Skips over paths that contain variables.r   r  )rstriprL   rM   rN   rO   r  s     r<   r   zMakefileWriter.Absolutify  sI     t|| [[7BGLLD99:::r>   c                 *    d|vrd|vr|S |||dz  }|S )Nr
   r   )
INPUT_ROOTINPUT_DIRNAMEr   )r   template	expansionr  rM   s        r<   r?  zMakefileWriter.ExpandInputRoot  s>    x'',?x,O,Oo 
 
 
D Kr>   c                 |    | j         dk    r(| j        dk    s| j        dk    rd| j        d| j        S d| j        z   S )zCReturns the location of the final output for an installable target.r   r   r   z$(builddir)/lib.r  z$(builddir)/)r   r9   r   r   r  s    r<   r   z,MakefileWriter._InstallableTargetInstallPath  sP     		%%%			!9!9 )-djjAADJ&&r>   )NF)NNFFFN)r   rk   )$__name__
__module____qualname____doc__r   r  r  r   r   r   r   r   r   r  r  r  r   r   r   r   r  r   r   rN  r2  rL  r   r   r,  r  r1  rt  r   r   r?  r   r   r>   r<   r   r     sZ        
+ + +6B B BJ  6a a aH} } }@# # #L# # #  6z z zx  B(/ (/ (/VO O O
@ @ @D D DG G GE E E,* * *i) i) i)X ,0'6 6 6 6 GK!7 7 7 70 BFHL; ; ; ;|P P Pf      K K KH H H  H H H; ; ;  	' 	' 	' 	' 	'r>   r   c                    | d         fd| d         D             }t           j                            | d         j                  }|                    t
          j                  s t
          j                            d|          }|	                    d|d                    t          t          |                    t           j                            |dgt          j                  z   |z             d	z             d
S )z,Write the target to regenerate the Makefile.rB   c                 Z    g | ]'}t           j                            |j                  (S r   )r,   r-   RelativePathrK   )rn   rp   rB   s     r<   r   z-WriteAutoRegenerationRule.<locals>.<listcomp>  sD     A A A" j--h8LMM A A Ar>   build_files_arg
gyp_binaryr  zquiet_cmd_regen_makefile = ACTION Regenerating $@
cmd_regen_makefile = cd $(srcdir); %(cmd)s
%(makefile_name)s: %(deps)s
	$(call do_cmd,regen_makefile)

r   z-fmake)makefile_namer   cmdN)r,   r-   FixIfRelativePathrK   r  rL   seprM   rO   r\   r3  r   r0  RegenerateFlags)r8   root_makefiler+  build_filesbuild_files_argsr*  rB   s         @r<   WriteAutoRegenerationRuler3    s&    9'A A A A&,->&?A A A z++F<,@,3,@B B*			rv	&	& /c:..J, )((3y+667700 (+(112%&' '/( /(	(
) 
) 
) 
) 
)r>   c                     |d         }|D ]d}dg}|j         r|j         dk    r|d|j         fz  }|                    d|z              t          d|d|           t          j        |           ed S )NrB   maker  z-Cz
BUILDTYPE=z
Building [z]: )rK   r   r   
subprocess
check_call)dataconfigurationsr8   rB   r  	argumentss         r<   PerformBuildr;    s    9' % %fI . 4 ; ;4---i\F*+++	E
3444)$$$$% %r>   c                 P  123 |d         3t           j                            |          }|                    di           }|                    dd          }|                    dd           }|                    dd          }3fd}	d }
t	          fd	| D                       }| D ] }|         }|d
         dk    r
|d
         }
 n!|
sd}
d}d3j        z   }t          j                            3j	        |          }3j
        rRt          j                            3j	        3j
        |          }t           j                            |3j
                  }dad}d}d}|||
|dt          d|||d
}|dk    r'd}|                    |dt          t           d           n|dk    r|                    dt"          i           n|dk    r#d}d}|                    ||t$          d           nf|dk    r|                    d dd!           nG|d"k    rd#}|                    d$|i           n'|d%k    r!d#}|                    |t&          d dd&           |                    t)          d'd(          t)          d)d*          t)          d+d,          t)          d-d.          t)          d/d0          t)          d1d2          t)          d3d4          t)          d5d6          d7           t           j                            | d8                   \  1}}|1                             d9g           }i }|D ]8\  }}|                    d:          rd;|z  ||d t/          d:                    <   9d}|D ]\  }}t1          j        d<|          r|d8         d=k    rd;|z  }|                    |          }|r
|d>|}||= |d?v rP|d@|z  z  }|                    ddA          }|t          j        v rt          j        |         }|dB|dC|dDz  }|dEz  }||dF|dDz  }||d9<   t           j                            |           t;          |dG          }|                    t>          |z             |r|                    dH           |D ])}|                    dI|z             tA          |           *t          j        !                    |          }t           j        "                    ||           t	                      2|dJ         D ];1t           j        #                    | 1          D ]}2$                    |           <t	                      } t	                      }!| D ].}"t           j                            |"          \  1}}|1                             d9g           }#||#k    sJ dK|#dL|            | $                    t           j                            13j	                             |1         dM         }$|$D ]}%t           j                            t           j        %                    |%1          3j	                  }&t          j        &                    |&          }'|dN         r1|''                    |dN                   r| $                    |'           | $                    |&            |	1|dz   |z   3j        z   dOz             \  }(})|"         }|dP         }*|dk    r&t           j(        )                    |1         |           tU          ||          }+|++                    |"|(|)||*|"2v Q           t           j                            |)t          j        !                    |                    },|!$                    |,           0t           j                            3j,        t          j-                              }-| D ]1t          j                            |-1          112fdR| D             }.|.s5 |	1t          j        .                    t          j        /                    1                    d8         dSz             \  }(})t           j                            t          j        !                    |          t          j        !                    |)                    }/|+0                    |)|/|.|           |                    dD           tc          |!          D ]M}0|                    dT|0z   dUz              |                    dV|0z   dDz              |                    dE           N|                    dD           |                    dW          s(|                    dXdY          rte          ||||            |                    tf                     |4                                 d S )ZNrB   r@   rC   rD   rA   default_targetr  c                    t           j                            t          j                            |           j                  }t          j                            j        ||          }j        r,t          j                            j        j        ||          }t           j                            t          j                            |           j	                  }||fS )z9Determine where to write a Makefile for a given gyp file.)
r,   r-   r(  rL   rM   r  depthrO   rJ   rK   )
build_file	base_namer   output_filerB   s       r<   CalculateMakefilePathz-GenerateOutput.<locals>.CalculateMakefilePath  s     
''
(C(C(/7 7I ',,w}iCCK IGLL
-19iI Ik
''
(C(C(/(<> >Ik!!r>   c                 ,    g | ]}|         d          S )r   r   )rn   r   target_dictss     r<   r   z"GenerateOutput.<locals>.<listcomp>  s#    LLLf,v&y1LLLr>   default_configurationDefaultr  Makefilez
$(srcdir)/flockz-afz-MMDr   r   )
r=  builddirrF  rI  flock_indexlink_commandsextra_commandssrcdircopy_archive_argsmakedep_argsr   z./gyp-mac-tool flock   )rI  rK  rL  rM  r(   rL  zosz-fPRz-qmakedep=gcc)rO  rP  rL  solarisz./gyp-flock-tool flock)rI  rK  r  z-pPRfrO  r*   )rO  rL  rI  rK  )	CC_targetCCz$(CC))	AR_targetARz$(AR))
CXX_targetCXXz$(CXX))LINK_targetLINKz$(LINK))CC_hostrU  gcc)AR_hostrW  ar)CXX_hostrY  zg++)	LINK_hostr[  z$(CXX.host))z	CC.targetz	AR.targetz
CXX.targetzLINK.targetCC.hostzAR.hostCXX.hostz	LINK.hostr   make_global_settings_wrapperz$(abspath %s)z
.*_wrapperr   r   )rU  rb  rY  rc  z3ifneq (,$(filter $(origin %s), undefined default))
r   r   rY  rW   zendif
z ?= r   zU# Define LOCAL_PATH for build of Android applications.
LOCAL_PATH := $(call my-dir)

zTOOLSET := %s
r1  z;make_global_settings needs to be the same for all targets. z vs. included_fileshome_dot_gypz.mkr9  r\  c                 ^    g | ])}|                               r|v |         d          *S )r   )r  )rn   r   r@  needed_targetsrE  s     r<   r   z"GenerateOutput.<locals>.<listcomp>  sM     - - -6''
33-^++  '6+++r>   z	.Makefilezmifeq ($(strip $(foreach prefix,$(NO_LOAD),\
    $(findstring $(join ^,$(prefix)),\
                 $(join ^,z)))),)
z
  include 
standaloneauto_regenerationT)5r,   r-   r.   rH   r   r  rL   rM   rO   rK   rJ   r(  r   LINK_COMMANDS_LINUXr6   LINK_COMMANDS_MACSHARED_HEADER_MAC_COMMANDSLINK_COMMANDS_ANDROIDLINK_COMMANDS_OS390LINK_COMMANDS_AIXr   ParseQualifiedTargetrm   r   r   matchr   environr   r   r\   SHARED_HEADERr`   r  CopyTool
AllTargetsr.  UnrelativePathabspathr  r   MergeGlobalXcodeSettingsToSpecr   r  r?  getcwdrz   r   r  rX   r3  SHARED_FOOTERr   )4target_listrE  r8  r8   r9   r@   rQ   rA   r=  rC  rF  toolsetsr   r   rN  r+  r  flock_commandcopy_archive_argumentsmakedep_argumentsheader_paramsr   make_global_settings_arraywrappersrU   valuerd  wrapperenv_keyr0  r   	dest_pathr1  include_listr   this_make_global_settingsrf  included_filerelative_include_fileabs_include_filer   rB  r   r]   mkfile_rel_pathdepth_rel_pathgyp_targetsmakefile_rel_pathinclude_filer@  ri  rB   s4    `                                               @@@r<   GenerateOutputr    sY   9':''&JJ0"55/!%%lE::-'++,A4HH"&&'7??." " " " "( LLLLLLLMM(  fD#$	11"#:;e 2 
 &%&w~--',,w3]CC- !GLLg6G GMZ$$VW-EFFF M- &4*1' - u__*M*4	      .     #'3),     
 )      $3     $3*)	     %&97CC%&97CC%&;XFF%&=yII%&7??%&7>>%&95AA%&;]KK	 	 	 	 	 Z44[^DD*a#J/334JBOO(. A Ajc5
||J A)85)@hs$S__$$%&. : :jc5	xc"" Qx3%ell3G  %%(e
3-
222
@3
FH C%%g	BJ		
7#sssEEE::i'ccc55599 +?-&'*]+++}c**-mm3444  	    . .g)G3444}---- goom,,)*fi((( 55.=) ! !j*''\:NN ! !    ! +,% ,& ,&"%*"A"A# #J !%Z 0 4 45KR P P%)BBBBB	"	"	"$8$8	: CBB OOCJ++J8LMMNNN*%&67N' / / "j55
*
#
#M:
>
>

    )>?? 
  /

%
%f^&<
=
=/())))-....22:w/%79 9I{ ()D#$G	88j9I4PPPOV44F
LL!9k4-?  A A A
 j--k.0goom.L.LN NO_%%%% :**7=")++FF. ' 'j nj99J- - - - - -[ - - -K  22:
))*5566q9KGI II{
//0N0N020L0LN N
%6%' ' ' '
 d\** 
# 
#l
 	%'3	46@	AB B B |3d:;;;	""""d


l
+
+ Q


14
8
8Qfm]KPPPm$$$r>   )r   )6
__future__r   rL   r   sysr6  r,   
gyp.commongyp.xcode_emulationr   r   r  r0   $generator_supports_multiple_toolsetsrI   r!   r"   r#   rP   r=   rR   r  rl  rm  ro  rq  rp  ru  rn  r`   r   r   r|  r   r5   rs   rw   r{   r   r   r   r   r   r   r   r   r   r   r   objectr   r3  r;  r  r   r>   r<   <module>r     s_  0 & % % % % % 				 				 



     



         ) ) ) ) ) )        8)%+$"#&  $ (, $ ', # /1 +%' "$& ! "A "A "AJ  B  " H  8 $ (H&P ):QH:P=QIR "3SI3R_6ShP +Qh+RMSHMR 6GSIGRJ)SJ)T ,=UJ=V!&Wl\ >  (( #
( #

 		

    ! ! !
. . .
- - -      . . .
      
M M M@ 
  p' p' p' p' p'V p' p' p'f') ) )2% % %H H H H Hr>   