
    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;d4Z-d5 Z.i Z/i Z0 G d6 d7e1      Z2d8 Z3d9 Z4d: Z5y)<    )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                  j                  |      }|dk(  r| j                  dd       | j                  dd       | j                  dt        d          | j                  dt        d          dd	lmc m} t        |d
g       a	t        |dg       a
t        |dg       at        j                  ddd       y	|}|dk(  rd}| j                  d|       |dk(  r| j                  dd       n| j                  dd       | j                  dd       | j                  dd       y	)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   s7   ::'&u_  u-  !4h?  !1!<]!KM  !<]!KM
 2129/5r3;/ *1,b*2& )0+R)1%  !AB   '78""#6=""#6>  !12NO  ,?@    c                 X   | j                  di       }|j                  dd      }|rda| d   j                  xs | d   j                  }|j                  dd      }t        j
                  j                  t        j
                  j                  ||d            }| d   j                  |d	ay)
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/'++,A4H*.'i 11 .i -- !%%lE:-gg&&rww||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        j                         t        j                        }| j                  d       |D ]1  }| j                  d|z         | j                  dt        |   z         3 | j                  d       |D ]1  }| j                  d|z         | j                  dt        |   z         3 | j                  d       |D ]1  }| j                  d|z         | j                  dt        |   z         3 | j                  d       y )	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`     s   +002		B*,,CD Jc
LLH3NO
LL+.CC.HHIJ 	,,?@ Jc
LLG#MO
LL+.CC.HHIJ 	,,t Jc
LLEKL
LL+.CC.HHIJ 	,,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                 6      fdt         D        D ]  }|s y y)z:Return true if the file is compilable (should be in OBJS).c              3   @   K   | ]  }j                  |        y wNendswith).0efilenames     r<   	<genexpr>zCompilable.<locals>.<genexpr>J  s     Bqh"Bs   TF)r5   )rp   ress   ` r<   
Compilablers   H  s#    B,AB c
 
r>   c                 $    | j                  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                 L    t         j                  j                  |       d   dz   S )z1Translate a compilable filename to its .o target.r   ru   )rL   rM   splitextrv   s    r<   Targetrz   U  s!    			(	#A	&	--r>   c                 2    d| j                  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                 &    | j                  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                 R    t        |       } t        |       } | j                  dd      S )zBEscapes a CPP define so that it will reach the compiler unaltered.#z\#)r   r   r~   r   s    r<   EscapeCppDefiner   h  s)    !!!!$! 
3	r>   c                 >    d| v rd| j                  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                 0    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                 b    d| v r| S t         j                  j                  |       r| S t        | z   S )z,Convert a path to its source directory form.$()rL   rM   isabssrcdir_prefix)rM   s    r<   	Sourceifyr     s.    	T\KWW]]4K		r>   c                 &    | j                  d|      S )N r}   )r   quotes     r<   QuoteSpacesr     s    	
3	r>   c                    | j                  dd      dk7  ryi }|D ]k  }t        j                  j                  |      \  }}|dv }|s,t        j                  j	                  |      }|j                  |g       j                  |       m d}|j                         D ]/  \  }}	t        |	      dkD  s|d|dd	j                  |	      d
z  }1 |r%t        d| d   z  |z   dz   dz          t        d      y)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   ry   basenamer/   appenditemslenrO   printr   )
specall_sources	basenamessourcenamer_   is_compiled_filer   errorfiless
             r<   _ValidateSourcesForOSXr     s    
XXfd//
) 6f  (ID# > >ww%H2&--f56 %"* :oh
5zA~x%99e: 	
I
}
 %&(GH
  ! K
LL	 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#y)'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
        j                         D ]  }| j                  j                  |d|dt
        |   di       | j                  j                  |d|dt
        |   di       | j                  j                  |d|dt
        |   di        y )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 %))+ +
%%s !#&.( '* + && !#&/( (* + && !#&/( (* ++r>   c                 
    t         j                  j                  |       t        |d       _         j                  j                  t               | _        | _        |d    _	        |d    _
        |d    _        t         j                  j                   j                  |       _         j                  dk(  r%t         j                  j!                  |       _        nd _         j%                  |      \  }}g }	g }
g }g }g } j                  r- j'                  |       _         j+                  |       _        n j/                  |      x _         _        t1        |j3                  dd             _        d	 _         j4                  s j                   j6                  v r?t8        j                  j;                   j(                         _         j?                         }n j(                   _         j(                  } jA                  d
 j                  z           jA                  d j                  z          d|v r jC                  |d   |
|	||       d|v r jE                  |d   |
|	||       d|v r jG                  |d   |	|        j                  r8|j3                  dg       |z   } jI                  ||        jK                  |       |j3                  dg       |
z   }|r j                  dk(  rtM        ||        jO                  ||||	||t         j                  jQ                   j"                   fd jR                               |D cg c]  }tU        |      s| }}|r7 jA                  tV               tY        |D cg c]$  }t8        j                  j[                  |      d   & c}      }|D ]/  }| j\                  v s jA                   j\                  |          1  jA                  t^               |D ]/  }| j`                  v s jA                   j`                  |          1 |D ]/  }| jb                  v s jA                   jb                  |          1  jA                  d        j                  r|je                   j,                          jg                  |||||z   ||	|       |th        |<    j                  dv r j,                  tj        |<    jl                  j3                  dd      r jo                   j                  ||        j                  jq                          yc c}w c c}w )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                 8    t        j                  |             S rk   r   
Absolutifypr   s    r<   <lambda>z&MakefileWriter.Write.<locals>.<lambda>3  s    Ytq7I-J r>   r   z!# End of this set of suffix rules)r   r   rA   )9r,   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Pchifyrs   #SHARED_HEADER_SUFFIX_RULES_COMMENT1setry   r   #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   xr   r   r^   r_   s   `                     r<   WritezMakefileWriter.Write  s    JJ/?C(DGGGMM&,DDI}%DKVDI	?DL,,88dKD{{e//==dCd d&&t,OD)
 MMO!#O//5dk<<TBd)-););D)AAdkD&(,,a0)2D%!3D))		T...77##DKK0dj779l;;dj[[lLL-.LL+, D
Y2KA $
ood7m]M0+? 4
tH~}kB 
(()2
.1K
K 
""#;_M
_- ((9b)M9K		 	t[1

4m
;



-
-!!#Jkk (9q:a=9g9	89'BQ"''**1-a0BC
 	8CD,,,LL11#67	8 	89 	9CD---LL22378	9  	9CD---LL22378	9 	89 

 
 !3!3
4T7D/I*E$m[B (4N#$ yy88+/+=+='(  5t<
$$T[[+yIGGMMOG : Cs   U)U)Uc                    t         j                  j                  |       t        |d      | _        | j                  j                  t               | j                  dt        j                  j                  t        j                  j                  |      |      z         | j                  d       | j                  d       |rd|z   }| j                  d|ddj                  |             | j                  j                          y)	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     JJ/?C(DGGGMM& 	LL-bggooo>	JK LLLLL},mLL]CHHW4EFGGGMMOr>   c                    | j                         }|D ]  }t        | j                  d|d         }| j                  d|d   z         |d   }	|d   }
t	               }|
D ]8  }t
        j                  j                  |      d   }|s(|j                  |       : t        |j                  dd            r||
z  }t        |j                  d	d            r||
z  }|d
   }| j                  dk(  r-|D cg c]"  }t        j                  j                  ||      $ }}t        j                  j!                  |      }d|v r| j                  d|d|d   d       n| j                  d|d|d       t#        |      dkD  rddj%                  |      z  dz   |z   }dt'        | j                  xs d      z  }|j)                  d| j*                        }|j)                  d| j*                        }| j                  d|d||       | j                          |
D cg c]  }| j-                  |       }
}| j                  dt/        |
d         z         | j                  dt/        |
d         z         | j1                  |
d   | j                                |	D ]  }d|vrJ d|z          |
D ]  }d|vrJ d|z          |
D cg c]"  }t        j                  j                  ||      $ }
}|	D cg c]"  }t        j                  j                  ||      $ }	}| j3                  |
t5        t&        t5        | j,                  |	            ||       d|z  }| j                  |ddj%                  |
             |j7                  d|z         | j                           | j                          y c c}w c c}w c c}w c c}w )!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   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; %s: obj := $(abs_obj)%s: builddir := $(abs_builddir)z3Spaces in action input filenames not supported (%s)z4Spaces in action output filenames not supported (%s))r   commandzaction_%s_outputs := $(%s)N)GetSortedXcodeEnvr   r   r   r   rL   rM   splitaddintrH   r9   r,   r   ExpandEnvVarsr-   EncodePOSIXShellListr   rO   r   r~   r   r   r   WriteSortedXcodeEnv
WriteDoCmdmapr   )r   r   r   r   r   r   envr  r   r  r	  dirsrD   diraction_commandsr  	cd_actionoinputr   ioutputs_variables                         r<   r   zMakefileWriter.WriteActionsv  s    
 
 
"C S%1F1F171F'H Id
ll/&2GGHhfy!g Ud #ggmmC #
((3- 
VZZ4e<	= 	VZZA5I	J"g-" x(o		)8:% ..<<WcJ : :

//@g	f	dF9<MNOdDAB	TQ#((4.047'Ai		(8S99i
 T[[9g##K=i ll Iw	0 1
 lln-45#5g5 ll*[-DDE
ll4{71:7NNO
wqz4+A+A+CD L%% 	LAUJ	LL  N&&  	NBfL	N N
 ELLq$$221c:LgLCIJa##11!S9JfJ
oogs9c$//6.JK"-t  = -t3
ll!1388G3DEF7%556
llngSj 	LLN:< 6* MJs   4'N7N<'O5'Oc                 ^	   | j                         }|D ]W  }t        | j                  d|d         }d}	| j                  d|z         g }
|j	                  dg       D ]  }t               }t        j                  j                  |      \  }}t        j                  j                  |      \  }}|d   D cg c]  }| j                  |||       }}|D ]5  }t        j                  j                  |      }|s%|j                  |       7 t        |j	                  dd            r||z  }t        |j	                  d	d            r||z  }t        t        t        | j                   |g|j	                  d
g       z               }d||	fz  g}|dk(  r|dgz  }|D cg c]"  }t"        j$                  j'                  ||      $ }}|D cg c]"  }t"        j$                  j'                  ||      $ }}|D cg c]  }| j!                  |       }}|
|z  }
| j                  d|d   z         | j                  d|d   z         | j)                  |||d||	fz         t+        j,                  d      }|D ]'  }t+        j.                  |d|      }d|vrJ d|z          | j                  ddj1                  |      z         |d   D cg c]  }| j                  |||       }}d}t3        |      dkD  rddj1                  |      z  }dt        | j                  xs d      z  }| j4                  dk(  r-|D cg c]"  }t"        j$                  j'                  ||      $ }}t"        j6                  j9                  |      }|j;                  d| j<                        }|j;                  d| j<                        }|j;                  d| j<                        }| j                  d|||	||dz         | j                  d|	|d z         | j                          |	d!z  }	 d"|z  }| j?                  |
|       |jA                  d#|z         | j                  d$|z         | j                          Z | j                  d%       | j                  d       y&c c}w c c}w c c}w c c}w c c}w c c}w )'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_sourcesr	  r
  Fr  r  z$(call do_cmd,%s_%d)resources_gritz@touch --no-create $@r  r  z%s_%d)r  z\$\([^ ]* \$<\)r   r   z/Spaces in rule filenames not yet supported (%s)all_deps += %sr  zmkdir -p %s; r  r  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  r%  countmkdirsr   z9quiet_cmd_%(name)s_%(count)d = RULE %(name)s_%(count)d $@)r/  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  ry   ExpandInputRootr  r  r  r   r   r   r,   r   r  WriteMakeRuler   compiler   rO   r   r9   r-   r  r~   r   	WriteListr   ) r   r   r   r   r   r   r!  ruler   r/  all_outputsrule_sourcer"  rule_source_dirnamerule_source_basenamerule_source_rootrule_source_extrD   r	  r#  r  r   r&  r(  variables_with_spacesr   acr  r0  r%  r  r)  s                                    r<   r   zMakefileWriter.WriteRules  s    
 
 
"C p%1F1F15k1B'D Ede
ll/$67k."5 a+u68ggmmK6P3	2GG12 	,	?
 #9o/ ''-=(;= / /  	C$#HHSM	 txx4e<=
7
"-txxA5IJ
$
/
$YDOOk]$(HHXr$:6; !< =)T5M9:## -.
.' GNN3&&44Q<NNEKL#%%33As;LL/67!4??1%77w 	,wqz9:6CD7FG#*dE]#: 	 	< !#

+= > 	KF66/V<&F" K?6IK"	K 	%(99: !N, &&r+;':< , , t9q="SXXd^3&	$))*:s ;;	
 ;;%#)+ ''55gsC +& +008T[[9%%k4;;?	T[[9 	2  5
	

	 	GK
 
	
 	
CaF +T1
nn["237%556
ll9D@A
llnapb 	LL89LLI/4 OL7(,+s$   7R'R	'R6R R%7'R*c           
         | j                  d       t        | j                  dz         }g }|D ]  }|d   D ]  }t        | j	                  |            }t
        j                  j                  |      d   }t        | j	                  t
        j                  j                  |d   |                  }	| j                         }
t        j                  j                  |	|
      }	t        j                  j                  ||
      }| j                  |	g|gd|       |j                  |	         | j                  |ddj                  t        t         |                   |j                  d	|z         | j                          y
)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  r  r   r   r   )r   r   r   r   variabler	  rA  rM   rp   r   r!  s              r<   r   zMakefileWriter.WriteCopiesZ  sI    	LL/0'(=(=	(IJHG w- $./77==&q)4??277<<]8K8@,B C D $$&$$2263?""00s;4&&+>v), 	LLh['1J(KLM8+,LLNr>   c                 ~   | j                  d       t        j                  j                  t        d   | j
                  t        t        t        | j                  |                  D ]U  \  }}t        j                  j                  |      \  }}|dk7  s.| j                  |g|gdd       |j                  |       W y)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   r   r   r   rL   rM   ry   r  r   )r   	resourcesbundle_depsr   rr   r   r_   s          r<   r   z&MakefileWriter.WriteMacBundleResources  s    LL9:**@@#M2D4G4GIs4??I679 # ww'fa		3%)J$( 	 	*6"#r>   c                     t         j                  j                  t        d    j                   fd      \  }}}}|sy|rWdt
        j                  j                  |      z   } j                  ||dz   dt                j                  |g|gdd	g       |} j                  | j                  |
              j                  |g|gdd       |j                  |       y)z0Write Makefile code for bundle Info.plist files.r   c                 8    t        j                  |             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-plistTrE  )r,   r   GetMacInfoPlistr0   r   rL   rM   r   r4  r   r2  r  r  r  r   )r   rH  
info_plistrD   defines	extra_envintermediate_plists   `      r<   r   z MakefileWriter.WriteMacInfoPlist  s    *-*=*=*M*M#M2D4G4G/+1'JWi :
''

:
&'
nnW03HH$   "
,-
|% )*+
 &jT##	#BDOOSEJ<)E $  &sr>   c           
      2	   t        |j                               D ]  }||   }	| j                  |	j                  d      d|z  dt               | j
                  dk(  r| j                  j                  |      }
| j                  j                  |      }| j                  j                  |      }| j                  j                  |      }| j                  j                  |      }n3|	j                  d      }
|	j                  d      }|	j                  d      }| j                  d	       | j                  |
d
|z         | j                  d       | j                  |d|z         | j                  d       | j                  |d|z         | j
                  dk(  rL| j                  d       | j                  d|z         | j                  d       | j                  d|z         |	j                  d      }|r'|D cg c]  }t        | j                  |             }}| j                  |d|z  d        t        t         |      }|D cg c]+  }| j#                  | j                  t%        |                  - }}| j                  |d       |D ]  }d|vrJ d|z          | j                  d       | j                  d       | j                          |r| j'                  dg|dd       |r| j'                  dg|d d       |j)                  ||      }|rC| j                  d!       |D ]  \  }}}| j                  |d"|        | j                  d#       |r|j+                  d       | j                  d$       | j                  d%       | j                  d&|j-                  d'      z  d(z          | j                  d)|j-                  d*      z  d+z          | j
                  dk(  rL| j                  d,|j-                  d-      z  d.z          | j                  d/|j-                  d0      z  d1z          | j/                  |j1                                ||D cg c]  }t3        |      s| c}z  }| j                          y2c c}w c c}w c c}w )3a  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'
    rQ  zDEFS_%srK  )prefixrL  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_dirszINCS_%sz-I)rU  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))N)rX   rY   r4  rH   r   r9   r   	GetCflags
GetCflagsCGetCflagsCCGetCflagsObjCGetCflagsObjCCr   r   r   filterrs   	Objectifyrz   r2  GetObjDependenciesr   
GetIncludeWritePchTargetsGetPchBuildCommandsrw   )r   r   r   r   r   r   r   precompiled_header
confignameconfigrV  rW  rX  cflags_objccflags_objccincludesinclude
compilabler   objsobjpchdepsr   gchs                           r<   r   zMakefileWriter.WriteSources  s    W\\^, D
z"f
nnVZZ	*I
,B4   " 
	$$..z:&&11*=''33J?	))77
C**99*EH%::j)JJ{+	
ll89
nnV[:56
ll45
nnX}z9:
ll67
nnY ;<		9:{$4z$AB;<|%6%CDN+h	GOPGIdoog67PP
nnXy:5dnC=D@ 
G,J@JK1DNN4??6!956KDKNN4  B^ B
9S
@B^B 	LL % &LL&'LLN 
)d$7&*  , 
)m$7&*  ,
 !33JFG
llOP% ,
&#sc*+,
ll:;Y'
ll C D ll34
ll  .88=>.	. / ll  .88>?/	/ 0 
	  0::3?@3	3 	4 	  0::4@A4	4 	5 	+??AB WI68HIIOLLN] Q LP Js   <!R
0RR0Rc           	      h   |sy|D ]  \  }}}}ddddd|   }ddd	d
d|   }| j                  |d|d|ddz   |z          | j                  |d|d       | j                  d|z         | j                  d       d|vs
J d|z         | j                  d|z         | j                  d        y)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)))r^  ra   r_  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)r.  )r   )r   pch_commandsrw  	lang_flaglangr'  extra_flagsvar_names           r<   rj  zMakefileWriter.WritePchTargets&  s    '3 #Ye')CF	
 	k   #	
 	h llc8Y?-- 	   llC78
ll/$67
ll2^ ?
6#
=?^
ll#c)*
ll23r>   c                 H   | j                   rJ | j                  dk(  r(| j                  dv r| j                  j	                         S |d   }d}d}| j                  dk(  r|dd dk(  r|dd }d}d	}np| j                  d
v r$|dd dk(  r|dd }d}| j                  dk(  rd	}nAd}n>| j                  dk(  rd|z  }n)| j                  dk7  rt        dd| j                  d|f       |j                  d|      }|j                  d|      }|j                  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  sY    !!!!{{e		 .M !M  2244- FMJyy$$	u	mj	;	;	u	m		

	f	F"f	l	";TYY&2 3 HH-}=MXXnf-F((./K$j6!J..r>   c                 b    | j                   dk(  xr | j                  dk(  xr | j                  dv S )Nr   r   r  )r   r9   r   r   s    r<   _InstallImmediatelyz"MakefileWriter._InstallImmediatelyr  s?    <<8# Ou(< O OO BO Or>   c                 P   | j                   rJ t        j                  j                  d| j                  z   | j                        }| j
                  dk(  s| j                         rd}|j                  d|      }t        j                  j                  || 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     !!!!77<<	DLL0$))<DyyL D$<$<$>d88M4(D77<<d88>??r>   c                     | j                   sJ t        d   }t        j                  j	                  || 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77<<d11@@BCCr>   c                     t         d   }t        j                  j                  || 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  s0    &}5D77<<d11CCEFFr>   c                 t   g }g }d|v rn|j                  |d   D cg c]  }t        |   r	t        |    c}       |d   D ]#  }|t        v s|j                  t        |          % |j                  |       t        j
                  j                  |      t        j
                  j                  |      fS c c}w )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).
    dependencies)extendr   r   r   r,   r-   uniquer)r   r   r   r   deps        r<   r   zMakefileWriter.ComputeDeps  s     DI
kk$~2F +3$S) "#& + ,n% 2#""


+C0
12 kk) JJt$cjj&8&8&CDD+s   B5c                 D    | j                  | j                  g|dd       y )Nz Build our special outputs first.Tr[  )r2  r   )r   r   r   s      r<   WriteDependencyOnExtraOutputsz,MakefileWriter.WriteDependencyOnExtraOutputs  s(    **+]!C$(  *r>   c                      j                  d       |r1 j                   j                  |        j                  ||dd       i } j                  dk7  rt        |j                               D ]  }	||	   }
 j                  dk(  r j                  j                  |	t        d    fd      }t        j                  j                   j                        } j                  j                  |	t!        t"        j                  j%                  t"        j                  j'                  | j(                                    t!        t"        j                  j%                  t"        j                  j'                  | j                                          }|rf|||	<   n`|
j+                  d	g       }t-        d
 |D              r<|j/                  d j0                  z         |j/                  d j0                  z         |
j+                  dg       }||D cg c]  }d|z  	 c}z  } j3                  |d|	z          j                  dk(  s؉ j3                   j                  j5                  |	      d|	z          |j+                  d      }|rIt        j                  j7                  |      } j                  dk(  r j                  j9                  |      } j3                  |d        j                  dt!         j                        z          j                  dt!         j                        z          j                  dk(  r' j                  dt!         j                        z         g } j                  dk(  rA|r|j/                  d       |j;                  t        j<                  j?                  |             |rJ jA                   j(                   jC                                |D ]N  }	 j                  t!         j(                        d|	dt        j                  jE                  ||	                P |jG                  dt        j                  jE                  d j                  g             tI        |      D ]%  \  }}|jK                  d      rtM        |      ||<   '  j                  dt!         j(                        z          j                  t!         j(                        ddj'                  |              jN                  r j                   j(                  |        j3                  tQ        t         |      d        j                  d t!         j(                        z          j                  d!v r, j                  d" j                  jS                         z         |r j                  d#       g } j                  d$        j                  d%t!         j(                        z         |r+ jN                  rJ d& jT                  z         d'|vsJ d(        j                  d)k(  r j                  t!         j                        d*dj'                  tQ        t         |                    j0                  d+k(  r2 j                  d,k(  r# jW                   j                  g|d-||.       n jW                   j                  g|d/||.       nӉ j                  d0k(  ru|D ]  }d|vrJ d1|z           j                  d2vr/ jX                  s# jW                   j                  g|d3||.       nr jW                   j                  g|d4||.       nO j                  d5k(  rh j                  t!         j                        d*dj'                  tQ        t         |                    jW                   j                  g|d6||.       n؉ j                  d7k(  rw|D ]  }d|vrJ d8|z           j0                  d+k(  r1 j                  d,k(  r" jW                   j                  g|d9||.       nt jW                   j                  g|d:||.       nR j                  dk(  r" jW                   j                  g|d;||.       n!t[        d< j                   jT                          j(                  r j(                   jT                  k7  rf j                   j\                  vrN j                   jT                  g j(                  gd=d>       |r! j                  d?g jT                  gd@d>        j                   j\                  v s jX                  rq j                  d5k(  rdA}n j                  d0k(  rdB}nd)} j_                         } j(                  g} j                  dk(  r8d'|vr4 j0                  dCk(  r%| j(                  k(  sJ |dD j(                          j                   jT                  g|gd=d>       | j(                  k7  rD jN                  rJ  jW                  |g j(                  gdEdF|z  |G       |j/                  |        j(                   j`                  k7  r< j`                   jT                  k7  r# j                   j`                  g|dH|z  d>       |r j                  d?g|gdI|z  d>       yJyJyJc c}w )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.Tr[  r  r   r   c                 8    t        j                  |             S rk   r   r   s    r<   r   z,MakefileWriter.WriteTarget.<locals>.<lambda>  s    	$//!"45 r>   ldflagsc              3   J   K   | ]  }|j                  d       xs d|v   yw)r+   z.so.Nrl   )rn   r  s     r<   rq   z-MakefileWriter.WriteTarget.<locals>.<genexpr>  s%     F#e$5#5Fs   !#z-Wl,-rpath=\$$ORIGIN/lib.%s/z$-Wl,-rpath-link=\$(builddir)/lib.%s/library_dirsz-L%sz
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)r\  phonyallz!Add target alias to "all" target.zshared libraryzstatic libraryr   z != rA  z Copy this to the %s output path.)r\  r   z!Short alias for building this %s.zAdd %s to "all" target.N)1r   r  r   r2  r   rX   rY   r9   r   
GetLdflagsr0   r,   r-   InvertRelativePathrM   AddImplicitPostbuildsr   rL   rN   rO   r   rH   anyr   r   r4  GetLibtoolflagsr  AdjustLibrariesr  r   GetSpecPostbuildCommandsr  GetSortedXcodePostbuildEnvr  insert	enumerate
startswithr   r   r   GetFrameworkVersionr   r  r   r   r   r   r   )r   r   r   r   r   rH  r   r   target_postbuildsrm  rn  r  gyp_to_buildtarget_postbuildr  library_dirr  r  r(  	postbuildlink_dep	file_descr   installable_depss   `                       r<   r   zMakefileWriter.WriteTarget  s
    	LL./
((););]K
#<&*  ,
 yyFw||~. 9*$;;%''22:)-857'
 66tyyA,!00FF"''**277<<8<,E F G"''**277<<8<8J8J,L M N	O
 ,<j)JJy"-'FFF NN:T\\IJNNB<<( )zz."5lK{Vk)KKwz 9:;;%
..,,<<ZH*Z79=9@ ((;'i	JJ&&y1	;;%))99)D)
nnY'
ll?
d((
)* +
ll(;t7I7I+JJK		K**+, 	-
 J{{e	=>



6
6t
<>  t{{D,K,K,MN) N*%ZZ,,->z-JKM 	NN 3::::D$));LMN#J/ 9,!Y##C(-i8*Q-9 ll4{4;;7OOP
ll
dkk
"CHHZ$8: ;  ((mD nnSk2MB
ll'+dkk*BBC 
;	;C3356 	7
 
/0j ll45 ll#k$++&>>?## I ':<@KK'H I#$&   *  & yyL 
ll
d((
)
((3{I.
/1 2 
	DKK9$<++,i#
 	 	< 	++,i#- 	 	/ 
&	& N((" 	N@HL	N"N ++@
@

+
+++,i#
 	 	< 	++,i+#- 	 	/	&	&
ll**+HHSi013 4 oot))*Ix!+  -	'	' O((" 	OAXM	O"O 
	DKK9$<++,i9M#
 	 	< 	 )_k! 	 	# 
f	
oot))*D';!+  - $dii= 
3	$33	3
$++!3T  C	E7T[[M%H#' 	 	) 			T...))	&	&$	99(($	 	779l++
++
}'<
,,(
"t{{* 	'$++-' 	'* $++!3T  C		$%%%%v"D!#"/: 	 	< 	-	

	"tzzT[['@DJJ<)9%H$&%.2 	 	4 
E7\N%>%J#' 	 	) 
9 	*u Ls   kNr   c                     d}|r,|D cg c]  } |||z          }}ddj                  |      z   }| j                  j                  |d|d       yc c}w )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   z \
	z :=z

N)rO   r   r\   )r   
value_listrC  rU  rL  valuesls          r<   r4  zMakefileWriter.WriteList  sU     F0:;1F6A:&;j;9>>*55fGGMM8V45 <s   Ac                     d}|rd|vsJ d}| j                  ||d||dg||d       |D cg c]  }t        |t               }}| j                  dd	j	                  |      z         y
c c}w )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   r\  r  forcer.  r   N)r2  r   SPACE_REPLACEMENTr   rO   )	r   r	  r  r  r   r\  r  suffixr&  s	            r<   r  zMakefileWriter.WriteDoCmd  s     Ffw;BF"K!L!(!(#	  % ;BBQ{1/0BGBLL!CHHW$556 Cs   A,c	                    |D 	cg c]  }	t        |	       }}	t        t         |      }|r| j                  d|z          |r#| j                  ddj                  |      z          |r| j                  d|d   z         |rdnd}
|r8| j                  dj                  |      ddj                  |      |
       nt	        |      d	k(  r+| j                  |d   d
dj                  |      |
       n|r|n| j
                  j                  d      }t        j                  |      j                         }d|z  }| j                  dj                  |      d
|       | j                  ddz         | j                  dd
|       | j                  |d
dj                  |      |
       |j                  dd       |r|D ]  }| j                  d|z          | j                          yc c}	w )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
    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)r   r   r   rO   r   r   encodehashlibsha1	hexdigestr  )r   r	  r  r   r\  r]  r  r  r  r&  force_append	cmdstring	cmddigestintermediater  s                  r<   r2  zMakefileWriter.WriteMakeRule  s     (//!{1~/G/f%F
ll4'>"
ll: 112
ll.;<&+?L llHHW%sxx'7G H	W	
llSXXf-=|LM &74;;>>wGi,,y)335i&)4l
llsxx0,?@
ll6D=!
ll=>
ll #((6"2LB CnnQ./ &&Vf_%&LLNW 0s   G3c           	         | j                   dvry| j                  d       | j                  d       | j                  d|z          | j                  d       | j                  d       | j                  d       | j                  d	       d
d
d
d}d}|D ]D  }t        j                  j	                  |      d   }||v s*||xx   dz  cc<   ||   ||   kD  sC|}F | j                  d|z          | j                  t        | j                  t        t        |            d       d }ddi}	i }
t        |
|	       | j                   ||t        d   |
d         d       | j                   ||t        d   t        d         d       | j                   dk(  r| j                  d       nA| j                   dk(  r| j                  d       n | j                   dk(  r| j                  d       | j                          y)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 ]l  }t         j                  j                  |      }|j                  |      s4|j	                  |      sF|j                  |t        |      t        |               n |S rk   )rL   rM   r   r  rm   r   r   )r   rU  r  modulesfilepathrp   s         r<   DepsToModulesz?MakefileWriter.WriteAndroidNdkModuleRule.<locals>.DepsToModules2  si    g =(77##H-v&8+<+<V+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   ry   r4  r   r   rf  rs   r=   r0   )r   module_namer   r   cpp_extdefault_cpp_extrp   r_   r  r8   r7   s              r<   r   z(MakefileWriter.WriteAndroidNdkModuleRule   s    yyJJLLBCLL()LL#k12LL 	( 	) 	LL>?LL&'LLBC A.GO  GGX&q)c	3<'/22/  	LL*_<=NN3tz;(GH$&
  F(&1NNi12EF'(;<	> 	!	"
 	NNi12EF12EF	H 	!	" yyL 
ll01	&	&
ll45	&	&
ll45LLNr>   c                 @    | j                   j                  |dz          y )NrW   )r   r\   )r   texts     r<   r   zMakefileWriter.WriteLnS  s    GGMM$+r>   c                     t         j                  j                  | j                  dt        j
                  j                  d| j
                        d|      S )Nz$(abs_builddir)z$(abs_srcdir)r   )r,   r   r  r   rL   rM   rO   )r   rN  s     r<   r  z MakefileWriter.GetSortedXcodeEnvW  sB    00.
_dii0. r>   c                 b    | j                   j                  dd      }| j                  d|i      S )NCHROMIUM_STRIP_SAVE_FILEr   rM  )r   GetPerTargetSettingr  )r   strip_save_files     r<   r  z)MakefileWriter.GetSortedXcodePostbuildEnv^  sC     ))=="B(O !!7I " K Kr>   c                 \    |D ]'  \  }}| j                  t        |      d|d|       ) y )Nz	: export r  )r   r   )r   r   r!  kvs        r<   r  z"MakefileWriter.WriteSortedXcodeEnvi  s1     H1 llK,?AFGHr>   c                 x    d|v r|j                  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<   rg  zMakefileWriter.Objectifyt  s>    t|\\)%;dll%JKdt)-t<dKr>   c                     | j                  |      }d|v r$|j                  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}  sR    ??4 Dt|\\)<<&/ 0dk  /3llD$GGr>   c                     d|v r|j                  d      S t        j                  j                  t        j                  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  sD     t| [[77BGGLLD9::r>   c                 *    d|vrd|vr|S |||dz  }|S )Nr
   r   )
INPUT_ROOTINPUT_DIRNAME )r   template	expansionr  rM   s        r<   r1  zMakefileWriter.ExpandInputRoot  s3    x',?x,Oo 
 
D Kr>   c                     | j                   dk(  r:| j                  dk7  s| j                  dk7  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  sM     			%%		!9 )-djjAADJJ&&r>   )NF)NNFFFN)r   rk   )$__name__
__module____qualname____doc__r   r   r  r   r   r   r   r   r   rj  r  r  r   r   r   r   r  r   r   r4  r  r2  r   r   r  r  r  rg  r   r   r1  r   r  r>   r<   r   r     s    
+6BJ6aH}@#L#6zxB(/VO
@DGE,*i)X ,0'6 GK!70 BFHL;|PfKHH;	'r>   r   c                 >   | d   }| d   D cg c],  }t         j                  j                  ||j                        . }}t         j                  j	                  | d   |j                        }|j                  t        j                        s t        j                  j                  d|      }|j                  d|dj                  t        t        |            t         j                  j                  |dgt        j                  |      z   |z         dz         y	c c}w )
z,Write the target to regenerate the Makefile.rB   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-   RelativePathrK   FixIfRelativePathr  rL   seprM   rO   r\   r   r   r  RegenerateFlags)r8   root_makefiler	  build_filesrB   rp   build_files_argsr  s           r<   WriteAutoRegenerationRuler    s	    9'&,->&?A" jj--h8L8LM A A zz++F<,@,3,@,@B*			rvv	&c:.J, )((3y+6700 (+((12%&'/(	(
)As   1Dc                     |d   }|D ]k  }dg}|j                   r |j                   dk7  r|d|j                   fz  }|j                  d|z          t        d|d|       t        j                  |       m y )NrB   maker  z-Cz
BUILDTYPE=z
Building [z]: )rK   r   r   
subprocess
check_call)dataconfigurationsr8   rB   rn  	argumentss         r<   PerformBuildr    s{    9' %fI 4 4 ;4----i\F*+	
34)$%r>   c                   3 |d   3t         j                  j                  |      }|j                  di       }|j                  dd      }|j                  dd       }|j                  dd      }3fd}	d }
t	        | D cg c]
  }||   d	    c}      }| D ]  }||   }|d
   dk7  s|d
   }
 n |
sd}
d}d3j
                  z   }t        j                  j                  3j                  |      }3j                  rat        j                  j                  3j                  3j                  |      }t         j                  j                  |3j                        }dad}d}d}|||
|dt        d|||d
}|dk(  r!d}|j                  |dt        t         d       n|dk(  r|j                  dt"        i       ny|dk(  rd}d}|j                  ||t$        d       nV|dk(  r|j                  d dd!       n<|d"k(  rd#}|j                  d$|i       n!|d%k(  rd#}|j                  |t&        d dd&       |j                  t)        d'd(      t)        d)d*      t)        d+d,      t)        d-d.      t)        d/d0      t)        d1d2      t)        d3d4      t)        d5d6      d7       t         j                  j+                  | d8         \  }}}||   j                  d9g       }i }|D ],  \  }}|j-                  d:      sd;|z  ||d t/        d:        <   . d}|D ]  \  }}t1        j2                  d<|      r|d8   d=k7  rd;|z  }|j                  |      }|r
|d>|}||= |d?v rQ|d@|z  z  }|j5                  ddA      }|t        j6                  v rt        j6                  |   }|dB|dC|dDz  }|dEz  }||dF|dDz  } ||d9<   t         j                  j9                  |       t;        |dG      }|j=                  t>        |z         |r|j=                  dH       |D ]!  }|j=                  dI|z         tA        |       # t        j                  jC                  |      } t         j                  jE                  ||        t	               }!|dJ   D ]9  }t         j                  jG                  | ||      D ]  }|!jI                  |        ; t	               }"t	               }#| D ]  }$t         j                  j+                  |$      \  }}}||   j                  d9g       }%||%k(  sJ dK|%dL|       |"jI                  t         j                  j                  |3j                               ||   dM   }&|&D ]  }'t         j                  j                  t         j                  jK                  |'|      3j                        }(t        j                  jM                  |(      })|dN   r&|)jO                  |dN         r|"jI                  |)       |"jI                  |(         |	||dz   |z   3j
                  z   dOz         \  }*}+||$   }|dP   },|dk(  r#t         jP                  jS                  ||   |       tU        ||      }-|-jW                  |$|*|+||,|$|!v Q       t         j                  j                  |+t        j                  jC                  |            }.|#jI                  |.        t         j                  j                  3jX                  t        jZ                               }/|"D ]
  }t        j                  j                  |/|      }| D cg c]  }|jO                  |      r||!v r||   dR   ! }0}|0sQ |	|t        j                  j]                  t        j                  j_                  |            d8   dSz         \  }*}+t         j                  j                  t        j                  jC                  |      t        j                  jC                  |+            }1-ja                  |+|1|0|        |j=                  dD       tc        |#      D ]A  }2|j=                  dT|2z   dUz          |j=                  dV|2z   dDz          |j=                  dE       C |j=                  dD       |j                  dW      s |j                  dXdY      rte        ||||"       |j=                  tf               |ji                          y c c}w c c}w )ZNrB   r@   rC   rD   rA   default_targetr  c                    t         j                  j                  t        j                  j                  |       j                        }t        j                  j                  j                  ||      }j                  r6t        j                  j                  j                  j                  ||      }t         j                  j                  t        j                  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(/7I '',,w}}iCKGGLL
--119iIk

''
(C(/(<(<>Ik!!r>   r   default_configurationDefaultr  Makefilez
$(srcdir)/flockz-afz-MMDr   r   )
r  builddirr#  r&  flock_indexlink_commandsextra_commandssrcdircopy_archive_argsmakedep_argsr   z./gyp-mac-tool flock   )r&  r(  r)  r*  r(   r)  zosz-fPRz-qmakedep=gcc)r,  r-  r)  solarisz./gyp-flock-tool flock)r&  r(  r  z-pPRfr,  r*   )r,  r)  r&  r(  )	CC_targetCCz$(CC))	AR_targetARz$(AR))
CXX_targetCXXz$(CXX))LINK_targetLINKz$(LINK))CC_hostr2  gcc)AR_hostr4  ar)CXX_hostr6  zg++)	LINK_hostr8  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   )r2  r?  r6  r@  z3ifneq (,$(filter $(origin %s), undefined default))
r   r   rB  rW   zendif
z ?= r   zU# Define LOCAL_PATH for build of Android applications.
LOCAL_PATH := $(call my-dir)

zTOOLSET := %s
r  z;make_global_settings needs to be the same for all targets. z vs. included_fileshome_dot_gypz.mkr  rE  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  getcwdry   r   r  rX   r  SHARED_FOOTERr   )4target_listtarget_dictsr  r8   r9   r@   rQ   rA   r  r"  r#  r   toolsetsr   r+  r	  r  flock_commandcopy_archive_argumentsmakedep_argumentsheader_paramsr  r   make_global_settings_arraywrappersrU   valuerA  wrapperenv_keyr  r   	dest_pathneeded_targetsr  include_listr   this_make_global_settingsrC  included_filerelative_include_fileabs_include_filer   r!  r   r]   mkfile_rel_pathdepth_rel_pathgyp_targetsmakefile_rel_pathinclude_filerB   s4                                                      @r<   GenerateOutputrp    s<	   9'::'&JJ0"5/!%%lE:-'++,A4H"&&'7?."( Lf,v&y1LM( fD#$	1"#:;	
 
%&w~~--'',,w33]C-GGLLg66GMZZ$$VW-E-EFF M- &4*1'- u_*M*4	  .  #'3), 
 )  $3  $3*)	  %&97C%&97C%&;XF%&=yI%&7?%&7>%&95A%&;]K	 	 ZZ44[^D*a#J/334JBO(. Ajc5
||J)85)@hs$S_$%&A . :jc5	xxc"Qx3%ell3G %(e
3-
22
@3
FH C%g	BJJ	

7#sE::i'c599':. +?-&'**]+}c*-mm34 	  .g)G34}-.
 ggoom,)**fi( 5.=) !j**''\:N ! !! +,% ,&"%**"A"A#J !%Z 0 4 45KR P%)BB ;	"$8	:;B OOCJJ++J8L8LMN*%&67N' / "jj55
**
#
#M:
>


  )>? 
 

%
%f^&<
=()-./  3:w/%79I{ ()D#$G	88j9I4POV4F
LL!9k4-?  A
 jj--k.0ggoom.LNO_%Y,&^ ::**7=="))+F. 'j nj9JEP -6''
3^+  '6 -K - 2:
))*56q9KGII{

//0N020LN
%6%''( d\* 
#l
 	%'3	46@	AB |3d:;	"
# d


l
+


14
8fm]KPm$W MP-s   >c+=$c0)z\ )6
__future__r   rL   r   sysr  r,   
gyp.commongyp.xcode_emulationr   r   r  r0   $generator_supports_multiple_toolsetsrI   r!   r"   r#   rP   r=   rR   r  rG  rH  rJ  rL  rK  rP  rI  r`   r   r   rW  r   r5   rs   rw   rz   r   r   r   r   r   r   r   r   r   r   r   objectr   r  r  rp  r  r>   r<   <module>rw     s
  0 & 	 	 
  
   )   8)%+$"#& $ (, $ ', # /1 +%' "$& ! "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@ 
  p'V p'f')2%Hr>   