22c9b6b75b442af1ec9bc5db6b6d7af0db522f8b
[WebKit-https.git] / Source / WebInspectorUI / Scripts / copy-user-interface-resources.sh
1 #!/bin/sh
2
3 LICENSE=$(cat <<EOF
4 /*
5  * Copyright (C) 2007-2014 Apple Inc. All rights reserved.
6  * Copyright (C) 2009-2011 Google Inc. All rights reserved.
7  * Copyright (C) 2009-2010 Joseph Pecoraro. All rights reserved.
8  * Copyright (C) 2008 Matt Lilek. All rights reserved.
9  * Copyright (C) 2008-2009 Anthony Ricaud <rik@webkit.org>
10  * Copyright (C) 2009 280 North Inc. All Rights Reserved.
11  * Copyright (C) 2010 Nikita Vasilyev. All rights reserved.
12  * Copyright (C) 2011 Brian Grinstead All rights reserved.
13  * Copyright (C) 2013 Matt Holden <jftholden@yahoo.com>
14  * Copyright (C) 2013 Samsung Electronics. All rights reserved.
15  * Copyright (C) 2013 Seokju Kwon (seokju.kwon@gmail.com)
16  * Copyright (C) 2013 Adobe Systems Inc. All rights reserved.
17  * Copyright (C) 2013 University of Washington. All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions
21  * are met:
22  * 1. Redistributions of source code must retain the above copyright
23  *    notice, this list of conditions and the following disclaimer.
24  * 2. Redistributions in binary form must reproduce the above copyright
25  *    notice, this list of conditions and the following disclaimer in the
26  *    documentation and/or other materials provided with the distribution.
27  *
28  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
29  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
30  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
32  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
38  * THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 EOF
41 )
42
43 CODE_MIRROR_LICENSE=$(echo "/*" && sed 's/^/ * /' "${SRCROOT}/UserInterface/External/CodeMirror/LICENSE" && echo " */")
44
45 # Copy over dynamically loaded files from other frameworks, even if we aren't combining resources.
46 ditto "${JAVASCRIPTCORE_PRIVATE_HEADERS_DIR}/InspectorJSBackendCommands.js" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Protocol/InspectorJSBackendCommands.js"
47 ditto "${WEBCORE_PRIVATE_HEADERS_DIR}/InspectorWebBackendCommands.js" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Protocol/InspectorWebBackendCommands.js"
48
49 if [[ ${COMBINE_INSPECTOR_RESOURCES:=YES} == "YES" ]]; then
50     # Combine the JavaScript and CSS files in Production builds into single files (Main.js and Main.css).
51     "${SRCROOT}/Scripts/combine-resources.pl" --input-html "${SRCROOT}/UserInterface/Main.html" --derived-sources-dir "${DERIVED_SOURCES_DIR}" --output-dir "${DERIVED_SOURCES_DIR}" --output-script-name "Main.js" --output-style-name "Main.css"
52
53     # Combine the CodeMirror JavaScript and CSS files in Production builds into single files (CodeMirror.js and CodeMirror.css).
54     "${SRCROOT}/Scripts/combine-resources.pl" --input-dir "External/CodeMirror" --input-html "${DERIVED_SOURCES_DIR}/Main.html" --input-html-dir "${SRCROOT}/UserInterface" --derived-sources-dir "${DERIVED_SOURCES_DIR}" --output-dir "${DERIVED_SOURCES_DIR}" --output-script-name "CodeMirror.js" --output-style-name "CodeMirror.css"
55
56     # Remove console.assert calls from the Main.js file.
57     "${SRCROOT}/Scripts/remove-console-asserts.pl" --input-script "${DERIVED_SOURCES_DIR}/Main.js" --output-script "${DERIVED_SOURCES_DIR}/Main.js"
58
59     # Fix Image URLs in the Main.css file by removing the "../".
60     sed -i "" -e "s/\.\.\/Images/Images/g" "${DERIVED_SOURCES_DIR}/Main.css"
61
62     # Export the license into Main.js.
63     echo "${LICENSE}" > "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Main.js"
64
65     # Export the license into CodeMirror.js and CodeMirror.css.
66     echo "${CODE_MIRROR_LICENSE}" > "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CodeMirror.js"
67     echo "${CODE_MIRROR_LICENSE}" > "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CodeMirror.css"
68
69     # Minify the Main.js and Main.css files, with Main.js appending to the license that was exported above.
70     python "${SRCROOT}/Scripts/jsmin.py" <"${DERIVED_SOURCES_DIR}/Main.js" >>"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Main.js"
71     python "${SRCROOT}/Scripts/cssmin.py" <"${DERIVED_SOURCES_DIR}/Main.css" >"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Main.css"
72
73     # Minify the CodeMirror.js and CodeMirror.css files, appending to the license that was exported above.
74     python "${SRCROOT}/Scripts/jsmin.py" <"${DERIVED_SOURCES_DIR}/CodeMirror.js" >>"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CodeMirror.js"
75     python "${SRCROOT}/Scripts/cssmin.py" <"${DERIVED_SOURCES_DIR}/CodeMirror.css" >>"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/CodeMirror.css"
76
77     # Copy over Main.html and the Images directory.
78     ditto "${DERIVED_SOURCES_DIR}/Main.html" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Main.html"
79     ditto "${SRCROOT}/UserInterface/Images" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Images"
80
81     # Copy the Legacy directory.
82     ditto "${SRCROOT}/UserInterface/Protocol/Legacy" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Protocol/Legacy"
83 else
84     # Keep the files separate for engineering builds.
85     ditto "${SRCROOT}/UserInterface" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
86 fi