How to run Doxygen Makefile? - c#

I have created a .NET C# project that I have commented using blocks similar to ///<summary>A summary...</summary> that I would like to document using Doxygen. I have set up Doxygen and it runs generating a some 100 .tex-files and a Makefile.
As I have understood, the Makefile is the key to generating the documentation as a PDF, however I do not get it to work.
I'm using a Mac to do the LaTeX and Doxygen bit by writing make -f Makefile in the Terminal when I am in the Doxygen LaTeX output directory.
all: refman.pdf
pdf: refman.pdf
refman.pdf: clean refman.tex
pdflatex refman
makeindex refman.idx
pdflatex refman
latex_count=5 ; \
while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\
do \
echo "Rerunning latex...." ;\
pdflatex refman ;\
latex_count=`expr $$latex_count - 1` ;\
done
clean:
rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf
When running, i get the following message:
MacBook-Pro-13:latex sehlstrom$ make
rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf
make: *** No rule to make target `refman.tex', needed by `refman.pdf'. Stop.
How can I get the Makefil thing work?

refman.tex is supposed to be created by Doxygen. I just tested with my installed version, doxygen 1.7.2, and it created a refman.tex.
Make sure you aren't setting any option that says this is a component of a larger project that shouldn't have its own index.

Related

Retrieving shell script exit code (return value)

Trying to validate a Logstash config file. When running the following line from a Windows command line:
C:> C:\Logstash\bin\logstash -t -f C:\Logstash\config\my.config
I can then check the result using
echo %errorlevel%
which returns 1 in case of a syntax error. Now I want to do this programatically in C#, so:
using System.Diagnostics;
var logstashProcess = Process.Start(#"C:\Logstash\bin\logstash", #"-t -f C:\Logstash\config\my.config");
logstashProcess.WaitForExit();
return logstashProcess.ExitCode == 0;
The problem is that it always returns true (exit code is zero) - even when the config file is totally messed up.
My guess: since C:\Logstash\bin\logstash is a shell script, the zero I get is the shell itself running successfully - not the Logstash process (which is executed from within that script using jruby). Any idea on how to get the real return value? Will a batch file work? (I prefer not to add an extra script to the party at this point)

Extracting directory / file names in a Makefile

Could someone help me understand the behaviour of the makefile, below? To give some context, I am trying to generated a series of c# classes from a set of .proto files. The proto files are contained within a directory structure which i want to mirror in the output. So, assuming my source files are in a folder called 'Source' and I am outputting into a folder called 'Generated', if a file resides in:
'Source/Foo/Bar/myfile.protoc'
then output should be:
'Generated/Foo/Bar/MyFile.cs'.
This seems simple enough however I am seeing some strange behaviour when using dir/notdir in the make file. here is an example:
# Makefile to build message definitions within this repo
PROTOS:= SourceFiles/Module_1/BasicMessage.proto SourceFiles/Module_2/BasicMessage.proto
withVariables:
for proto in $(PROTOS) ; do \
echo $(dir $$proto) ; \
echo $(notdir $$proto) ; \
done;
hardCoded:
echo $(dir ./SourceFiles/Module_1/BasicMessage.proto)
echo $(notdir ./SourceFiles/Module_1/BasicMessage.proto)
echo $(dir ./SourceFiles/Module_2/BasicMessage.proto)
echo $(notdir ./SourceFiles/Module_2/BasicMessage.proto)
Essentially, when I have the collection of file names in a variable and try to iterate them, dir/notdir does not seem to recognised the separators in the path. Running Make hardCoded here gives:
./SourceFiles/Module_1/
BasicMessage.proto
./SourceFiles/Module_2/
BasicMessage.proto
which is what i would expect. However, running withVariables gives:
./
SourceFiles/Module_1/BasicMessage.proto
./
SourceFiles/Module_2/BasicMessage.proto
I am still pretty new to make files, so I am probably missing something simple, but if anyone can explain why these two examples behave differently, it would be greatly appreciated.
The recipes are expanded by make before being passed to the shell. So, in the recipe of withVariables, the $(dir $$proto) and $(notdir $$proto) are expanded to ./ and $proto, respectively. The recipe becomes:
for proto in SourceFiles/Module_1/BasicMessage.proto SourceFiles/Module_2/BasicMessage.proto; do \
echo ./ ; \
echo $proto ; \
done;
which logically produces the output you see. You cannot use make functions in your recipes and expect them to be executed by the shell. Instead you can invoke the standard dirname and basename external programs from your recipe:
withVariables:
for proto in $(PROTOS); do \
echo $$(dirname $$proto); \
echo $$(basename $$proto); \
done
The recipe is expanded by make as:
for proto in SourceFiles/Module_1/BasicMessage.proto SourceFiles/Module_2/BasicMessage.proto; do \
echo $(dirname $proto); \
echo $(basename $proto); \
done
which, when executed by the shell, outputs:
host> make withVariables
SourceFiles/Module_1
BasicMessage.proto
SourceFiles/Module_2
BasicMessage.proto

Xmlstarlet ed encoding and powershell inside Process C#

I want to use xmlstarlet from the powershell started with Process in a C# application.
My main problem is that when I use this code:
./xml.exe ed -N ns=http://www.w3.org/2006/04/ttaf1 -d '//ns:div[not(contains(#xml:lang,''Italian''))]' "C:\Users\1H144708H\Downloads\a.mul.ttml" > "C:\Users\1H144708H\Downloads\a.mul.ttml.conv"
on powershell I get a file with the wrong encoding (I need UTF-8).
On Bash I used to just
export LANG=it_IT.UTF-8 &&
before xmlstarlet but on powershell I really don't know how to do it.
Maybe there is an alternative, I saw that xmlstarlet is able to use sel --encoding utf-8 but I don't know how to use it in ed mode (I tried to use it after xml.exe after ed etc... but it always fail).
What is the alternative to export LANG=it_IT.UTF-8 or how to use --encoding utf-8?
PS. I tried many and many things like:
$MyFile = Get-Content "C:\Users\1H144708H\Downloads\a.mul.ttml"; $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False; [System.IO.File]::WriteAllLines("C:\Users\1H144708H\Downloads\a.mul.ttml.conv", $MyFile, $Utf8NoBomEncoding)
And:
./xml.exe ed -N ns=http://www.w3.org/2006/04/ttaf1 -d '//ns:div[not(contains(#xml:lang,''Italian''))]' "C:\Users\1H144708H\Downloads\a.mul.ttml" | Out-File "C:\Users\1H144708H\Downloads\a.mul.ttml.conv" -Encoding utf8
But characters like è à ì ù are still wrong. If I try to save the original file with Notepad before the conversion it works (only if I don't use xmlstarlet)... but I need to do the same thing in powershell and I don't know how.
EDIT.
I was able to print my utf8 on powershell:
Get-Content -Path "C:\Users\1H144708H\Downloads\a.mul.ttml" -Encoding UTF8
But I'm still not able to do the same thing with xmlstarlet.
In the end I decided to create a native C# method and I just used a StreamReader to ReadLine by line the file. With a simple Contains I decide where is the xml:lang="Language" and I then start to add every line to a string. Of course I added the head and the end of my file before the while loop and I stop to add every line when I read a line that Contains . I know that this is not the best way to do things, but it works for my case.

Compiling C# Code with Coderunner — No Warnings Allowed

I would love to have a little problem solved. I know that it's not the best way to debug a piece of code with possible warnings, but I love to debug all the time when I have a little break between to ideas. I just found out about mono and the possibility to compile C# code running on Mac OS X Mountain Lion. I integrated it in the CodeRunner app, and it works without any problems. However, if there appears a warning in the code, it does not work.
For example, I tried to compile a code that creates one integer (nothing more than that) and it was not debugging because of that warning. I'm getting this error message:
Untitled.cs(9,29): warning CS0219: The variable `test' is assigned but its value is never used
Cannot open assembly 'Compilation succeeded - 1 warning(s)
Untitled.exe': No such file or directory.
Someone may know how to deal with that. I know it's not an essential feature, but I would love to debug the code even with some unused variables.
The content of the compilation script file:
#!/bin/bash
enc[4]="UTF8" # UTF-8
enc[10]="UTF16" # UTF-16
enc[5]="ISO8859-1" # ISO Latin 1
enc[9]="ISO8859-2" # ISO Latin 2
enc[30]="MacRoman" # Mac OS Roman
enc[12]="CP1252" # Windows Latin 1
enc[3]="EUCJIS" # Japanese (EUC)
enc[8]="SJIS" # Japanese (Shift JIS)
enc[1]="ASCII" # ASCII
rm -rf "$4"/csharp-compiled
mkdir "$4"/csharp-compiled
#mcs is the Mono CSharp Compiler
file="$1"
length=${#file}
first=`expr $length - 3`
classname=`echo "$file" | cut -c 1-"$first"`
#echo -out:"$4"/csharp-compiled/"$classname".exe "$1"
dmcs -out:"$4"/csharp-compiled/"$classname".exe "$1"
status=$?
if [ $status -ne 0 ]
then
exit $status
fi
#echo "$4"/csharp-compiled/
currentDir="$PWD"
cd "$4"/csharp-compiled/
files=`ls -1 *.exe`
status=$?
if [ $status -ne 0 ]
then
exit 1
fi
cd "$currentDir"
for file in $files
do
mv -f "$4"/csharp-compiled/$file "$file"
done
# Otherwise output the name of the input file without extension (this should be the same as the class name)
file="$1"
length=${#file}
first=`expr $length - 3`
classname=`echo "$file" | cut -c 1-"$first"`
echo $classname".exe"
exit 0
dmcs -out:"$4"/csharp-compiled/"$classname".exe "$1"
dmcs puts some messages on stdout, and some on stderr. CodeRunner expects stdout to only contain the output file name, nothing else, so to make that happen, >&2 can be used to redirect everything else to stderr.
dmcs -out:"$4"/csharp-compiled/"$classname".exe "$1" >&2
This worked for me on Sierra with current Mono and CodeRunner versions:
Language compile script:
file=$CR_FILENAME
/Library/Frameworks/Mono.framework/Versions/Current/bin/mcs "$CR_FILENAME" >&2
status=$?
if [ $status -ne 0 ]
then
exit $status
fi
echo $file | sed -e "s/\.cs/.exe/"
exit 0
Run command:
PATH="/Library/Frameworks/Mono.framework/Versions/Current/bin:$PATH"; mono $compiler
In MS compiler thre is a way to hide warnings
Pragma Warning Preprocessor Directive
#pragma warning disable 219
var test = "";
#pragma warning restore 219
It might help you.

Gems with .NET Applications - How do I set up the Executables so they run without error?

I have a gem, roundhouse, which is an application compiled with .NET (C#). Runs on Windows and it should run in a 32 bit process.
To set up my gemspec, I set:
Gem::Specification.new do |s|
s.platform = 'mswin32'
s.name = 'roundhouse'
s.version = version
s.files = Dir['lib/**/*'] + Dir['bin/**/*']
s.bindir = 'bin'
s.executables << 'rh.exe'
When I install the gem, I should be able to type rh.exe from the command line at any path and it should run correctly.
In practice, I'm not seeing this work correctly. This is what I'm getting back:
Window has this for the header: 16 bit MS-DOS Subsystem
C:\WINDOWS\system32\cmd.exe - rh.exe
The NTVDM CPU has encountered an illegal instruction.
CS:xxxx IP:xxxx OP:xx xx xx xx xx Choose 'Close' to terminate the application.
Here is a picture of the issue (link to TwitPic): Error
If I go to the directory where the item was installed, I can run it and it works great. It's just something in the registration of the command to run from anywhere.
I did quite a bit of searching before asking and came up with nothing. It could be that I don't know what I should be searching for. So let me ask the question, is there a way to register an executable with gems for windows executable applications (built with .NET) and have them register properly with the command line? If so, how is that done?
UPDATE:
I found that gems creates a shim in the C:\Ruby\bin directory that points back to the other file. So there is a rh.exe file that is really just a text file. This is its contents:
#!C:/Ruby/bin/ruby.exe
#
# This file was generated by RubyGems.
#
# The application 'roundhouse' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
gem 'roundhouse', version
load Gem.bin_path('roundhouse', 'rh.exe', version)
if you're distributing it with the file "rh.exe"
then you'll want to create a file
bin/rh
s.executables << 'bin/rh'
then when it's installed gems will create an "rh.bat" file which runs ruby "bin/rh" essentially (as you've seen).
So within bin/rh put something like
result = system(File.dirname(__FILE__) + "/rh.exe" ARGV.join(' '))
exit 1 unless result
result = system(File.dirname(__FILE__) + "/rh.exe " + ARGV.join(' '))
exit 1 unless result
So the endresult should maybe look like? note the space after 'rh.exe'

Categories