summaryrefslogtreecommitdiffstats
path: root/build/windows/signtool.py
blob: d62836171a7de14c5cfdc4190e2a98a5fa1b7b82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python

import os
from SCons.Builder import Builder

def signtool_path(subject_name, path):
    print("Running signtool: ", path)
    command = "signtool sign /sm /n \"%s\" /v %s" % (subject_name, path)
    if os.system(command) != 0:
        raise Exception('signtool failed: ' + command)

def do_signtool(target, source, env):
    print('do_signtool', target, source, env)
    subject_name = env.get('SUBJECT_NAME', '')

    for s in source:
        path = str(s)
        if path.endswith('.exe') or path.endswith('.dll'):
            signtool_path(subject_name, path)

SignTool = Builder(action = do_signtool)

def generate(env):
    env['BUILDERS']['SignTool'] = SignTool

def exists(env):
    return os.platform == 'windows'