Skip to content

Commit a08ef78

Browse files
committed
Efforts to make the windowserver a cross-platform application
1 parent f180109 commit a08ef78

File tree

86 files changed

+2003
-924
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2003
-924
lines changed

applications/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Builds only the windowserver and its dependencies
2+
3+
SUBDIRS := libjson libproperties libfont libwindow windowserver
4+
5+
.PHONY: all $(SUBDIRS) clean
6+
7+
all: $(SUBDIRS)
8+
9+
$(SUBDIRS):
10+
@$(MAKE) -C $@
11+
12+
clean:
13+
@for dir in $(SUBDIRS); do \
14+
$(MAKE) -C $$dir clean; \
15+
done

applications/libfont/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
ifeq ($(target),windows)
2+
-include ../windows-mingw.mk
3+
else
4+
-include ../../ghost.mk
5+
endif
6+
7+
LIB := libfont.a
8+
CXXFLAGS := -Iinc -I$(FREETYPE_INC) -I$(CAIRO_INC) -I$(SYSROOT)/system/include -std=c++17 # -Wall -Wextra
9+
10+
SRC := $(shell find src -name '*.cpp')
11+
OBJ := $(patsubst src/%.cpp,obj/%.o,$(SRC))
12+
13+
all: $(LIB)
14+
15+
$(LIB): $(OBJ)
16+
$(AR) rcs $@ $^
17+
18+
obj/%.o: src/%.cpp
19+
@mkdir -p $(dir $@)
20+
$(CXX) $(CXXFLAGS) -c $< -o $@
21+
22+
install: $(LIB)
23+
mkdir -p $(SYSROOT)/system/include
24+
mkdir -p $(SYSROOT)/system/lib
25+
cp -r inc/* $(SYSROOT)/system/include/
26+
cp $(LIB) $(SYSROOT)/system/lib/
27+
28+
clean:
29+
rm -rf obj $(LIB)
30+
31+
.PHONY: all install clean

applications/libfont/src/font.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ g_font::g_font(std::string name, uint8_t* source, uint32_t sourceLength) : name(
2727
data = new uint8_t[sourceLength];
2828
if(!data)
2929
{
30-
klog("failed to allocate memory buffer for font '%s'", name);
30+
printf("failed to allocate memory buffer for font '%s'\n", name);
3131
return;
3232
}
3333
memcpy(data, source, sourceLength);
3434

3535
FT_Error error = FT_New_Memory_Face(g_font_manager::getInstance()->getLibraryHandle(), data, sourceLength, 0, &face);
3636
if(error)
3737
{
38-
klog("freetype2 failed at FT_New_Memory_Face with error code %i", error);
38+
printf("freetype2 failed at FT_New_Memory_Face with error code %i\n", error);
3939
delete data;
4040
return;
4141
}
@@ -45,7 +45,7 @@ g_font::g_font(std::string name, uint8_t* source, uint32_t sourceLength) : name(
4545
if(status != CAIRO_STATUS_SUCCESS)
4646
{
4747
FT_Done_Face(face);
48-
klog("cairo failed at cairo_ft_font_face_create_for_ft_face with error %i", status);
48+
printf("cairo failed at cairo_ft_font_face_create_for_ft_face with error %i\n", status);
4949
cairo_face = 0;
5050
delete data;
5151
return;
@@ -80,11 +80,12 @@ bool g_font::readAllBytes(FILE* file, uint32_t offset, uint8_t* buffer, uint32_t
8080

8181
g_font* g_font::load(std::string path, std::string name)
8282
{
83-
FILE* file = fopen(path.c_str(), "r");
83+
FILE* file = fopen(path.c_str(), "rb");
8484
if(!file)
8585
return nullptr;
8686

87-
int64_t length = g_length(fileno(file));
87+
fseek(file, 0, SEEK_END);
88+
long length = ftell(file);
8889
if(length == -1)
8990
{
9091
fclose(file);

applications/libfont/src/font_loader.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ g_font* g_font_loader::getFont(std::string path, std::string name)
4040

4141
g_font* g_font_loader::getSystemFont(std::string name)
4242
{
43+
#if _WIN32
44+
return getFont("../../sysroot/system/graphics/fonts/" + name + ".ttf", name);
45+
#else
4346
return getFont("/system/graphics/fonts/" + name + ".ttf", name);
47+
#endif
4448
}
4549

4650
g_font* g_font_loader::get(std::string name)
@@ -53,5 +57,9 @@ g_font* g_font_loader::get(std::string name)
5357

5458
g_font* g_font_loader::getDefault()
5559
{
60+
#if _WIN32
61+
return getFont("../../sysroot/system/graphics/fonts/default.ttf", "default");
62+
#else
5663
return getFont("/system/graphics/fonts/default.ttf", "default");
64+
#endif
5765
}

applications/libfont/src/font_manager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ void g_font_manager::initializeEngine()
4545
{
4646
FT_Error error = FT_Init_FreeType(&library);
4747
if(error)
48-
klog("freetype2 failed at FT_Init_FreeType with error code %i", error);
48+
printf("freetype2 failed at FT_Init_FreeType with error code %i\n", error);
4949
}
5050

5151
void g_font_manager::destroyEngine()
5252
{
5353
FT_Error error = FT_Done_Library(library);
5454
if(error)
55-
klog("freetype2 failed at FT_Done_Library with error code %i", error);
55+
printf("freetype2 failed at FT_Done_Library with error code %i\n", error);
5656
}
5757

5858
g_font* g_font_manager::getFont(std::string name)
@@ -66,7 +66,7 @@ bool g_font_manager::registerFont(std::string name, g_font* font)
6666
{
6767
if(fontRegistry.count(name) > 0)
6868
{
69-
klog("tried to create font '%s' that already exists", name.c_str());
69+
printf("tried to create font '%s' that already exists\n", name.c_str());
7070
return false;
7171
}
7272

applications/libjson/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
ifeq ($(target),windows)
2+
-include ../windows-mingw.mk
3+
else
4+
-include ../../ghost.mk
5+
endif
6+
7+
LIB := libjson.a
8+
CXXFLAGS := -Iinc -I$(SYSROOT)/system/include -std=c++17 # -Wall -Wextra
9+
10+
SRC := $(shell find src -name '*.cpp')
11+
OBJ := $(patsubst src/%.cpp,obj/%.o,$(SRC))
12+
13+
all: $(LIB)
14+
15+
$(LIB): $(OBJ)
16+
$(AR) rcs $@ $^
17+
18+
obj/%.o: src/%.cpp
19+
@mkdir -p $(dir $@)
20+
$(CXX) $(CXXFLAGS) -c $< -o $@
21+
22+
install: $(LIB)
23+
mkdir -p $(SYSROOT)/system/include
24+
mkdir -p $(SYSROOT)/system/lib
25+
cp -r inc/* $(SYSROOT)/system/include/
26+
cp $(LIB) $(SYSROOT)/system/lib/
27+
28+
clean:
29+
rm -rf obj $(LIB)
30+
31+
.PHONY: all install clean

applications/libjson/src/json.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ std::string g_json::parseString()
4646
{
4747
if(*source != '"')
4848
{
49-
klog("JSON ERROR; expected string at %i", source - start);
49+
printf("JSON ERROR; expected string at %i", source - start);
5050
return "";
5151
}
5252

@@ -73,7 +73,7 @@ std::string g_json::parseString()
7373

7474
if(*source != '"')
7575
{
76-
klog("JSON ERROR; unterminated string at %i", source - start);
76+
printf("JSON ERROR; unterminated string at %i", source - start);
7777
}
7878

7979
++source;
@@ -122,7 +122,7 @@ g_json_node g_json::parseValue()
122122
return g_json_node{nullptr};
123123
}
124124

125-
klog("JSON ERROR; invalid value at %i", source - start);
125+
printf("JSON ERROR; invalid value at %i", source - start);
126126
return g_json_node{nullptr};
127127
}
128128

@@ -143,7 +143,7 @@ g_json_node g_json::parseArray()
143143

144144
if(!consume(','))
145145
{
146-
klog("JSON ERROR; expected comma at %i", source - start);
146+
printf("JSON ERROR; expected comma at %i", source - start);
147147
break;
148148
}
149149
}
@@ -162,7 +162,7 @@ g_json_node g_json::parseObject()
162162
std::string key = parseString();
163163
if(!consume(':'))
164164
{
165-
klog("JSON ERROR; expected colon at %i", source - start);
165+
printf("JSON ERROR; expected colon at %i", source - start);
166166
break;
167167
}
168168
obj[key] = parseValue();
@@ -171,7 +171,7 @@ g_json_node g_json::parseObject()
171171
break;
172172
if(!consume(','))
173173
{
174-
klog("JSON ERROR; expected comma at %i", source - start);
174+
printf("JSON ERROR; expected comma at %i", source - start);
175175
break;
176176
}
177177
skipWhitespace();

applications/libpci/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-include ../../ghost.mk
2+
3+
LIB := libpci.a
4+
LIB_SHARED := libpci.so
5+
CXXFLAGS := -Iinc -Wall -Wextra -std=c++17
6+
LDFLAGS := -shared
7+
8+
SRC := $(shell find src -name '*.cpp')
9+
OBJ := $(patsubst src/%.cpp,obj/%.o,$(SRC))
10+
11+
all: $(LIB) $(LIB_SHARED)
12+
13+
$(LIB): $(OBJ)
14+
$(AR) rcs $@ $^
15+
16+
$(LIB_SHARED): $(OBJ)
17+
$(CXX) $(LDFLAGS) -o $@ $^
18+
19+
obj/%.o: src/%.cpp
20+
@mkdir -p $(dir $@)
21+
$(CXX) $(CXXFLAGS) -c $< -o $@
22+
23+
install: $(LIB) $(LIB_SHARED)
24+
mkdir -p $(SYSROOT)/system/include
25+
mkdir -p $(SYSROOT)/system/lib
26+
cp -r inc/* $(SYSROOT)/system/include/
27+
cp $(LIB) $(SYSROOT)/system/lib/
28+
cp $(LIB_SHARED) $(SYSROOT)/system/lib/
29+
30+
clean:
31+
rm -rf obj $(LIB) $(LIB_SHARED)
32+
33+
.PHONY: all install clean
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
ifeq ($(target),windows)
2+
-include ../windows-mingw.mk
3+
else
4+
-include ../../ghost.mk
5+
endif
6+
7+
LIB := libproperties.a
8+
CXXFLAGS := -Iinc -std=c++17 # -Wall -Wextra
9+
10+
SRC := $(shell find src -name '*.cpp')
11+
OBJ := $(patsubst src/%.cpp,obj/%.o,$(SRC))
12+
13+
all: $(LIB)
14+
15+
$(LIB): $(OBJ)
16+
$(AR) rcs $@ $^
17+
18+
obj/%.o: src/%.cpp
19+
@mkdir -p $(dir $@)
20+
$(CXX) $(CXXFLAGS) -c $< -o $@
21+
22+
install: $(LIB)
23+
mkdir -p $(SYSROOT)/system/include
24+
mkdir -p $(SYSROOT)/system/lib
25+
cp -r inc/* $(SYSROOT)/system/include/
26+
cp $(LIB) $(SYSROOT)/system/lib/
27+
28+
clean:
29+
rm -rf obj $(LIB)
30+
31+
.PHONY: all install clean

applications/libwindow/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
ifeq ($(target),windows)
2+
-include ../windows-mingw.mk
3+
else
4+
-include ../../ghost.mk
5+
endif
6+
7+
LIB := libwindow.a
8+
CXXFLAGS := -Iinc -I$(FREETYPE_INC) -I$(CAIRO_INC) -std=c++17 # -Wall -Wextra
9+
10+
SRC := $(shell find src -name '*.cpp')
11+
OBJ := $(patsubst src/%.cpp,obj/%.o,$(SRC))
12+
13+
all: $(LIB)
14+
15+
$(LIB): $(OBJ)
16+
$(AR) rcs $@ $^
17+
18+
obj/%.o: src/%.cpp
19+
@mkdir -p $(dir $@)
20+
$(CXX) $(CXXFLAGS) -c $< -o $@
21+
22+
install: $(LIB)
23+
mkdir -p $(SYSROOT)/system/include
24+
mkdir -p $(SYSROOT)/system/lib
25+
cp -r inc/* $(SYSROOT)/system/include/
26+
cp $(LIB) $(SYSROOT)/system/lib/
27+
28+
clean:
29+
rm -rf obj $(LIB)
30+
31+
.PHONY: all install clean

0 commit comments

Comments
 (0)