Commit ce22c5e56eb0aa61512323e0f8faa0531f4da5f0

Authored by Michał Lenart
1 parent 21d73a4d

spaczkowanie fsabuildera

git-svn-id: svn://svn.nlp.ipipan.waw.pl/morfeusz/morfeusz@77 ff4e3ee1-f430-4e82-ade0-24591c43f1fd
Showing 36 changed files with 152 additions and 51 deletions
CMakeLists.txt
... ... @@ -80,9 +80,13 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
80 80 set (CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_CONTACT}")
81 81 set (CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++6 (>= 4.6)")
82 82 elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
83   - set (CPACK_GENERATOR "NSIS" "TGZ")
  83 + if (${ARCHITECTURE} MATCHES "amd64")
  84 + set (CPACK_GENERATOR "NSIS64" "TGZ")
  85 + else ()
  86 + set (CPACK_GENERATOR "NSIS" "TGZ")
  87 + endif ()
84 88 elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
85   - set (CPACK_GENERATOR "BUNDLE" "TGZ")
  89 + set (CPACK_GENERATOR "STGZ" "TGZ")
86 90 endif ()
87 91  
88 92 include (CPack)
... ... @@ -100,6 +104,7 @@ configure_file (
100 104 include_directories("${PROJECT_BINARY_DIR}" )
101 105  
102 106 add_subdirectory (morfeusz)
  107 +add_subdirectory (fsabuilder)
103 108  
104 109 ########## add tests ##########
105 110  
... ...
buildAll.sh 0 → 100755
  1 +#!/bin/bash
  2 +
  3 +set -e -o pipefail
  4 +
  5 +function build {
  6 + os=$1
  7 + arch=$2
  8 + shift
  9 + shift
  10 + targets=$@
  11 +
  12 + srcDir=`pwd`
  13 + buildDir=build/build-$os-$arch
  14 + targetDir=$srcDir/target/$os-$arch
  15 + toolchain=$srcDir/morfeusz/Toolchain-$os-$arch.cmake
  16 +
  17 + echo "Will use $toolchain toolchain"
  18 +
  19 + rm -rf $buildDir
  20 + rm -rf $targetDir
  21 + mkdir -p $buildDir
  22 + mkdir -p $targetDir
  23 + cd $buildDir
  24 + cmake -D CMAKE_TOOLCHAIN_FILE=$toolchain -D TARGET_DIR=$targetDir $srcDir
  25 + make -j4
  26 + make $targets
  27 +
  28 + for f in `find "$targetDir" -name "*-Linux-*.deb"`
  29 + do
  30 + mv "$f" "`echo $f | sed -r 's/Linux-amd64.deb$/amd64.deb/' | sed -r 's/Linux-i386.deb/i386.deb/'`"
  31 + done
  32 +
  33 + cd "$srcDir"
  34 +}
  35 +
  36 +build Linux amd64 package package-java package-python
  37 +build Linux i386 package package-java
  38 +build Windows amd64 package package-java
  39 +build Windows i386 package package-java
  40 +build Darwin amd64 package package-java
... ...
fsabuilder/CMakeLists.txt 0 → 100644
  1 +
  2 +set (MORFEUSZBUILDER "morfeuszbuilder")
  3 +set (MORFEUSZBUILDER_VERSION "0.1.0")
  4 +set (DIST_PATH "${CMAKE_CURRENT_BINARY_DIR}")
  5 +
  6 +set (SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
  7 +set (SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
  8 +set (DEPS "")
  9 +
  10 +configure_file (${SETUP_PY_IN} ${SETUP_PY})
  11 +
  12 +add_custom_command (OUTPUT ${SETUP_PY}
  13 + COMMAND python
  14 + ARGS setup.py build
  15 + DEPENDS ${DEPS})
  16 +
  17 +add_custom_target (builder-setup DEPENDS ${SETUP_PY})
  18 +
  19 +#~ add_custom_target (buildfsa-exec ALL
  20 + #~ COMMAND pyinstaller --noconfirm --onefile --console --strip --distpath="${DIST_PATH}" --noupx --clean fsa/buildfsa.py
  21 +#~ )
  22 +#~
  23 +#~ add_executable (buildfsa IMPORTED)
  24 +#~ add_dependencies (buildfsa buildfsa-exec)
  25 +#~ set_property (TARGET buildfsa PROPERTY IMPORTED_LOCATION "${DIST_PATH}")
  26 +#~ install (PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/buildfsa" DESTINATION bin)
  27 +
  28 +if (${UNIX})
  29 + add_custom_target (install-builder
  30 + COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX}
  31 + DEPENDS builder-setup
  32 + )
  33 + add_custom_target (package-builder-tgz
  34 + COMMAND python ${SETUP_PY} bdist -d "${TARGET_DIR}"
  35 + DEPENDS builder-setup
  36 + )
  37 + add_custom_target (package-builder-egg
  38 + COMMAND python ${SETUP_PY} bdist_egg -d "${TARGET_DIR}"
  39 + DEPENDS builder-setup
  40 + )
  41 + set (PACKAGE_DEPENDS "package-builder-egg" "package-builder-tgz")
  42 +
  43 + if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  44 + add_custom_target (package-builder-deb-sdist
  45 + COMMAND python ${SETUP_PY} --command-packages=stdeb.command sdist_dsc --depends "${CPACK_DEBIAN_PACKAGE_NAME}"
  46 + DEPENDS builder-setup
  47 + )
  48 + add_custom_target (package-builder-deb-build
  49 + COMMAND debuild -us -uc
  50 + WORKING_DIRECTORY deb_dist/${MORFEUSZBUILDER}-${MORFEUSZBUILDER_VERSION}
  51 + DEPENDS package-builder-deb-sdist
  52 + )
  53 + add_custom_target(package-builder-deb
  54 + COMMAND mkdir -p "${TARGET_DIR}" && cp ${CMAKE_CURRENT_BINARY_DIR}/deb_dist/python-${MORFEUSZBUILDER}*.deb "${TARGET_DIR}"
  55 + DEPENDS package-builder-deb-build
  56 + )
  57 + list (APPEND PACKAGE_DEPENDS package-builder-deb)
  58 + #~ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
  59 + #~ add_custom_target (package-python-win-installer
  60 + #~ COMMAND python ${SETUP_PY} bdist_wininst -d ${TARGET_DIR} --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}"
  61 + #~ DEPENDS pymorfeusz
  62 + #~ )
  63 + #~ list (APPEND PACKAGE_DEPENDS package-python-win-installer)
  64 + endif ()
  65 + #~ message ("PACKAGE_DEPENDS=${PACKAGE_DEPENDS}")
  66 + add_custom_target (package-builder
  67 + DEPENDS ${PACKAGE_DEPENDS})
  68 +endif ()
... ...
fsabuilder/fsa/buildfsa.py renamed to fsabuilder/buildfsa.py
... ... @@ -8,11 +8,11 @@ Created on 21 paź 2013
8 8 import sys
9 9 import logging
10 10 import codecs
11   -import encode
12   -import convertinput
13   -import common
14   -from fsa import FSA
15   -from serializer import VLengthSerializer1, VLengthSerializer2, SimpleSerializer
  11 +from morfeuszbuilder.fsa import encode
  12 +from morfeuszbuilder.fsa import convertinput
  13 +from morfeuszbuilder.fsa import common
  14 +from morfeuszbuilder.fsa.fsa import FSA
  15 +from morfeuszbuilder.fsa.serializer import VLengthSerializer1, VLengthSerializer2, SimpleSerializer
16 16 from optparse import OptionParser
17 17  
18 18 class OutputFormat():
... ... @@ -70,11 +70,11 @@ def _parseOptions():
70 70 SIMPLE - fixed-length transitions, fastest and weakest compression \
71 71 V1 - variable-length transitions, compressed labels - strongest compression \
72 72 V2 - format similar to the default in Jan Daciuk's fsa package - variable-length transitions, non-compressed labels - good compression, good speed")
73   - parser.add_option('--visualize',
74   - dest='visualize',
75   - action='store_true',
76   - default=False,
77   - help='visualize result')
  73 + #~ parser.add_option('--visualize',
  74 + #~ dest='visualize',
  75 + #~ action='store_true',
  76 + #~ default=False,
  77 + #~ help='visualize result')
78 78 parser.add_option('--train-file',
79 79 dest='trainFile',
80 80 help='A text file used for training. Should contain words from some large corpus - one word in each line')
... ... @@ -83,11 +83,11 @@ def _parseOptions():
83 83 action='store_true',
84 84 default=False,
85 85 help='output some debugging info')
86   - parser.add_option('--profile',
87   - dest='profile',
88   - action='store_true',
89   - default=False,
90   - help='show profiling graph (required pycallgraph and graphviz')
  86 + #~ parser.add_option('--profile',
  87 + #~ dest='profile',
  88 + #~ action='store_true',
  89 + #~ default=False,
  90 + #~ help='show profiling graph (required pycallgraph and graphviz')
91 91  
92 92 opts, args = parser.parse_args()
93 93  
... ... @@ -221,20 +221,10 @@ def main(opts):
221 221 OutputFormat.BINARY: serializer.serialize2BinaryFile
222 222 }[opts.outputFormat](opts.outputFile)
223 223 logging.info('size: '+str(fsa.initialState.reverseOffset))
224   -
225   - if opts.visualize:
226   - from visualizer import Visualizer
227   - Visualizer().visualize(fsa)
228 224  
229 225 if __name__ == '__main__':
230 226 import os
231 227 print os.getcwd()
232 228 opts = _parseOptions()
233   - if opts.profile:
234   - from pycallgraph import PyCallGraph
235   - from pycallgraph.output import GraphvizOutput
236   - with PyCallGraph(output=GraphvizOutput()):
237   - main(opts)
238   - else:
239   - main(opts)
  229 + main(opts)
240 230  
... ...
fsabuilder/caseconv/CaseFolding.txt renamed to fsabuilder/morfeuszbuilder/caseconv/CaseFolding.txt
fsabuilder/caseconv/UnicodeData.txt renamed to fsabuilder/morfeuszbuilder/caseconv/UnicodeData.txt
fsabuilder/caseconv/__init__.py renamed to fsabuilder/morfeuszbuilder/caseconv/__init__.py
fsabuilder/caseconv/generate.py renamed to fsabuilder/morfeuszbuilder/caseconv/generate.py
fsabuilder/fsa/__init__.py renamed to fsabuilder/morfeuszbuilder/fsa/__init__.py
fsabuilder/fsa/common.py renamed to fsabuilder/morfeuszbuilder/fsa/common.py
fsabuilder/fsa/convertinput.py renamed to fsabuilder/morfeuszbuilder/fsa/convertinput.py
fsabuilder/fsa/encode.py renamed to fsabuilder/morfeuszbuilder/fsa/encode.py
fsabuilder/fsa/fsa.py renamed to fsabuilder/morfeuszbuilder/fsa/fsa.py
fsabuilder/fsa/fsa.pyc renamed to fsabuilder/morfeuszbuilder/fsa/fsa.pyc
No preview for this file type
fsabuilder/fsa/pycallgraph.png renamed to fsabuilder/morfeuszbuilder/fsa/pycallgraph.png

801 KB

fsabuilder/fsa/register.py renamed to fsabuilder/morfeuszbuilder/fsa/register.py
fsabuilder/fsa/register.pyc renamed to fsabuilder/morfeuszbuilder/fsa/register.pyc
No preview for this file type
fsabuilder/fsa/serializer.py renamed to fsabuilder/morfeuszbuilder/fsa/serializer.py
fsabuilder/fsa/serializer.pyc renamed to fsabuilder/morfeuszbuilder/fsa/serializer.pyc
No preview for this file type
fsabuilder/fsa/state.py renamed to fsabuilder/morfeuszbuilder/fsa/state.py
fsabuilder/fsa/state.pyc renamed to fsabuilder/morfeuszbuilder/fsa/state.pyc
No preview for this file type
fsabuilder/fsa/test/PoliMorfSmall.tab renamed to fsabuilder/morfeuszbuilder/fsa/test/PoliMorfSmall.tab
fsabuilder/fsa/test/__init__.py renamed to fsabuilder/morfeuszbuilder/fsa/test/__init__.py
fsabuilder/fsa/test/dupa.png renamed to fsabuilder/morfeuszbuilder/fsa/test/dupa.png

58.2 KB

fsabuilder/fsa/test/polimorf.tagset renamed to fsabuilder/morfeuszbuilder/fsa/test/polimorf.tagset
fsabuilder/fsa/test/testConstruction.py renamed to fsabuilder/morfeuszbuilder/fsa/test/testConstruction.py
fsabuilder/fsa/visualizer.py renamed to fsabuilder/morfeuszbuilder/fsa/visualizer.py
fsabuilder/fsa/visualizer.pyc renamed to fsabuilder/morfeuszbuilder/fsa/visualizer.pyc
No preview for this file type
fsabuilder/input/__init__.py renamed to fsabuilder/morfeuszbuilder/input/__init__.py
fsabuilder/utils/__init__.py renamed to fsabuilder/morfeuszbuilder/utils/__init__.py
fsabuilder/utils/extractTagset.py renamed to fsabuilder/morfeuszbuilder/utils/extractTagset.py
morfeusz/CMakeLists.txt
1 1  
2 2 ########## generate default dictionary data #################
3   -
4 3 add_custom_command (
5 4 OUTPUT "${INPUT_DICTIONARY_CPP}"
6   - COMMAND python ${PROJECT_SOURCE_DIR}/fsabuilder/fsa/buildfsa.py -i "${INPUT_DICTIONARY}" -o "${INPUT_DICTIONARY_CPP}" "--tagset-file=${INPUT_TAGSET}" --output-format=CPP --serialization-method=SIMPLE
  5 + COMMAND python ${PROJECT_SOURCE_DIR}/fsabuilder/buildfsa.py -i "${INPUT_DICTIONARY}" -o "${INPUT_DICTIONARY_CPP}" "--tagset-file=${INPUT_TAGSET}" --output-format=CPP --serialization-method=SIMPLE
7 6 DEPENDS "${INPUT_DICTIONARY}"
8 7 COMMENT "Building default dictionary C++ file"
9 8 )
... ...
morfeusz/Toolchain-Linux-i386.cmake
1 1  
2 2 set (CMAKE_SYSTEM_NAME Linux)
3 3 set (CMAKE_SYSTEM_VERSION 1)
4   -set (CMAKE_C_COMPILER gcc -m32)
5   -set (CMAKE_CXX_COMPILER g++ -m32)
  4 +set (CMAKE_C_COMPILER gcc)
  5 +set (CMAKE_CXX_COMPILER g++)
  6 +set (CMAKE_C_FLAGS "-m32")
  7 +set (CMAKE_CXX_FLAGS "-m32")
6 8  
7 9 set (CMAKE_SYSTEM_PROCESSOR "x86")
8 10  
... ... @@ -19,5 +21,7 @@ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
19 21 set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
20 22 set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
21 23  
  24 +set (JAVA_JVM_LIBRARY ${JAVA_ROOT}/bin)
  25 +set (JAVA_AWT_LIBRARY ${JAVA_ROOT}/bin)
22 26 set (JAVA_INCLUDE_PATH ${JAVA_ROOT}/include)
23 27 set (JAVA_INCLUDE_PATH2 ${JAVA_ROOT}/include/linux)
... ...
morfeusz/java/CMakeLists.txt
... ... @@ -44,5 +44,5 @@ add_custom_target(jmorfeusz-copy-readme
44 44 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/README" "${CMAKE_CURRENT_BINARY_DIR}/README")
45 45  
46 46 add_custom_target(package-java
47   - COMMAND mkdir -p "${TARGET_DIR}/java" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/java/jmorfeusz-${JMORFEUSZ_VERSION}-${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/*.jar" "${CMAKE_CURRENT_BINARY_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}" "${CMAKE_CURRENT_BINARY_DIR}/README"
  47 + COMMAND mkdir -p "${TARGET_DIR}/java" && ${CMAKE_COMMAND} -E tar "cfvz" "${TARGET_DIR}/jmorfeusz-${JMORFEUSZ_VERSION}-${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}.tar.gz" "${CMAKE_CURRENT_BINARY_DIR}/*.jar" "${CMAKE_CURRENT_BINARY_DIR}/*${CMAKE_SHARED_LIBRARY_SUFFIX}" "${CMAKE_CURRENT_BINARY_DIR}/README"
48 48 DEPENDS jmorfeusz-jar jmorfeusz-copy-readme jmorfeusz)
... ...
morfeusz/python/CMakeLists.txt
1 1  
2 2 # SWIG
3 3 #set(CMAKE_SWIG_OUTDIR swig)
4   -FIND_PACKAGE (SWIG REQUIRED)
  4 +#~ FIND_PACKAGE (SWIG REQUIRED)
5 5 FIND_PACKAGE (PythonLibs)
6   -INCLUDE (${SWIG_USE_FILE})
  6 +#~ INCLUDE (${SWIG_USE_FILE})
7 7  
8 8 set (PYMORFEUSZ_VERSION "0.1.0")
9 9  
... ... @@ -26,17 +26,12 @@ set (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build")
26 26  
27 27 configure_file (${SETUP_PY_IN} ${SETUP_PY})
28 28  
29   -add_custom_command (OUTPUT ${OUTPUT}
  29 +add_custom_command (OUTPUT ${SETUP_PY}
30 30 COMMAND python
31 31 ARGS setup.py build
32 32 DEPENDS ${DEPS})
33 33  
34   -add_custom_target (pymorfeusz ALL DEPENDS ${OUTPUT} morfeusz)
35   -
36   -
37   -#~ install(CODE "execute_process(COMMAND python ${SETUP_PY} install --home=${CMAKE_INSTALL_PREFIX})" COMPONENT pythonapi DEPENDS ${OUTPUT} MESSAGE "DUPA")
38   -#~ install(CODE "execute_process(COMMAND python ${SETUP_PY} --command-packages=stdeb.command bdist_deb)" COMPONENT pythondeb DEPENDS ${OUTPUT})
39   -#~ install(CODE "execute_process(COMMAND python ${SETUP_PY} bdist -d ${PROJECT_BINARY_DIR})" COMPONENT pythontgz DEPENDS ${OUTPUT})
  34 +add_custom_target (pymorfeusz DEPENDS ${SETUP_PY} morfeusz)
40 35  
41 36 if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
42 37 add_custom_target (install-python
... ... @@ -44,7 +39,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
44 39 DEPENDS ${pymorfeusz}
45 40 )
46 41 add_custom_target (package-python-bin
47   - COMMAND python ${SETUP_PY} bdist_egg -d "${TARGET_DIR}/python" --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}"
  42 + COMMAND python ${SETUP_PY} bdist_egg -d "${TARGET_DIR}" --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}"
48 43 DEPENDS pymorfeusz
49 44 )
50 45 set (PACKAGE_DEPENDS "package-python-bin")
... ... @@ -60,16 +55,16 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
60 55 DEPENDS package-python-deb-sdist
61 56 )
62 57 add_custom_target(package-python-deb
63   - COMMAND mkdir -p "${TARGET_DIR}/python" && cp ${CMAKE_CURRENT_BINARY_DIR}/deb_dist/python-pymorfeusz*.deb "${TARGET_DIR}/python"
  58 + COMMAND mkdir -p "${TARGET_DIR}" && cp ${CMAKE_CURRENT_BINARY_DIR}/deb_dist/python-pymorfeusz*.deb "${TARGET_DIR}"
64 59 DEPENDS package-python-deb-build
65 60 )
66 61 list (APPEND PACKAGE_DEPENDS package-python-deb)
67   - elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
68   - add_custom_target (package-python-win-installer
69   - COMMAND python ${SETUP_PY} bdist_wininst -d ${TARGET_DIR} --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}"
70   - DEPENDS pymorfeusz
71   - )
72   - list (APPEND PACKAGE_DEPENDS package-python-win-installer)
  62 + #~ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
  63 + #~ add_custom_target (package-python-win-installer
  64 + #~ COMMAND python ${SETUP_PY} bdist_wininst -d ${TARGET_DIR} --plat-name "${CMAKE_SYSTEM_NAME}-${ARCHITECTURE}"
  65 + #~ DEPENDS pymorfeusz
  66 + #~ )
  67 + #~ list (APPEND PACKAGE_DEPENDS package-python-win-installer)
73 68 endif ()
74 69 message ("PACKAGE_DEPENDS=${PACKAGE_DEPENDS}")
75 70 add_custom_target (package-python
... ...
morfeusz/python/setup.py.in
... ... @@ -4,7 +4,7 @@ from setuptools import setup, Extension
4 4 morfeusz = Extension('_morfeusz',
5 5 libraries=['morfeusz'],
6 6 library_dirs=['${CMAKE_CURRENT_BINARY_DIR}/..'],
7   - include_dirs = ['${CMAKE_CURRENT_SOURCE_DIR}/..'],
  7 + include_dirs=['${CMAKE_CURRENT_SOURCE_DIR}/..'],
8 8 sources=['${CMAKE_CURRENT_BINARY_DIR}/${SWIG_PYTHON_OUTFILE}'])
9 9  
10 10 if __name__ == '__main__':
... ...