sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #10523
Re: [Question #196620]: How to import sikuli source code in eclipse?
Question #196620 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/196620
RaiMan proposed the following answer:
Based on my comment #1 and the mentioned steps and projects you need, it
is the result of project 5 (I named it VisionSWIG), that is missing now.
Now you must decide about your further steps based on what you want to achieve:
1. stay on the Java level (this is what you have now)
2. step down to the native level and be able to deal with the native code too
For 1.
just unjar a running sikuli-script.jar, make a library reference to org.sikuli.script.natives (see 2. for the background) and build.
This should run now without errors.
Then copy all your newly compiled classes to the jar folder at org.sikuli.script to replace them and rebuild the jar file.
This can be done in many ways. I did it with an ANT workflow (see comment #1).
And remember: I do not copy any original source file from my sikuli fork
to the Eclipse projects - everything is referenced as linked resources.
The same way I use the build directory in the fork as the place for the
compiled/generated stuff.
For 2.
The functions, that use the OpenCV and Tesseract features are written in C++. To call these functions from Java code, you have to implement a JNI (Java Native Interface). The Java part is contained in VisionProxy.java, which is generated using the SWIG utility with the following call in the original cmake build:
(separated on different lines to be more readable)
/usr/local/bin/swig
-java
-package org.sikuli.script.natives
-outdir ......../sikuli/sikuli-script/build/org/sikuli/script/natives
-c++
-I/System/Library/Frameworks/JavaVM.framework/Headers
-I/usr/local/Cellar/opencv/2.2/include/opencv
-I/usr/local/Cellar/opencv/2.2/include
-I......./sikuli/sikuli-script/src/main/native
-I/usr/local/include
-o ......./sikuli/sikuli-script/build/src/main/native/visionJAVA_wrap.cxx
........./sikuli/sikuli-script/src/main/native/vision.i
where:
............/sikuli ... is the location of the sources
/usr/local/Cellar/opencv is the location, where I have the prereq stuff, since I use homebrew for package management
To mange this, I have made a general project containing only vision.i
and setup an external Builder to fire the above SWIG command.
This is the launch file, that is generated behind the respective Eclipse
GUI (Project Properties -> Builders -> new)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="${workspace_loc:/0_sikuli-script-make/log.txt}"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="/usr/local/bin/swig"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-v -java -package org.sikuli.script.natives -outdir ${siks_loc}/java/org/sikuli/script/natives -c++ -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/Cellar/opencv/2.2/include/opencv -I/usr/local/Cellar/opencv/2.2/include -I${siks_loc}/native -I/usr/local/include -o ${siks_loc}/native/visionJAVA_wrap.cxx ${siks_loc}/native/vision.i"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/VisionSWIG}"/>
</launchConfiguration>
So this would generate the missing class folder
org.sikuli.script.natives.
The rest are the three C++ projects 2-4, that build the dynamic
libraries (in the jar at META-INF/lib). These are only needed at runtime
and not needed to compile the Java stuff.
And finally some additional stuff is packed into the jar (the Python
API, Jython library and the tessdata).
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.