58c0231c3f4659eff4f63734f55957552b3d08dc
[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         target.command('CFLAGS=-fPIC cmake .')
27     elif target.platform == 'osx':
28         if target.bits == 64:
29             type = 'osx'
30         else:
31             type = 'osx32'
32         blockdev = 'linux'
33         ext = 'dylib'
34         device = 'dev'
35     elif target.platform == 'windows':
36         type = 'mingw' if target.bits == 64 else 'mingw-32'
37         blockdev = 'windows'
38         ext = 'dll'
39         device = 'windows'
40
41     target.command('mkdir -p %s/include/lwext4' % target.directory)
42     target.command('cp -r include/* %s/include/lwext4' % target.directory)
43     target.command('make %s' % type)
44     target.command('make -j%d -C build_%s' % (target.parallel, type))
45     target.command('cp -r build_%s/include/generated %s/include/lwext4' % (type, target.directory))
46     target.command('cp blockdev/%s/file_%s.h %s/include/lwext4' % (blockdev, device, target.directory))
47     target.command('mkdir -p %s/lib' % target.directory)
48     target.command('cp build_%s/src/liblwext4.%s %s/lib' % (type, ext, target.directory))
49     target.command('cp build_%s/blockdev/libblockdev.%s %s/lib' % (type, ext, target.directory))