Commit e7a9535e26e8f9dcb9a591dc8f5bfe99aa4fd7b7

Authored by Michał Lenart
1 parent 4780ee9c

- praca nad paczkowaniem pythona do .deb

- porządki w paczkowaniu Javy (wyrzucenie mavenowej maszynerii, użycie tylko cmake-owego add_jar)

git-svn-id: svn://svn.nlp.ipipan.waw.pl/morfeusz/morfeusz@70 ff4e3ee1-f430-4e82-ade0-24591c43f1fd
CMakeLists.txt
1 1  
2 2 cmake_minimum_required (VERSION 2.8)
3   -project (Morfeusz)
  3 +project (Morfeusz)
  4 +
4 5 set (Morfeusz_VERSION_MAJOR 0)
5 6 set (Morfeusz_VERSION_MINOR 1)
6 7 set (CMAKE_BUILD_TYPE "Release")
... ... @@ -53,30 +54,9 @@ set (PYMORFEUSZ pymorfeusz)
53 54 set (JMORFEUSZ jmorfeusz)
54 55  
55 56 ###### add some dependencies for SWIG modules ######
56   -add_dependencies (${PYMORFEUSZ} morfeusz)
  57 +#~ add_dependencies (${PYMORFEUSZ} morfeusz)
57 58 add_dependencies (${JMORFEUSZ} morfeusz)
58 59  
59   -########## PYTHON ##########
60   -
61   -# find out library suffix
62   -#~ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
63   - #~ set (CMAKE_PYTHON_LIBRARY_SUFFIX ".so")
64   -#~ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
65   - #~ set (CMAKE_PYTHON_LIBRARY_SUFFIX ".pyd")
66   -#~ else ()
67   - #~ set (CMAKE_PYTHON_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
68   -#~ endif ()
69   -
70   -# copy python->c++ bindings
71   -#~ add_custom_target (copy-pymorfeusz-libs ALL
72   - #~ COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/morfeusz/python/pymorfeusz${CMAKE_PYTHON_LIBRARY_SUFFIX} ${PROJECT_BINARY_DIR}/pymorfeusz
73   - #~ DEPENDS ${PYMORFEUSZ})
74   -#~ add_custom_target (copy-pymorfeusz-wrapper ALL
75   - #~ COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/morfeusz/python/morfeusz.py ${PROJECT_BINARY_DIR}/pymorfeusz
76   - #~ DEPENDS ${PYMORFEUSZ})
77   -#~
78   -#~ add_test (TestPyMorfeusz python pymorfeusz/test.py)
79   -
80 60 ########## tests ##########
81 61  
82 62 macro (test_build_and_recognize fname method)
... ... @@ -104,3 +84,4 @@ set (CPACK_GENERATOR "DEB" "TGZ" "NSIS")
104 84 set (CPACK_DEBIAN_PACKAGE_MAINTAINER "Michał Lenart") #required
105 85  
106 86 include (CPack)
  87 +set (CPACK_PROJECT_CONFIG_FILE PackConfig.txt)
... ...
CPackConfig.txt 0 → 100644
  1 +set (CPACK_COMPONENTS_ALL baseasdfa)
  2 +#~ if (CPACK_GENERATOR STREQUAL "DEB")
  3 + #~ set (CPACK_COMPONENTS_ALL base pythondeb)
  4 +#~ elseif (CPACK_GENERATOR STREQUAL "TGZ")
  5 + #~ set (CPACK_COMPONENTS_ALL base pythontgz)
  6 +#~ elseif (CPACK_GENERATOR STREQUAL "NSIS")
  7 + #~ set (CPACK_COMPONENTS_ALL base)
  8 +#~ else
  9 + #~ set (CPACK_COMPONENTS_ALL base)
  10 +#~ endif ()
... ...
jmorfeusz/nb-configuration.xml deleted
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<project-shared-configuration>
3   - <!--
4   -This file contains additional configuration written by modules in the NetBeans IDE.
5   -The configuration is intended to be shared among all the users of project and
6   -therefore it is assumed to be part of version control checkout.
7   -Without this configuration present, some functionality in the IDE may be limited or fail altogether.
8   --->
9   - <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
10   - <!--
11   -Properties that influence various parts of the IDE, especially code formatting and the like.
12   -You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
13   -That way multiple projects can share the same settings (useful for formatting rules for example).
14   -Any value defined here will override the pom.xml file value but is only applicable to the current project.
15   --->
16   - <org-netbeans-modules-whitelist.whitelist-oracle>false</org-netbeans-modules-whitelist.whitelist-oracle>
17   - </properties>
18   -</project-shared-configuration>
jmorfeusz/nbactions.xml deleted
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<actions>
3   - <action>
4   - <actionName>run</actionName>
5   - <packagings>
6   - <packaging>jar</packaging>
7   - </packagings>
8   - <goals>
9   - <goal>process-classes</goal>
10   - <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
11   - </goals>
12   - <properties>
13   - <exec.args>-Djava.library.path=target -classpath %classpath ${packageClassName}</exec.args>
14   - <exec.executable>java</exec.executable>
15   - </properties>
16   - </action>
17   - <action>
18   - <actionName>debug</actionName>
19   - <packagings>
20   - <packaging>jar</packaging>
21   - </packagings>
22   - <goals>
23   - <goal>process-classes</goal>
24   - <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
25   - </goals>
26   - <properties>
27   - <exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Djava.library.path=target -classpath %classpath ${packageClassName}</exec.args>
28   - <exec.executable>java</exec.executable>
29   - <jpda.listen>true</jpda.listen>
30   - </properties>
31   - </action>
32   - <action>
33   - <actionName>profile</actionName>
34   - <packagings>
35   - <packaging>jar</packaging>
36   - </packagings>
37   - <goals>
38   - <goal>process-classes</goal>
39   - <goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
40   - </goals>
41   - <properties>
42   - <exec.args>-Djava.library.path=target -classpath %classpath ${packageClassName}</exec.args>
43   - <exec.executable>java</exec.executable>
44   - </properties>
45   - </action>
46   - </actions>
jmorfeusz/pom.xml deleted
1   -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2   - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3   - <modelVersion>4.0.0</modelVersion>
4   -
5   - <groupId>pl.waw.ipipan.morfeusz</groupId>
6   - <artifactId>jmorfeusz</artifactId>
7   - <version>1.0</version>
8   - <packaging>jar</packaging>
9   -
10   - <name>jmorfeusz</name>
11   - <url>http://maven.apache.org</url>
12   -
13   - <properties>
14   - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15   - </properties>
16   -
17   - <dependencies>
18   - <dependency>
19   - <groupId>junit</groupId>
20   - <artifactId>junit</artifactId>
21   - <version>4.11</version>
22   - <scope>test</scope>
23   - </dependency>
24   - </dependencies>
25   -
26   - <build>
27   - <plugins>
28   - <plugin>
29   - <groupId>org.apache.maven.plugins</groupId>
30   - <artifactId>maven-compiler-plugin</artifactId>
31   - <version>2.3.2</version>
32   - <configuration>
33   - <source>1.5</source>
34   - <target>1.5</target>
35   - </configuration>
36   - </plugin>
37   -
38   - <plugin>
39   - <groupId>org.apache.maven.plugins</groupId>
40   - <artifactId>maven-surefire-plugin</artifactId>
41   - <version>2.16</version>
42   - <configuration>
43   - <argLine>-Djava.library.path=src/main/native</argLine>
44   - </configuration>
45   - </plugin>
46   -
47   - <plugin>
48   - <groupId>org.apache.maven.plugins</groupId>
49   - <artifactId>maven-jar-plugin</artifactId>
50   - <version>2.4</version>
51   - <configuration>
52   - <archive>
53   - <manifest>
54   - <mainClass>pl.waw.ipipan.morfeusz.app.App</mainClass>
55   - </manifest>
56   - </archive>
57   - </configuration>
58   - </plugin>
59   -
60   - <plugin>
61   - <artifactId>maven-resources-plugin</artifactId>
62   - <version>2.6</version>
63   - <executions>
64   - <execution>
65   - <id>copy-resources</id>
66   - <!-- here the phase you need -->
67   - <phase>validate</phase>
68   - <goals>
69   - <goal>copy-resources</goal>
70   - </goals>
71   - <configuration>
72   - <outputDirectory>${project.build.directory}</outputDirectory>
73   - <resources>
74   - <resource>
75   - <directory>src/main/resources</directory>
76   - <!--<filtering>true</filtering>-->
77   - </resource>
78   - </resources>
79   - </configuration>
80   - </execution>
81   - </executions>
82   - </plugin>
83   -
84   - <plugin>
85   - <groupId>org.apache.maven.plugins</groupId>
86   - <artifactId>maven-assembly-plugin</artifactId>
87   - <configuration>
88   - <descriptor>src/main/assembly/bin.xml</descriptor>
89   - <outputDirectory>${packageDir}</outputDirectory>
90   -<!--
91   - <finalName>apache-maven-cookbook-${pom.version}</finalName>
92   --->
93   - </configuration>
94   - <executions>
95   - <execution>
96   - <phase>package</phase>
97   - <goals>
98   - <goal>single</goal>
99   - </goals>
100   - </execution>
101   - </executions>
102   - </plugin>
103   - </plugins>
104   - </build>
105   -
106   -
107   - <profiles>
108   - <profile>
109   - <id>otherOutputDir</id>
110   - <build>
111   - <directory>${buildDir}</directory>
112   - </build>
113   - </profile>
114   - </profiles>
115   -</project>
morfeusz/CMakeLists.txt
... ... @@ -62,6 +62,6 @@ endif ()
62 62 add_subdirectory (java)
63 63 add_subdirectory (python)
64 64  
65   -install (FILES ${INCLUDE_FILES} DESTINATION include/morfeusz)
66   -install (TARGETS libmorfeusz DESTINATION lib)
67   -install (TARGETS morfeusz DESTINATION bin)
  65 +install (FILES ${INCLUDE_FILES} DESTINATION include/morfeusz COMPONENT base)
  66 +install (TARGETS libmorfeusz DESTINATION lib COMPONENT base)
  67 +install (TARGETS morfeusz DESTINATION bin COMPONENT base)
... ...
morfeusz/java/CMakeLists.txt
1 1 # SWIG
2 2 #set(CMAKE_SWIG_OUTDIR swig)
3 3 #FIND_PACKAGE(SWIG REQUIRED)
4   -FIND_PACKAGE(JNI REQUIRED)
  4 +set (JMORFEUSZ_VERSION "0.1.0")
  5 +find_package(JNI REQUIRED)
5 6 #INCLUDE(${SWIG_USE_FILE})
6 7 include(UseJava)
  8 +find_package(Java REQUIRED)
7 9  
8 10 # SWIG Java
9 11 include_directories (${JAVA_INCLUDE_PATH})
... ... @@ -11,10 +13,11 @@ include_directories (${JAVA_INCLUDE_PATH2})
11 13 include_directories (..)
12 14  
13 15 set (SWIG_JAVA_OUTFILE swigJAVA.cpp)
  16 +set (JAVA_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pl/waw/ipipan/morfeusz")
14 17 # set (JAVA_WRAPPER_FILE ${CMAKE_SHARED_LIBRARY_PREFIX}morfeusz${CMAKE_SHARED_LIBRARY_SUFFIX})
15 18 add_custom_command (
16 19 OUTPUT ${SWIG_JAVA_OUTFILE}
17   - COMMAND swig -java -c++ -package pl.waw.ipipan.morfeusz -o ${SWIG_JAVA_OUTFILE} -outdir ${CMAKE_SOURCE_DIR}/jmorfeusz/src/main/java/pl/waw/ipipan/morfeusz ${CMAKE_SOURCE_DIR}/morfeusz/morfeusz.i
  20 + COMMAND swig -java -c++ -package pl.waw.ipipan.morfeusz -o ${SWIG_JAVA_OUTFILE} -outdir ${JAVA_SRC_DIR} ${CMAKE_SOURCE_DIR}/morfeusz/morfeusz.i
18 21 DEPENDS libmorfeusz
19 22 )
20 23 #set (CMAKE_SHARED_LINKER_FLAGS "-s -Os -static-libstdc++ -static-libgcc")
... ... @@ -38,23 +41,14 @@ if (${CMAKE_SYSTEM_NAME} MATCHES &quot;Darwin&quot;)
38 41 set (CMAKE_SHARED_LIBRARY_SUFFIX ".jnilib")
39 42 endif ()
40 43  
  44 +set (CMAKE_JAVA_TARGET_VERSION ${JMORFEUSZ_VERSION})
  45 +set (CMAKE_JAVA_TARGET_OUTPUT_NAME jmorfeusz)
  46 +
41 47 # build jmorfeusz
42   -add_custom_target ( jmorfeusz-maven-package package
43   - COMMAND mvn package -PotherOutputDir -DbuildDir=${CMAKE_CURRENT_BINARY_DIR} -DpackageDir=${PROJECT_BINARY_DIR} -DskipTests=true
44   - DEPENDS ${JMORFEUSZ}
45   - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/jmorfeusz)
46   -
47   -#~ file(GLOB JMORFEUSZ_PACKAGE_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.tar.gz")
48   -#~
49   -#~ add_custom_target(jmorfeusz-maven-package-copy ALL
50   - #~ DEPENDS jmorfeusz-maven-package)
51   -#~
52   -#~ foreach (f ${JMORFEUSZ_PACKAGE_FILES})
53   - #~ MESSAGE ("COPY ${f} TO ${PROJECT_BINARY_DIR}")
54   - #~ add_custom_command (
55   - #~ TARGET jmorfeusz-maven-package-copy
56   - #~ COMMAND ${CMAKE_COMMAND} -E copy ${f} ${PROJECT_BINARY_DIR}
57   - #~
58   - #~ )
59   -#~ endforeach ()
  48 +add_jar (jmorfeusz-jar
  49 + SOURCES ${JAVA_SRC_DIR}/*.java ${JAVA_SRC_DIR}/app/*.java )
60 50  
  51 +file (GLOB FILES_TO_TAR "*.jar *.so *.dylib *.jnilib *.dll README*")
  52 +add_custom_target(package-java
  53 + COMMAND ${CMAKE_COMMAND} -E tar "cfvz" "${PROJECT_BINARY_DIR}/jmorfeusz-${JMORFEUSZ_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}.tgz" "${FILES_TO_TAR}"
  54 + DEPENDS jmorfeusz-jar jmorfeusz)
... ...
morfeusz/java/pl/waw/ipipan/morfeusz/app/App.java 0 → 100644
  1 +package pl.waw.ipipan.morfeusz.app;
  2 +
  3 +import pl.waw.ipipan.morfeusz.Morfeusz;
  4 +import pl.waw.ipipan.morfeusz.ResultsIterator;
  5 +
  6 +/**
  7 + * Hello world!
  8 + *
  9 + */
  10 +public class App {
  11 +
  12 + public static void main(String[] args) {
  13 + System.err.println("Working Directory = " +
  14 + System.getProperty("user.dir"));
  15 + System.err.println("java.library.path="+System.getProperty("java.library.path"));
  16 + Morfeusz morfeusz = new Morfeusz();
  17 + ResultsIterator it = morfeusz.analyze("Ala ma kota i żółć.");
  18 + while (it.hasNext()) {
  19 + System.out.println(MorfeuszUtils.getInterpretationString(it.getNext()));
  20 + }
  21 + }
  22 +}
... ...
morfeusz/java/pl/waw/ipipan/morfeusz/app/MorfeuszUtils.java 0 → 100644
  1 +package pl.waw.ipipan.morfeusz.app;
  2 +
  3 +import java.io.ByteArrayOutputStream;
  4 +import java.io.PrintStream;
  5 +import pl.waw.ipipan.morfeusz.MorphInterpretation;
  6 +
  7 +/**
  8 + *
  9 + * @author mlenart
  10 + */
  11 +public class MorfeuszUtils {
  12 +
  13 + public static String getInterpretationString(MorphInterpretation interp) {
  14 + ByteArrayOutputStream baos = new ByteArrayOutputStream();
  15 + PrintStream ps = new PrintStream(baos);
  16 + ps.printf("%d %d %s %s %s %s",
  17 + interp.getStartNode(),
  18 + interp.getEndNode(),
  19 + interp.getOrth(),
  20 + interp.getLemma(),
  21 + interp.getTag(),
  22 + interp.getName());
  23 + ps.flush();
  24 + return baos.toString();
  25 + }
  26 +}
... ...
morfeusz/python/CMakeLists.txt
1 1  
2 2 # SWIG
3 3 #set(CMAKE_SWIG_OUTDIR swig)
4   -FIND_PACKAGE(SWIG REQUIRED)
5   -FIND_PACKAGE(PythonLibs)
6   -INCLUDE(${SWIG_USE_FILE})
  4 +FIND_PACKAGE (SWIG REQUIRED)
  5 +FIND_PACKAGE (PythonLibs)
  6 +INCLUDE (${SWIG_USE_FILE})
  7 +
  8 +set (PYMORFEUSZ_VERSION "0.1.0")
7 9  
8 10 # SWIG Java
9   -INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
10   -INCLUDE_DIRECTORIES(..)
  11 +INCLUDE_DIRECTORIES (${PYTHON_INCLUDE_PATH})
  12 +INCLUDE_DIRECTORIES (..)
11 13  
12 14 set (SWIG_PYTHON_OUTFILE swigPYTHON.cpp)
13 15 # set (JAVA_WRAPPER_FILE ${CMAKE_SHARED_LIBRARY_PREFIX}morfeusz${CMAKE_SHARED_LIBRARY_SUFFIX})
... ... @@ -35,21 +37,50 @@ add_custom_command (
35 37 #~
36 38 #~ endif ()
37 39  
38   -set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
39   -set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
40   -set(DEPS "${CMAKE_CURRENT_BINARY_DIR}/morfeusz.py" "${SWIG_PYTHON_OUTFILE}")
41   -set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build")
  40 +set (SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
  41 +set (SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
  42 +set (DEPS "${CMAKE_CURRENT_BINARY_DIR}/morfeusz.py" "${SWIG_PYTHON_OUTFILE}")
  43 +set (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build")
42 44  
43   -configure_file(${SETUP_PY_IN} ${SETUP_PY})
  45 +configure_file (${SETUP_PY_IN} ${SETUP_PY})
44 46  
45   -add_custom_command(OUTPUT ${OUTPUT}
  47 +add_custom_command (OUTPUT ${OUTPUT}
46 48 COMMAND python
47 49 ARGS setup.py build
48 50 DEPENDS ${DEPS})
49 51  
50   -add_custom_target(pymorfeusz ALL DEPENDS ${OUTPUT})
  52 +add_custom_target (pymorfeusz ALL DEPENDS ${OUTPUT} morfeusz)
  53 +
  54 +
  55 +#~ install(CODE "execute_process(COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX})" COMPONENT pythonapi DEPENDS ${OUTPUT} MESSAGE "DUPA")
  56 +#~ install(CODE "execute_process(COMMAND python ${SETUP_PY} --command-packages=stdeb.command bdist_deb)" COMPONENT pythondeb DEPENDS ${OUTPUT})
  57 +#~ install(CODE "execute_process(COMMAND python ${SETUP_PY} bdist -d ${PROJECT_BINARY_DIR})" COMPONENT pythontgz DEPENDS ${OUTPUT})
  58 +
  59 +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  60 + add_custom_target (install-python
  61 + COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX}
  62 + DEPENDS ${pymorfeusz}
  63 + )
  64 + add_custom_target (package-python-bin
  65 + COMMAND python ${SETUP_PY} bdist -d ${PROJECT_BINARY_DIR}
  66 + DEPENDS pymorfeusz
  67 + )
  68 + add_custom_target (package-python-src
  69 + COMMAND python ${SETUP_PY} sdist -d ${PROJECT_BINARY_DIR}
  70 + DEPENDS pymorfeusz
  71 + )
  72 + add_custom_target (package-python
  73 + DEPENDS package-python-bin package-python-src)
  74 +
  75 + set (PYMORFEUSZ_SRC_PACKAGE "${PROJECT_BINARY_DIR}/pymorfeusz-${PYMORFEUSZ_VERSION}.tar.gz")
  76 + add_custom_target (package-python-deb-src
  77 + COMMAND py2dsc ${PYMORFEUSZ_SRC_PACKAGE}
  78 + )
  79 +endif ()
  80 +#~ install (install-python
  81 + #~ COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX}
  82 + #~ DEPENDS pymorfeusz)
51 83  
52   -set (CPACK_PACKAGE_NAME "dupa")
53   -install (FILES setup.py.in DESTINATION bin)
54   -include (CPack)
55   -#install(CODE "execute_process(COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX})")
  84 +#~ install (CODE
  85 + #~ COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX}
  86 + #~ DEPENDS pymorfeusz)
... ...
morfeusz/python/setup.py.in
... ... @@ -7,8 +7,8 @@ morfeusz = Extension(&#39;pymorfeusz&#39;,
7 7 sources=['${CMAKE_CURRENT_BINARY_DIR}/${SWIG_PYTHON_OUTFILE}'])
8 8  
9 9 if __name__ == '__main__':
10   - setup(name='morfeusz',
11   - version='${PACKAGE_VERSION}',
  10 + setup(name='pymorfeusz',
  11 + version='${PYMORFEUSZ_VERSION}',
12 12 package_dir={ '': '${CMAKE_CURRENT_BINARY_DIR}'},
13 13 py_modules = ['morfeusz'],
14 14 ext_modules = [morfeusz])
... ...
nbproject/configurations.xml
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <configurationDescriptor version="90">
3 3 <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
4   - <logicalFolder name="f1" displayName="input" projectFiles="true" kind="ROOT">
  4 + <logicalFolder name="f1" displayName="input" projectFiles="true">
5 5 </logicalFolder>
6 6 <df root="morfeusz" name="0">
7 7 <df name="charset">
... ...