]> khamidou — GitHub mirrors - electron.git/commitdiff
win: Fix generating location.pak.
authorCheng Zhao <zcbenz@gmail.com>
Fri, 12 Dec 2014 03:29:36 +0000 (19:29 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 12 Dec 2014 03:29:36 +0000 (19:29 -0800)
atom.gyp
tools/make_locale_paks.py [new file with mode: 0755]
tools/posix/make_locale_paks.sh [deleted file]

index 28975eb23188d95bd2e37b299a5af04ed071a09e..249185a321edaab75a47319651b0cbf5a3bb0173 100644 (file)
--- a/atom.gyp
+++ b/atom.gyp
             {
               'action_name': 'Make Empty Paks',
               'inputs': [
-                'tools/posix/make_locale_paks.sh',
+                'tools/make_locale_paks.py',
               ],
               'outputs': [
                 '<(PRODUCT_DIR)/locales'
               ],
               'action': [
-                'tools/posix/make_locale_paks.sh',
+                'python',
+                'tools/make_locale_paks.py',
                 '<(PRODUCT_DIR)',
                 '<@(locales)',
               ],
diff --git a/tools/make_locale_paks.py b/tools/make_locale_paks.py
new file mode 100755 (executable)
index 0000000..70597f5
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+# usage: make_locale_paks build_dir [...]
+#
+# This script creates the .pak files under locales directory, it is used to fool
+# the ResourcesBundle that the locale is available.
+
+import errno
+import sys
+import os
+
+
+def main():
+  target_dir = sys.argv[1]
+  locale_dir = os.path.join(target_dir, 'locales')
+  safe_mkdir(locale_dir)
+  for pak in sys.argv[2:]:
+    touch(os.path.join(locale_dir, pak + '.pak'))
+
+
+def touch(filename):
+  with open(filename, 'w+'):
+    pass
+
+
+def safe_mkdir(path):
+  try:
+    os.makedirs(path)
+  except OSError as e:
+    if e.errno != errno.EEXIST:
+      raise
+
+
+if __name__ == '__main__':
+  sys.exit(main())
diff --git a/tools/posix/make_locale_paks.sh b/tools/posix/make_locale_paks.sh
deleted file mode 100755 (executable)
index 6f66a04..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-# Copyright (c) 2011 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# usage: make_locale_paks locale_dir [...]
-#
-# This script creates the .pak files under locales directory, it is used to fool
-# the ResourcesBundle that the locale is available.
-
-set -eu
-
-if [[ ${#} -eq 0 ]]; then
-  echo "usage: ${0} build_dir [locale_pak...]" >& 2
-  exit 1
-fi
-
-PRODUCT_DIR="$1"
-shift
-
-LOCALES_DIR="${PRODUCT_DIR}/locales"
-if [[ ! -d "${LOCALES_DIR}" ]]; then
-  mkdir "${LOCALES_DIR}"
-fi
-
-cd "${LOCALES_DIR}"
-
-for pak in "${@}"; do
-  if [[ ! -f "${pak}.pak" ]]; then
-    touch "${pak}.pak"
-  fi
-done