Add cscript.
[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 = 'so'
25     elif target.platform == 'osx':
26         type = 'generic'
27         blockdev = 'linux'
28         ext = 'dylib'
29     elif target.platform == 'windows':
30         type = 'mingw'
31         blockdev = 'windows'
32         ext = 'dll'
33
34     target.command('mkdir -p %s/include/lwext4' % target.directory)
35     target.command('cp -r include/* %s/include/lwext4' % target.directory)
36     target.command('make %s' % type)
37     target.command('make -j%d -C build_%s' % (target.parallel, type))
38     target.command('cp -r build_%s/include/generated %s/include/lwext4' % (type, target.directory))
39     target.command('cp blockdev/%s/file_dev.h %s/include/lwext4' % (blockdev, target.directory))
40     target.command('cp build_%s/src/liblwext4.%s %s/lib' % (type, ext, target.directory))
41     target.command('cp build_%s/blockdev/libblockdev.%s %s/lib' % (type, ext, target.directory))