From 4f6448a2ba13527972fe9fa10640de4dd6c67607 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 8 Jun 2021 20:15:47 +0200 Subject: [PATCH] Switching to C --- Makefile | 44 +++++++++++---------- debian/Manifest | 9 +++++ src/test.py => include/localthread.h | 0 include/scheduler.h | 0 include/server.h | 0 include/types.h | 32 +++++++++++++++ {src => oldsrc}/localthread.py | 0 {src => oldsrc}/main.py | 0 {src => oldsrc}/scheduler.py | 0 {src => oldsrc}/server.py | 0 oldsrc/test.py | 0 src/__pycache__/localthread.cpython-39.pyc | Bin 1692 -> 0 bytes src/__pycache__/scheduler.cpython-39.pyc | Bin 1803 -> 0 bytes src/__pycache__/server.cpython-39.pyc | Bin 436 -> 0 bytes 14 files changed, 64 insertions(+), 21 deletions(-) create mode 100644 debian/Manifest rename src/test.py => include/localthread.h (100%) create mode 100644 include/scheduler.h create mode 100644 include/server.h create mode 100644 include/types.h rename {src => oldsrc}/localthread.py (100%) rename {src => oldsrc}/main.py (100%) rename {src => oldsrc}/scheduler.py (100%) rename {src => oldsrc}/server.py (100%) create mode 100644 oldsrc/test.py delete mode 100644 src/__pycache__/localthread.cpython-39.pyc delete mode 100644 src/__pycache__/scheduler.cpython-39.pyc delete mode 100644 src/__pycache__/server.cpython-39.pyc diff --git a/Makefile b/Makefile index 1f1f918..f955db5 100644 --- a/Makefile +++ b/Makefile @@ -19,40 +19,42 @@ # along with this program. If not, see . # #=----------------------------------------------------------------------------=# -CCOPTS=-pthread -fPIC -fwrapv -Wall -fno-strict-aliasing -CCFLAGS=-I /usr/include/python3.9 -LDFLAGS=-lpython3.9 -lpthread -lm -lutil -ldl +CCINCLUDES=-Iinclude +CCOPTS=-pthread -Wall +LDFLAGS= -lc -lpthread BINDIR=bin SRCDIR=src -DYNLIBS= $(BINDIR)/scheduler.so $(BINDIR)/server.so $(BINDIR)/localthread.so +DEBDIR=debian +OBJ=$(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localthread.o $(BINDIR)/main.o .DEFAULT_GOAL:= all -.PHONY: all clean -.PRECIOUS: $(SRCDIR)/%.c +.PHONY: all clean deb # ---- General recipes ------------------------------------------------------- # -$(BINDIR)/%.so: $(SRCDIR)/%.c - @echo "Building dynamic library $@" - @$(CC) --shared $(CCOPTS) $(CCFLAGS) -o $@ $< - -$(SRCDIR)/%.c: $(SRCDIR)/%.py - @echo "Cythonizing $< to $@" - @cython3 -3 $< -o $@ +$(BINDIR)/%.o: $(SRCDIR)/%.c + @echo "Compiling $<" + @$(CC) $(CCINCLUDES) $(CCOPTS) $(CCFLAGS) -c -o $@ $< # ---- Main recipe ----------------------------------------------------------- # -$(BINDIR)/gem-graph-server: $(SRCDIR)/main.c +$(BINDIR)/gem-graph-server: $(OBJ) @echo "Building program to $@" - @$(CC) $(CCOPTS) -no-pie $(CCFLAGS) -o $@ $< $(LDFLAGS) + @$(CC) -o $@ $(OBJ) $(LDFLAGS) @echo "Success!" -$(SRCDIR)/main.c: $(SRCDIR)/main.py - @echo "Cythonizing main file to $@" - @cython3 -3 $< -o $@ --embed - - # ---- Misc recipes ---------------------------------------------------------- # clean: - rm -rf $(SRCDIR)/*.c $(BINDIR)/* + rm -rf $(SRCDIR)/*.o $(BINDIR)/* *.deb all: $(DYNLIBS) $(BINDIR)/gem-graph-server + +# ---- Build debian package -------------------------------------------------- # +$(BINDIR)/gem-graph-server.deb: all + mkdir -p gem-graph-server/usr/bin + mkdir -p gem-graph-server/DEBIAN + cp $(DEBDIR)/Manifest gem-graph-server/DEBIAN/control + cp $(BINDIR)/* gem-graph-server/usr/bin + dpkg-deb --build gem-graph-server + rm -rf gem-graph-server + +deb: $(BINDIR)/gem-graph-server.deb diff --git a/debian/Manifest b/debian/Manifest new file mode 100644 index 0000000..27314c1 --- /dev/null +++ b/debian/Manifest @@ -0,0 +1,9 @@ +Package: gem-graph-server +Version: 0.0.1 +Section: custom +Priority: optional +Architecture: amd64 +Essential: no +Installed-Size: 1049 +Maintainer: The Gem-graph Project +Description: The gem-graph computation server diff --git a/src/test.py b/include/localthread.h similarity index 100% rename from src/test.py rename to include/localthread.h diff --git a/include/scheduler.h b/include/scheduler.h new file mode 100644 index 0000000..e69de29 diff --git a/include/server.h b/include/server.h new file mode 100644 index 0000000..e69de29 diff --git a/include/types.h b/include/types.h new file mode 100644 index 0000000..960b71d --- /dev/null +++ b/include/types.h @@ -0,0 +1,32 @@ +//=-------------------------------------------------------------------------=// +// Main // +// // +// Copyright © 2021 The Gem-graph Project // +// // +// This file is part of gem-graph. // +// // +// This program is free software: you can redistribute it and/or modify // +// it under the terms of the GNU Affero General Public License as // +// published by the Free Software Foundation, either version 3 of the // +// License, or (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU Affero General Public License for more details. // +// // +// You should have received a copy of the GNU Affero General Public License // +// along with this program. If not, see . // +//=-------------------------------------------------------------------------=// + +#include + +struct { + size_t size; + bool *space; +} typedef BoolArray_t; + +struct { + size_t size; + int *space; +} typedef IntArray_t; diff --git a/src/localthread.py b/oldsrc/localthread.py similarity index 100% rename from src/localthread.py rename to oldsrc/localthread.py diff --git a/src/main.py b/oldsrc/main.py similarity index 100% rename from src/main.py rename to oldsrc/main.py diff --git a/src/scheduler.py b/oldsrc/scheduler.py similarity index 100% rename from src/scheduler.py rename to oldsrc/scheduler.py diff --git a/src/server.py b/oldsrc/server.py similarity index 100% rename from src/server.py rename to oldsrc/server.py diff --git a/oldsrc/test.py b/oldsrc/test.py new file mode 100644 index 0000000..e69de29 diff --git a/src/__pycache__/localthread.cpython-39.pyc b/src/__pycache__/localthread.cpython-39.pyc deleted file mode 100644 index 9f20a7402926a707b0526ecfa4ac4cb23de9b463..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1692 zcmb7Ey>A>v6rY*>ybs65G2v6!&X#{3GYIg!hWvAPa8l-KFi~+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--git a/src/__pycache__/server.cpython-39.pyc b/src/__pycache__/server.cpython-39.pyc deleted file mode 100644 index 4e7eb19dd625c5a7a7fd820691c62c6e0328a860..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 436 zcmY*VJx{|h5Is8ygo+A;5MpG_(0X7+s8S^=B$TCF7Gu>`3u-=UCrBVVwG;n@f5V8f z@)OvYxJv{|&wA&3=X<`hRlnZ@w2!yq{&NrDi%8czBqM}7K{o*nnr#sqo`B|4h`br* zcZ?$&A>1iC0}0cRaLqK|LgHx;HGX|CHTKEa@!jo?oS}j+{*!CAhF5UMC2U{~D_;Z3 zd3+PGI(W#6s*G5&@5;O=jD818!~R@~MV=b*XjCR9CcT(gRV>8Zq=Pv{1J|?`&dx*| z4vXhHaHX>4IrR