Convert project to meson.

This commit is contained in:
King_DuckZ 2020-05-06 00:38:45 +02:00
parent 528467ca8e
commit 28d70a32b6
5 changed files with 57 additions and 6 deletions

51
meson.build Normal file
View file

@ -0,0 +1,51 @@
project('tigersum', 'c', 'd',
version: '0.1',
meson_version: '>=0.49.2',
default_options: [
'buildtype=release',
],
)
pvt_incl = include_directories('src')
read_buff_size = (get_option('read_buff_size') / 64) * 64
if (read_buff_size < 64)
read_buff_size = 64
endif
conf = configuration_data()
conf.set('PROJECT_NAME', meson.project_name())
conf.set('DEFAULT_TIGER_VERSION', get_option('default_tiger_version'))
version_arr = meson.project_version().split('.')
conf.set('TIGERSUM_MAJOR', version_arr[0])
conf.set('TIGERSUM_MINOR', version_arr[1])
conf.set('READ_BUFF_SIZE', read_buff_size)
if get_option('reference_tiger')
conf.set('BACKEND_NAME', 'tiger')
conf.set('BACKEND_WEBSITE', 'http://www.cs.technion.ac.il/~biham/Reports/Tiger/')
conf.set('BACKEND_AUTHOR', 'Ross Anderson and Eli Biham')
tiger_src = files('lib/reference_tiger/sboxes.c', 'lib/reference_tiger/tiger.c')
else
conf.set('BACKEND_NAME', 'freetiger')
conf.set('BACKEND_WEBSITE', 'http://klondike.es/freetiger/')
conf.set('BACKEND_AUTHOR', 'klondike')
tiger_src = files('lib/freetiger/C/tiger.c')
endif
project_config_file = configure_file(
input: 'src/' + meson.project_name() + 'Config.d.in',
output: meson.project_name() + 'Config.d',
configuration: conf
)
executable(meson.project_name(),
'src/main.d',
'src/sums.d',
'src/tiger.d',
project_config_file,
tiger_src,
install: true,
include_directories: pvt_incl,
d_import_dirs: [include_directories('.')],
)

3
meson_options.txt Normal file
View file

@ -0,0 +1,3 @@
option('reference_tiger', type: 'boolean', value: false)
option('default_tiger_version', type: 'combo', description: 'Default version of the Tiger algorithm', choices: ['1', '2'], value: '1')
option('read_buff_size', type: 'integer', value: 16384, min: 64, description: 'Read buffer size in bytes')

View file

@ -15,14 +15,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import tigersumConfig;
import std.stdio; import std.stdio;
import std.file; import std.file;
import std.array; import std.array;
import std.getopt; import std.getopt;
import sums; import sums;
mixin(import("tigersumConfig.d"));
int main (string[] parArgs) { int main (string[] parArgs) {
if (parArgs.length == 1) if (parArgs.length == 1)
return 0; return 0;

View file

@ -15,6 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import tigersumConfig;
import std.regex; import std.regex;
import std.stdio; import std.stdio;
import std.file : isDir; import std.file : isDir;
@ -24,8 +25,6 @@ import std.exception;
import std.format; import std.format;
import std.array : appender; import std.array : appender;
mixin(import("tigersumConfig.d"));
private void writeError (string parFile, string parMessage) { private void writeError (string parFile, string parMessage) {
stderr.writefln("tigersum: %s: %s", parFile, parMessage); stderr.writefln("tigersum: %s: %s", parFile, parMessage);
} }

View file

@ -15,13 +15,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import tigersumConfig;
import std.stdio; import std.stdio;
import std.string; import std.string;
import std.array, std.range; import std.array, std.range;
import std.algorithm; import std.algorithm;
mixin(import("tigersumConfig.d"));
private extern(C) void tiger (char* parMessage, ulong parLength, out ulong[3] parOut, char parPadding); private extern(C) void tiger (char* parMessage, ulong parLength, out ulong[3] parOut, char parPadding);
private extern(C) void tiger_init (out ulong[3] parOut); private extern(C) void tiger_init (out ulong[3] parOut);
private extern(C) void tiger_chunk (char* parMessage, ulong parLength, out ulong[3] parOut); private extern(C) void tiger_chunk (char* parMessage, ulong parLength, out ulong[3] parOut);