From 23be9cb40e95a9c4e9526b0b1b020ac2b6afca4f Mon Sep 17 00:00:00 2001 From: Andrew <51118083+ArionThinker@users.noreply.github.com> Date: Fri, 19 Jan 2024 17:38:59 +0200 Subject: [PATCH] + (#4903) --- .../github.com/python-cffi/cffi/package.yml | 53 +++++++++++++++++++ projects/github.com/python-cffi/cffi/sum.c | 1 + 2 files changed, 54 insertions(+) create mode 100644 projects/github.com/python-cffi/cffi/package.yml create mode 100644 projects/github.com/python-cffi/cffi/sum.c diff --git a/projects/github.com/python-cffi/cffi/package.yml b/projects/github.com/python-cffi/cffi/package.yml new file mode 100644 index 00000000..e9b785c7 --- /dev/null +++ b/projects/github.com/python-cffi/cffi/package.yml @@ -0,0 +1,53 @@ +distributable: + url: git+https://github.com/python-cffi/cffi.git + ref: ${{version.tag}} + +versions: + github: python-cffi/cffi + +dependencies: + python.org: '>=3.11' + github.com/eliben/pycparser: ^2.21 + sourceware.org/libffi: ^3.4 + +runtime: + env: + PYTHONPATH: ${{prefix}}/lib/python3/site-packages:$PYTHONPATH + +build: + - python -m pip install . --prefix={{prefix}} + - run: ln -s python{{deps.python.org.version.marketing}} python{{deps.python.org.version.major}} + working-directory: ${{prefix}}/lib + +test: + dependencies: + llvm.org: '*' + script: + - clang -shared sum.c -o $SHARED_LIBRARY + - run: | + cat << EOF > sum_build.py + from cffi import FFI + ffibuilder = FFI() + + declaration = """ + int sum(int a, int b); + """ + + ffibuilder.cdef(declaration) + ffibuilder.set_source( + "_sum_cffi", + declaration, + libraries=['sum'], + extra_link_args=['-L$PWD', '-Wl,-rpath,$PWD'] + ) + + ffibuilder.compile(verbose=True) + EOF + - python sum_build.py + - python -c "import _sum_cffi; assert _sum_cffi.lib.sum(1, 2) == 3" + env: + CC: clang + linux: + SHARED_LIBRARY: libsum.so + darwin: + SHARED_LIBRARY: libsum.dylib \ No newline at end of file diff --git a/projects/github.com/python-cffi/cffi/sum.c b/projects/github.com/python-cffi/cffi/sum.c new file mode 100644 index 00000000..1a8e678a --- /dev/null +++ b/projects/github.com/python-cffi/cffi/sum.c @@ -0,0 +1 @@ +int sum(int a, int b) { return a + b; } \ No newline at end of file