← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #196620]: How to import sikuli source code in eclipse?

 

Question #196620 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/196620

    Status: Open => Answered

RaiMan proposed the following answer:
--- sikuli-ide.jar
... should be rather easy, since it is a plain Java project and needs only library references to sikuli-script.jar and junit.

--- sikuli-script.jar
I have managed to set up an environment to build sikuli-script.jar from the sikuli/sikuli-script/src folder in Eclipse Indigo on Mac Lion.
These where the steps:

** Step 1: made a fork from sikuli github repository
(https://github.com/RaiMan/sikuli) on my local machine (I am using the
GitHub client for Mac)

** Step 2: in Eclipse made different projects for the native and java stuff:
-1 sikuli-script (Java, Eclipse files: .project, .classpath)
-2 MacHotkeyManager (C++, .project .cproject)
-3 MacUtil (C++, .project .cproject)
-4 VisionProxy (C++, .project .cproject)
-5 VisionSWIG (run swig via Eclipse externalToolBuilder)
-6 VDictProxy (still using the result from the package)

All projects are setup with linked resources to the local github folder,
so my changes are directly commitable to my fork on github.

** Step 3: analyze the Cmake/make files from the normal build
... and setting up the build environments for each project in Eclipse
This was partly a little bit tricky with the g++ and linker options, but finally worked.

** Step 4: setting the dependencies
1 depends on (2, 3, (4 depends on 5))
So when I build sikuli-script (compile to create the class files), all the dependent stuff is built automatically, if something has changed. To clean, I currently delete the sikuli-script.jar manually, so it gets built again.

** Step 5: to make sikuli-script.jar
... I decided to make a separate project with a build.xml, that puts together all needed stuff and finally creates sikuli-script.jar in the target directory of the local git fork.
Since I told this project to be dependent on project 1 (sikuli-script), I just have to run this build.xml to get my running sikuli-script.jar.  To clean, I currently delete the sikuli-script.jar manually, so it gets built again.

this is the current build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== 
     23.02.2012 19:03:48                                                        
     Build sikuli-script.jar Mac (Eclipse build)
     rhocke/RaiMan                                                                
     ====================================================================== -->
<project name="sikuli-script-make" default="make_sikuli_script">
	<description>
        Build sikuli-script.jar Mac (Eclipse build)
    </description>

        <property name="my.current" value="sikuli-script" />

	<property name="my.git.sikuli" location="${user.home}/github/sikuli" />
	<property name="my.build" location="${my.git.sikuli}/${my.current}/build" />
	<property name="my.source" location="${my.git.sikuli}/${my.current}/src" />

	<property name="my.build.jar" location="${my.build}/jar" />
	<property name="my.build.jar.Lib" location="${my.build}/jar/Lib" />
	<property name="my.build.jar.META-INF" location="${my.build}/jar/META-INF" />
	<property name="my.build.jar.META-INF.lib" location="${my.build}/jar/META-INF/lib" />
	<property name="my.build.jar.tessdata" location="${my.build}/jar/tessdata" />
	<property name="my.build.Release" location="${my.build}/Release" />
	<property name="my.build.Artifakt" location="${my.build.Release}/${my.current}.jar" />

	<property name="my.source.jython" location="${my.git.sikuli}/lib/jython-2.5.2.jar" />
	<property name="my.source.jythonlib" location="${my.git.sikuli}/lib/jython-lib-2.5.2.tgz" />
	<property name="my.source.python" location="${my.source}/main/python" />
	<property name="my.source.tessdata" location="/usr/local/share/tessdata" />

	<filelist id="jnilibs">
		<file name="${my.eclipse.workspace}/MacHotkeyManager/Release/libMacHotkeyManager.jnilib" />
		<file name="${my.eclipse.workspace}/MacUtil/Release/libMacUtil.jnilib" />
		<file name="${my.eclipse.workspace}/VisionProxy/Release/libVisionProxy.jnilib" />
		<!-- libVDictProxy compile and link missing -->
		<file name="${my.eclipse.workspace}/VDictProxy/Release/libVDictProxy.jnilib" />
	</filelist>
	
	<defaultexcludes add=".*"/>
	
	<!-- ================================= 
          target: make_sikuli_script              
         ================================= -->
	<target name="make_sikuli_script" depends="makejar" description="make all">
	</target>

	<target name="makejar" depends="copystuff">
		<jar destfile="${my.build.Artifakt}" 
			 basedir="${my.build.jar}" 
			 manifest="${my.git.sikuli}/${my.current}/target/MANIFEST.txt"
			 defaultexcludes="yes">
		</jar>
	</target>

	<!-- - - - - - - - - - - - - - - - - - 
          target: copystuff                       
         - - - - - - - - - - - - - - - - - -->
	<target name="copystuff" depends="makedirs">
		<!-- copy dynamic libs -->
		<copy todir="${my.build.jar.META-INF.lib}" flatten="true">
			<filelist refid="jnilibs"/>
		</copy>

		<!-- copy jython jar -->
		<unjar src="${my.source.jython}" dest="${my.build.jar}" />
		
		<!-- copy jython Lib -->
		<gunzip src="${my.source.jythonlib}" dest="${my.build.jar.Lib}/temp.tar" />
		<untar src="${my.build.jar.Lib}/temp.tar" dest="${my.build.jar.Lib}"/>	
		<delete file="${my.build.jar.Lib}/temp.tar" />

		<!-- copy Python source -->
		<copy todir="${my.build.jar.Lib}">
			<fileset dir="${my.source.python}"/>
		</copy>
		
		<!-- copy tessdata -->		
		<copy todir="${my.build.jar.tessdata}">
			<fileset dir="${my.source.tessdata}"/>
		</copy>

        </target>

	<!-- - - - - - - - - - - - - - - - - - 
      target: makedirs                      
     - - - - - - - - - - - - - - - - - -->
	<target name="makedirs" depends="makeinit">
		<mkdir dir="${my.build.jar}"/>
		<mkdir dir="${my.build.Release}"/>
		<mkdir dir="${my.build.jar.META-INF.lib}"/>
		<mkdir dir="${my.build.jar.Lib}/sikuli"/>
	</target>

	<!-- - - - - - - - - - - - - - - - - - 
          target: makeinit                      
         - - - - - - - - - - - - - - - - - -->
	<target name="makeinit">
		<echoproperties prefix="my.">
		</echoproperties>
	</target>

	<!-- ================================= 
          target: clean              
         ================================= -->
	<target name="clean" description="reset build">
		<echo message="${my.build}" />
	</target>
</project>

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.