s4:torture: add a test-suite for VSS
[bbaumbach/samba-autobuild/.git] / examples / winexe / wscript_build
1 #!/usr/bin/env python
2
3 import samba_utils
4
5 def generate_winexesvc_c_from_exe(t):
6     src = t.inputs[0].bldpath(t.env)
7     tgt = t.outputs[0].bldpath(t.env)
8     fn = t.env.SAMBA_GENERATOR_VARS['WINEXE_FN']
9     src_blob = samba_utils.load_file(src)
10
11     def c_array(src):
12         N = 0
13         result = ''
14         while src:
15             l = src[:8]
16             src = src[8:]
17             h = ' '.join(["0x%02X," % ord(x) for x in l])
18             result += "\t\t%s\n" % (h)
19         return result
20
21     src_array = c_array(src_blob)
22
23     contents = '''
24 #include "replace.h"
25 #include "lib/util/data_blob.h"
26
27 const DATA_BLOB *%s(void);
28 const DATA_BLOB *%s(void)
29 {
30 \tstatic const uint8_t array[] = {
31 %s
32 \t};
33 \tstatic const DATA_BLOB blob = {
34 \t\t.data = discard_const_p(uint8_t, array),
35 \t\t.length = ARRAY_SIZE(array),
36 \t};
37 \treturn &blob;
38 }
39 ''' % (fn, fn, src_array)
40
41     ret = samba_utils.save_file(tgt, contents)
42     assert(ret == True)
43
44 winexesvc_binaries = ''
45
46 if bld.env.WINEXE_CC_WIN32:
47     bld.SAMBA_GENERATOR(
48         'winexesvc32_exe',
49         source='winexesvc.c',
50         target='winexesvc32.exe',
51         rule='${WINEXE_CC_WIN32} ${SRC} -o ${TGT} ${WINEXE_LDFLAGS}')
52     vars = {"WINEXE_FN": "winexesvc32_exe_binary"}
53     bld.SAMBA_GENERATOR(
54         'winexesvc32_exe_binary',
55         source='winexesvc32.exe',
56         target='winexesvc32_exe_binary.c',
57         group='build_source',
58         vars=vars,
59         rule=generate_winexesvc_c_from_exe)
60     winexesvc_binaries += ' winexesvc32_exe_binary.c'
61
62 if bld.env.WINEXE_CC_WIN64:
63     bld.SAMBA_GENERATOR(
64         'winexesvc64_exe',
65         source='winexesvc.c',
66         target='winexesvc64.exe',
67         rule='${WINEXE_CC_WIN64} ${SRC} -o ${TGT} ${WINEXE_LDFLAGS}')
68     vars = {"WINEXE_FN": "winexesvc64_exe_binary"}
69     bld.SAMBA_GENERATOR(
70         'winexesvc64_exe_binary',
71         source='winexesvc64.exe',
72         target='winexesvc64_exe_binary.c',
73         group='build_source',
74         vars=vars,
75         rule=generate_winexesvc_c_from_exe)
76     winexesvc_binaries += ' winexesvc64_exe_binary.c'
77
78 if winexesvc_binaries != '':
79     bld.SAMBA3_BINARY('winexe',
80                       source='winexe.c ' + winexesvc_binaries,
81                       deps='''
82                           popt
83                           samba-credentials
84                           LOADPARM_CTX
85                           libsmb
86                           msrpc3
87                       ''')