initial setup
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
testapp
|
||||
libgravity.so
|
||||
obj/
|
||||
35
Makefile
Normal file
35
Makefile
Normal file
@@ -0,0 +1,35 @@
|
||||
SRC=src
|
||||
OBJ=obj
|
||||
|
||||
CC=gcc
|
||||
CFLAGS=-Wall -Wextra -pedantic -std=c99 -pedantic-errors
|
||||
|
||||
TARGET=libgravity.so
|
||||
TEST_TARGET=testapp
|
||||
|
||||
SRCS=$(wildcard $(SRC)/*.c)
|
||||
OBJS=$(patsubst $(SRC)/%.c,$(OBJ)/%.o,$(SRCS))
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) -shared $(OBJS) -o $(TARGET)
|
||||
|
||||
$(OBJ)/%.o: $(SRC)/%.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(TEST_TARGET): test.c $(TARGET)
|
||||
$(CC) test.c -lgravity -L. -o $(TEST_TARGET)
|
||||
|
||||
test: $(TEST_TARGET)
|
||||
|
||||
setup:
|
||||
mkdir -p $(OBJ)
|
||||
|
||||
clean:
|
||||
rm $(TARGET)
|
||||
rm $(TEST_TARGET)
|
||||
rm -r $(OBJ)/*.o
|
||||
|
||||
install: $(TARGET)
|
||||
sudo cp $(TARGET) /usr/local/lib/
|
||||
|
||||
.PHONY: setup clean test install
|
||||
12
include/gravity/core.h
Normal file
12
include/gravity/core.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef __GRAVITY_CORE_H
|
||||
#define __GRAVITY_CORE_H
|
||||
|
||||
// === STRUCT DEFINITIONS === //
|
||||
typedef struct GravityOpaqueModule* GravityModule;
|
||||
// ========================== //
|
||||
|
||||
// === FUNCTION DEFINITIONS === //
|
||||
GravityModule gravityCreateModule();
|
||||
// ============================ //
|
||||
|
||||
#endif
|
||||
8
src/function.h
Normal file
8
src/function.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef __GRAVITY_FUNCTION_H
|
||||
#define __GRAVITY_FUNCTION_H
|
||||
|
||||
typedef struct {
|
||||
|
||||
} GravityIRFunction;
|
||||
|
||||
#endif
|
||||
10
src/module.c
Normal file
10
src/module.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "module.h"
|
||||
|
||||
GravityOpaqueModule* gravityCreateModule() {
|
||||
GravityOpaqueModule* newModule = malloc(sizeof(GravityOpaqueModule));
|
||||
if (newModule == NULL) return NULL;
|
||||
|
||||
|
||||
|
||||
return newModule;
|
||||
}
|
||||
12
src/module.h
Normal file
12
src/module.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef __GRAVITY_MODULE_H
|
||||
#define __GRAVITY_MODULE_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct {
|
||||
int hi;
|
||||
} GravityOpaqueModule;
|
||||
|
||||
GravityOpaqueModule* gravityCreateModule();
|
||||
|
||||
#endif
|
||||
9
test.c
Normal file
9
test.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "include/gravity/core.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
GravityModule module = gravityCreateModule();
|
||||
printf("module: %p\n", module);
|
||||
|
||||
return 0;
|
||||
}
|
||||
12
tests/ir/add.gir
Normal file
12
tests/ir/add.gir
Normal file
@@ -0,0 +1,12 @@
|
||||
; types:
|
||||
; u8 - u64
|
||||
; i8 - i64
|
||||
; f, d
|
||||
; void
|
||||
; ptr
|
||||
|
||||
fn add (i32 num1, i32 num2) i32 {
|
||||
add_entry:
|
||||
sum = addi num1, num2
|
||||
ret sum
|
||||
}
|
||||
Reference in New Issue
Block a user