Skip to content

Commit 5f7a8be

Browse files
committed
standardize around pathname_kpsewhich; setup appveyor flags
1 parent b38102f commit 5f7a8be

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ install:
1616
- cmd: refreshenv
1717
# autoinstall latex packages (0=no, 1=autoinstall, 2=ask)
1818
# this adds this to the registry!
19-
- if "%setup%"=="miktex" initexmf --set-config-value "[MPM]AutoInstall=1"
19+
- if "%setup%"=="miktex" initexmf --admin --enable-installer --verbose --set-config-value "[MPM]AutoInstall=1"
2020
- cmd: refreshenv
2121
- if not exist "C:\strawberry" choco install strawberryperl -y
2222
- set PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%

Makefile.PL

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ use FindBin;
2828

2929
our $OLD_LIBXML = grep { /OLD_LIBXML/ } @ARGV;
3030
our $NOMKTEXLSR = grep { /NOMKTEXLSR/ } @ARGV;
31-
our $TEXMF;
31+
our $KPSE_TOOLCHAIN = "";
32+
our ($KPSEV, $TEXMF);
3233
my ($texmfspec) = grep { /^TEXMF/ } @ARGV;
3334
if ($texmfspec && $texmfspec =~ /^TEXMF\s*=(.*)$/) {
3435
$TEXMF = $1;
@@ -120,6 +121,7 @@ sub record_revision {
120121
## $$MORE_MACROS{REVISION} = '$(shell svnversion $(REVISION_BASE))';
121122
## This command is appropriate for git (I think)
122123
if ((-d '.git') && (system("git --version") == 0)) { # If a git checkout & can run git?
124+
print STDERR "\n"; # space out messages
123125
$$MORE_MACROS{REVISION} = '$(shell git log --max-count=1 --abbrev-commit --pretty="%h")'; }
124126
# Extract the previously recorded revision from the revision file (awkward)
125127
$$MORE_MACROS{OLD_REVISION}
@@ -151,7 +153,7 @@ RecordRevision
151153
#======================================================================
152154
# We'll compile the RecDescent grammar during make; don't need to install grammar.
153155
sub compile_MathGrammar {
154-
push(@EXCLUSIONS, 'blib/lib/LaTeXML/MathGrammar');
156+
push(@EXCLUSIONS, 'README.pod', 'blib/lib/LaTeXML/MathGrammar');
155157
$MORE_MAKERULES .= <<'MakeGrammar';
156158
157159
# Precompile the (Recursive Descent) MathGrammar
@@ -199,8 +201,10 @@ MakeGrammar
199201
# embedded spaces.
200202
sub install_TeXStyles {
201203
if (!$TEXMF) {
202-
if (system("kpsewhich --expand-var='\$TEXMFLOCAL'") == 0) { # can run kpsewhich?
203-
$TEXMF = `kpsewhich --expand-var='\$TEXMFLOCAL'`;
204+
if ($ENV{"APPVEYOR"}) { # assume miktex admin on windows CI
205+
$KPSE_TOOLCHAIN = "--miktex-admin"; }
206+
if (system("kpsewhich --version $KPSE_TOOLCHAIN") == 0) { # can run kpsewhich?
207+
$TEXMF = `kpsewhich --expand-var='\$TEXMFLOCAL' $KPSE_TOOLCHAIN`;
204208
# Strip the quotes (they appear in windows, when spaces in pathnames(?))
205209
# These quotes inhibit pasting pathnames togheter,
206210
# but we DO need to wrap quotes around all completed paths!!

lib/LaTeXML/Package.pm

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ sub ComposeURL {
543543
#======================================================================
544544

545545
my $parameter_options = { # [CONSTANT]
546-
nargs => 1, reversion => 1, optional => 1, novalue => 1,
546+
nargs => 1, reversion => 1, optional => 1, novalue => 1,
547547
beforeDigest => 1, afterDigest => 1,
548548
semiverbatim => 1, undigested => 1 };
549549

@@ -1589,7 +1589,7 @@ sub DefEnvironmentI {
15891589
afterConstruct => flatten($options{afterConstruct}, sub { $STATE->popFrame; }),
15901590
nargs => $options{nargs},
15911591
captureBody => 1,
1592-
properties => $options{properties} || {},
1592+
properties => $options{properties} || {},
15931593
(defined $options{reversion} ? (reversion => $options{reversion}) : ()),
15941594
(defined $sizer ? (sizer => $sizer) : ()),
15951595
), $options{scope});
@@ -1653,7 +1653,7 @@ sub DefEnvironmentI {
16531653

16541654
# Specify the properties of a Node tag.
16551655
my $tag_options = { # [CONSTANT]
1656-
autoOpen => 1, autoClose => 1, afterOpen => 1, afterClose => 1,
1656+
autoOpen => 1, autoClose => 1, afterOpen => 1, afterClose => 1,
16571657
'afterOpen:early' => 1, 'afterClose:early' => 1,
16581658
'afterOpen:late' => 1, 'afterClose:late' => 1 };
16591659
my $tag_prepend_options = { # [CONSTANT]
@@ -1716,8 +1716,8 @@ sub RegisterDocumentNamespace {
17161716
# should we assume a raw type can be processed if being read from within a raw type????
17171717
# yeah, that sounds about right...
17181718
my %definition_name = ( # [CONSTANT]
1719-
sty => 'package', cls => 'class', clo => 'class options',
1720-
'cnf' => 'configuration', 'cfg' => 'configuration',
1719+
sty => 'package', cls => 'class', clo => 'class options',
1720+
'cnf' => 'configuration', 'cfg' => 'configuration',
17211721
'ldf' => 'language definitions', 'def' => 'definitions', 'dfu' => 'definitions');
17221722

17231723
sub pathname_is_raw {
@@ -1787,7 +1787,6 @@ sub FindFile_aux {
17871787
# The main point, though, is to we make only ONE (more) call.
17881788
return if grep { pathname_is_nasty($_) } @$paths; # SECURITY! No nasty paths in cmdline
17891789
# Do we need to sanitize these environment variables?
1790-
my $kpsewhich = which($ENV{LATEXML_KPSEWHICH} || 'kpsewhich');
17911790
local $ENV{TEXINPUTS} = join($Config::Config{'path_sep'},
17921791
@$paths, $ENV{TEXINPUTS} || $Config::Config{'path_sep'});
17931792
my @candidates = (((!$options{noltxml} && !$nopaths) ? ("$file.ltxml") : ()),

lib/LaTeXML/Util/Pathname.pm

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,9 @@ sub candidate_pathnames {
351351
return @paths; }
352352

353353
#======================================================================
354-
our $kpsewhich = which($ENV{LATEXML_KPSEWHICH} || 'kpsewhich');
355-
our $kpse_cache = undef;
354+
our $kpsewhich = which($ENV{LATEXML_KPSEWHICH} || 'kpsewhich');
355+
our $kpse_cache = undef;
356+
our $kpse_toolchain = "";
356357

357358
sub pathname_kpsewhich {
358359
my (@candidates) = @_;
@@ -364,7 +365,7 @@ sub pathname_kpsewhich {
364365
# If we've failed to read the cache, try directly calling kpsewhich
365366
# For multiple calls, this is slower in general. But MiKTeX, eg., doesn't use texmf ls-R files!
366367
my $files = join(' ', @candidates);
367-
if ($kpsewhich && (my $result = `"$kpsewhich" $files`)) {
368+
if ($kpsewhich && (my $result = `"$kpsewhich" $files $kpse_toolchain`)) {
368369
if ($result =~ /^\s*(.+?)\s*\n/s) {
369370
return $1; } }
370371
return; }
@@ -373,10 +374,13 @@ sub build_kpse_cache {
373374
$kpse_cache = {}; # At least we've tried.
374375
return unless $kpsewhich;
375376
# This finds ALL the directories looked for for any purposes, including docs, fonts, etc
376-
my $texmf = `"$kpsewhich" --expand-var \'\\\$TEXMF\'`; chomp($texmf);
377+
if ($ENV{"APPVEYOR"}) {
378+
$kpse_toolchain = "--miktex-admin";
379+
}
380+
my $texmf = `"$kpsewhich" --expand-var \'\\\$TEXMF\' $kpse_toolchain`; chomp($texmf);
377381
# These are directories which contain the tex related files we're interested in.
378382
# (but they're typically below where the ls-R indexes are!)
379-
my $texpaths = `"$kpsewhich" --show-path tex`; chomp($texpaths);
383+
my $texpaths = `"$kpsewhich" --show-path tex $kpse_toolchain`; chomp($texpaths);
380384
my @filters = ();
381385
foreach my $path (split(/$KPATHSEP/, $texpaths)) {
382386
$path =~ s/^!!//; $path =~ s|//+$|/|;

lib/LaTeXML/Util/Test.pm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use base qw(Exporter);
1919
our @EXPORT = (qw(&latexml_ok &latexml_tests),
2020
qw(&process_domstring &process_xmlfile &is_strings),
2121
@Test::More::EXPORT);
22-
my $kpsewhich = which($ENV{LATEXML_KPSEWHICH} || 'kpsewhich'); # [CONFIGURATION]
2322
# Note that this is a singlet; the same Builder is shared.
2423

2524
# Test the conversion of all *.tex files in the given directory (typically t/something)
@@ -81,7 +80,7 @@ sub check_requirements {
8180
foreach my $reqmts (@reqmts) {
8281
next unless defined $reqmts;
8382
foreach my $reqmt (!$reqmts ? () : (ref $reqmts ? @$reqmts : $reqmts)) {
84-
if (($kpsewhich && (`"$kpsewhich" $reqmt`)) || (pathname_find($reqmt))) { }
83+
if (pathname_kpsewhich($reqmt) || pathname_find($reqmt)) { }
8584
else {
8685
my $message = "Missing requirement $reqmt for $test";
8786
diag("Skip: $message");

0 commit comments

Comments
 (0)