Skip to content

Commit f109772

Browse files
authored
Merge pull request #315 from libtom/perl-generate-def
remove generate_def.sh, move code to helper.pl
2 parents e24af22 + 8a1ae86 commit f109772

File tree

5 files changed

+36
-27
lines changed

5 files changed

+36
-27
lines changed

generate_def.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

helper.pl

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,26 @@ sub update_dep
437437
}
438438

439439
sub generate_def {
440-
system("sh", "generate_def.sh");
440+
my @files = split /\n/, `git ls-files`;
441+
@files = grep(/\.c/, @files);
442+
@files = map { my $x = $_; $x =~ s/^bn_|\.c$//g; $x; } @files;
443+
@files = grep(!/mp_radix_smap/, @files);
444+
445+
@files = grep(!/conversion/, @files);
446+
push(@files, qw(mp_set_i32 mp_set_i64 mp_set_u32 mp_set_u64 mp_set_int mp_set_long mp_set_long_long mp_get_i32 mp_get_i64 mp_get_mag32 mp_get_mag64 mp_get_int mp_get_long mp_get_long_long mp_init_i32 mp_init_i64 mp_init_u32 mp_init_u64 mp_init_set_int));
447+
448+
my $files = join("\n ", sort(grep(/^mp_/, @files)));
449+
write_file "tommath.def", "; libtommath
450+
;
451+
; Use this command to produce a 32-bit .lib file, for use in any MSVC version
452+
; lib -machine:X86 -name:libtommath.dll -def:tommath.def -out:tommath.lib
453+
; Use this command to produce a 64-bit .lib file, for use in any MSVC version
454+
; lib -machine:X64 -name:libtommath.dll -def:tommath.def -out:tommath.lib
455+
;
456+
EXPORTS
457+
$files
458+
";
459+
return 0;
441460
}
442461

443462
sub die_usage {
@@ -446,7 +465,7 @@ sub die_usage {
446465
$0 -o OR $0 --check-comments
447466
$0 -m OR $0 --check-makefiles
448467
$0 -a OR $0 --check-all
449-
$0 -u OR $0 --update-makefiles
468+
$0 -u OR $0 --update-files
450469
MARKER
451470
}
452471

@@ -455,7 +474,7 @@ sub die_usage {
455474
"m|check-makefiles" => \my $check_makefiles,
456475
"d|check-doc" => \my $check_doc,
457476
"a|check-all" => \my $check_all,
458-
"u|update-makefiles" => \my $update_makefiles,
477+
"u|update-files" => \my $update_files,
459478
"h|help" => \my $help
460479
) or die_usage;
461480

@@ -464,9 +483,9 @@ sub die_usage {
464483
$failure ||= check_comments() if $check_all || $check_comments;
465484
$failure ||= check_doc() if $check_doc; # temporarily excluded from --check-all
466485
$failure ||= process_makefiles(0) if $check_all || $check_makefiles;
467-
$failure ||= process_makefiles(1) if $update_makefiles;
468-
$failure ||= update_dep() if $update_makefiles;
469-
$failure ||= generate_def() if $update_makefiles;
486+
$failure ||= process_makefiles(1) if $update_files;
487+
$failure ||= update_dep() if $update_files;
488+
$failure ||= generate_def() if $update_files;
470489

471490
die_usage unless defined $failure;
472491
exit $failure ? 1 : 0;

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ zipup: clean astyle new_file manual poster docs
149149
gpg -b -a ltm-$(VERSION).zip
150150

151151
new_file:
152-
perl helper.pl --update-makefiles
152+
perl helper.pl --update-files
153153

154154
perlcritic:
155155
perlcritic *.pl doc/*.pl

testme.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ if [[ "$CHECK_FORMAT" == "1" ]]
295295
then
296296
make astyle
297297
_check_git "make astyle"
298-
perl helper.pl --update-makefiles
299-
_check_git "helper.pl --update-makefiles"
298+
perl helper.pl --update-files
299+
_check_git "helper.pl --update-files"
300300
perl helper.pl --check-all
301301
_check_git "helper.pl --check-all"
302302
exit $?

tommath.def

100755100644
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ EXPORTS
2323
mp_copy
2424
mp_count_bits
2525
mp_decr
26+
mp_div
2627
mp_div_2
2728
mp_div_2d
2829
mp_div_3
29-
mp_div
3030
mp_div_d
3131
mp_dr_is_modulus
3232
mp_dr_reduce
@@ -63,25 +63,25 @@ EXPORTS
6363
mp_init_u32
6464
mp_init_u64
6565
mp_invmod
66+
mp_is_square
6667
mp_iseven
6768
mp_isodd
68-
mp_is_square
6969
mp_kronecker
7070
mp_lcm
7171
mp_lshd
72-
mp_mod_2d
7372
mp_mod
73+
mp_mod_2d
7474
mp_mod_d
7575
mp_montgomery_calc_normalization
7676
mp_montgomery_reduce
7777
mp_montgomery_setup
78+
mp_mul
7879
mp_mul_2
7980
mp_mul_2d
80-
mp_mul
8181
mp_mul_d
8282
mp_mulmod
83-
mp_neg
8483
mp_n_root
84+
mp_neg
8585
mp_or
8686
mp_prime_fermat
8787
mp_prime_frobenius_underwood
@@ -93,15 +93,14 @@ EXPORTS
9393
mp_prime_strong_lucas_selfridge
9494
mp_radix_size
9595
mp_rand
96-
mp_rand_digit
9796
mp_read_radix
9897
mp_read_signed_bin
9998
mp_read_unsigned_bin
99+
mp_reduce
100100
mp_reduce_2k
101101
mp_reduce_2k_l
102102
mp_reduce_2k_setup
103103
mp_reduce_2k_setup_l
104-
mp_reduce
105104
mp_reduce_is_2k
106105
mp_reduce_is_2k_l
107106
mp_reduce_setup
@@ -125,12 +124,12 @@ EXPORTS
125124
mp_sub
126125
mp_sub_d
127126
mp_submod
128-
mp_toradix
129-
mp_toradix_n
130127
mp_to_signed_bin
131128
mp_to_signed_bin_n
132129
mp_to_unsigned_bin
133130
mp_to_unsigned_bin_n
131+
mp_toradix
132+
mp_toradix_n
134133
mp_unsigned_bin_size
135134
mp_xor
136135
mp_zero

0 commit comments

Comments
 (0)