Cleanup the build system and add porting instructions
This commit is contained in:
@@ -26,7 +26,14 @@ set(CMAKE_CXX_STANDARD 20)
|
||||
add_compile_definitions(-Dstddbg=stdout)
|
||||
add_compile_options(-g)
|
||||
|
||||
if(BANAN_OS)
|
||||
set(PLATFORM "banan-os" CACHE STRING "target platform")
|
||||
|
||||
set(VALID_PLATFORMS "banan-os" "SDL3")
|
||||
if(NOT PLATFORM IN_LIST VALID_PLATFORMS)
|
||||
message(FATAL_ERROR "platform \"${PLATFORM}\" not known, valid platforms are ${VALID_PLATFORMS}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "banan-os")
|
||||
find_library(BAN ban REQUIRED)
|
||||
add_library(ban SHARED IMPORTED)
|
||||
set_target_properties(ban PROPERTIES IMPORTED_LOCATION "${BAN}")
|
||||
@@ -48,16 +55,19 @@ else()
|
||||
set_target_properties(libc PROPERTIES IMPORTED_LOCATION "${LIBC}")
|
||||
|
||||
add_subdirectory(banan-os/BAN)
|
||||
add_subdirectory(banan-os/userspace/libraries/LibClipboard)
|
||||
add_subdirectory(banan-os/userspace/libraries/LibDEFLATE)
|
||||
add_subdirectory(banan-os/userspace/libraries/LibFont)
|
||||
add_subdirectory(banan-os/userspace/libraries/LibGUI)
|
||||
add_subdirectory(banan-os/userspace/libraries/LibImage)
|
||||
add_subdirectory(banan-os/userspace/libraries/LibInput)
|
||||
|
||||
add_subdirectory(banan-os/userspace/programs/ProgramLauncher)
|
||||
add_subdirectory(banan-os/userspace/programs/Terminal)
|
||||
add_subdirectory(banan-os/userspace/programs/WindowServer)
|
||||
if(PLATFORM STREQUAL "banan-os")
|
||||
add_subdirectory(banan-os/userspace/libraries/LibClipboard)
|
||||
add_subdirectory(banan-os/userspace/libraries/LibFont)
|
||||
add_subdirectory(banan-os/userspace/libraries/LibGUI)
|
||||
add_subdirectory(banan-os/userspace/libraries/LibImage)
|
||||
add_subdirectory(banan-os/userspace/libraries/LibInput)
|
||||
|
||||
add_subdirectory(banan-os/userspace/programs/ProgramLauncher)
|
||||
add_subdirectory(banan-os/userspace/programs/Terminal)
|
||||
add_subdirectory(banan-os/userspace/programs/WindowServer)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(xbanan)
|
||||
|
||||
36
README.md
36
README.md
@@ -1,29 +1,45 @@
|
||||
# xbanan
|
||||
|
||||
An X11 compatibility layer for [banan-os's](https://git.bananymous.com/Bananymous/banan-os) native GUI windowing system.
|
||||
A portable X11 compatibility layer. There are 2 officially supported platforms: [banan-os's](https://git.bananymous.com/Bananymous/banan-os) native GUI windowing system and SDL3.
|
||||
|
||||
## Running on linux
|
||||
|
||||
### Prerequisites
|
||||
|
||||
You need to have SDL3 development library and X11 headers installed on your system.
|
||||
|
||||
### Building
|
||||
```sh
|
||||
git clone --recursive https://git.bananymous.com/Bananymous/xbanan.git
|
||||
cd xbanan
|
||||
|
||||
cd banan-os
|
||||
git apply ../0001-linux-window-server-sdl2.patch
|
||||
cd ..
|
||||
|
||||
cmake -B build -S . -G Ninja
|
||||
cmake --build build
|
||||
cmake -B build -S . -DPLATFORM=SDL3
|
||||
cmake --build build --parallel $(nproc)
|
||||
```
|
||||
|
||||
### Running
|
||||
|
||||
To start the WindowServer, run the following command in project root
|
||||
To start xbanan, run the following command in project root
|
||||
```sh
|
||||
./build/banan-os/userspace/programs/WindowServer/WindowServer
|
||||
./build/xbanan/xbanan
|
||||
```
|
||||
To run X11 apps specify `DISPLAY=:69` environment variable. For example
|
||||
To run X11 apps, specify `DISPLAY=:69` environment variable. For example
|
||||
```sh
|
||||
DISPLAY=:69 xeyes
|
||||
```
|
||||
|
||||
## Porting to a new platform
|
||||
|
||||
Add your platform to the `VALID_PLATFORMS` list in the root `CMakeLists.txt` file. Create a directory for your platform in `xbanan/<your platform>` and define the needed source files and libraries in `xbanan/CMakeLists.txt` based on your platform.
|
||||
|
||||
### Barebones
|
||||
|
||||
For the simplest port, you need to implement 3 functions: `initialize`, `create_window` and `invalidate`. Define the variable `g_platform_ops` declared in `xbanan/Platform.h` with function pointers to the your functions. You can look at the existing platforms and the `xbanan/Platform.h` header for help.
|
||||
|
||||
### Events
|
||||
|
||||
To handle events, you have to hook an event receiver fd for your platform using `register_event_fd` declared in `xbanan/Events.h` and define the `poll_events` function in `g_platform_ops`. When the registered fd becomes readable, xbanan will call your platform's `poll_events` function. This function should drain all of the pending events and call appropriate `on_*_event` function declared in the events header. If your platform does not expose fd(s) that can be polled for events, you can do what the SDL3 port does and create an eventfd/pipe that gets signaled periodically.
|
||||
|
||||
### Installation
|
||||
|
||||
To install xbanan to sysroot, just copy the `build/xbanan/xbanan` to the destination. xbanan is statically linked against the libraries from this repository so you don't have to care about those. **DO NOT** use the cmake's install target, as that installs banan-os libraries to the root of the sysroot. You also need to have the x11 misc fonts at `FONT_PATH/misc` in your sysroot if you want server side font support. The fonts are shipped (public domain) with xbanan, so you can just copy `fonts/misc` into `FONT_PATH`. You can specify the `FONT_PATH` with cmake using `-DFONT_PATH=...` when configuring.
|
||||
|
||||
@@ -13,6 +13,8 @@ set(XBANAN_SOURCES
|
||||
SafeGetters.cpp
|
||||
)
|
||||
|
||||
set(FONT_PATH ${CMAKE_SOURCE_DIR}/fonts CACHE STRING "path to X11 fonts")
|
||||
|
||||
option(ENABLE_GLX "enable glx extension" ON)
|
||||
if(ENABLE_GLX)
|
||||
list(APPEND XBANAN_SOURCES ExtGLX.cpp)
|
||||
@@ -23,13 +25,6 @@ if(ENABLE_SHM)
|
||||
list(APPEND XBANAN_SOURCES ExtSHM.cpp)
|
||||
endif()
|
||||
|
||||
set(PLATFORM "banan-os" CACHE STRING "target platform")
|
||||
|
||||
set(VALID_PLATFORMS "banan-os" "SDL3")
|
||||
if(NOT PLATFORM IN_LIST VALID_PLATFORMS)
|
||||
message(FATAL_ERROR "platform \"${PLATFORM}\" not known, valid platforms are ${VALID_PLATFORMS}")
|
||||
endif()
|
||||
|
||||
if(PLATFORM STREQUAL "banan-os")
|
||||
list(APPEND XBANAN_SOURCES banan-os/banan-os.cpp)
|
||||
elseif(PLATFORM STREQUAL "SDL3")
|
||||
@@ -40,6 +35,8 @@ add_executable(xbanan ${XBANAN_SOURCES})
|
||||
banan_link_library(xbanan ban)
|
||||
banan_link_library(xbanan libdeflate)
|
||||
|
||||
target_compile_definitions(xbanan PRIVATE FONT_PATH="${FONT_PATH}")
|
||||
|
||||
if(PLATFORM STREQUAL "banan-os")
|
||||
banan_link_library(xbanan libgui)
|
||||
banan_link_library(xbanan libinput)
|
||||
@@ -56,7 +53,4 @@ target_compile_options(xbanan PRIVATE
|
||||
-Wno-unused-but-set-variable
|
||||
)
|
||||
|
||||
#target_compile_options(xbanan PRIVATE -fsanitize=address)
|
||||
#target_link_options(xbanan PRIVATE -fsanitize=address)
|
||||
|
||||
install(TARGETS xbanan OPTIONAL)
|
||||
|
||||
@@ -385,7 +385,7 @@ static BAN::ErrorOr<BAN::RefPtr<PCFFont>> parse_font(const BAN::String& path)
|
||||
font->font_ascent = font->max_bounds.ascent;
|
||||
font->font_descent = font->max_bounds.descent;
|
||||
|
||||
font->is_cursor_font = (path == "fonts/misc/cursor.pcf.gz"_sv);
|
||||
font->is_cursor_font = (path == FONT_PATH "/misc/cursor.pcf.gz"_sv);
|
||||
|
||||
return font;
|
||||
}
|
||||
@@ -393,7 +393,7 @@ static BAN::ErrorOr<BAN::RefPtr<PCFFont>> parse_font(const BAN::String& path)
|
||||
__attribute__((constructor))
|
||||
static void initialize_fonts()
|
||||
{
|
||||
const char* font_path = "fonts/misc";
|
||||
const char* font_path = FONT_PATH "/misc";
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
@@ -42,7 +42,8 @@ enum class SystemCursorType
|
||||
ResizeHorizontal,
|
||||
};
|
||||
|
||||
// initialize, poll_events, create_window and invalidate are required
|
||||
// initialize, create_window and invalidate are required
|
||||
// poll_events is required when an event fd is registered
|
||||
struct PlatformOps
|
||||
{
|
||||
/* Do platform initialization */
|
||||
|
||||
Reference in New Issue
Block a user