Fixes to make the 2.1 branch working on OS4 - WIP

This commit is contained in:
George Sokianos 2022-04-04 11:31:17 +01:00
parent aa14bd6a88
commit ab72e26080
7 changed files with 149 additions and 114 deletions

View File

@ -5,17 +5,20 @@
# #
LiteXL_OBJ := \ LiteXL_OBJ := \
src/dirmonitor.o src/main.o src/rencache.o src/renderer.o \ src/main.o src/rencache.o src/renderer.o src/renwindow.o \
src/renwindow.o src/api/api.o src/api/regex.o \ src/api/dirmonitor/os4.o \
src/api/renderer.o src/api/system.o src/platform/amigaos4.o src/api/api.o src/api/dirmonitor.o src/api/regex.o \
src/api/renderer.o src/api/system.o \
src/platform/amigaos4.o
# src/api/process.o
outfile := lite outfile := lite
compiler := gcc compiler := gcc
cxxcompiler := g++ cxxcompiler := g++
INCPATH := -Isrc -Ilib/dmon -I/sdk/local/newlib/include/SDL2 -I/sdk/local/common/include/freetype2 INCPATH := -Isrc -Ilib/dmon -I/sdk/local/newlib/include/SDL2 -I/sdk/local/common/include/freetype2
DFLAGS := -D__USE_INLINE__ -DLITE_XL_DATA_USE_EXEDIR DFLAGS := -D__USE_INLINE__ -DLITE_XL_DATA_USE_EXEDIR -DDIRMONITOR_BACKEND=os4 -DDIRMONITOR_OS4
# -DLITE_USE_SDL_RENDERER # -DLITE_USE_SDL_RENDERER
# -Wextra -Wall # -Wextra -Wall
CFLAGS := -Werror -Wwrite-strings -O3 -g -std=gnu11 -fno-strict-aliasing CFLAGS := -Werror -Wwrite-strings -O3 -g -std=gnu11 -fno-strict-aliasing
@ -43,10 +46,8 @@ LiteXL: $(LiteXL_OBJ)
@echo "Compiling $<" @echo "Compiling $<"
@$(compiler) -c $< -o $*.o $(CFLAGS) $(INCPATH) $(DFLAGS) @$(compiler) -c $< -o $*.o $(CFLAGS) $(INCPATH) $(DFLAGS)
src/dirmonitor.o: src/dirmonitor.c src/platform/amigaos4.h
src/main.o: src/main.c src/api/api.h src/rencache.h \ src/main.o: src/main.c src/api/api.h src/rencache.h \
src/renderer.h src/platform/amigaos4.h src/dirmonitor.h src/renderer.h src/platform/amigaos4.h
src/rencache.o: src/rencache.c src/rencache.o: src/rencache.c
@ -54,8 +55,12 @@ src/renderer.o: src/renderer.c
src/renwindow.o: src/renwindow.c src/renwindow.o: src/renwindow.c
src/api/dirmonitor/os4.o: src/api/dirmonitor/os4.c
src/api/api.o: src/api/api.c src/api/api.o: src/api/api.c
src/api/dirmonitor.o: src/api/dirmonitor.c src/api/dirmonitor/os4.c
src/api/regex.o: src/api/regex.c src/api/regex.o: src/api/regex.c
src/api/renderer.o: src/api/renderer.c src/api/renderer.o: src/api/renderer.c
@ -65,8 +70,6 @@ src/api/system.o: src/api/system.c
src/platform/amigaos4.o: src/platform/amigaos4.c src/platform/amigaos4.o: src/platform/amigaos4.c
release: release:
mkdir -p release/LiteXL mkdir -p release/LiteXL
cp release_files/* release/LiteXL/ -r cp release_files/* release/LiteXL/ -r
@ -79,3 +82,4 @@ release:
cp README_OS4.md release/LiteXL/ cp README_OS4.md release/LiteXL/
cp LICENSE release/LiteXL/ cp LICENSE release/LiteXL/
lha -aeqr3 a LiteXL.lha release/ lha -aeqr3 a LiteXL.lha release/

View File

@ -13,7 +13,8 @@ function dirwatch.new()
scanned = {}, scanned = {},
watched = {}, watched = {},
reverse_watched = {}, reverse_watched = {},
monitor = dirmonitor.new(), -- monitor = dirmonitor.new(),
monitor = 0,
windows_watch_top = nil, windows_watch_top = nil,
windows_watch_count = 0 windows_watch_count = 0
} }
@ -36,23 +37,25 @@ function dirwatch:watch(directory, bool)
if not self.watched[directory] and not self.scanned[directory] then if not self.watched[directory] and not self.scanned[directory] then
if PLATFORM == "Windows" then if PLATFORM == "Windows" then
if not self.windows_watch_top or directory:find(self.windows_watch_top, 1, true) ~= 1 then if not self.windows_watch_top or directory:find(self.windows_watch_top, 1, true) ~= 1 then
-- Get the highest level of directory that is common to this directory, and the original. -- Get the highest level of directory that is common to this directory, and the original.
local target = directory local target = directory
while self.windows_watch_top and self.windows_watch_top:find(target, 1, true) ~= 1 do while self.windows_watch_top and self.windows_watch_top:find(target, 1, true) ~= 1 do
target = common.dirname(target) target = common.dirname(target)
end end
if target ~= self.windows_watch_top then if target ~= self.windows_watch_top then
local value = self.monitor:watch(target) local value = self.monitor:watch(target)
if value and value < 0 then if value and value < 0 then
return self:scan(directory) return self:scan(directory)
end end
self.windows_watch_top = target self.windows_watch_top = target
self.windows_watch_count = self.windows_watch_count + 1 self.windows_watch_count = self.windows_watch_count + 1
end end
end end
self.watched[directory] = true self.watched[directory] = true
else else
local value = self.monitor:watch(directory) -- TODO: Fix value to get it from monitor
-- local value = self.monitor:watch(directory)
local value = -1
-- If for whatever reason, we can't watch this directory, revert back to scanning. -- If for whatever reason, we can't watch this directory, revert back to scanning.
-- Don't bother trying to find out why, for now. -- Don't bother trying to find out why, for now.
if value and value < 0 then if value and value < 0 then
@ -218,3 +221,4 @@ end
return dirwatch return dirwatch

View File

@ -1321,3 +1321,4 @@ end
return core return core

View File

@ -4,14 +4,14 @@ int luaopen_system(lua_State *L);
int luaopen_renderer(lua_State *L); int luaopen_renderer(lua_State *L);
int luaopen_regex(lua_State *L); int luaopen_regex(lua_State *L);
// int luaopen_process(lua_State *L); // int luaopen_process(lua_State *L);
// int luaopen_dirmonitor(lua_State* L); int luaopen_dirmonitor(lua_State* L);
static const luaL_Reg libs[] = { static const luaL_Reg libs[] = {
{ "system", luaopen_system }, { "system", luaopen_system },
{ "renderer", luaopen_renderer }, { "renderer", luaopen_renderer },
{ "regex", luaopen_regex }, { "regex", luaopen_regex },
// { "process", luaopen_process }, // { "process", luaopen_process },
// { "dirmonitor", luaopen_dirmonitor }, { "dirmonitor", luaopen_dirmonitor },
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -5,6 +5,8 @@
#elif __linux__ #elif __linux__
#include <sys/inotify.h> #include <sys/inotify.h>
#include <limits.h> #include <limits.h>
#elif __amigaos4__
// #define DIRMONITOR_BACKEND 'os4'
#else #else
#include <sys/event.h> #include <sys/event.h>
#endif #endif
@ -94,3 +96,4 @@ int luaopen_dirmonitor(lua_State* L) {
lua_setfield(L, -2, "__index"); lua_setfield(L, -2, "__index");
return 1; return 1;
} }

23
src/api/dirmonitor/os4.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdlib.h>
struct dirmonitor {
};
struct dirmonitor* init_dirmonitor_os4() {
return NULL;
}
void deinit_dirmonitor_os4(struct dirmonitor* monitor) {
}
int check_dirmonitor_os4(struct dirmonitor* monitor, int (*change_callback)(int, const char*, void*), void* data) {
return -1;
}
int add_dirmonitor_os4(struct dirmonitor* monitor, const char* path) {
return -1;
}
void remove_dirmonitor_os4(struct dirmonitor* monitor, int fd) {
}