aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/build_commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/servo/build_commands.py')
-rw-r--r--python/servo/build_commands.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py
index ad8e58d04c2..285f24d2534 100644
--- a/python/servo/build_commands.py
+++ b/python/servo/build_commands.py
@@ -1,5 +1,6 @@
from __future__ import print_function, unicode_literals
+import sys
import os
import os.path as path
import subprocess
@@ -16,6 +17,48 @@ from servo.command_base import CommandBase, cd
def is_headless_build():
return int(os.getenv('SERVO_HEADLESS', 0)) == 1
+# Function to generate desktop notification once build is completed & limit exceeded!
+def notify(elapsed):
+ if elapsed < 300:
+ return
+
+ if sys.platform.startswith('linux'):
+ try:
+ import dbus
+ bus = dbus.SessionBus()
+ notify_obj = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications')
+ method = notify_obj.get_dbus_method('Notify', 'org.freedesktop.Notifications')
+ method('Servo Build System', 0, '', ' Servo build complete!', '', [], [], -1)
+ except:
+ print("[Warning] Could not generate notification! Please make sure that the python dbus module is installed!")
+
+ elif sys.platform.startswith('win'):
+ try:
+ from ctypes import Structure, windll, POINTER, sizeof
+ from ctypes.wintypes import DWORD, HANDLE, WINFUNCTYPE, BOOL, UINT
+ class FLASHWINDOW(Structure):
+ _fields_ = [("cbSize", UINT),
+ ("hwnd", HANDLE),
+ ("dwFlags", DWORD),
+ ("uCount", UINT),
+ ("dwTimeout", DWORD)]
+ FlashWindowExProto = WINFUNCTYPE(BOOL, POINTER(FLASHWINDOW))
+ FlashWindowEx = FlashWindowExProto(("FlashWindowEx", windll.user32))
+ FLASHW_CAPTION = 0x01
+ FLASHW_TRAY = 0x02
+ FLASHW_TIMERNOFG = 0x0C
+ params = FLASHWINDOW(sizeof(FLASHWINDOW),
+ windll.kernel32.GetConsoleWindow(),
+ FLASHW_CAPTION | FLASHW_TRAY | FLASHW_TIMERNOFG, 3, 0)
+ FlashWindowEx(params)
+ except:
+ print("[Warning] Could not generate notification! Please make sure that the required libraries are installed!")
+
+ elif sys.platform.startswith('darwin'):
+ # Notification code for Darwin here! For the time being printing simple msg
+ print("[Warning] : Darwin System! Notifications not supported currently!")
+
+
@CommandProvider
class MachCommands(CommandBase):
@Command('build',
@@ -102,6 +145,9 @@ class MachCommands(CommandBase):
env=env, cwd=self.servo_crate())
elapsed = time() - build_start
+ # Generate Desktop Notification if elapsed-time > some threshold value
+ notify(elapsed)
+
print("Build completed in %0.2fs" % elapsed)
return status
@@ -135,6 +181,9 @@ class MachCommands(CommandBase):
env=self.build_env())
elapsed = time() - build_start
+ # Generate Desktop Notification if elapsed-time > some threshold value
+ notify(elapsed)
+
print("CEF build completed in %0.2fs" % elapsed)
return ret
@@ -170,6 +219,9 @@ class MachCommands(CommandBase):
ret = subprocess.call(["cargo", "build"] + opts, env=env)
elapsed = time() - build_start
+ # Generate Desktop Notification if elapsed-time > some threshold value
+ notify(elapsed)
+
print("Gonk build completed in %0.2fs" % elapsed)
return ret