]> git.pld-linux.org Git - packages/android-tools.git/blame - generate_build.rb
update to 6.0 git snapshot
[packages/android-tools.git] / generate_build.rb
CommitLineData
b4bc8a71
ER
1#!/usr/bin/ruby
2
3# Android build system is complicated and does not allow to build
4# separate parts easily.
5# This script tries to mimic Android build rules.
6
7def expand(dir, files)
8 files.map{|f| File.join(dir,f)}
9end
10
11# Compiles sources to *.o files.
12# Returns array of output *.o filenames
13def compile(sources, cflags)
14 outputs = []
15 for s in sources
16 ext = File.extname(s)
17
18 case ext
19 when '.c'
20 cc = 'gcc'
21 lang_flags = '-std=gnu11 $CFLAGS $CPPFLAGS'
22 when '.cpp', '.cc'
23 cc = 'g++'
24 lang_flags = '-std=gnu++14 $CXXFLAGS $CPPFLAGS'
25 else
26 raise "Unknown extension #{ext}"
27 end
28
29 output = s + '.o'
30 outputs << output
31 puts "#{cc} -o #{output} #{lang_flags} #{cflags} -c #{s}\n"
32 end
33
34 return outputs
35end
36
37# Links object files
38def link(output, objects, ldflags)
39 puts "g++ -o #{output} #{ldflags} $LDFLAGS #{objects.join(' ')}"
40end
41
42minicryptfiles = %w(
43 dsa_sig.c
44 p256_ec.c
45 rsa.c
46 sha.c
47 p256.c
48 p256_ecdsa.c
49 sha256.c
50)
51libminicrypt = compile(expand('libmincrypt', minicryptfiles), '-Iinclude')
52
53adbdfiles = %w(
54 adb.cpp
55 adb_auth.cpp
56 adb_io.cpp
57 adb_listeners.cpp
58 adb_utils.cpp
59 sockets.cpp
60 transport.cpp
61 transport_local.cpp
62 transport_usb.cpp
63 services.cpp
64 adb_trace.cpp
65 get_my_path_linux.cpp
66 usb_linux.cpp
67 diagnose_usb.cpp
68 adb_auth_host.cpp
69 sysdeps_unix.cpp
70)
71libadbd = compile(expand('adb', adbdfiles), '-DADB_REVISION=\"$PKGVER\" -DADB_HOST=1 -fpermissive -Iinclude -Ibase/include')
72
73adbshfiles = %w(
74 fdevent.cpp
75 shell_service.cpp
76 shell_service_protocol.cpp
77)
78libadbsh = compile(expand('adb', adbshfiles), '-DADB_REVISION=\"$PKGVER\" -DADB_HOST=0 -D_Nonnull= -D_Nullable= -fpermissive -Iadb -Iinclude -Ibase/include')
79
80adbfiles = %w(
81 console.cpp
82 commandline.cpp
83 adb_client.cpp
84 file_sync_client.cpp
85 line_printer.cpp
86 client/main.cpp
87)
88libadb = compile(expand('adb', adbfiles), '-DADB_REVISION=\"$PKGVER\" -D_GNU_SOURCE -DADB_HOST=1 -D_Nonnull= -D_Nullable= -fpermissive -Iadb -Iinclude -Ibase/include')
89
90basefiles = %w(
91 file.cpp
92 logging.cpp
93 parsenetaddress.cpp
94 stringprintf.cpp
95 strings.cpp
96 errors_unix.cpp
97)
98libbase = compile(expand('base', basefiles), '-DADB_HOST=1 -D_GNU_SOURCE -Ibase/include -Iinclude')
99
100logfiles = %w(
101 logger_write.c
102 config_write.c
103 logger_lock.c
104 logger_name.c
105 log_event_list.c
106 log_event_write.c
107 fake_log_device.c
108 fake_writer.c
109)
110liblog = compile(expand('liblog', logfiles), '-DLIBLOG_LOG_TAG=1005 -DFAKE_LOG_DEVICE=1 -D_GNU_SOURCE -Ilog/include -Iinclude')
111
112cutilsfiles = %w(
113 load_file.c
114 socket_inaddr_any_server_unix.c
115 socket_local_client_unix.c
116 socket_local_server_unix.c
117 socket_loopback_client_unix.c
118 socket_loopback_server_unix.c
119 socket_network_client_unix.c
120 threads.c
121 sockets.cpp
122 sockets_unix.cpp
123)
124libcutils = compile(expand('libcutils', cutilsfiles), '-D_GNU_SOURCE -Iinclude')
125
126link('adb/adb', libbase + liblog + libcutils + libadbd + libadbsh + libadb, '-lrt -ldl -lpthread -lcrypto -lutil')
127
128
129fastbootfiles = %w(
130 socket.cpp
131 tcp.cpp
132 udp.cpp
133 protocol.cpp
134 engine.cpp
135 bootimg_utils.cpp
136 fastboot.cpp
137 util.cpp
138 fs.cpp
139 usb_linux.cpp
140 util_linux.cpp
141)
142libfastboot = compile(expand('fastboot', fastbootfiles), '-DFASTBOOT_REVISION=\"$PKGVER\" -D_GNU_SOURCE -Iadb -Iinclude -Imkbootimg -Ibase/include -Ilibsparse/include -I../extras/ext4_utils -I../extras/f2fs_utils')
143
144sparsefiles = %w(
145 backed_block.c
146 output_file.c
147 sparse.c
148 sparse_crc32.c
149 sparse_err.c
150 sparse_read.c
151)
152libsparse = compile(expand('libsparse', sparsefiles), '-Ilibsparse/include')
153
154zipfiles = %w(
155 zip_archive.cc
156)
157libzip = compile(expand('libziparchive', zipfiles), '-Ibase/include -Iinclude')
158
159utilfiles = %w(
160 FileMap.cpp
161)
162libutil = compile(expand('libutils', utilfiles), '-Iinclude')
163
164ext4files = %w(
165 make_ext4fs.c
166 ext4fixup.c
167 ext4_utils.c
168 allocate.c
169 contents.c
170 extent.c
171 indirect.c
172 sha1.c
173 wipe.c
174 crc16.c
175 ext4_sb.c
176)
177libext4 = compile(expand('../extras/ext4_utils', ext4files), '-Ilibsparse/include -Iinclude')
178
179link('fastboot/fastboot', libsparse + libzip + liblog + libutil + libcutils + libbase + libext4 + libfastboot + libadbsh + libadbd, '-lpthread -lselinux -lz -lcrypto -lutil')
180
181simg2imgfiles = %w(
182 simg2img.c
183)
184libsimg2img = compile(expand('libsparse', simg2imgfiles), '-Iinclude -Ilibsparse/include')
185link('libsparse/simg2img', libsparse + libsimg2img, '-lz')
186
187img2simgfiles = %w(
188 img2simg.c
189)
190libimg2simg = compile(expand('libsparse', img2simgfiles), '-Iinclude -Ilibsparse/include')
191link('libsparse/img2simg', libsparse + libimg2simg, '-lz')
This page took 0.126709 seconds and 4 git commands to generate.