More.
[lwext4.git] / cscript
1 # -*- mode: python -*-
2 #
3 #    Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
4 #
5 #    This program is free software; you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License as published by
7 #    the Free Software Foundation; either version 2 of the License, or
8 #    (at your option) any later version.
9 #
10 #    This program is distributed in the hope that it will be useful,
11 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #    GNU General Public License for more details.
14 #
15 #    You should have received a copy of the GNU General Public License
16 #    along with this program; if not, write to the Free Software
17 #    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #
19
20 def build(target, options):
21     if target.platform == 'linux':
22         type = 'generic'
23         blockdev = 'linux'
24         ext = 'a'
25         device = 'dev'
26     elif target.platform == 'osx':
27         if target.bits == 64:
28             type = 'osx'
29         else:
30             type = 'osx32'
31         blockdev = 'linux'
32         ext = 'dylib'
33         device = 'dev'
34     elif target.platform == 'windows':
35         type = 'mingw' if target.bits == 64 else 'mingw-32'
36         blockdev = 'windows'
37         ext = 'dll'
38         device = 'windows'
39
40     target.command('mkdir -p %s/include/lwext4' % target.directory)
41     target.command('cp -r include/* %s/include/lwext4' % target.directory)
42     target.command('make %s' % type)
43     target.command('make -j%d -C build_%s' % (target.parallel, type))
44     target.command('cp -r build_%s/include/generated %s/include/lwext4' % (type, target.directory))
45     target.command('cp blockdev/%s/file_%s.h %s/include/lwext4' % (blockdev, device, target.directory))
46     target.command('mkdir -p %s/lib' % target.directory)
47     target.command('cp build_%s/src/liblwext4.%s %s/lib' % (type, ext, target.directory))
48     target.command('cp build_%s/blockdev/libblockdev.%s %s/lib' % (type, ext, target.directory))