Skip to content

Commit

Permalink
grass.lib: Update ctypesgen (#2243)
Browse files Browse the repository at this point in the history
* ctypesgen: update to upstream fd495e5 version

ctypesgen/ctypesgen@fd495e5

* apply patches

* update makefile

* lib imagery test: HOST_DIRSEP is now str, no need to decode
  • Loading branch information
nilason committed Mar 26, 2022
1 parent b454411 commit df16f09
Show file tree
Hide file tree
Showing 44 changed files with 5,067 additions and 7,301 deletions.
6 changes: 2 additions & 4 deletions lib/imagery/testsuite/test_imagery_signature_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,17 @@
I_make_signatures_dir,
)

H_DIRSEP = HOST_DIRSEP.decode("utf-8")


class GetSignaturesElementTestCase(TestCase):
def test_get_sig(self):
cdir = ctypes.create_string_buffer(GNAME_MAX)
I_get_signatures_dir(cdir, I_SIGFILE_TYPE_SIG)
self.assertEqual(utils.decode(cdir.value), f"signatures{H_DIRSEP}sig")
self.assertEqual(utils.decode(cdir.value), f"signatures{HOST_DIRSEP}sig")

def test_get_sigset(self):
cdir = ctypes.create_string_buffer(GNAME_MAX)
I_get_signatures_dir(cdir, I_SIGFILE_TYPE_SIGSET)
self.assertEqual(utils.decode(cdir.value), f"signatures{H_DIRSEP}sigset")
self.assertEqual(utils.decode(cdir.value), f"signatures{HOST_DIRSEP}sigset")


class MakeSignaturesElementTestCase(TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2007-2008, Ctypesgen Developers
Copyright (c) 2007-2022, Ctypesgen Developers
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -9,14 +9,11 @@ modification, are permitted provided that the following conditions are met:
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the <ORGANIZATION> nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Expand Down
39 changes: 19 additions & 20 deletions python/libgrass_interface_generator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,48 +56,47 @@ proj_INC = $(PROJINC)
vector_INC = $(VECT_INC) $(VECT_CFLAGS)
vedit_INC = $(VECT_INC) $(VECT_CFLAGS)

MAC_FLAGS = ""
ifneq ($(findstring darwin,$(ARCH)),)
MAC_FLAGS = "-D_Nullable="
endif

CTYPESGEN = ./run.py
CTYPESFLAGS = --cpp "$(CC) -E $(CPPFLAGS) $(LFS_CFLAGS) $(MAC_FLAGS) $(EXTRA_CFLAGS) $(NLS_CFLAGS) $(DEFS) $(EXTRA_INC) $(INC) -D__GLIBC_HAVE_LONG_LONG"
EXTRA_CLEAN_FILES := $(wildcard ctypesgencore/*.pyc) $(wildcard ctypesgencore/*/*.pyc)

ifneq ($(MINGW),)
INTLLIB = -lintl-8
endif

CTYPESGEN = ./run.py
CTYPESFLAGS = --no-embed-preamble --strip-build-path "$(ARCH_DISTDIR)" \
--cpp "$(CC) -E $(CPPFLAGS) $(LFS_CFLAGS) $(EXTRA_CFLAGS) $(NLS_CFLAGS) $(DEFS) $(EXTRA_INC) $(INC) -D__GLIBC_HAVE_LONG_LONG"
EXTRA_CLEAN_FILES := $(wildcard ctypesgen/*.pyc) $(wildcard ctypesgen/*/*.pyc)

include $(MODULE_TOPDIR)/include/Make/Python.make

PYDIR = $(ETC)/python
GDIR = $(PYDIR)/grass
DSTDIR = $(GDIR)/lib

PYFILES := $(patsubst %,$(DSTDIR)/%.py,$(MODULES) __init__ ctypes_preamble ctypes_loader)
PYCFILES := $(patsubst %,$(DSTDIR)/%.pyc,$(MODULES) __init__ ctypes_preamble ctypes_loader)
PYFILES := $(patsubst %,$(DSTDIR)/%.py,$(MODULES))
PYCFILES := $(patsubst %,$(DSTDIR)/%.pyc,$(MODULES))
LPYFILES := $(patsubst %,$(OBJDIR)/%.py,$(MODULES))

COPY_FILES = $(DSTDIR)/ctypes_loader.py $(DSTDIR)/ctypes_preamble.py $(DSTDIR)/__init__.py
COPY_FILES = ctypes_loader ctypes_preamble __init__
PY_COPY_FILES = $(patsubst %,$(DSTDIR)/%.py,$(COPY_FILES))
PYC_COPY_FILES = $(patsubst %,$(DSTDIR)/%.pyc,$(COPY_FILES))

ifeq ($(strip $(GRASS_LIBRARY_TYPE)),shlib)
default: $(COPY_FILES)
default:
$(MAKE) $(DSTDIR)
$(MAKE) $(LPYFILES) $(PYFILES) $(PYCFILES)
$(MAKE) $(PY_COPY_FILES) $(PYC_COPY_FILES)
else
default:
@echo "Cannot build Python wrappers for static libraries" >&2
exit 1
endif

$(COPY_FILES): | $(DSTDIR)
$(DSTDIR)/ctypes_loader.py: ctypesgen/libraryloader.py
cp -f $< $@
$(DSTDIR)/ctypes_preamble.py: ctypesgen/printer_python/preamble/3_2.py
cp -f $< $@
$(PY_COPY_FILES): | $(DSTDIR)
$(DSTDIR)/__init__.py: libgrass__init__.py
cp -f $< $@
$(INSTALL_DATA) $< $@
$(DSTDIR)/ctypes_loader.py: $(OBJDIR)/ctypes_loader.py
$(INSTALL_DATA) $< $@
$(DSTDIR)/ctypes_preamble.py: $(OBJDIR)/ctypes_preamble.py
$(INSTALL_DATA) $< $@

$(DSTDIR)/%.py: $(OBJDIR)/%.py | $(DSTDIR)
$(INSTALL_DATA) $< $@
Expand All @@ -118,4 +117,4 @@ $(GDIR): | $(PYDIR)
$(DSTDIR): | $(GDIR)
$(MKDIR) $@

.SECONDARY: $(patsubst %,%.py,$(MODULES))
.SECONDARY: $(patsubst %,%.py,$(MODULES)) $(patsubst %,%.py,$(COPY_FILES))

0 comments on commit df16f09

Please sign in to comment.