|
2 | 2 | set -e
|
3 | 3 | set +x
|
4 | 4 |
|
5 |
| -if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then |
6 |
| - echo "usage: $(basename $0) [output-absolute-path]" |
7 |
| - echo |
8 |
| - echo "Generate distributable .zip archive from ./output folder that was previously downloaded." |
9 |
| - echo |
10 |
| - exit 0 |
11 |
| -fi |
12 |
| - |
13 |
| -ZIP_PATH=$1 |
14 |
| -if [[ $ZIP_PATH != /* ]]; then |
15 |
| - echo "ERROR: path $ZIP_PATH is not absolute" |
16 |
| - exit 1 |
17 |
| -fi |
18 |
| -if [[ $ZIP_PATH != *.zip ]]; then |
19 |
| - echo "ERROR: path $ZIP_PATH must have .zip extension" |
20 |
| - exit 1 |
21 |
| -fi |
22 |
| -if [[ -f $ZIP_PATH ]]; then |
23 |
| - echo "ERROR: path $ZIP_PATH exists; can't do anything." |
24 |
| - exit 1 |
25 |
| -fi |
26 |
| -if ! [[ -d $(dirname $ZIP_PATH) ]]; then |
27 |
| - echo "ERROR: folder for path $($ZIP_PATH) does not exist." |
28 |
| - exit 1 |
29 |
| -fi |
30 |
| - |
31 | 5 | trap "cd $(pwd -P)" EXIT
|
32 | 6 | cd "$(dirname $0)"
|
| 7 | +SCRIPT_PATH=$(pwd -P) |
| 8 | + |
| 9 | +main() { |
| 10 | + if [[ ("$1" == "-h") || ("$1" == "--help") ]]; then |
| 11 | + echo "usage: $(basename $0) [output-absolute-path]" |
| 12 | + echo |
| 13 | + echo "Generate distributable .zip archive from ./output folder that was previously downloaded." |
| 14 | + echo |
| 15 | + exit 0 |
| 16 | + fi |
| 17 | + |
| 18 | + ZIP_PATH=$1 |
| 19 | + |
| 20 | + if [[ $ZIP_PATH != /* ]]; then |
| 21 | + echo "ERROR: path $ZIP_PATH is not absolute" |
| 22 | + exit 1 |
| 23 | + fi |
| 24 | + if [[ $ZIP_PATH != *.zip ]]; then |
| 25 | + echo "ERROR: path $ZIP_PATH must have .zip extension" |
| 26 | + exit 1 |
| 27 | + fi |
| 28 | + if [[ -f $ZIP_PATH ]]; then |
| 29 | + echo "ERROR: path $ZIP_PATH exists; can't do anything." |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | + if ! [[ -d $(dirname $ZIP_PATH) ]]; then |
| 33 | + echo "ERROR: folder for path $($ZIP_PATH) does not exist." |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | + |
| 37 | + BUILD_TYPE=$2 |
| 38 | + if [[ "${BUILD_TYPE}" == "--compile"* ]]; then |
| 39 | + archive_compiled_chromium "${BUILD_TYPE}" |
| 40 | + elif [[ "${BUILD_TYPE}" == "--mirror"* ]]; then |
| 41 | + archive_mirrored_chromium "${BUILD_TYPE}" |
| 42 | + else |
| 43 | + echo "ERROR: unknown build type - ${BUILD_TYPE}" |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | + |
| 47 | + cd "${SCRIPT_PATH}" |
| 48 | + cp output/build.zip $ZIP_PATH |
| 49 | +} |
| 50 | + |
| 51 | +function archive_compiled_chromium() { |
| 52 | + CHROMIUM_FOLDER_NAME="" |
| 53 | + CHROMIUM_FILES_TO_ARCHIVE=() |
| 54 | + |
| 55 | + if [[ $1 == "--compile-mac"* ]]; then |
| 56 | + CHROMIUM_FOLDER_NAME="chrome-mac" |
| 57 | + CHROMIUM_FILES_TO_ARCHIVE=("Chromium.app") |
| 58 | + elif [[ $1 == "--compile-linux" ]]; then |
| 59 | + CHROMIUM_FOLDER_NAME="chrome-linux" |
| 60 | + CHROMIUM_FILES_TO_ARCHIVE=( |
| 61 | + "chrome" |
| 62 | + "chrome_100_percent.pak" |
| 63 | + "chrome_200_percent.pak" |
| 64 | + "chrome_sandbox" |
| 65 | + "chrome-wrapper" |
| 66 | + "ClearKeyCdm" |
| 67 | + "crashpad_handler" |
| 68 | + "icudtl.dat" |
| 69 | + "libEGL.so" |
| 70 | + "libGLESv2.so" |
| 71 | + "locales" |
| 72 | + "MEIPreload" |
| 73 | + "nacl_helper" |
| 74 | + "nacl_helper_bootstrap" |
| 75 | + "nacl_helper_nonsfi" |
| 76 | + "nacl_irt_x86_64.nexe" |
| 77 | + "product_logo_48.png" |
| 78 | + "resources" |
| 79 | + "resources.pak" |
| 80 | + "swiftshader" |
| 81 | + "v8_context_snapshot.bin" |
| 82 | + "xdg-mime" |
| 83 | + "xdg-settings" |
| 84 | + ) |
| 85 | + elif [[ $1 == "--compile-win"* ]]; then |
| 86 | + CHROMIUM_FOLDER_NAME="chrome-win" |
| 87 | + CHROMIUM_FILES_TO_ARCHIVE=( |
| 88 | + "chrome.dll" |
| 89 | + "chrome.exe" |
| 90 | + "chrome_100_percent.pak" |
| 91 | + "chrome_200_percent.pak" |
| 92 | + "chrome_elf.dll" |
| 93 | + "chrome_proxy.exe" |
| 94 | + "chrome_pwa_launcher.exe" |
| 95 | + "D3DCompiler_47.dll" |
| 96 | + "elevation_service.exe" |
| 97 | + "eventlog_provider.dll" |
| 98 | + "First Run" |
| 99 | + "icudtl.dat" |
| 100 | + "libEGL.dll" |
| 101 | + "libGLESv2.dll" |
| 102 | + "locales" |
| 103 | + "MEIPreload" |
| 104 | + "mojo_core.dll" |
| 105 | + "nacl_irt_x86_64.nexe" |
| 106 | + "notification_helper.exe" |
| 107 | + "resources.pak" |
| 108 | + "swiftshader/libEGL.dll" |
| 109 | + "swiftshader/libGLESv2.dll" |
| 110 | + "v8_context_snapshot.bin" |
| 111 | + ) |
| 112 | + else |
| 113 | + echo "ERROR: unknown command, use --help for details" |
| 114 | + exit 1 |
| 115 | + fi |
| 116 | + |
| 117 | + # Prepare resulting archive. |
| 118 | + cd "$SCRIPT_PATH" |
| 119 | + rm -rf output |
| 120 | + mkdir -p "output/${CHROMIUM_FOLDER_NAME}" |
| 121 | + |
| 122 | + # On Mac, use 'ditto' to copy directories instead of 'cp'. |
| 123 | + COPY_COMMAND="cp -R" |
| 124 | + if [[ $(uname) == "Darwin" ]]; then |
| 125 | + COPY_COMMAND="ditto" |
| 126 | + fi |
| 127 | + |
| 128 | + for ((i = 0; i < ${#CHROMIUM_FILES_TO_ARCHIVE[@]}; i++)) do |
| 129 | + file="${CHROMIUM_FILES_TO_ARCHIVE[$i]}" |
| 130 | + mkdir -p "output/${CHROMIUM_FOLDER_NAME}/$(dirname $file)" |
| 131 | + $COPY_COMMAND "${CR_CHECKOUT_PATH}/src/out/Default/${file}" "output/${CHROMIUM_FOLDER_NAME}/${file}" |
| 132 | + done |
| 133 | + |
| 134 | + if [[ $1 == "--compile-win"* ]]; then |
| 135 | + $COPY_COMMAND "${CR_CHECKOUT_PATH}/src/out/Default/"*.manifest "output/${CHROMIUM_FOLDER_NAME}/" |
| 136 | + fi |
| 137 | + |
| 138 | + cd output |
| 139 | + zip --symlinks -r build.zip "${CHROMIUM_FOLDER_NAME}" |
| 140 | +} |
| 141 | + |
| 142 | +archive_mirrored_chromium() { |
| 143 | + cd "${SCRIPT_PATH}/output" |
| 144 | + |
| 145 | + CHROMIUM_FOLDER_NAME="" |
| 146 | + CHROMIUM_FILES_TO_REMOVE=() |
| 147 | + |
| 148 | + PLATFORM="$1" |
| 149 | + if [[ "${PLATFORM}" == "--mirror-win32" ]]; then |
| 150 | + CHROMIUM_FOLDER_NAME="chrome-win" |
| 151 | + CHROMIUM_FILES_TO_REMOVE+=("chrome-win/interactive_ui_tests.exe") |
| 152 | + elif [[ "${PLATFORM}" == "--mirror-win64" ]]; then |
| 153 | + CHROMIUM_FOLDER_NAME="chrome-win" |
| 154 | + CHROMIUM_FILES_TO_REMOVE+=("chrome-win/interactive_ui_tests.exe") |
| 155 | + elif [[ "${PLATFORM}" == "--mirror-mac" ]]; then |
| 156 | + CHROMIUM_FOLDER_NAME="chrome-mac" |
| 157 | + elif [[ "${PLATFORM}" == "--mirror-linux" ]]; then |
| 158 | + CHROMIUM_FOLDER_NAME="chrome-linux" |
| 159 | + else |
| 160 | + echo "ERROR: unknown platform to build: $PLATFORM" |
| 161 | + exit 1 |
| 162 | + fi |
| 163 | + |
| 164 | + for file in ${CHROMIUM_FILES_TO_REMOVE[@]}; do |
| 165 | + rm -f "${file}" |
| 166 | + done |
| 167 | + |
| 168 | + zip --symlinks -r build.zip "${CHROMIUM_FOLDER_NAME}" |
| 169 | +} |
33 | 170 |
|
34 |
| -cp output/build.zip $ZIP_PATH |
| 171 | +main "$@" |
0 commit comments