geninfo searches .da instead of .gcda - command

When I try to execute the following lcov command through Plink (I give Plink a text file as an argument containing the following command)
lcov --capture --directory . --output-file coverage.info
it results with
GNU gcov version 1.5 Capturing coverage data from .
Scanning . for .da files ... gcov [-b] [-v] [-n] [-l] [-f] [-o OBJDIR] file geninfo: Use of uninitialized value in pattern match
(m//) at /home/myUser/lcov/lcov/usr/bin/geninfo line 1874. gcov [-b]
[-v] [-n] [-l] [-f] [-o OBJDIR] file geninfo: Use of uninitialized
value in pattern match (m//) at /home/myUser/lcov/lcov/usr/bin/geninfo
line 3622. geninfo: Use of uninitialized value in pattern match (m//)
at /home/myUser/lcov/lcov/usr/bin/geninfo line 3622.
geninfo: ERROR: no .da files found in .!
It seems that the geninfo expects for .da files instead of .gcda files.
when I execute the same command without Plink (in the same CWD), the lcov runs fine and generates a valid .info file. It also runs fine when I execute it manually thorugh PuTTY.
what might be the reason for this?

The problem was more general. Plink uses different environment variables. The solution was to set manually the correct environment variables. In my case I run perl script so I added in the head of the file:
use Env;
$ENV{PATH} = "correct PATH variable";
a missing environment variable caused the code to get wrong gcov version and therefore .da files were serached instead of .gcda files that belong to newer lcov versions

Upgrading lcov version to latest solved the issue. Older version of lcov searches .da instead of .gcda. Updating to latest version 1.13 solves the issue

Related

Avoid executing custom commands in cmake when unnecessary

I have this custom build which invokes matlab to compile a .slx file into a .dll file.
function(BUILD_SIMULINK model)
set(EXECUTE_COMMAND matlab -r "rtwbuild( ${model} )" )
add_custom_target(
${model} ALL
COMMAND ${EXECUTE_COMMAND}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${model}.slx
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${model}.dll
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Building: ${model}"
)
endfunction(BUILD_SIMULINK)
However my problem is that whenever I use cmake --build ., this command will always be executed.
How can I prevent this command from executing when the DEPENDS hasn't changed and the OUTPUT exists? What I'm looking for is similar to how cmake avoids re-compiling c/cpp files when the source hasn't changed and the appropriate object file exists.
See add_custom_target() command documentation:
The target has no output file and is always considered out of date even if the commands try to create a file with the name of the target. Use the add_custom_command() command to generate a file with dependencies.
There is not OUTPUT keyword. I think its only accepted because CMake sees OUTPUT as a dependency. Actually I get an CMake warning when I run your code:
...
This project specifies custom command DEPENDS on files in the build tree
that are not specified as the OUTPUT or BYPRODUCTS of any
add_custom_command or add_custom_target:
test_model.dll
You need to use add_custom_command():
cmake_minimum_required(VERSION 2.6)
project(TestCustomTargetWithDependency NONE)
function(BUILD_SIMULINK model)
#set(EXECUTE_COMMAND matlab -r "rtwbuild( ${model} )" )
set(EXECUTE_COMMAND "${CMAKE_COMMAND}" -E touch "${model}.dll")
add_custom_command(
OUTPUT "${model}.dll"
COMMAND ${EXECUTE_COMMAND}
DEPENDS "${model}.slx"
COMMENT "Building: ${model}"
)
add_custom_target(
${model} ALL
DEPENDS "${model}.dll"
)
endfunction(BUILD_SIMULINK)
file(WRITE "test_model.slx" "")
BUILD_SIMULINK(test_model)
𝓝𝓸𝓽𝓮: Sources/Dependencies default is CMAKE_CURRENT_SOURCE_DIR and outputs default is CMAKE_CURRENT_BINARY_DIR. No need to explicitly prefix those.

Getting error while running perl module from command line

I have a customized perl module(Modulehere) that take xls sheet and parsing it.
I tried to run that from commandline itself like:
perl -I /home/suser/modules -e "use Modulehere;Modulehere::load_it('/tmp/test.xls')"
But it gives the error like:
Can't open perl script "–e": No such file or directory
Please help!
It works on my machines (OS X and Linux) but looking at the documentation (man perlrun)
-Idirectory
Directories specified by -I are prepended to the search path for modules (#INC).
There is no space between -I and the directory. Maybe your Perl version is being to strict and considering everything after the space as a script file.

Encrypt a PDF file in the command line using pdftk command

i am tiring to perform PDF file encryption using pdftk and installed the dependency modules of PDF::Tk [Perl integration for the pdf toolkit (pdftk)] , but getting error as mentioned below. Can any one please help me in resolving the below issue.
Source code: test.pl
use PDF::Tk;
system(pdftk input.pdf output outPDF.pdf owner_pw foopass) or die "Error!!!!!!!!!!\n";
output:
Can't locate object method "pdftk" via package "input" (perhaps you forgot to load "input"?) at test.pl line 2.
use PDF::Tk module functions instead the system. PDF::Tk is a wrapper over the pdftk utility, so using system is the topic it avoids:
use PDF::Tk;
my $doc=PDF::Tk->new();
$doc->call_pdftk('input.pdf', 'outPDF.pdf', 'owner_pw', 'foopass');
Note: The PDF::Tk constructor could be used to set the pdftk binary. It defaults value is "/usr/bin/pdftk"
my $doc=PDF::Tk->new({pdftk=>'/other/path/to/bin/pdftk'});

How do we replace PATH in all the files with an env variable

I have around 230 files which are *.pl , *.txt and some are *.conf files which has a default path set to the current environment say /home/AD/USR/perl/5.8.0/bin/perl. I need to replace "/home/AD/USR" with an environment variable ${USR_PATH}. The files I want to modify are in subdirectories. Which means my script should find e.g find .|xargs grep -l "/home/AD/USR" all the files and then replace the string.
OLD: /home/AD/USR/perl/5.8.0/bin/perl
New : ${USR_PATH}/perl/5.8.0/bin/perl
Can some one give me a clue how do I do that?
Shell : /bin/bash
Env : Linux x86_64
If you replace part of a string with ${USR_PATH} you will refer to the perl variable $USR_PATH, not the environment variable, which is in perl referred to as $ENV{USR_PATH}.
perl -pi.bak -we 's#/home/AD/USR(?=/perl/5.8.0/bin/perl)#\$ENV{USR_PATH}#g'
*.pl *.txt *.conf
Using the lookahead will save you the trouble of replacing the rest of the path afterwards.
I assume you want to replace it with the literal value. If you want to replace it with the actual value in the environment variable, just remove the backslash in front of $ENV.
While using an environment variable seems handy and all, it will reduce your scripts portability. Why not use a configuration file? If you had done that from the start, you wouldn't be having this trouble. Search CPAN for a nice module.
perl -i -pe 's|/home/AD/USR/perl/5.8.0/bin/perl|\${USR_PATH}/perl/5.8.0/bin/perl|' <your files>

How to find a workaround for latexdiff /latexdiff-vc on Windows on filenames containing spaces

I'm running latexdiff v 0.25 and when I attempt latexdiff-vc --svn -r "myFile with spaces.tex" I get the following command line output:
Working on myFile with spaces.tex svn: 'myFile' is not under version
control Running latexdiff 2 and only 2 non-option arguments required.
Write latexdiff -h to get help Something went wrong in latexdiff.
Deleting myFile with spaces.tex and abort
I'm assuming it's a bug where the right filename isn't passed correctly to svn. The command runs fine on names w/o spaces.
Does anyone know a workaround?
Assuming you are doing this manually, you may be able to use the 8.3 file name that you can get on the command line using dir /x.