Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dynare
reporting
Commits
34bcbb7b
Commit
34bcbb7b
authored
Jul 07, 2014
by
Houtan Bastani
Browse files
reporting: rework option handling for compile.m
parent
b6b787f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
@report/compile.m
View file @
34bcbb7b
...
...
@@ -30,18 +30,29 @@ function o = compile(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
length
(
varargin
)
==
0
||
length
(
varargin
)
==
2
,
...
'@report.compile: calling form: compiler,
''
/path/to/compiler
''
.'
);
if
length
(
varargin
)
==
2
assert
(
ischar
(
varargin
{
1
})
&&
strcmp
(
lower
(
varargin
{
1
}),
'compiler'
),
...
'@report.compile:
''
compiler
''
is the only option.'
);
assert
(
ischar
(
varargin
{
2
}),
...
'@report.compile: the argument to
''
compiler
''
must be a char'
);
compiler
=
varargin
{
2
};
else
compiler
=
o
.
compiler
;
opts
.
compiler
=
o
.
compiler
;
if
nargin
>
1
if
round
((
nargin
-
1
)/
2
)
~=
(
nargin
-
1
)/
2
error
(
'@report.compile: options must be supplied in name/value pairs'
);
end
optNames
=
fieldnames
(
opts
);
% overwrite default values
for
pair
=
reshape
(
varargin
,
2
,
[])
ind
=
find
(
strcmpi
(
optNames
,
pair
{
1
}));
assert
(
isempty
(
ind
)
||
length
(
ind
)
==
1
);
if
~
isempty
(
ind
)
opts
.
(
optNames
{
ind
})
=
pair
{
2
};
else
error
(
'@report.compile: %s is not a recognized option.'
,
pair
{
1
});
end
end
end
assert
(
ischar
(
opts
.
compiler
),
'@report.compile: compiler file must be a string'
);
if
~
exist
(
o
.
fileName
,
'file'
)
o
.
write
();
end
...
...
@@ -53,26 +64,26 @@ if isoctave
else
echo
=
'-echo'
;
end
if
isempty
(
compiler
)
if
isempty
(
opts
.
compiler
)
if
strncmp
(
computer
,
'MACI'
,
4
)
||
~
isempty
(
regexpi
(
computer
,
'.*apple.*'
,
'once'
))
% Add most likely places for pdflatex to exist outside of default $PATH
[
status
,
compiler
]
=
...
[
status
,
opts
.
compiler
]
=
...
system
([
'PATH=$PATH:/usr/texbin:/usr/local/bin:/usr/local/sbin;'
...
'which pdflatex'
],
echo
);
elseif
strcmp
(
computer
,
'PCWIN'
)
||
strcmp
(
computer
,
'PCWIN64'
)
[
status
,
compiler
]
=
system
(
'findtexmf --file-type=exe pdflatex'
,
echo
);
[
status
,
opts
.
compiler
]
=
system
(
'findtexmf --file-type=exe pdflatex'
,
echo
);
middle
=
' '
;
compiler
=
[
'"'
strtrim
(
compiler
)
'"'
];
opts
.
compiler
=
[
'"'
strtrim
(
opts
.
compiler
)
'"'
];
else
% gnu/linux
[
status
,
compiler
]
=
system
(
'which pdflatex'
,
echo
);
[
status
,
opts
.
compiler
]
=
system
(
'which pdflatex'
,
echo
);
end
assert
(
status
==
0
,
...
'@report.compile: Could not find a tex compiler on your system'
);
compiler
=
strtrim
(
compiler
);
o
.
compiler
=
compiler
;
opts
.
compiler
=
strtrim
(
opts
.
compiler
);
o
.
compiler
=
opts
.
compiler
;
end
status
=
system
([
compiler
' '
options
middle
o
.
fileName
],
echo
);
status
=
system
([
opts
.
compiler
' '
options
middle
o
.
fileName
],
echo
);
[
junk
,
rfn
,
junk
]
=
fileparts
(
o
.
fileName
);
if
status
~=
0
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment