HEX
Server: Apache/2.4.65 (Debian)
System: Linux kubikelcreative 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64
User: www-data (33)
PHP: 8.4.13
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/gyp/generator/__pycache__/make.cpython-39.pyc
a

�o�_�i�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlZddddddd	d
ddd
dddd�ZdZ
dagagagadadd�Zdd�ZdZdZdZdZdZdZdeded ed!ed"ed#Zd$Zd%d&�Zd'Zd(Zd)Z d*Z!d+d,d,d,d+d+d-�Z"d.d/�Z#d0d1�Z$d2d3�Z%d4d5�Z&d6d7�Z'd8d9�Z(d:d;�Z)d<d=�Z*da+d>d?�Z,dMdAdB�Z-dCdD�Z.iZ/iZ0GdEdF�dFe1�Z2dGdH�Z3dIdJ�Z4dKdL�Z5dS)N�)�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))ZEXECUTABLE_PREFIXZEXECUTABLE_SUFFIX�STATIC_LIB_PREFIX�SHARED_LIB_PREFIX�STATIC_LIB_SUFFIXZINTERMEDIATE_DIRZSHARED_INTERMEDIATE_DIR�PRODUCT_DIRZRULE_INPUT_ROOTZRULE_INPUT_DIRNAMEZRULE_INPUT_PATHZRULE_INPUT_EXTZRULE_INPUT_NAMEZCONFIGURATION_NAMETFcCs�tj�|�}|dkr�|�dd�|�dd�|�dtd�|�dtd�dd	lmm}t|d
g�a	t|dg�a
t|dg�at�
d
dd��nV|}|dkr�d}|�d|�|dkr�|�dd�n|�dd�|�dd�|�dd�d	S)zDCalculate additional variables for use in the build (called by gyp).�macZOS�SHARED_LIB_SUFFIXz.dylibZSHARED_LIB_DIRrZLIB_DIRrN�+generator_additional_non_configuration_keys�"generator_additional_path_sections�!generator_extra_sources_for_rulesZobjcZobjcxx)�.m�.mm�android�linux�aixr�.soz$(builddir)/lib.$(TOOLSET)z$(obj).$(TOOLSET))�gyp�common�	GetFlavor�
setdefault�generator_default_variablesZgyp.generator.xcode�	generatorZxcode�getattrrrr�COMPILABLE_EXTENSIONS�update)�default_variables�params�flavorZxcode_generatorZoperating_system�r'�4/usr/lib/python3/dist-packages/gyp/generator/make.py�CalculateVariablesDs<�����r)cCsl|�di�}|�dd�}|r da|djp2|dj}|�dd�}tj�tj�||d��}|dj|d	�adS)
zOCalculate the generator specific info that gets fed to input (called by
  gyp).�generator_flags�android_ndk_versionNT�options�
output_dir�outZgypfiles)Ztoplevel�qualified_out_dir)	�get�#generator_wants_sorted_dependencies�generator_output�toplevel_dir�os�path�normpath�join�generator_filelist_paths)r%r*r+r-�
builddir_namer/r'r'r(�CalculateGeneratorInputInfois
���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)
ahquiet_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 "$@"
cCs�tt��tjd�}|�d�|D]$}|�d|�|�dt|�q |�d�|D]$}|�d|�|�dt|�qT|�d�|D]$}|�d|�|�dt|�q�|�d�dS)	N)�key�1# 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
)�sortedr"�keys�str�lower�write)�writer�
extensions�extr'r'r(�WriteRootHeaderSuffixRuless 

�
rGr=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.

�ccZcxx)�.c�.cc�.cpp�.cxx�.s�.Scs&�fdd�tD�D]}|rdSqdS)z:Return true if the file is compilable (should be in OBJS).c3s|]}��|�VqdS�N��endswith)�.0�e��filenamer'r(�	<genexpr>J�zCompilable.<locals>.<genexpr>TF)r")rU�resr'rTr(�
CompilableHsrYcCs
|�d�S)zAReturn true if the file is linkable (should be on the link line).�.orPrTr'r'r(�LinkablePsr[cCstj�|�ddS)z1Translate a compilable filename to its .o target.rrZ�r4r5�splitextrTr'r'r(�TargetUsr^cCsd|�dd�dS)z�Quotes 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��sr'r'r(�EscapeShellArgumentZsrdcCs|�dd�S)zrMake has its own variable expansion syntax using $. We must escape it for
     string to be interpreted literally.�$z$$r`rbr'r'r(�EscapeMakeVariableExpansionbsrfcCst|�}t|�}|�dd�S)zBEscapes a CPP define so that it will reach the compiler unaltered.�#z\#)rdrfrarbr'r'r(�EscapeCppDefinehsrhcCs d|vrd|�dd�d}|S)zSTODO: Should this ideally be replaced with one or more of the above
     functions?�"z\"r`��stringr'r'r(�QuoteIfNecessaryqsrlcCst�dd|�S)zGConvert a string to a value that is acceptable as a make variable name.z
[^a-zA-Z0-9_]�_)�re�subrjr'r'r(�StringToMakefileVariableysrpcCs$d|vr|Stj�|�r|St|S)z,Convert a path to its source directory form.�$()r4r5�isabs�
srcdir_prefix)r5r'r'r(�	Sourceifys
rt�\ cCs|�d|�S)N� r`)rcZquoter'r'r(�QuoteSpaces�srwc
Cs�|�dd�dkrdSi}|D]@}tj�|�\}}|dv}|s>qtj�|�}|�|g��|�qd}|��D]*\}}	t|	�dkrj|d|d�	|	�f7}qj|r�t
d	|d
|dd�td
��dS)z�Makes 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)rIrJrKrLrrrMrNr�z	  %s: %s
rvz<static library %s has several files with the same basename:
�target_namezlibtool on OS X will generatez warnings for them.z6Duplicate basenames in sources section, see list above)r0r4r5r]�basenamer�append�items�lenr7�printr)
�spec�all_sourcesZ	basenames�source�namerFZis_compiled_filer|�error�filesr'r'r(�_ValidateSourcesForOSX�s2����r�c@seZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'efd(d)�ZdCd+d,�ZdDd-d.�Zd/d0�ZdEd1d2�ZdFd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#d&S)G�MakefileWriterz�MakefileWriter packages up the writing of one target-specific foobar.mk.

  Its only real entry point is Write(), and is mostly used for namespacing.
  cCs�||_||_i|_i|_i|_t��D]X}|j�|d|t|fi�|j�|d|t|fi�|j�|d|t|fi�q&dS)NzT$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(srcdir)/%%%s FORCE_DO_CMD
	@$(call do_cmd,%s,1)
z\$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj).$(TOOLSET)/%%%s FORCE_DO_CMD
	@$(call do_cmd,%s,1)
zQ$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD
	@$(call do_cmd,%s,1)
)r*r&�suffix_rules_srcdir�suffix_rules_objdir1�suffix_rules_objdir2r"r@r#)�selfr*r&rFr'r'r(�__init__�s

�

�

�zMakefileWriter.__init__csdtj�|�t|d��_�j�t�|�_|�_|d�_	|d�_
|d�_tj�
�j|��_�jdkrztj�|��_nd�_��|�\}}g}	g}
g}g}g}
�jrˆ�|��_��|��_n��|��_�_t|�dd���_d	�_�j�s�j
�jv�rtj��j��_���}n�j�_�j}�� d
�j��� d�j	�d|v�rj��!|d|
|	||�d
|v�r���"|d
|
|	||�d|v�r���#|d|	|��j�r�|�dg�|}��$||
���%|
�|�dg�|
}|�r��jdk�rt&||���'||||	||tj�(�j�fdd��j)��dd�|D�}|�r��� t*�t+dd�|D��}|D]"}|�j,v�rb�� �j,|��qb�� t-�|D]"}|�j.v�r��� �j.|��q�|D]"}|�j/v�r��� �j/|��q��� d��j�r�|
�0�j���1||||||
|	|�|t2|<�j
dv�r6�jt3|<�j4�dd��rV��5�j	||��j�6�dS)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{rx�toolsetrNZstandalone_static_libraryr)�
executable�loadable_module�shared_libraryzTOOLSET := z
TARGET := �actions�rules�copiesZmac_bundle_resources�sourcescst��|��SrO�rt�
Absolutify��p�r�r'r(�<lambda>3rWz&MakefileWriter.Write.<locals>.<lambda>cSsg|]}t|�r|�qSr')rY�rR�xr'r'r(�
<listcomp>5rWz(MakefileWriter.Write.<locals>.<listcomp>cSsg|]}tj�|�d�qS)rzr\)rRrcr'r'r(r�8rWz!# End of this set of suffix rules)ryr�r+)7rr�EnsureDirExists�open�fprC�header�qualified_targetr5�targetrxr��xcode_emulationZIsMacBundler&�
is_mac_bundleZ
XcodeSettings�xcode_settings�ComputeDeps�ComputeMacBundleOutput�output�ComputeMacBundleBinaryOutput�
output_binary�
ComputeOutput�boolr0�is_standalone_static_library�_INSTALLABLE_TARGETSr4r|�alias�_InstallableTargetInstallPath�WriteLn�WriteActions�
WriteRules�WriteCopies�WriteMacBundleResources�WriteMacInfoPlistr��WriteSourcesZMacPrefixHeader�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_resourcesZmac_bundle_deps�install_pathZall_mac_bundle_resourcesr�r�rErFr'r�r(�Write�s�




�
�

�
�
�

��


�
zMakefileWriter.WritecCs�tj�|�t|d�|_|j�t�|�dtj	�
tj	�|�|��|�d�|�d�|rdd|}|�d|d�
|�f�|j��dS)	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�zexport builddir_name ?= %sz.PHONY: allzall:z -C z
	$(MAKE)%s %srvN)
rrr�r�r�rCr�r�r4r5r7�dirnamer�)r�r��
makefile_path�targetsZ	build_dirr'r'r(�WriteSubMake[s�

zMakefileWriter.WriteSubMakecs�����|D�]|}td�j|df�}��d|d�|d}|d}	t�}
|	D]"}tj�|�d}|rT|
�|�qTt	|�
dd��r�||	7}t	|�
d	d��r�||	7}|d
}
�jdkṙfdd
�|
D�}
tj
�|
�}d|vr���d||df�n��d||f�t|
�dk�r.dd�|
�d|}dt�j�p<d�}|�d�j�}|�d�j�}��d|||f�����fdd
�|	D�}	��dt|	d����dt|	d����|	d����|D]}d|v�s�Jd|���q�|	D]}d|v�s�Jd|���q�fdd
�|	D�}	�fdd
�|D�}�j|	ttt�j|��||d�d|}��d |d�|	�f�|�d!|����q���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'
    �%s_%sZaction_namez### Rules for action "%s":�inputs�outputsr�process_outputs_as_sourcesF�'process_outputs_as_mac_bundle_resources�actionrcsg|]}tj�|���qSr'�rr��
ExpandEnvVars�rR�command��envr'r(r��s�z/MakefileWriter.WriteActions.<locals>.<listcomp>�messagezquiet_cmd_%s = ACTION %s $@zmkdir -p %srvz; �cd %s; �.�	$(TARGET)ztcmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; %s%scsg|]}��|��qSr'�r��rR�or�r'r(r��rW�%s: obj := $(abs_obj)�%s: builddir := $(abs_builddir)z3Spaces in action input filenames not supported (%s)z4Spaces in action output filenames not supported (%s)csg|]}tj�|���qSr'r�r�r�r'r(r��rWcsg|]}tj�|���qSr'r��rR�ir�r'r(r��rW)r�r�zaction_%s_outputsz%s := %s�$(%s)N)�GetSortedXcodeEnvrpr�r�r�r4r5�split�add�intr0r&rr�EncodePOSIXShellListrr7rtrar�rw�WriteSortedXcodeEnv�
WriteDoCmd�mapr�r})r�r�r�r�r�r�r�r�r�r��dirsr.�dirZaction_commandsr��	cd_action�inputr��outputs_variabler')r�r�r(r�vsr
�

��	���
zMakefileWriter.WriteActionscs$����|D�]�}td�j|df�}d}��d|�g}	|�dg�D�]�}
t�}tj�|
�\�}tj�	|�\�}
���fdd�|dD�}|D]}tj�
|�}|r�|�|�q�t|�d	d
��r�||7}t|�dd
��r�||7}t
tt
�j|
g|�dg���}d
||fg}|dk�r&|dg7}�fdd�|D�}�fdd�|D�}�fdd�|D�}|	|7}	��d|d���d|d��j|||d||fd�t�d�}|D]*}t�|d|�}d|v�s�Jd|���q���dd�|�����fdd�|dD�}d}t|�dk�r*dd�|�}dt�j�p8d �}�jd!k�r\�fd"d�|D�}tj�|�}|�d#�j�}|�d#�j�}|�d#�j�}��d$|||||d%����d&||d'�����|d(7}qJd)|}��|	|�|�d*|���d+|����q��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�Z	rule_namerz### Generated for rule %s:Zrule_sourcescsg|]}��|����qSr'��ExpandInputRoot)rRr.��rule_source_dirname�rule_source_rootr�r'r(r��s��z-MakefileWriter.WriteRules.<locals>.<listcomp>r�r�Fr�r�z$(call do_cmd,%s_%d)Zresources_gritz@touch --no-create $@csg|]}tj�|���qSr'r�r�r�r'r(r�
rWcsg|]}tj�|���qSr'r�r�r�r'r(r�rWcsg|]}��|��qSr'r�r�r�r'r(r�rWr�r�z%s_%d)r�z\$\([^ ]* \$<\)rrvz/Spaces in rule filenames not yet supported (%s)�all_deps += %scsg|]}��|����qSr'r�)rRZacr�r'r(r�$s��r�z
mkdir -p %s; r�r�rcsg|]}tj�|���qSr'r�r�r�r'r(r�0s�r�z�cmd_%(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�rzzrule_%s_outputsr�z$### Finished generating for rule: %sz%### Finished generating for all rulesN)r�rpr�r�r0r�r4r5r�r]r�r�r�r�rtr��
WriteMakeRulern�compileror7rr&rrr�rar��	WriteListr})r�r�r�r�r�r�Zruler�r�Zall_outputsZrule_sourcer�Zrule_source_basenameZrule_source_extr�r.r�r�r�Zvariables_with_spacesr�r�rr�r�r')r�r�r�r�r(r��s�

�
��
�



�
��
������


zMakefileWriter.WriteRulesc	Cs�|�d�t|jd�}g}|D]�}|dD]�}t|�|��}tj�|�d}t|�tj�|d|���}	|�	�}
t
j�|	|
�}	t
j�||
�}|�
|	g|gd|�|�|	�q,q |�d|d�tt|��f�|�d	|�|��d
S)aWrite 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.Z_copiesr�rzZdestination�copyz%s = %srvr�N)r�rpr�rtr�r4r5r�r7r�rr�r�r�r}r�rw)r�r�r�r��variabler�rr5rUr�r�r'r'r(r�Zs$
�zMakefileWriter.WriteCopiesc	Cst|�d�tj�td|jttt|j|���D]@\}}t	j
�|�\}}|dkr.|j|g|gddd�|�
|�q.dS)z0Writes Makefile code for 'mac_bundle_resources'.z&### Generated for mac_bundle_resourcesrz	.xcassetszmac_tool,,,copy-bundle-resourceT�r�N)r�rr�ZGetMacBundleResourcesrr�r�rtr�r4r5r]r�r})r�Z	resources�bundle_depsr�rXrmrFr'r'r(r��s

��z&MakefileWriter.WriteMacBundleResourcescs�tj�td�j�fdd��\}}}}|s.dS|rrdtj�|�}�j||ddt	d���
|g|gd	d
g�|}��|�j|d���j
|g|gdd
d�|�|�dS)z0Write Makefile code for bundle Info.plist files.rcst��|��SrOr�r�r�r'r(r��rWz2MakefileWriter.WriteMacInfoPlist.<locals>.<lambda>Nz$(obj).$(TOOLSET)/$(TARGET)/z: INFOPLIST_DEFINES�-D)�quoterz$(call do_cmd,infoplist)z@plutil -convert xml1 $@ $@��additional_settingszmac_tool,,,copy-info-plistTr)rr�ZGetMacInfoPlistrr�r4r5r|rrhrr�r�r�r})r�rZ
info_plistr.�definesZ	extra_envZintermediate_plistr'r�r(r��s4

�
������z MakefileWriter.WriteMacInfoPlistcst|���D�]R}||}	�j|	�d�d|dtd��jdkr~�j�|�}
�j�|�}�j�	|�}�j�
|�}
�j�|�}n|	�d�}
|	�d�}|	�d�}��d	���|
d
|���d���|d|���d
���|d|��jdk�r*��d���|
d|���d���|d|�|	�d�}|�rL�fdd�|D�}�j|d|dd�qt
t|�}�fdd�|D�}��|d�|D]}d|v�s�Jd|���q���d���d����|�r�jdg|d d!d"�|�r��jdg|d#d!d"�|�||�}|�rF��d$�|D]\}}}��d%||f��q��d&�|�r�|�d���d'���d(���d)|�d*�d+���d,|�d-�d.��jdk�rֈ�d/|�d0�d1���d2|�d3�d4���|���|d5d�|D�7}���d6S)7aWrite 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'
    rzDEFS_%sr��prefixr	r�cflags�cflags_c�	cflags_ccz## Flags passed to all source files.z	CFLAGS_%sz# Flags passed to only C files.zCFLAGS_C_%sz!# Flags passed to only C++ files.zCFLAGS_CC_%sz"# Flags passed to only ObjC files.zCFLAGS_OBJC_%sz$# Flags passed to only ObjC++ files.zCFLAGS_OBJCC_%sZinclude_dirscsg|]}t��|���qSr'r�)rRZincluder�r'r(r��rWz/MakefileWriter.WriteSources.<locals>.<listcomp>zINCS_%sz-I)rcs g|]}����t|����qSr')�	Objectifyr�r^r�r�r'r(r��rWZOBJSrvz-Spaces in object filenames not supported (%s)z?# Add to the list of files we specially track dependencies for.zall_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 headers�%s: %sz%# 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 rHz0$(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))cSsg|]}t|�r|�qSr')r[)rRr�r'r'r(r�"rWN)r?r@rr0rhr&r�Z	GetCflagsZ
GetCflagsCZGetCflagsCCZ
GetCflagsObjCZGetCflagsObjCCr��filterrYrZGetObjDependenciesr}Z
GetInclude�WritePchTargetsZGetPchBuildCommands)r�r�r�r�r�r�r�Zprecompiled_header�
configname�configrrrZcflags_objcZcflags_objccZincludesZ
compilableZobjs�objZpchdepsr��gchr'r�r(r��s��










�


�
�




��������zMakefileWriter.WriteSourcescCs�|sdS|D]�\}}}}ddddd�|}ddd	d
d�|}|�d|||fd|�|�d
||f�|�d|�|�d�d|vs�Jd|��|�d|�|�d�qdS)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)))rrHrrZGYP_PCH_CFLAGSZGYP_PCH_CXXFLAGSZGYP_PCH_OBJCFLAGSZGYP_PCH_OBJCXXFLAGSz
%s: %s := %s zA$(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) z%s: %s FORCE_DO_CMDz	@$(call do_cmd,pch_%s,1)rrvz*Spaces in gch filenames not supported (%s)r�)r�)r�Zpch_commandsrZ	lang_flag�langr��extra_flagsZvar_namer'r'r(r&s<������

�zMakefileWriter.WritePchTargetscCs|jr
J�|jdkr(|jdvr(|j��S|d}d}d}|jdkrh|dd�dkr^|dd�}d}d	}nr|jd
vr�|dd�dkr�|dd�}d}|jdkr�d	}q�d}n2|jd
kr�d|}n|jdkr�tdd|jd|f�|�d|�}|�d|�}|�d�}|�r
d|}|||S)z�Return the 'output basename' of a gyp spec.

    E.g., the loadable module 'foobar' in directory 'baz' will produce
      'libfoobar.so'
    r�ryr�r�r�r{rryN�rr)r�r�rr�nonez%s.stampr�z,ERROR: What output file should be generated?rxr�Zproduct_prefixZproduct_nameZproduct_extensionr�)r�r&rxr��GetExecutablePathr�r0)r�r�r�Z
target_prefixZ
target_extZproduct_extr'r'r(�ComputeOutputBasenameGs<








�
z$MakefileWriter.ComputeOutputBasenamecCs|jdko|jdko|jdvS)Nr�rr")r�r&rxr�r'r'r(�_InstallImmediatelyrsz"MakefileWriter._InstallImmediatelycCsV|jr
J�tj�d|j|j�}|jdks2|��r6d}|�d|�}tj�||�|��S)z�Return the 'output' (full output path) of a gyp spec.

    E.g., the loadable module 'foobar' in directory 'baz' will produce
      '$(obj)/baz/libfoobar.so'
    z$(obj).r�r�product_dir)	r�r4r5r7r�rxr'r0r&�r�r�r5r'r'r(r�ws
zMakefileWriter.ComputeOutputcCs&|js
J�td}tj�||j���S)zDReturn the 'output' (full output path) to a bundle output directory.r)r�rr4r5r7r�ZGetWrapperNamer)r'r'r(r��s
z%MakefileWriter.ComputeMacBundleOutputcCstd}tj�||j���S)zAReturn the 'output' (full output path) to the binary in a bundle.r)rr4r5r7r�r%r)r'r'r(r��sz+MakefileWriter.ComputeMacBundleBinaryOutputcCsng}g}d|vrV|�dd�|dD��|dD]}|tvr0|�t|�q0|�|�tj�|�tj�|�fS)z�Compute 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).
    ZdependenciescSsg|]}t|rt|�qSr')r��rR�depr'r'r(r��s�z.MakefileWriter.ComputeDeps.<locals>.<listcomp>)�extendr�r}rr�uniquer)r�r�r�r�r+r'r'r(r��s
zMakefileWriter.ComputeDepscCs|j|jg|ddd�dS)Nz Build our special outputs first.Tr)rr�)r�r�r�r'r'r(�WriteDependencyOnExtraOutputs�s�z,MakefileWriter.WriteDependencyOnExtraOutputscs.��d�|r.���j|��j||ddd�i}�jdk�r�t|���D�]}	||	}
�jdkrڈj�	|	t
d�fdd	��}tj�
�j�}�j�|	ttj�tj�|�j���ttj�tj�|�j����}
|
r�|
||	<n@|
�d
g�}tdd�|D���r|�d
�j�|�d�j�|
�dg�}|dd�|D�7}��|d|	��jdkrJ���j�|	�d|	�qJ|�d�}|�r�tj�|�}�jdk�r��j�|�}��|d���dt�j����dt�j���jdk�r��dt�j��g}�jdk�r&|�r|�d�|�tj�|��|�r�� �j��!��|D],}	��dt�j�|	tj�"||	�f��qB|�#dtj�"d�jg��t$|�D]"\}}|�%d��s�t&|�||<�q���dt�j����dt�j�d �|�f��j'�rv���j|���t(t|�d!���d"t�j���jd#v�rD��d$�j�)��|�rT��d%�g}��d&���d't�j��|�r��j'�r�Jd(�j*��d)|v�s�Jd*���jd+k�r"��d,t�j�d �t(t|��f��jd-k�r�jd.k�r�j+�jg|d/||d0�n�j+�jg|d1||d0��np�jd2k�r�|D]}d |v�s2Jd3|���q2�jd4v�r~�j,�s~�j+�jg|d5||d0�n�j+�jg|d6||d0�n��jd7k�r��d,t�j�d �t(t|��f��j+�jg|d8||d0�n��jd9k�r\|D]}d |v�s�Jd:|���q�jd-k�rB�jd.k�rB�j+�jg|d;||d0�n�j+�jg|d<||d0�n6�jdk�r��j+�jg|d=||d0�nt-d>�j�j*��j�r�j�j*k�r�j�j.v�r�j�j*g�jgd?dd@�|�r�jdAg�j*gdBdd@��j�j.v�s�j,�r*�jd7k�rdC}n�jd2k�r(dD}nd+}��/�}�jg}�jdk�r|d)|v�r|�jdEk�r||�jk�s|JdF|�jf���j�j*g|gd?dd@�|�jk�rԈj'�r�J��j+|g�jgdGdH||dI�|�|��j�j0k�r
�j0�j*k�r
�j�j0g|dJ|dd@�|�r*�jdAg|gdK|dd@�dLS)Ma&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.Trr$rrcst��|��SrOr�r�r�r'r(r��rWz,MakefileWriter.WriteTarget.<locals>.<lambda>�ldflagscss |]}|�d�pd|vVqdS)rz.so.NrPr*r'r'r(rV�rWz-MakefileWriter.WriteTarget.<locals>.<genexpr>z-Wl,-rpath=\$$ORIGIN/lib.%s/z$-Wl,-rpath-link=\$(builddir)/lib.%s/�library_dirscSsg|]}d|�qS)z-L%sr')rRZlibrary_dirr'r'r(r��rWz.MakefileWriter.WriteTarget.<locals>.<listcomp>z
LDFLAGS_%szLIBTOOLFLAGS_%s�	librariesZLIBSz*%s: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))z%s: LIBS := $(LIBS)z4%s: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))z!$(TARGET_POSTBUILDS_$(BUILDTYPE))z%s: TARGET_POSTBUILDS_%s := %srZcdrer�z%s: POSTBUILDS := %srvZBUNDLE_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%s: LD_INPUTS := %sZhostrZ	link_host)�
postbuilds�linkryz2Spaces in alink input filenames not supported (%s))r�openbsdZnetbsd�winZ
alink_thinZalinkr�Zsolinkr�z3Spaces in module input filenames not supported (%s)Zsolink_module_hostZ
solink_moduleZtouchzWARNING: no output forzAdd target alias)r�phony�allz!Add target alias to "all" target.zshared libraryzstatic libraryr�z%s != %srz Copy this to the %s output path.)rr�z!Short alias for building this %s.zAdd %s to "all" target.N)1r�r.r�rrxr?r@r&r�Z
GetLdflagsrrrZInvertRelativePathr5ZAddImplicitPostbuildsrwr4r6r7r�r0�anyr}r�rZGetLibtoolflagsr-ZAdjustLibrariesr,r�ZGetSpecPostbuildCommandsr��GetSortedXcodePostbuildEnvr��insert�	enumerate�
startswithrdr�r�ZGetFrameworkVersionr�r�r�r�r�r�r�)r�r�r�r�r�rr�r�Ztarget_postbuildsrrr/Zgyp_to_buildZtarget_postbuildr0r1r2r�Z	postbuildZlink_depZ	file_descr�Zinstallable_depsr'r�r(r��s�

�

����
�
�
��

���
��

����
����������
���������
���zMakefileWriter.WriteTargetNrcsBd}|r*��fdd�|D�}dd�|�}|j�d||f�dS)z�Write 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.
    rcsg|]}��|��qSr'r')rR�lr
r'r(r��rWz,MakefileWriter.WriteList.<locals>.<listcomp>z \
	z	%s :=%s

N)r7r�rC)r�Z
value_listrrr	�valuesr'r
r(r�s
zMakefileWriter.WriteListFcCs^d}|rd|vsJ�d}|j||d||fg||dd�dd�|D�}|�d	d
�|��dS)z�Write 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,%s%s)T)r�rr��forcecSsg|]}t|t��qSr')rw�SPACE_REPLACEMENTr�r'r'r(r��rWz-MakefileWriter.WriteDoCmd.<locals>.<listcomp>r�rvN)rr�r7)r�r�r�r�r�rr2�suffixr'r'r(r��s�	zMakefileWriter.WriteDoCmdc	Csjdd�|D�}tt|�}|r*|�d|�|rB|�dd�|��|rX|�d|d�|r`dnd	}	|r�|�d
d�|�d�|�|	f�n�t|�dkr�|�d|dd�|�|	f�n�|r�|n|j�d
�}
t�|
��	�}d|}|�dd�|�|f�|�dd�|�dd|f�|�d|d�|�|	f�|�
dd�|�r^|D]}
|�d|
��qH|��dS)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
    cSsg|]}t|��qSr')rwr�r'r'r(r��rWz0MakefileWriter.WriteMakeRule.<locals>.<listcomp>z# z.PHONY: rvz%s: TOOLSET := $(TOOLSET)rz
 FORCE_DO_CMDrz
%s: | %s%srzz%s: %s%szutf-8z%s.intermediaterz	%sz@:z
.INTERMEDIATEz$(call do_cmd,touch)N)r�rwr�r7rr��encode�hashlibZsha1Z	hexdigestr:)r�r�r�r�rrr@r6r�Zforce_appendZ	cmdstringZ	cmddigestZintermediater�r'r'r(r�s:
� �zMakefileWriter.WriteMakeRulecCs~|jdvrdS|�d�|�d�|�d|�|�d�|�d�|�d�|�d	�d
d
d
d�}d}|D]@}tj�|�d
}||vrl||d
7<||||krl|}ql|�d|�|�t|jtt	|��d�dd�}ddi}	i}
t
|
|	�|�||td|
d�d�|�||tdtd�d�|jdk�rD|�d�n.|jdk�r\|�d�n|jdk�rr|�d�|��dS) 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�ryNz/# Variable definitions for Android applicationszinclude $(CLEAR_VARS)zLOCAL_MODULE := ziLOCAL_CFLAGS := $(CFLAGS_$(BUILDTYPE)) $(DEFS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))z+LOCAL_CPPFLAGS := $(CFLAGS_CC_$(BUILDTYPE))zLOCAL_C_INCLUDES :=z/LOCAL_LDLIBS := $(LDFLAGS_$(BUILDTYPE)) $(LIBS)r)rJrKrLrKrzzLOCAL_CPP_EXTENSION := ZLOCAL_SRC_FILEScSsNg}|D]@}tj�|�}|�|�r|�|�r|�|t|�t|���q|SrO)r4r5r|r<rQr}r)r�rrB�modules�filepathrUr'r'r(�
DepsToModules2sz?MakefileWriter.WriteAndroidNdkModuleRule.<locals>.DepsToModulesr&rr
rZLOCAL_SHARED_LIBRARIESrrZLOCAL_STATIC_LIBRARIESr�zinclude $(BUILD_EXECUTABLE)r�zinclude $(BUILD_SHARED_LIBRARY)ryzinclude $(BUILD_STATIC_LIBRARY))rxr�r4r5r]rr�r�rrYr)r)r�Zmodule_namer�r�Zcpp_extZdefault_cpp_extrUrFrGr%r$r'r'r(r�s\






�	
����
z(MakefileWriter.WriteAndroidNdkModuleRulecCs|j�|d�dS)Nr>)r�rC)r��textr'r'r(r�SszMakefileWriter.WriteLncCs"tj�|jdtj�d|j�d|�S)Nz$(abs_builddir)z
$(abs_srcdir)r)rr�r�r�r4r5r7)r�rr'r'r(r�Ws
�z MakefileWriter.GetSortedXcodeEnvcCs|j�dd�}|jd|id�S)NZCHROMIUM_STRIP_SAVE_FILErr
)r�ZGetPerTargetSettingr�)r�Zstrip_save_filer'r'r(r9^s��z)MakefileWriter.GetSortedXcodePostbuildEnvcCs*|D] \}}|�dt|�||f�qdS)Nz%s: export %s := %s)r�rw)r�r�r��k�vr'r'r(r�isz"MakefileWriter.WriteSortedXcodeEnvcCs4d|vr|�dd|j�}d|vr0d|j|f}|S)z,Convert a path to its output directory form.rq�$(obj)/z$(obj).%s/$(TARGET)/z$(obj)z$(obj).%s/$(TARGET)/%s)rar��r�r5r'r'r(rts
zMakefileWriter.ObjectifycCs<|�|�}d|vr,|�dd|j|f�}|Sd|j||fS)z:Convert a prefix header path to its output directory form.rqrKz$(obj).%s/$(TARGET)/pch-%sz$(obj).%s/$(TARGET)/pch-%s/%s)r�rar�)r�r5r r'r'r(r�}s
�zMakefileWriter.PchifycCs*d|vr|�d�Stj�tj�|j|��S)zlConvert a subdirectory-relative path into a base-relative path.
    Skips over paths that contain variables.rq�/)�rstripr4r5r6r7rLr'r'r(r��s
zMakefileWriter.AbsolutifycCs&d|vrd|vr|S|||d�}|S)Nr	r
)Z
INPUT_ROOTZ
INPUT_DIRNAMEr')r��templateZ	expansionr�r5r'r'r(r��s�zMakefileWriter.ExpandInputRootcCs8|jdkr.|jdks|jdkr.d|j|jfSd|jS)zCReturns the location of the final output for an installable target.r�rr�z$(builddir)/lib.%s/%sz$(builddir)/)rxr&r�r�r�r'r'r(r��s
��z,MakefileWriter._InstallableTargetInstallPath)NF)NNFFFN)r)N)$�__name__�
__module__�__qualname__�__doc__r�r�r�r�r�r�r�r�r�rr&r'r�r�r�r�r.r�rlrr�rr�r�r�r9r�rr�r�r�r�r'r'r'r(r��sRd&|!+m�
�
�
>S

	

r�cs�|d��fdd�|dD�}tj�|d�j�}|�tj�sLtj�d|�}|�	d|d�t
t|��tj�|d	gt�
��|�d
��dS)z,Write the target to regenerate the Makefile.r,csg|]}tj�|�j��qSr')rr�RelativePathr3)rRrU�r,r'r(r��s�z-WriteAutoRegenerationRule.<locals>.<listcomp>Zbuild_files_arg�
gyp_binaryr�z�quiet_cmd_regen_makefile = ACTION Regenerating $@
cmd_regen_makefile = cd $(srcdir); %(cmd)s
%(makefile_name)s: %(deps)s
	$(call do_cmd,regen_makefile)

rvz-fmake)�
makefile_namer��cmdN)rrZFixIfRelativePathr3r<r4�sepr5r7rCr�rtr�ZRegenerateFlags)r%�
root_makefilerW�build_filesZbuild_files_argsrVr'rUr(�WriteAutoRegenerationRule�s.
��������r\cCsb|d}|D]P}dg}|jr4|jdkr4|d|jf7}|�d|�td||f�t�|�qdS)Nr,Zmaker�z-Cz
BUILDTYPE=zBuilding [%s]: %s)r3r}r��
subprocessZ
check_call)�data�configurationsr%r,rZ	argumentsr'r'r(�PerformBuild�sr`c1s�|d�tj�|�}|�di�}|�dd�}|�dd�}|�dd�}�fdd	�}	d}
t�fd
d�|D��}|D]$}�|}
|
dd
krn|
d}
q�qn|
s�d
}
d}d�j}tj��j	|�}�j
r�tj��j	�j
|�}tj�|�j
�}dad}d}d}|||
|dt
d|||d�
}|dk�r2d}|�|dttd��n�|dk�rL|�dti�n�|dk�rrd}d}|�||td ��n\|d!k�r�|�d"dd#��n@|d$k�r�d%}|�d&|i�n"|d'k�r�d%}|�|td"dd(��|�td)d*�td+d,�td-d.�td/d0�td1d2�td3d4�td5d6�td7d8�d9��tj�|d:�\�}}|��d;g�}i}|D]0\}}|�d<��rHd=|||dtd<��<�qHd}|D]�\}}t�d>|��r��q�|d:d?k�r�d=|}|�|�}|�r�d@||f}||=|dAv�r&|dB|7}|�ddC�}|tjv�rtj|}|dD||f7}|dE7}n|dF||f7}�q�||d;<tj�|�t|dG�}|�t|�|�rv|�dH�|D]}|�dI|�t |��qztj�!|�}tj�"||�t��|dJD](�tj�#|���D]}��$|��qԐq�t�} t�}!|D�]V}"tj�|"�\�}}|��d;g�}#||#k�s<JdK|#|f��| �$tj���j	��|�dL}$|$D]\}%tj�tj�%|%���j	�}&tj�&|&�}'|dM�r�|'�'|dM��r�| �$|'�n
| �$|&��qb|	�|d|�jdN�\}(})�|"}
|
dO}*|dk�rtj(�)|�|
�t*||�}+|+j+|"|(|)|
|*|"�vdP�tj�|)tj�!|��},|!�$|,��q�tj��j,t�-��}-| D]��tj�|-������fdQd�|D�}.|.�s��ql|	�tj�.tj�/���d:dR�\}(})tj�tj�!|�tj�!|)��}/|+�0|)|/|.|��ql|�dS�t1|!�D]4}0|�dT|0dU�|�dV|0dS�|�dE��q|�dS�|�dW��sp|�dXdY��rpt2|||| �|�t3�|�4�dS)ZNr,r*r-r.r+�default_targetr7csftj�tj�|��j�}tj��j||�}�jrFtj��j�j||�}tj�tj�|��j	�}||fS)z9Determine where to write a Makefile for a given gyp file.)
rrrTr4r5r��depthr7r2r3)�
build_fileZ	base_namer��output_filerUr'r(�CalculateMakefilePath�s���z-GenerateOutput.<locals>.CalculateMakefilePathcsg|]}�|d�qS)r�r'�rRr�)�target_dictsr'r(r��rWz"GenerateOutput.<locals>.<listcomp>�default_configurationZDefaultr�ZMakefilez
$(srcdir)/�flockz-afz-MMDrzr)
raZbuilddirrhri�flock_index�
link_commands�extra_commands�srcdir�copy_archive_args�makedep_argsrz./gyp-mac-tool flock�)rirjrkrlrrkZzosz-fPRz
-qmakedep=gcc)rnrorkZsolarisz./gyp-flock-tool flock)rirjr4z-pPRfrnr)rnrkrirj)Z	CC_target�CCz$(CC))Z	AR_target�ARz$(AR))Z
CXX_target�CXXz$(CXX))ZLINK_target�LINKz$(LINK))ZCC_hostrqZgcc)ZAR_hostrrZar)ZCXX_hostrszg++)Z	LINK_hostrtz$(CXX.host))z	CC.targetz	AR.targetz
CXX.targetzLINK.target�CC.hostzAR.host�CXX.hostz	LINK.hostr�make_global_settingsZ_wrapperz
$(abspath %s)z
.*_wrapperrez%s %s)rqrursrvz3ifneq (,$(filter $(origin %s), undefined default))
rmz
  %s = %s
zendif
z	%s ?= %s
r�zU# Define LOCAL_PATH for build of Android applications.
LOCAL_PATH := $(call my-dir)

zTOOLSET := %s
r[zDmake_global_settings needs to be the same for all targets. %s vs. %s�included_filesZhome_dot_gypz.mkr_rcs*g|]"}|���r|�vr�|d�qS)r{)r<rf)rc�needed_targetsrgr'r(r��s
�z	.Makefiler>zmifeq ($(strip $(foreach prefix,$(NO_LOAD),\
    $(findstring $(join ^,$(prefix)),\
                 $(join ^,z)))),)
z
  include Z
standaloneZauto_regenerationT)5rrrr0r�rBr4r5r7r3r2rTrs�LINK_COMMANDS_LINUXr#�LINK_COMMANDS_MAC�SHARED_HEADER_MAC_COMMANDS�LINK_COMMANDS_ANDROID�LINK_COMMANDS_OS390�LINK_COMMANDS_AIXrZParseQualifiedTargetrQrrn�matchra�environr�r�rC�
SHARED_HEADERrGr�ZCopyToolZ
AllTargetsr�ZUnrelativePath�abspathr<r�ZMergeGlobalXcodeSettingsToSpecr�r�rb�getcwdr]r|r�r?r\�
SHARED_FOOTERr�)1Ztarget_listrgr^r%r&r*r9r+rarerhZtoolsetsr�r�rmrWr�Z
flock_commandZcopy_archive_argumentsZmakedep_argumentsZ
header_paramsrmZmake_global_settings_arrayZwrappersr<�valuerw�wrapperZenv_keyrZr�Z	dest_pathr[Zinclude_listr�Zthis_make_global_settingsrxZ
included_fileZrelative_include_fileZabs_include_filer�rdr�rDZmkfile_rel_pathZdepth_rel_pathZgyp_targetsZmakefile_rel_pathZinclude_filer')rcryr,rgr(�GenerateOutput�s�

��
�

�
�

�
	
�
��

�


�
�
���
��

�
��
�
�
���

�
r�)ru)6Z
__future__rr4rn�sysr]rZ
gyp.commonZgyp.xcode_emulationrrrDrZ$generator_supports_multiple_toolsetsr1rrrr8r)r:rArzr{r}rr~r�r|rGr�r�r�r�r"rYr[r^rdrfrhrlrprsrtrwr�r�r��objectr�r\r`r�r'r'r'r(�<module>s��%!$H�H�I�I�)��*��J��J��K��L��o
�			
 |