HEX
Server: Apache
System: Linux p102.lithium.hosting 4.18.0-553.141.1.el8_10.x86_64 #1 SMP Fri Jul 10 17:48:02 UTC 2026 x86_64
User: bvzmoamr (9955)
PHP: 8.1.34
Disabled: syslog
Upload Files
File: //usr/lib/python3.6/site-packages/gyp/generator/__pycache__/make.cpython-36.opt-1.pyc
3

?9�^	k�@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��libz.az $(obj).$(TOOLSET)/$(TARGET)/geniz
$(obj)/genz$(builddir)z%(INPUT_ROOT)sz%(INPUT_DIRNAME)sz
$(abspath $<)z$(suffix $<)z$(notdir $<)z$(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�tjj|�}|dkr�|jdd�|jdd�|jdtd�|jdtd�dd	ljj}t|d
g�a	t|dg�a
t|dg�atj
d
dd��nV|}|dkr�d}|jd|�|dkr�|jdd�n|jdd�|jdd�|jdd�d	S)zDCalculate additional variables for use in the build (called by gyp).�macZOS�SHARED_LIB_SUFFIXz.dylibZSHARED_LIB_DIRr
ZLIB_DIRrN�+generator_additional_non_configuration_keys�"generator_additional_path_sections�!generator_extra_sources_for_rulesZobjcZobjcxx)z.mz.mm�android�linux�aixz.az.soz$(builddir)/lib.$(TOOLSET)z$(obj).$(TOOLSET))�gyp�common�	GetFlavor�
setdefault�generator_default_variablesZgyp.generator.xcode�	generatorZxcode�getattrr
rr�COMPILABLE_EXTENSIONS�update)�default_variables�params�flavorZxcode_generatorZoperating_system�r�/usr/lib/python3.6/make.py�CalculateVariablesDs2

r!cCsl|jdi�}|jdd�}|r da|djp2|dj}|jdd�}tjjtjj||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)rr"r#r%�
builddir_namer'rrr �CalculateGeneratorInputInfois

r2�?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)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS)

# 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)) -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)
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)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $<

quiet_cmd_cxx = CXX($(TOOLSET)) $@
cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
%(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�ttj�tjd�}|jd�x,|D]$}|jd|�|jdt|�q"W|jd�x,|D]$}|jd|�|jdt|�qZW|jd�x,|D]$}|jd|�|jdt|�q�W|jd�dS)	N)�keyz1# 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�extrrr �WriteRootHeaderSuffixRuless






r>z1# Suffix rules, putting all outputs into $(obj).
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)z.cz.ccz.cppz.cxxz.sz.Scs(x"�fdd�tD�D]}|rdSqWdS)z:Return true if the file is compilable (should be in OBJS).c3s|]}�j|�VqdS)N)�endswith)�.0�e)�filenamerr �	<genexpr>JszCompilable.<locals>.<genexpr>TF)r)rC�resr)rCr �
CompilableHsrFcCs
|jd�S)zAReturn true if the file is linkable (should be on the link line).z.o)r@)rCrrr �LinkablePsrGcCstjj|�ddS)z1Translate a compilable filename to its .o target.rz.o)r,r-�splitext)rCrrr �TargetUsrIcCsd|jdd�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)�srrr �EscapeShellArgumentZsrMcCs|jdd�S)zrMake has its own variable expansion syntax using $. We must escape it for
     string to be interpreted literally.�$z$$)rK)rLrrr �EscapeMakeVariableExpansionbsrOcCst|�}t|�}|jdd�S)zBEscapes a CPP define so that it will reach the compiler unaltered.�#z\#)rMrOrK)rLrrr �EscapeCppDefinehsrQcCs d|krd|jdd�d}|S)zSTODO: Should this ideally be replaced with one or more of the above
     functions?�"z\")rK)�stringrrr �QuoteIfNecessaryqsrTcCstjdd|�S)zGConvert a string to a value that is acceptable as a make variable name.z
[^a-zA-Z0-9_]�_)�re�sub)rSrrr �StringToMakefileVariableysrXcCs$d|kr|Stjj|�r|St|S)z,Convert a path to its source directory form.z$()r,r-�isabs�
srcdir_prefix)r-rrr �	Sourceifys
r[�\ cCs|jd|�S)N� )rK)rLZquoterrr �QuoteSpaces�sr^c

Cs�|jdd�dkrdSi}xH|D]@}tjj|�\}}|dk}|s@qtjj|�}|j|g�j|�qWd}x6|j�D]*\}}	t|	�d
krp|d|dj	|	�f7}qpW|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�.c�.cc�.cpp�.cxx�.m�.mm�.s�.Sr�z	  %s: %s
r]z<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)rarbrcrdrerfrgrh)r(r,r-rH�basenamer�append�items�lenr/�printr)
�spec�all_sourcesZ	basenames�source�namer=Zis_compiled_filerk�error�filesrrr �_ValidateSourcesForOSX�s(
rvc@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|_xdtj�D]X}|jj|d|t|fi�|jj|d|t|fi�|jj|d|t|fi�q(WdS)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_objdir2rr7r)�selfr"rr=rrr �__init__�szMakefileWriter.__init__csptjj|�t|d��_�jjt�|�_|�_|d�_	|d�_
|d�_tjj
�j|��_�jdkrztjj|��_nd�_�j|�\}}g}	g}
g}g}g}
�jrˆj|��_�j|��_n�j|��_�_t|jdd���_d�_�j�s�j
�jk�rtjj�j��_�j�}n�j�_�j}�j d�j��j d
�j	�d|k�rj�j!|d|
|	||�d|k�r��j"|d|
|	||�d|k�r��j#|d|	|��j�r�|jdg�|}�j$||
��j%|
�|jdg�|
}|�r
�jdk�rt&||��j'||||	||tjj(�j�fdd��j)��dd�|D�}|�r
�j t*�t+dd�|D��}x*|D]"}|�j,k�rd�j �j,|��qdW�j t-�x*|D]"}|�j.k�r��j �j.|��q�Wx*|D]"}|�j/k�rƈj �j/|��q�W�j d��j�r
|
j0�j��j1||||||
|	|�|t2|<�j
dk�rB�jt3|<�j4jdd��rb�j5�j	||��jj6�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'
    �wrjr_�toolsetrNZstandalone_static_libraryr�
executable�loadable_module�shared_libraryzTOOLSET := z
TARGET := �actions�rules�copiesZmac_bundle_resources�sourcescst�j|��S)N)r[�
Absolutify)�p)r{rr �<lambda>3sz&MakefileWriter.Write.<locals>.<lambda>cSsg|]}t|�r|�qSr)rF)rA�xrrr �
<listcomp>5sz(MakefileWriter.Write.<locals>.<listcomp>cSsg|]}tjj|�d�qS)ri)r,r-rH)rArLrrr r�8sz!# End of this set of suffix rulesr`r#)rr�r�)r`r�)7rr�EnsureDirExists�open�fpr:�header�qualified_targetr-�targetr_r~�xcode_emulationZIsMacBundler�
is_mac_bundleZ
XcodeSettings�xcode_settings�ComputeDeps�ComputeMacBundleOutput�output�ComputeMacBundleBinaryOutput�
output_binary�
ComputeOutput�boolr(�is_standalone_static_library�_INSTALLABLE_TARGETSr,rk�alias�_InstallableTargetInstallPath�WriteLn�WriteActions�
WriteRules�WriteCopies�WriteMacBundleResources�WriteMacInfoPlistrv�WriteSourcesZMacPrefixHeader�Pchify�#SHARED_HEADER_SUFFIX_RULES_COMMENT1�setrx�#SHARED_HEADER_SUFFIX_RULES_COMMENT2ryrzrl�WriteTarget�target_outputs�target_link_depsr"�WriteAndroidNdkModuleRule�close)r{r��	base_path�output_filenamerp�configs�part_of_all�deps�	link_deps�
extra_outputs�
extra_sources�extra_link_deps�extra_mac_bundle_resourcesZmac_bundle_deps�install_pathZall_mac_bundle_resourcesrqr�r<r=r)r{r �Write�s�


















zMakefileWriter.WritecCs�tjj|�t|d�|_|jjt�|jdtj	j
tj	j|�|��|jd�|jd�|rdd|}|jd|dj
|�f�|jj�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 %sr]N)
rrr�r�r�r:r�r�r,r-r/�dirnamer�)r{r��
makefile_pathZtargetsZ	build_dirrrr �WriteSubMake[s

zMakefileWriter.WriteSubMakecs��j���xh|D�]^}td�j|df�}�jd|d�|d}|d}	t�}
x*|	D]"}tjj|�d}|rZ|
j|�qZWt	|j
dd��r�||	7}t	|j
d	d��r�||	7}|d
}
�jdkrԇfdd
�|
D�}
tj
j|
�}d|k�r�jd||df�n�jd||f�t|
�dk�r8ddj|
�d|}dt�j�pFd�}|jd�j�}|jd�j�}�jd|||f��j��fdd
�|	D�}	�jdt|	d���jdt|	d���j|	d�j��x|D]}�q�Wx|	D]}�q�W�fdd
�|	D�}	�fdd
�|D�}�j|	ttt�j|��||d�d|}�jd|dj|	�f�|jd|��j�qW�j�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'
    z%s_%sZaction_namez### Rules for action "%s":�inputs�outputsr�process_outputs_as_sourcesF�'process_outputs_as_mac_bundle_resources�actionrcsg|]}tjj|���qSr)rr��
ExpandEnvVars)rA�command)�envrr r��sz/MakefileWriter.WriteActions.<locals>.<listcomp>�messagezquiet_cmd_%s = ACTION %s $@zmkdir -p %sr]z; zcd %s; �.z	$(TARGET)ztcmd_%s = LD_LIBRARY_PATH=$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; %s%scsg|]}�j|��qSr)r�)rA�o)r{rr r��sz%s: obj := $(abs_obj)z%s: builddir := $(abs_builddir)csg|]}tjj|���qSr)rr�r�)rAr�)r�rr r��scsg|]}tjj|���qSr)rr�r�)rA�i)r�rr r��s)r�r�zaction_%s_outputsz%s := %sz$(%s)N)�GetSortedXcodeEnvrXr�r�r�r,r-�split�add�intr(rrr�EncodePOSIXShellListrnr/r[rKr�r^�WriteSortedXcodeEnv�
WriteDoCmd�mapr�rl)r{r�r�r�r�r�r�rsr�r��dirsr&�dirZaction_commandsr��	cd_action�inputr��outputs_variabler)r�r{r r�vsb



	


zMakefileWriter.WriteActionsc
s"�j���x�|D�]�}td�j|df�}d}�jd|�g}	�x�|jdg�D�]v}
t�}tjj|
�\�}tjj	|�\�}
���fdd�|dD�}x&|D]}tjj
|�}|r�|j|�q�Wt|jd	d
��r�||7}t|jdd
��r�||7}t
tt
�j|
g|jdg���}d
||fg}|dk�r2|dg7}�fdd�|D�}�fdd�|D�}�fdd�|D�}|	|7}	�jd|d��jd|d��j|||d||fd�tjd�}x|D]}tj|d|�}�q�W�jddj|�����fdd�|dD�}d}t|�dk�r$ddj|�}dt�j�p2d�}�jd k�rV�fd!d�|D�}tjj|�}|jd"�j�}|jd"�j�}|jd"�j�}�jd#|||||d$���jd%||d&���j�|d'7}qRWd(|}�j|	|�|jd)|��jd*|��j�qW�jd+��jd�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'
    z%s_%sZ	rule_namerz### Generated for rule %s:Zrule_sourcescsg|]}�j|����qSr)�ExpandInputRoot)rAr&)�rule_source_dirname�rule_source_rootr{rr r��sz-MakefileWriter.WriteRules.<locals>.<listcomp>r�r�Fr�r�z$(call do_cmd,%s_%d)Zresources_gritz@touch --no-create $@csg|]}tjj|���qSr)rr�r�)rAr�)r�rr r�
scsg|]}tjj|���qSr)rr�r�)rAr�)r�rr r�scsg|]}�j|��qSr)r�)rAr�)r{rr r�sz%s: obj := $(abs_obj)z%s: builddir := $(abs_builddir)z%s_%d)r�z\$\([^ ]* \$<\)rzall_deps += %sr]csg|]}�j|����qSr)r�)rAZac)r�r�r{rr r�$sr�z
mkdir -p %s; zcd %s; r�rcsg|]}tjj|���qSr)rr�r�)rAr�)r�rr r�0sz	$(TARGET)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�mkdirsrsz9quiet_cmd_%(name)s_%(count)d = RULE %(name)s_%(count)d $@)r�rsrizrule_%s_outputsz$(%s)z$### Finished generating for rule: %sz%### Finished generating for all rulesN)r�rXr�r�r(r�r,r-r�rHr�r�r�r�r[r��
WriteMakeRulerV�compilerWr/rnrrrr�rKr��	WriteListrl)r{r�r�r�r�r�Zrulersr�Zall_outputsZrule_sourcer�Zrule_source_basenameZrule_source_extr�r&r�r�r�Zvariables_with_spacesr�r�r�r�r�r)r�r�r�r{r r��s�








zMakefileWriter.WriteRulescCs�|jd�t|jd�}g}x�|D]�}x�|dD]�}t|j|��}tjj|�d}t|jtjj|d|���}	|j	�}
t
jj|	|
�}	t
jj||
�}|j
|	g|gd|�|j|	�q0Wq"W|jd|djtt|��f�|jd	|�|j�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_copiesruriZdestination�copyz%s = %sr]z$(%s)N)r�rXr�r[r�r,r-r�r/r�rr�r�r�rlr�r^)r{r�r�r��variabler�r�r-rCr�r�rrr r�Zs"


zMakefileWriter.WriteCopiescCsx|jd�xhtjjtd|jttt|j|���D]@\}}t	j
j|�\}}|dkr0|j|g|gddd�|j
|�q0WdS)z0Writes Makefile code for 'mac_bundle_resources'.z&### Generated for mac_bundle_resourcesr
z	.xcassetszmac_tool,,,copy-bundle-resourceT)r�N)r�rr�ZGetMacBundleResourcesrr�r�r[r�r,r-rHr�rl)r{Z	resources�bundle_depsr�rErUr=rrr r��s

z&MakefileWriter.WriteMacBundleResourcescs�tjjtd�j�fdd��\}}}}|s.dS|rrdtjj|�}�j||ddt	d��j
|g|gd	d
g�|}�j|�j|d���j
|g|gdd
d�|j|�dS)z0Write Makefile code for bundle Info.plist files.r
cst�j|��S)N)r[r�)r�)r{rr r��sz2MakefileWriter.WriteMacInfoPlist.<locals>.<lambda>Nz$(obj).$(TOOLSET)/$(TARGET)/z: INFOPLIST_DEFINESz-D)�quoterz$(call do_cmd,infoplist)z@plutil -convert xml1 $@ $@)�additional_settingszmac_tool,,,copy-info-plistT)r�)rr�ZGetMacInfoPlistrr�r,r-rkr�rQr�r�r�r�rl)r{r�Z
info_plistr&�definesZ	extra_envZintermediate_plistr)r{r r��s&
z MakefileWriter.WriteMacInfoPlistcs6�x�t|j��D�]�}||}	dg}
�j|	jd�d|dtd��jdkr��jj|�}�jj|�}�jj	|�}
�jj
|�}�jj|�}nT|	jd�}|r�||
7}n|
}|	jd�}|r�||
7}n|
}|	jd	�}
|
r�|
|
7}
n|
}
�jd
��j|d|��jd��j|d
|��jd��j|
d|��jdk�rj�jd��j|d|��jd��j|d|�|	jd�}|�r��fdd�|D�}�j|d|dd�qWt
t|�}�fdd�|D�}�j|d�x|D]}�q�W�jd��jd��j�|�r�jdg|dd d!�|�r,�jdg|d"d d!�|j||�}|�rz�jd#�x&|D]\}}}�jd$||f��qNW�jd%�|�r
|jd��jd&��jd'��jd(|jd)�d*��jd+|jd,�d-��jdk�r
�jd.|jd/�d0��jd1|jd2�d3��j|j��|d4d�|D�7}�j�d5S)6aWrite 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'
    z$(RPM_OPT_FLAGS)r�zDEFS_%sz-D)�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�j|���qSr)r[r�)rA�include)r{rr r��sz/MakefileWriter.WriteSources.<locals>.<listcomp>zINCS_%sz-I)r�cs g|]}�j�jt|����qSr)�	Objectifyr�rI)rAr�)r{rr r��sZOBJSz?# 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 headersz%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 r?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))cSsg|]}t|�r|�qSr)rG)rArrrrr r�/sN)r6r7r�r(rQrr�Z	GetCflagsZ
GetCflagsCZGetCflagsCCZ
GetCflagsObjCZGetCflagsObjCCr��filterrFr�ZGetObjDependenciesrlZ
GetInclude�WritePchTargetsZGetPchBuildCommands)r{r�r�r�r�r�r�Zprecompiled_header�
configname�configZrpmoptflagsr�r�r�Zcflags_objcZcflags_objccZincludesZ
compilableZobjs�objZpchdepsrr�gchr)r{r r��s�


























zMakefileWriter.WriteSourcescCs�|sdSx�|D]�\}}}}ddddd�|}ddd	d
d�|}|jd|||fd|�|jd
||f�|jd|�|jd�|jd|�|jd�qWdS)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�r?r�r�ZGYP_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)rzall_deps += %s)r�)r{Zpch_commandsr�Z	lang_flag�langr��extra_flagsZvar_namerrr r�3s*
zMakefileWriter.WritePchTargetscCs|jdkr|jdkr|jj�S|d}d}d}|jdkr^|dd	�d
krT|d	d�}d
}d}nr|jdkr�|dd	�d
kr�|d	d�}d
}|jdkr�d}q�d
}n2|jdkr�d|}n|jdkr�tdd|jd|f�|jd|�}|jd|�}|jd�}|�rd|}|||S)z�Return the 'output basename' of a gyp spec.

    E.g., the loadable module 'foobar' in directory 'baz' will produce
      'libfoobar.so'
    rr`rr�r�rjrN�rz.arz.so�nonez%s.stampz,ERROR: What output file should be generated?r_r�Zproduct_prefixZproduct_nameZproduct_extensionr�)r`rr�r�)r�r�)rr_r��GetExecutablePathror()r{rpr�Z
target_prefixZ
target_extZproduct_extrrr �ComputeOutputBasenameTs:







z$MakefileWriter.ComputeOutputBasenamecCs|jdko|jdko|jdkS)Nr�rr`rr�r�)r`rr�r�)r~rr_)r{rrr �_InstallImmediatelysz"MakefileWriter._InstallImmediatelycCsLtjjd|j|j�}|jdks(|j�r,d}|jd|�}tjj||j|��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).rz$(builddir)�product_dir)r,r-r/r~r_r�r(r�)r{rpr-rrr r��s
zMakefileWriter.ComputeOutputcCstd}tjj||jj��S)zDReturn the 'output' (full output path) to a bundle output directory.r
)rr,r-r/r�ZGetWrapperName)r{rpr-rrr r��sz%MakefileWriter.ComputeMacBundleOutputcCstd}tjj||jj��S)zAReturn the 'output' (full output path) to the binary in a bundle.r
)rr,r-r/r�r�)r{rpr-rrr r��sz+MakefileWriter.ComputeMacBundleBinaryOutputcCsrg}g}d|krZ|jdd�|dD��x&|dD]}|tkr2|jt|�q2W|j|�tjj|�tjj|�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�)rA�deprrr r��sz.MakefileWriter.ComputeDeps.<locals>.<listcomp>)�extendr�rlrr�uniquer)r{rpr�r�r�rrr r��s
zMakefileWriter.ComputeDepscCs|j|jg|ddd�dS)Nz Build our special outputs first.T)r�r�)r�r�)r{r�r�rrr �WriteDependencyOnExtraOutputs�sz,MakefileWriter.WriteDependencyOnExtraOutputsc	s��jd�|r.�j�j|��j||ddd�i}�jdk�r��x0t|j��D�]}	||	}
�jdkrވjj	|	t
d�fdd	��}tjj
�j�}�jj|	ttjjtjj|�j���ttjjtjj|�j����}
|
r�|
||	<n@|
jd
g�}tdd�|D���r|jd
�j�|jd�j�|
jdg�}|dd�|D�7}�j|d|	��jdkrN�j�jj|	�d|	�qNW|jd�}|�r�tjj|�}�jdk�r��jj|�}�j|d��jdt�j���jdt�j���jdk�r��jdt�j��g}�jdk�r,|�r|jd�|jtjj|��|�r��j �j�j!��x4|D],}	�jdt�j�|	tjj"||	�f��qJW|j#dtjj"d�jg��x.t$|�D]"\}}|j%d��s�t&|�||<�q�W�jdt�j���jdt�j�d j|�f��j'�r��j�j|��jt(t|�d!��jd"t�j���jdIk�rR�jd%�jj)��|�rb�jd&�g}�jd'��jd(t�j��|�r��jd)k�r�jd*t�j�d jt(t|��f��jd+k�r�jd,k�r�j*�jg|d-||d.�n�j*�jg|d/||d.��nN�jd0k�rnx|D]}�qW�jdJk�rT�j+�rT�j*�jg|d4||d.�n�j*�jg|d5||d.�n�jd#k�r��jd*t�j�d jt(t|��f��j*�jg|d6||d.�n��jd$k�r x|D]}�q�W�jd+k�r�jd,k�r�j*�jg|d7||d.�n�j*�jg|d8||d.�n6�jdk�rF�j*�jg|d9||d.�nt,d:�j�j-��j�r��j�j-k�r��j�j.k�r��j�j-g�jgd;dd<�|�r��jd=g�j-gd>dd<��j�j.k�sȈj+�rĈjd#k�r�d?}n�jd0k�r�d@}nd)}�j/�}�jg}�jdk�r"dA|k�r"�jdBk�r"�j�j-g|gd;dd<�|�jk�rn�j*|g�jgdCdD||dE�|j|��j�j0k�r��j0�j-k�r��j�j0g|dF|dd<�|�rĈjd=g|gdG|dd<�dHS)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.T)r�r�r�rr
cst�j|��S)N)r[r�)r�)r{rr r��sz,MakefileWriter.WriteTarget.<locals>.<lambda>�ldflagscss |]}|jd�pd|kVqdS)z.soz.so.N)r@)rAr�rrr rD�sz-MakefileWriter.WriteTarget.<locals>.<genexpr>z-Wl,-rpath=\$$ORIGIN/lib.%s/z$-Wl,-rpath-link=\$(builddir)/lib.%s/�library_dirscSsg|]}d|�qS)z-L%sr)rAZlibrary_dirrrr r��sz.MakefileWriter.WriteTarget.<locals>.<listcomp>z
LDFLAGS_%szLIBTOOLFLAGS_%s�	libraries�LIBSz*%s: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))z%s: LIBS := $(LIBS)z4%s: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))z!$(TARGET_POSTBUILDS_$(BUILDTYPE))z%s: TARGET_POSTBUILDS_%s := %srZcdrNz%s: builddir := $(abs_builddir)z%s: POSTBUILDS := %sr]ZBUNDLE_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 %srz%s: LD_INPUTS := %s�hostrZ	link_host)�
postbuilds�linkr`�openbsd�netbsd�winZ
alink_thinZalinkZsolinkZsolink_module_hostZ
solink_moduleZtouchzWARNING: no output forzAdd target alias)r��phony�allz!Add target alias to "all" target.zshared libraryzstatic libraryr�r�r�z Copy this to the %s output path.)r�r�z!Short alias for building this %s.zAdd %s to "all" target.N)r�r�)rr	r
r)1r�rr�r�r_r6r7rr�Z
GetLdflagsrrrZInvertRelativePathr-ZAddImplicitPostbuildsr^r,r.r/r�r(�anyrlr~r�ZGetLibtoolflagsrZAdjustLibrariesr�r�ZGetSpecPostbuildCommandsr��GetSortedXcodePostbuildEnvr��insert�	enumerate�
startswithrMr�r�ZGetFrameworkVersionr�r�ror�r�r�r�)r{rpr�r�r�r�r�r�Ztarget_postbuildsr�r�rZgyp_to_buildZtarget_postbuildrrrr�Z	postbuildZlink_depZ	file_descr�Zinstallable_depsr)r{r r��s,





















zMakefileWriter.WriteTargetNrcsBd}|r*��fdd�|D�}ddj|�}|jjd||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|]}��|��qSrr)rA�l)r�r�rr r��sz,MakefileWriter.WriteList.<locals>.<listcomp>z \
	z	%s :=%s

N)r/r�r:)r{Z
value_listr�r�r��valuesr)r�r�r r��s
zMakefileWriter.WriteListFcCsRd}|rd}|j||d||fg||dd�dd�|D�}|jdd	j|��d
S)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.
    rz,,1z$(call do_cmd,%s%s)T)r�r�r��forcecSsg|]}t|t��qSr)r^�SPACE_REPLACEMENT)rAr�rrr r��sz-MakefileWriter.WriteDoCmd.<locals>.<listcomp>zall_deps += %sr]N)r�r�r/)r{r�r�r�r�r�r�suffixrrr r��szMakefileWriter.WriteDoCmdc	Csrdd�|D�}tt|�}|r*|jd|�|rB|jddj|��|rX|jd|d�|r`dnd	}	|r�|jd
dj|�dj|�|	f�n�t|�dkr�|jd|ddj|�|	f�n�|r�|n|jjd
�}
tj|
dd�j	�}d|}|jddj|�|f�|jdd�|jdd|f�|jd|dj|�|	f�|j
dd�|�rfx|D]}
|jd|
��qNW|j�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)r^)rAr�rrr r��sz0MakefileWriter.WriteMakeRule.<locals>.<listcomp>z# z.PHONY: r]z%s: TOOLSET := $(TOOLSET)rz
 FORCE_DO_CMDrz
%s: | %s%sriz%s: %s%szutf-8F)Zusedforsecurityz%s.intermediatez%s: %sz	%sz@:z
.INTERMEDIATEz$(call do_cmd,touch)N)r�r^r�r/rnr��encode�hashlibZsha1Z	hexdigestr)r{r�r�r�r�r�rrr�Zforce_appendZ	cmdstringZ	cmddigestZintermediater�rrr r��s6
 
zMakefileWriter.WriteMakeRulecCs�|jdkrdS|jd�|jd�|jd|�|jd�|jd	�|jd
�|jd�dddd
�}d}xH|D]@}tjj|�d}||krn||d7<||||krn|}qnW|jd|�|jt|jtt	|��d�dd�}ddi}	i}
t
|
|	�|j||td|
d�d�|j||tdtd�d�|jdk�rH|jd�n.|jdk�r`|jd�n|jdk�rv|jd�|j�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.
    rr�r`Nz/# 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)z.ccz.cppz.cxxz.cpprizLOCAL_CPP_EXTENSION := ZLOCAL_SRC_FILEScSsRg}xH|D]@}tjj|�}|j|�r
|j|�r
|j|t|�t|���q
W|S)N)r,r-rkrr@rlrn)r�r�r�modules�filepathrCrrr �
DepsToModules?s
 z?MakefileWriter.WriteAndroidNdkModuleRule.<locals>.DepsToModulesrrrrZLOCAL_SHARED_LIBRARIESrr	ZLOCAL_STATIC_LIBRARIESzinclude $(BUILD_EXECUTABLE)zinclude $(BUILD_SHARED_LIBRARY)zinclude $(BUILD_STATIC_LIBRARY))rr�r`)r_r�r,r-rHr�r�r�r�rFr!r)r{Zmodule_namerqr�Zcpp_extZdefault_cpp_extrCr=rrrrrr r�
sR







	

z(MakefileWriter.WriteAndroidNdkModuleRulecCs|jj|d�dS)Nr5)r�r:)r{�textrrr r�`szMakefileWriter.WriteLncCs"tjj|jdtjjd|j�d|�S)Nz$(abs_builddir)z
$(abs_srcdir)z$(BUILDTYPE))rr�r�r�r,r-r/)r{r�rrr r�dsz MakefileWriter.GetSortedXcodeEnvcCs|jjdd�}|jd|id�S)NZCHROMIUM_STRIP_SAVE_FILEr)r�)r�ZGetPerTargetSettingr�)r{Zstrip_save_filerrr rksz)MakefileWriter.GetSortedXcodePostbuildEnvcCs.x(|D] \}}|jdt|�||f�qWdS)Nz%s: export %s := %s)r�r^)r{r�r��k�vrrr r�vsz"MakefileWriter.WriteSortedXcodeEnvcCs4d|kr|jdd|j�}d|kr0d|j|f}|S)z,Convert a path to its output directory form.z$(z$(obj)/z$(obj).%s/$(TARGET)/z$(obj)z$(obj).%s/$(TARGET)/%s)rKr~)r{r-rrr r��s
zMakefileWriter.ObjectifycCs<|j|�}d|kr,|jdd|j|f�}|Sd|j||fS)z:Convert a prefix header path to its output directory form.z$(z$(obj)/z$(obj).%s/$(TARGET)/pch-%sz$(obj).%s/$(TARGET)/pch-%s/%s)r�rKr~)r{r-r�rrr r��s
zMakefileWriter.PchifycCs*d|kr|jd�Stjjtjj|j|��S)zlConvert a subdirectory-relative path into a base-relative path.
    Skips over paths that contain variables.z$(�/)�rstripr,r-r.r/)r{r-rrr r��s
zMakefileWriter.AbsolutifycCs&d|krd|kr|S|||d�}|S)Nz%(INPUT_ROOT)sz%(INPUT_DIRNAME)s)Z
INPUT_ROOTZ
INPUT_DIRNAMEr)r{�templateZ	expansionr�r-rrr 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)/)r_rr~r�)r{rrr r��s
z,MakefileWriter._InstallableTargetInstallPath)NF)NNFFFN)r)N)$�__name__�
__module__�__qualname__�__doc__r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�rTr�r�r�r�r�r�rr�r�r�r�r�r�rrrr rw�sNd&
!+m

=S

	

rwcs�|d��fdd�|dD�}tjj|d�j�}|jtj�sLtjjd|�}|j	d|djt
t|��tjj|d	gtj
��|�d
��dS)z,Write the target to regenerate the Makefile.r$csg|]}tjj|�j��qSr)rr�RelativePathr+)rArC)r$rr r��sz-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)

r]z-fmake)�
makefile_namer��cmdN)rrZFixIfRelativePathr+rr,�sepr-r/r:r�r[r�ZRegenerateFlags)r�
root_makefiler)�build_filesZbuild_files_argsr(r)r$r �WriteAutoRegenerationRule�s
r.cCsf|d}xX|D]P}dg}|jr6|jdkr6|d|jf7}|jd|�td||f�tj|�qWdS)Nr$Zmaker�z-Cz
BUILDTYPE=zBuilding [%s]: %s)r+rlro�
subprocessZ
check_call)�data�configurationsrr$r�Z	argumentsrrr �PerformBuild�s
r2c1s�|d�tjj|�}|jdi�}|jdd�}|jdd�}|jdd�}�fdd	�}	d}
t�fd
d�|D��}x*|D]"}�|}
|
dd
krp|
d}
PqpW|
s�d
}
d}d�j}tjj�j	|�}�j
r�tjj�j	�j
|�}tjj|�j
�}dad}d}d}|||
|dt
d|||d�
}|dk�r4d}|j|dttd��n�|dk�rN|jdti�n�|dk�rtd}d}|j||td ��nv|d!k�r�|jd"dd#��nZ|d$k�r�|jdd%i�n@|d&k�r�d'}|jd(|i�n"|d)k�r�d'}|j|td"dd*��|jtd`d-�tdad0�tdbd3�tdcd6�tddd8�tded:�tdfd<�tdgd>�d?��tjj|d@�\�}}|�jdAg�}i}x8|D]0\}}|jdB��rfdC|||dtdB��<�qfWd}x�|D]�\}}tjdD|��r��q�|d@dEk�r�dC|}|j|�}|�r�dF||f}||=|dhk�rH|dI|7}|jddJ�}|tjk�r.tj|}|dK||f7}|dL7}n|dM||f7}�q�W||dA<tjj|�t|dN�}|jt|�|�r�|jdO�x$|D]}|jdP|�t |��q�Wtjj!|�}tjj"||�t��x8|dQD],�x$tjj#|���D]}�j$|��qW�q�Wt�} t�}!�xJ|D�]@}"tjj|"�\�}}|�jdAg�}#| j$tjj��j	��|�dR}$xd|$D]\}%tjjtjj%|%���j	�}&tjj&|&�}'|dS�r�|'j'|dS��r�| j$|'�n
| j$|&��q~W|	�|d|�jdT�\}(})�|"}
|
dU}*|dk�r*tj(j)|�|
�t*||�}+|+j+|"|(|)|
|*|"�kdV�tjj|)tjj!|��},|!j$|,��q.Wtjj�j,tj-��}-x�| D]��tjj|-������fdWd�|D�}.|.�s��q�|	�tjj.tjj/���d@dX�\}(})tjjtjj!|�tjj!|)��}/|+j0|)|/|.|��q�W|jdY�x@t1|!�D]4}0|jdZ|0d[�|jd\|0dY�|jdL��q.W|jdY�|jd]��r�|jd^d_��r�t2|||| �|jt3�|j4�dS)iNr$r"r%r&r#�default_targetr
csftjjtjj|��j�}tjj�j||�}�jrFtjj�j�j||�}tjjtjj|��j	�}||fS)z9Determine where to write a Makefile for a given gyp file.)
rrr'r,r-r��depthr/r*r+)�
build_fileZ	base_namer��output_file)r$rr �CalculateMakefilePath�sz-GenerateOutput.<locals>.CalculateMakefilePathcsg|]}�|d�qS)r~r)rAr�)�target_dictsrr r��sz"GenerateOutput.<locals>.<listcomp>�default_configurationZDefaultr��Makefilez
$(srcdir)/�flockz-afz-MMDrir)
r3Zbuilddirr9r;�flock_index�
link_commands�extra_commands�srcdir�copy_archive_args�makedep_argsrz./gyp-mac-tool flock�)r;r<r=r>rr=Zzosz-fPRz
-qmakedep=gcc)r@rAr=�solarisz./gyp-flock-tool flock)r;r<Zfreebsd�lockfr	z-pPRfr@r)r@r=r;r<�	CC_target�CCz$(CC)�	AR_target�ARz$(AR)�
CXX_target�CXXz$(CXX)�LINK_target�LINKz$(LINK)�CC_host�gcc�AR_host�ar�CXX_hostzg++�	LINK_hostz$(CXX.host))z	CC.targetz	AR.targetz
CXX.targetzLINK.targetzCC.hostzAR.hostzCXX.hostz	LINK.hostr�make_global_settingsZ_wrapperz
$(abspath %s)z
.*_wrapperrNz%s %s�CC.host�CXX.hostz3ifneq (,$(filter $(origin %s), undefined default))
rUz
  %s = %s
zendif
z	%s ?= %s
r}zU# Define LOCAL_PATH for build of Android applications.
LOCAL_PATH := $(call my-dir)

zTOOLSET := %s
r-�included_filesZhome_dot_gypz.mkr1)r�cs*g|]"}|j��r|�kr�|d�qS)rj)r)rAr�)r5�needed_targetsr8rr r��s
z	.Makefiler5zmifeq ($(strip $(foreach prefix,$(NO_LOAD),\
    $(findstring $(join ^,$(prefix)),\
                 $(join ^,z)))),)
z
  include Z
standaloneZauto_regenerationT)rErF)rGrH)rIrJ)rKrL)rM)rO)rQ)rR)rFrTrJrU)5rrrr(r�rr,r-r/r+r*r'rZ�LINK_COMMANDS_LINUXr�LINK_COMMANDS_MAC�SHARED_HEADER_MAC_COMMANDS�LINK_COMMANDS_ANDROID�LINK_COMMANDS_OS390�LINK_COMMANDS_AIXrZParseQualifiedTargetr@rnrV�matchrK�environr�r�r:�
SHARED_HEADERr>r�ZCopyToolZ
AllTargetsr�ZUnrelativePath�abspathrr�ZMergeGlobalXcodeSettingsToSpecrwr�r4�getcwdrHrkr�r6r.�
SHARED_FOOTERr�)1Ztarget_listr8r0rrr"r1r#r3r7r9Ztoolsetsr�rpr?r)r�Z
flock_commandZcopy_archive_argumentsZmakedep_argumentsZ
header_paramsrUZmake_global_settings_arrayZwrappersr4�valuerS�wrapperZenv_keyr,r~Z	dest_pathr-Zinclude_listr�Zthis_make_global_settingsrVZ
included_fileZrelative_include_fileZabs_include_filer�r6r�r;Zmkfile_rel_pathZdepth_rel_pathZgyp_targetsZmakefile_rel_pathZinclude_filer)r5rWr$r8r �GenerateOutput�s^









 











"



rf)r\)6Z
__future__rr,rV�sysr/rZ
gyp.commonZgyp.xcode_emulationrrrrZ$generator_supports_multiple_toolsetsr)r
rrr0r!r2rrXrYr[r]r\r`rZr>r�r�rcr�rrFrGrIrMrOrQrTrXrZr[r^rvr�r��objectrwr.r2rfrrrr �<module>s�%!%P&"