Makefile
This commit is contained in:
11
.gitignore
vendored
11
.gitignore
vendored
@@ -1,5 +1,16 @@
|
|||||||
|
# Zig stuff
|
||||||
.zig-cache/
|
.zig-cache/
|
||||||
zig-out/
|
zig-out/
|
||||||
|
# Data dir
|
||||||
!data/.gitkeep
|
!data/.gitkeep
|
||||||
|
# Makefile build
|
||||||
|
build/*
|
||||||
|
!build/.gitkeep
|
||||||
|
# VScode slop
|
||||||
.vscode/
|
.vscode/
|
||||||
|
# Random logs some tools may output
|
||||||
*.log
|
*.log
|
||||||
|
# Makefile output
|
||||||
|
/neonucleus
|
||||||
|
/libneonucleus.so
|
||||||
|
/libneonucleus.a
|
||||||
|
|||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -13,3 +13,6 @@
|
|||||||
path = foreign/lua52
|
path = foreign/lua52
|
||||||
url = https://github.com/lua/lua
|
url = https://github.com/lua/lua
|
||||||
branch = v5-2
|
branch = v5-2
|
||||||
|
[submodule "data/moirai"]
|
||||||
|
path = data/moirai
|
||||||
|
url = https://gitea.codersquack.nl/NeoFlock/moirai
|
||||||
|
|||||||
60
Makefile
Normal file
60
Makefile
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
BIN=neonucleus
|
||||||
|
DYNLIB=libneonucleus.so
|
||||||
|
LIB=libneonucleus.a
|
||||||
|
|
||||||
|
CC=cc
|
||||||
|
OPT=-O3
|
||||||
|
SANITIZE=
|
||||||
|
DEBUG=
|
||||||
|
NNFLAGS=
|
||||||
|
CFLAGS=-fPIC $(OPT) $(SANITIZE) $(DEBUG) $(NNFLAGS)
|
||||||
|
|
||||||
|
LD=$(CC)
|
||||||
|
LDFLAGS=$(OPT) $(DEBUG)
|
||||||
|
|
||||||
|
AR=ar
|
||||||
|
RANLIB=ranlib
|
||||||
|
|
||||||
|
LINKRAYLIB=-lraylib
|
||||||
|
INCLUA=-I /usr/include/lua5.3
|
||||||
|
LINKLUA=-llua5.3
|
||||||
|
LINKLIBM=-lm
|
||||||
|
LINKLIBC=
|
||||||
|
|
||||||
|
BUILD_DIR=build
|
||||||
|
SRC_DIR=src
|
||||||
|
|
||||||
|
$(BUILD_DIR)/neonucleus.o: $(SRC_DIR)/neonucleus.c $(SRC_DIR)/neonucleus.h
|
||||||
|
$(CC) -o $(BUILD_DIR)/neonucleus.o -c $(SRC_DIR)/neonucleus.c $(CFLAGS)
|
||||||
|
|
||||||
|
$(BUILD_DIR)/ncomplib.o: $(SRC_DIR)/ncomplib.c $(SRC_DIR)/ncomplib.h
|
||||||
|
$(CC) -o $(BUILD_DIR)/ncomplib.o -c $(SRC_DIR)/ncomplib.c $(CFLAGS)
|
||||||
|
|
||||||
|
nn: $(BUILD_DIR)/neonucleus.o $(BUILD_DIR)/ncomplib.o
|
||||||
|
|
||||||
|
$(BUILD_DIR)/luaarch.o: $(SRC_DIR)/luaarch.c $(SRC_DIR)/machine.lua
|
||||||
|
$(CC) -o $(BUILD_DIR)/luaarch.o -c $(SRC_DIR)/luaarch.c $(CFLAGS) $(INCLUA)
|
||||||
|
|
||||||
|
$(BUILD_DIR)/glyphcache.o: $(SRC_DIR)/glyphcache.c $(SRC_DIR)/glyphcache.h
|
||||||
|
$(CC) -o $(BUILD_DIR)/glyphcache.o -c $(SRC_DIR)/glyphcache.c $(CFLAGS)
|
||||||
|
|
||||||
|
$(BUILD_DIR)/main.o: $(SRC_DIR)/main.c $(SRC_DIR)/minBIOS.lua
|
||||||
|
$(CC) -o $(BUILD_DIR)/main.o -c $(SRC_DIR)/main.c $(CFLAGS) $(INCLUA)
|
||||||
|
|
||||||
|
bin: nn $(BUILD_DIR)/main.o $(BUILD_DIR)/luaarch.o $(BUILD_DIR)/glyphcache.o
|
||||||
|
$(LD) $(LDFLAGS) -o $(BIN) $(BUILD_DIR)/neonucleus.o $(BUILD_DIR)/ncomplib.o $(BUILD_DIR)/main.o $(BUILD_DIR)/glyphcache.o $(BUILD_DIR)/luaarch.o $(LINKLIBC) $(LINKLIBM) $(LINKRAYLIB) $(LINKLUA)
|
||||||
|
|
||||||
|
lib: nn
|
||||||
|
$(AR) rc $(LIB) $(BUILD_DIR)/neonucleus.o $(BUILD_DIR)/ncomplib.o
|
||||||
|
$(RANLIB) $(LIB)
|
||||||
|
|
||||||
|
dynlib: nn
|
||||||
|
$(LD) $(LDFLAGS) -o $(DYNLIB) -shared $(BUILD_DIR)/neonucleus.o $(BUILD_DIR)/ncomplib.o $(LINKLIBM) $(LINKLIBC)
|
||||||
|
|
||||||
|
all: bin lib dynlib
|
||||||
|
|
||||||
|
cleancache:
|
||||||
|
rm -rf $(BUILD_DIR)/*.o
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(BIN) $(DYNLIB) $(LIB)
|
||||||
0
build/.gitkeep
Normal file
0
build/.gitkeep
Normal file
1
data/moirai
Submodule
1
data/moirai
Submodule
Submodule data/moirai added at b2f75735a1
@@ -651,15 +651,18 @@ static nn_Exit luaArch_handler(nn_ArchitectureRequest *req) {
|
|||||||
nn_Computer *computer = req->computer;
|
nn_Computer *computer = req->computer;
|
||||||
luaArch *arch = req->localState;
|
luaArch *arch = req->localState;
|
||||||
nn_Context *ctx = nn_getComputerContext(computer);
|
nn_Context *ctx = nn_getComputerContext(computer);
|
||||||
|
// the memory scale, used to give Lua extra memory in 64-bit systems
|
||||||
|
// due to it also using more memory.
|
||||||
|
double memScale = sizeof(void *) > 4 ? 1.8 : 1;
|
||||||
switch(req->action) {
|
switch(req->action) {
|
||||||
case NN_ARCH_FREEMEM:
|
case NN_ARCH_FREEMEM:
|
||||||
req->freeMemory = arch->freeMem / nn_getMemoryScale(computer);
|
req->freeMemory = arch->freeMem / memScale;
|
||||||
return NN_OK;
|
return NN_OK;
|
||||||
case NN_ARCH_INIT:
|
case NN_ARCH_INIT:
|
||||||
// wrapped in a block to prevent L from leaking, because L is common in Lua code so it may be used by mistake
|
// wrapped in a block to prevent L from leaking, because L is common in Lua code so it may be used by mistake
|
||||||
{
|
{
|
||||||
arch = nn_alloc(ctx, sizeof(*arch));
|
arch = nn_alloc(ctx, sizeof(*arch));
|
||||||
arch->freeMem = nn_getTotalMemory(computer) * nn_getMemoryScale(computer);
|
arch->freeMem = nn_getTotalMemory(computer) * memScale;
|
||||||
arch->computer = computer;
|
arch->computer = computer;
|
||||||
#if LUA_VERSION_NUM >= 505L
|
#if LUA_VERSION_NUM >= 505L
|
||||||
lua_State *L = lua_newstate(luaArch_alloc, arch, rand());
|
lua_State *L = lua_newstate(luaArch_alloc, arch, rand());
|
||||||
|
|||||||
@@ -447,6 +447,7 @@ int main(int argc, char **argv) {
|
|||||||
nn_Component *testDrive = ncl_createDrive(u, NULL, &nn_defaultDrives[3], testDriveData, strlen(testDriveData), false);
|
nn_Component *testDrive = ncl_createDrive(u, NULL, &nn_defaultDrives[3], testDriveData, strlen(testDriveData), false);
|
||||||
nn_Component *testFlash = ncl_createFlash(u, NULL, &nn_defaultSSDs[3], testDriveData, strlen(testDriveData), false);
|
nn_Component *testFlash = ncl_createFlash(u, NULL, &nn_defaultSSDs[3], testDriveData, strlen(testDriveData), false);
|
||||||
|
|
||||||
|
ncl_setCLabel(eepromCard, "EEPROM");
|
||||||
ncl_setCLabel(managedfs, "Main Filesystem");
|
ncl_setCLabel(managedfs, "Main Filesystem");
|
||||||
ncl_setCLabel(testingfs, "Secondary Filesystem");
|
ncl_setCLabel(testingfs, "Secondary Filesystem");
|
||||||
ncl_setCLabel(testDrive, "Unmanaged Storage");
|
ncl_setCLabel(testDrive, "Unmanaged Storage");
|
||||||
@@ -454,6 +455,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
size_t ramTotal = 0;
|
size_t ramTotal = 0;
|
||||||
ramTotal += 4 * nn_ramSizes[5];
|
ramTotal += 4 * nn_ramSizes[5];
|
||||||
|
//ramTotal += nn_ramSizes[0];
|
||||||
|
|
||||||
SetExitKey(KEY_NULL);
|
SetExitKey(KEY_NULL);
|
||||||
|
|
||||||
@@ -495,9 +497,6 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
nn_setCallBudget(c, 0);
|
nn_setCallBudget(c, 0);
|
||||||
|
|
||||||
// default for 64-bit
|
|
||||||
if(sizeof(void *) > 4) nn_setMemoryScale(c, 1.8);
|
|
||||||
|
|
||||||
nn_setArchitecture(c, &arch);
|
nn_setArchitecture(c, &arch);
|
||||||
nn_addSupportedArchitecture(c, &arch);
|
nn_addSupportedArchitecture(c, &arch);
|
||||||
|
|
||||||
|
|||||||
@@ -1056,7 +1056,6 @@ typedef struct nn_Computer {
|
|||||||
size_t signalCount;
|
size_t signalCount;
|
||||||
size_t userCount;
|
size_t userCount;
|
||||||
double idleTimestamp;
|
double idleTimestamp;
|
||||||
double memoryScale;
|
|
||||||
nn_Beep beep;
|
nn_Beep beep;
|
||||||
nn_Value callstack[NN_MAX_STACK];
|
nn_Value callstack[NN_MAX_STACK];
|
||||||
char errorBuffer[NN_MAX_ERROR_SIZE];
|
char errorBuffer[NN_MAX_ERROR_SIZE];
|
||||||
@@ -1180,7 +1179,6 @@ nn_Computer *nn_createComputer(nn_Universe *universe, void *userdata, const char
|
|||||||
c->signalCount = 0;
|
c->signalCount = 0;
|
||||||
c->userCount = 0;
|
c->userCount = 0;
|
||||||
c->idleTimestamp = 0;
|
c->idleTimestamp = 0;
|
||||||
c->memoryScale = 1;
|
|
||||||
// set to empty string
|
// set to empty string
|
||||||
c->errorBuffer[0] = '\0';
|
c->errorBuffer[0] = '\0';
|
||||||
nn_clearComputerBeep(c);
|
nn_clearComputerBeep(c);
|
||||||
@@ -1447,14 +1445,6 @@ void nn_setEnergyHandler(nn_Computer *computer, void *energyState, nn_EnergyHand
|
|||||||
computer->energyHandler = handler;
|
computer->energyHandler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nn_setMemoryScale(nn_Computer *computer, double scale) {
|
|
||||||
computer->memoryScale = scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
double nn_getMemoryScale(nn_Computer *computer) {
|
|
||||||
return computer->memoryScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t nn_getTotalMemory(nn_Computer *computer) {
|
size_t nn_getTotalMemory(nn_Computer *computer) {
|
||||||
return computer->totalMemory;
|
return computer->totalMemory;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -451,18 +451,6 @@ const char *nn_getComputerAddress(nn_Computer *computer);
|
|||||||
nn_Universe *nn_getComputerUniverse(nn_Computer *computer);
|
nn_Universe *nn_getComputerUniverse(nn_Computer *computer);
|
||||||
nn_Context *nn_getUniverseContext(nn_Universe *universe);
|
nn_Context *nn_getUniverseContext(nn_Universe *universe);
|
||||||
nn_Context *nn_getComputerContext(nn_Computer *computer);
|
nn_Context *nn_getComputerContext(nn_Computer *computer);
|
||||||
// Sets the memory scale, which defaults to 1.
|
|
||||||
// For context, OC will set the memory scale to 1.8 on 64-bit systems by default.
|
|
||||||
// This scale affects how much real-world memory an amount of VM actually takes up.
|
|
||||||
// This means if the total memory is 4 MiB, and the scale is set to 2, the computer can take up to 8MiB of actual RAM.
|
|
||||||
// However, nn_getTotalMemory() will still return 4 MiB.
|
|
||||||
// The architecture is meant to ensure that the reported free memory is also scaled. As in, the real-world free memory
|
|
||||||
// is divided by this scale to ensure it is within the correct range.
|
|
||||||
// It is undefined behavior to change the memory scale *after* the first call to nn_tick().
|
|
||||||
// Some architectures may ignore this, if they are very low-level and thus
|
|
||||||
// do not have any implicit changes of sizes between 32-bit and 64-bit.
|
|
||||||
void nn_setMemoryScale(nn_Computer *computer, double scale);
|
|
||||||
double nn_getMemoryScale(nn_Computer *computer);
|
|
||||||
|
|
||||||
// Returns the memory usage limit of the computer.
|
// Returns the memory usage limit of the computer.
|
||||||
size_t nn_getTotalMemory(nn_Computer *computer);
|
size_t nn_getTotalMemory(nn_Computer *computer);
|
||||||
|
|||||||
Reference in New Issue
Block a user