Swig output line endings - swig

I'm running swig using cmake to interface some c++ libraries with java. Was wondering if there was an option to specify the line endings of the java output files generated by swig?
set(swig_interface "swig/my_swig.i")
set_source_files_properties("${swig_interface}" PROPERTIES CPLUSPLUS ON)
set(jni_output "${SWIG_WRAPPER_OUTPUT}/com/domain/group")
# Hoping theres a flag I can add here which will set the line endings
set(CMAKE_SWIG_FLAGS "-package" "com.domain.group"
"-I${CMAKE_CURRENT_SOURCE_DIR}/include")
set(CMAKE_SWIG_OUTDIR "${jni_output}")
swig_add_module(jni_wrapper java "${swig_interface}" ${lib_src_files})
swig_link_libraries(jni_wrapper other_lib)

Related

Inject a preprocessor definition into the Eclipse parser for a certain file type?

I'm using Eclipse CDT (actually, nVIDIA's nSight, but the same goes for both) to edit some source files. Now, some of these are meant for use both with nvcc and with regular host-side compilers, and have some instances of:
#ifdef __CUDACC__
something
#else
some other thing
#endif
I want to get the __CUDACC__ part when the preprocessor is reaching a file while parsing a .cuh or .cu, but not when reaching it while parsing a .h or .cpp (or .c). Now, I know I can inject a preprocessor define through the project settings (using the "built-in compiler" command line), but I was wondering whether it's possible to make that conditional on the extension of the file being parsed originally (i.e. the file being edited in the IDE).
How are you configuring the project's include paths and defined macros?
If you use the Build Output Parser, can you arrange for the build system to include -D __CUDACC__ in the compiler commands for .cu files, but not for the compiler commands for .cpp files?
CDT allows for each file in the project to have its own settings, and the Build Output Parser will assign each file that has a compilation command in the build output its own settings based on the flags that appear in the command, so things should just work.

EvoSuit generate test for specific class with maven

Is it possible to configure in maven plugin,for which classes (like include/exclude by name pattern) JUNIT tests should be generated?
As i don't need tests for every class.
I managed to do it with command line but I need to do it in maven.
It isn't possible to do that, but you can use the -Dcuts and -DcutsFile command line arguments to generate test classes for 1..N classes.
Writing a small class that generates the class names for a given package structure is pretty trivial. You can then use the results to create a comma-delimited string that can be pasted into the file you associate with the -DcutsFile argument, e.g.:
mvn evosuite:generate evosuite:export -DcutsFile=c:\temp\cutsFile.txt
Where the contents of cutsFile.txt are:
com.foo.A, com.foo.B
Another way to generate the list of testable classes is to run the EvoSuite jar from the command line with the -listClasses and -target parameters and pipe the output to a file (Windows example below):
java -jar c:\evosuite\evosuite-master-1.0.5.jar -listClasses -target target/classes > c:temp\testableClasses.txt
From there you can just pick and choose the classes you'd want to add to the CUTs file or add them to the command line using the -Dcuts command line argument.

trasform csv to xml file genertaion using xslt programing

I would like to generate xml file from an extisng csv file using xslt.
Can anybody tell me command to use.
I don't knwo the command to convert the file.
Suppose my csv file named :- source.csv
ouput template :- temp.xsl
command:-
msxsl source.csv temp.xsl -o result.xml
Is this the right command or not?
Here is a XSL file to convert CSV to XML: http://andrewjwelch.com/code/xslt/csv/csv-to-xml_v2.html
To run it from the command line, the instructions say to download Saxon and use:
java -cp saxon.jar net.sf.saxon.Transform -o output.xml -it main csv-to-xml.xslt pathToCSV=file:/C:/dev/test.csv
Here are the parts of that command line explained:
java The java executable (programming language in which Saxon is written
-cp saxon.jar saxon.jar contains the XSLT code, -cp stands for "classpath" and tells java how to find it
-o output.xml Where the output should go. That is result.xml in your example.
-it main csv-to-xml.xslt specify the xslt file (csv-to-xml.xslt) and the entry point within it (main)
pathToCSV=file:/C:/dev/test.csv your input csv file (source.csv in your example, but formatted as a url)
I do not have sufficient reputation to comment on Stephen's answer.
the transform as described is highly dependent on the XSL stylesheet which defines a parameter pathToCSV and a template with the identifier of "main"
the command will not work as Stephen has written it for version 9 of the Home Edition; when I attempt to run the command as written I get a response of "Command line option -o requires a value". However, this format of the command works as of the day of this posting:
java -cp saxon9he.jar net.sf.saxon.Transform -o:csvfile.xml -it:main "csv2xml.xsl" pathToCSV="csvfile.csv"
the linked xsl appears to be buggy (probably hasn't been maintained) and will not correctly transform all csv files (e.g. the csv example from Michael Kay's book). However, it is a good example from which to learn.

Cython -a flag (to generate yellow-shaded HTML) without command line

When you run from the command line
$ cython -a mycode.pyx
you get a really nice HTML "annotation" file with yellow shading to indicate slow python operations vs fast C operations. You also get this same HTML file as a link every time you compile Cython code in Sage. My questions are: (1) Can I get this HTML file if I'm compiling using distutils? (2) Can I get this HTML file if I'm compiling using pyximport? Thanks!!
Thanks to larsmans's comment and the Cython email list, I now have many satisfying options to generate the "annotate" HTML file without leaving IPython:
(1) Use subprocess...
import subprocess
subprocess.call(["cython","-a","myfilename.pyx"])
(2) Turn on the global annotate flag in Cython myself, before compiling:
import Cython.Compiler.Options
Cython.Compiler.Options.annotate = True
(3) Pass annotate=True into cythonize() [when using the distutils compilation method].
It seems that pyximport does not have its own direct option for turning on annotation.

tcl - how to find the path of package loaded?

In tcl how does one find out the path of the package loaded?
% tclsh
% package require csv
I want to find out the path from which csv was loaded.
In python, one can find the path of a module using
>>> import os
>>> print os.__file__
'/a/b/python2.2.1/linux26_x86_64/lib/python2.2/os.pyc'
I am looking for a similar command in tcl
It's not that simple: a package in Tcl appears to be a more abstract thing than that in Python.
First, there are two kinds of packages: "classic" and "modules" which have different underlying mechanisms for finding what to load in response to the package require ... command.
Next, both kinds of packages are able to do whatever they wish to provide their functionality. It means they can be (but not limited to):
Pure Tcl packages, source'ing just one Tcl file or any number of files.
Packages implemented in C or another compiled language, which are in the form of dynamic library which gets loaded when the package is required.
A combination of the above, when there's a C library and a layer of Tcl code around it (usually providing helper/convenience commands).
Hence the question per se has little sense as only modules are represented by exactly one self-contained file but "classic" packages are free to implement themselves as they see fit.
On the other hand, each package normally provides (using one way or another) certain information to the package subsystem which can be retreived (and parsed) using the package ifneeded command. For instance, on my Windows system with ActiveState Tcl 8.5.x, I have:
% package require csv
0.7.2
% package ifneeded csv 0.7.2
package provide csv 0.7.2;source -encoding utf-8 {C:/Program Files/Tcl/lib/teapot/package/tcl/teapot/tcl8/8.3/csv-0.7.2.tm}
Note that what package ifneeded returns is just a Tcl script which is meant to be evaluated to get the package loaded, so parsing of this information is bound to be inherently ad-hoc and fragile.
For Tcl packages you can view list of all loadedable path dirs by command:
join $::auto_path \n
This manual addresses auto_path and other loadable library variables: https://www.systutorials.com/docs/linux/man/n-auto_path/
New or missing loadable package search directory can be added within tclsh:
lappend auto_path /new_directoty