Switching to C

This commit is contained in:
Adrien Bourmault 2021-06-08 20:15:47 +02:00
parent 6540aeadd2
commit 4f6448a2ba
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
14 changed files with 64 additions and 21 deletions

View File

@ -19,40 +19,42 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
#=----------------------------------------------------------------------------=#
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

9
debian/Manifest vendored Normal file
View File

@ -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

0
include/scheduler.h Normal file
View File

0
include/server.h Normal file
View File

32
include/types.h Normal file
View File

@ -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 <https://www.gnu.org/licenses/>. //
//=-------------------------------------------------------------------------=//
#include <stdbool.h>
struct {
size_t size;
bool *space;
} typedef BoolArray_t;
struct {
size_t size;
int *space;
} typedef IntArray_t;

0
oldsrc/test.py Normal file
View File