Browse Source

Include version in each build

Signed-off-by: Jerome Flesch <jflesch@openpaper.work>
tags/0.2.3
Jerome Flesch 1 year ago
parent
commit
45b27aa665

+ 1
- 0
.gitignore View File

@@ -1,5 +1,6 @@
*~
cbuild
_version.h
venv*/

# Byte-compiled / optimized / DLL files

+ 17
- 16
CMakeLists.txt View File

@@ -8,24 +8,25 @@ add_definitions(-DNO_PYTHON)
include_directories(include)

add_library(pillowfight SHARED
src/pillowfight/_ace.c
src/pillowfight/_blackfilter.c
src/pillowfight/_blurfilter.c
src/pillowfight/_border.c
src/pillowfight/_canny.c
src/pillowfight/_compare.c
src/pillowfight/_gaussian.c
src/pillowfight/_grayfilter.c
src/pillowfight/_masks.c
src/pillowfight/_noisefilter.c
src/pillowfight/_sobel.c
src/pillowfight/util.c
src/pillowfight/_ace.c
src/pillowfight/_blackfilter.c
src/pillowfight/_blurfilter.c
src/pillowfight/_border.c
src/pillowfight/_canny.c
src/pillowfight/_compare.c
src/pillowfight/_gaussian.c
src/pillowfight/_grayfilter.c
src/pillowfight/_masks.c
src/pillowfight/_noisefilter.c
src/pillowfight/_sobel.c
src/pillowfight/_version.c
src/pillowfight/util.c
)

install (TARGETS pillowfight DESTINATION ${LIBDIR})
install (FILES
include/pillowfight/pillowfight.h
include/pillowfight/util.h
DESTINATION
include/pillowfight
include/pillowfight/pillowfight.h
include/pillowfight/util.h
DESTINATION
include/pillowfight
)

+ 10
- 8
Makefile View File

@@ -1,27 +1,30 @@
# If you want to build in MSYS2 on Windows
# export CMAKE_OPTS=-G "MSYS Makefiles"

build: build_py build_c
VERSION_FILE = src/pillowfight/_version.h

build: build_c build_py

install: install_py install_c

uninstall: uninstall_py

build_py:
build_py: ${VERSION_FILE}
python3 ./setup.py build

build_c: build/libpillowfight.so

build/libpillowfight.so: build/CMakeLists.txt
build/libpillowfight.so: ${VERSION_FILE} build/CMakeLists.txt
(cd build && make -j4)

build/CMakeLists.txt:
mkdir -p build
(cd build && cmake ${CMAKE_OPTS} ..)

# TODO(Jflesch)
# src/pillowfight/version.h:
# git describe --always >| $@
${VERSION_FILE}:
echo -n "#define INTERNAL_PILLOWFIGHT_VERSION \"" >| $@
echo -n $(shell git describe --always) >> $@
echo "\"" >> $@

doc: install_py
(cd doc && make html)
@@ -31,8 +34,7 @@ doc: install_py
clean:
rm -rf doc/build
rm -rf build dist *.egg-info
# TODO(Jflesch)
# rm -f src/pillowfight/version.h
rm -f ${VERSION_FILE}

install_py:
python3 ./setup.py install ${PIP_ARGS}

+ 5
- 0
include/pillowfight/pillowfight.h View File

@@ -156,6 +156,11 @@ extern void pf_unpaper_grayfilter(const struct pf_bitmap *in, struct pf_bitmap *
extern void pf_unpaper_masks(const struct pf_bitmap *in, struct pf_bitmap *out);

extern void pf_unpaper_noisefilter(const struct pf_bitmap *in, struct pf_bitmap *out);

/*!
* \brief return Libpillowfight version
*/
extern const char *pf_get_version(void);
#endif

extern void pf_write_bitmap_to_ppm(const char *filepath, const struct pf_bitmap *in);

+ 1
- 0
setup.py View File

@@ -63,6 +63,7 @@ setup(
'src/pillowfight/_pymod.c',
'src/pillowfight/_sobel.c',
'src/pillowfight/_swt.c',
'src/pillowfight/_version.c',
],
include_dirs=["include"],
libraries=libdep,

+ 7
- 0
src/pillowfight/__init__.py View File

@@ -273,3 +273,10 @@ def swt(img_in, output_type=SWT_OUTPUT_BW_TEXT):
size=(img_in.size[0], img_in.size[1]),
data=img_out
).convert("RGB")


def get_version():
return _clib.get_version()


__version__ = get_version()

+ 1
- 0
src/pillowfight/_pymod.c View File

@@ -7,6 +7,7 @@ static PyMethodDef clib_methods[] = {
{"canny", pycanny, METH_VARARGS, NULL},
{"compare", pycompare, METH_VARARGS, NULL},
{"gaussian", pygaussian, METH_VARARGS, NULL},
{"get_version", pyget_version, METH_NOARGS, NULL},
{"sobel", pysobel, METH_VARARGS, NULL},
{"swt", pyswt, METH_VARARGS, NULL},
{"unpaper_blackfilter", pyblackfilter, METH_VARARGS, NULL},

+ 1
- 0
src/pillowfight/_pymod.h View File

@@ -12,3 +12,4 @@ PyObject *pymasks(PyObject *self, PyObject* args);
PyObject *pynoisefilter(PyObject *self, PyObject* args);
PyObject *pysobel(PyObject *self, PyObject* args);
PyObject *pyswt(PyObject *self, PyObject* args);
PyObject *pyget_version(PyObject *self, PyObject* args);

+ 21
- 0
src/pillowfight/_version.c View File

@@ -0,0 +1,21 @@
#ifndef NO_PYTHON
#include "_pymod.h"
#endif
#include "_version.h"


#ifndef NO_PYTHON
static
#endif
const char *pf_get_version(void)
{
return INTERNAL_PILLOWFIGHT_VERSION;
}


#ifndef NO_PYTHON
PyObject *pyget_version(PyObject *self, PyObject* args)
{
return PyUnicode_FromString(pf_get_version());
}
#endif // !NO_PYTHON

Loading…
Cancel
Save