1b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#!/bin/sh 2b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# Copyright 2013 the V8 project authors. All rights reserved. 3b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# Redistribution and use in source and binary forms, with or without 4b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# modification, are permitted provided that the following conditions are 5b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# met: 6b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# 7b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# * Redistributions of source code must retain the above copyright 8b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# notice, this list of conditions and the following disclaimer. 9b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# * Redistributions in binary form must reproduce the above 10b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# copyright notice, this list of conditions and the following 11b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# disclaimer in the documentation and/or other materials provided 12b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# with the distribution. 13b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# * Neither the name of Google Inc. nor the names of its 14b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# contributors may be used to endorse or promote products derived 15b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# from this software without specific prior written permission. 16b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# 17b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 29b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# Monkey-patch GYP. 30b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochcat > build/gyp/gyp.mingw << EOF 31b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch#!/usr/bin/env python 32b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 33b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# Copyright (c) 2009 Google Inc. All rights reserved. 34b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# Use of this source code is governed by a BSD-style license that can be 35b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# found in the LICENSE file. 36b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 37b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochimport sys 38b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 39b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# TODO(mark): sys.path manipulation is some temporary testing stuff. 40b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochtry: 41b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch import gyp 42b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochexcept ImportError, e: 43b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch import os.path 44b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 'pylib')) 45b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch import gyp 46b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 47b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochdef MonkeyBuildFileTargets(target_list, build_file): 48b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch """From a target_list, returns the subset from the specified build_file. 49b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch """ 50b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch build_file = build_file.replace('/', '\\\\') 51b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return [p for p in target_list if gyp.common.BuildFile(p) == build_file] 52b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochgyp.common.BuildFileTargets = MonkeyBuildFileTargets 53b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 54b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochimport gyp.generator.make 55b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochimport os 56b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochdef Monkey_ITIP(self): 57b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch """Returns the location of the final output for an installable target.""" 58b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch sep = os.path.sep 59b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch # Xcode puts shared_library results into PRODUCT_DIR, and some gyp files 60b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch # rely on this. Emulate this behavior for mac. 61b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch if (self.type == 'shared_library' and 62b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch (self.flavor != 'mac' or self.toolset != 'target')): 63b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch # Install all shared libs into a common directory (per toolset) for 64b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch # convenient access with LD_LIBRARY_PATH. 65b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return '\$(builddir)%slib.%s%s%s' % (sep, self.toolset, sep, self.alias) 66b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch return '\$(builddir)' + sep + self.alias 67b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochgyp.generator.make.MakefileWriter._InstallableTargetInstallPath = Monkey_ITIP 68b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 69b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochif __name__ == '__main__': 70b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch sys.exit(gyp.main(sys.argv[1:])) 71b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochEOF 72b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 73b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# Delete old generated Makefiles. 74b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochfind out -name '*.mk' -or -name 'Makefile*' -exec rm {} \; 75b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 76b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# Generate fresh Makefiles. 77b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochmv build/gyp/gyp build/gyp/gyp.original 78b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochmv build/gyp/gyp.mingw build/gyp/gyp 79b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochmake out/Makefile.ia32 80b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochmv build/gyp/gyp build/gyp/gyp.mingw 81b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochmv build/gyp/gyp.original build/gyp/gyp 82b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch 83b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# Patch generated Makefiles: replace most backslashes with forward slashes, 84b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch# fix library names in linker flags. 85b8a8cc1952d61a2f3a2568848933943a543b5d3eBen MurdochFILES=$(find out -name '*.mk' -or -name 'Makefile*') 86b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochfor F in $FILES ; do 87b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch echo "Patching $F..." 88b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch cp $F $F.orig 89b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch cat $F.orig \ 90b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch | sed -e 's|\([)a-zA-Z0-9]\)\\\([a-zA-Z]\)|\1/\2|g' \ 91b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch -e 's|\([)a-zA-Z0-9]\)\\\\\([a-zA-Z]\)|\1/\2|g' \ 92b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch -e 's|'%s/n'|'%s\\\\n'|g' \ 93b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch -e 's|-lwinmm\.lib|-lwinmm|g' \ 94b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch -e 's|-lws2_32\.lib|-lws2_32|g' \ 95b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch > $F 96b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdoch rm $F.orig 97b8a8cc1952d61a2f3a2568848933943a543b5d3eBen Murdochdone 98