diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2026-01-01 19:48:40 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2026-01-01 19:48:40 -0700 |
| commit | 10c542f7a991756f195742389e26ef56a2ec9361 (patch) | |
| tree | d7edc647a026da4ad9b20aafe4a9f1509720de5a | |
| parent | 628174c992a5a740feb4dc119adf8dfb1f89f992 (diff) | |
| download | montis-10c542f7a991756f195742389e26ef56a2ec9361.tar.gz montis-10c542f7a991756f195742389e26ef56a2ec9361.tar.bz2 montis-10c542f7a991756f195742389e26ef56a2ec9361.zip | |
[reorg] - Finished reorg.
Finally have coherent building on top of CMake. And installing actually
works. In addition we use a static wlroots to avoid version hell.
| -rw-r--r-- | .gitignore | 4 | ||||
| -rw-r--r-- | CMakeLists.txt | 50 | ||||
| -rw-r--r-- | plug/package.yaml | 4 | ||||
| -rw-r--r-- | plug/stack.yaml | 2 | ||||
| -rw-r--r-- | rt/CMakeLists.txt | 56 | ||||
| -rw-r--r-- | rt/src/plugin.c | 2 |
6 files changed, 107 insertions, 11 deletions
@@ -1,4 +1,4 @@ -.stack-work/ +plug/.stack-work *~ harness/build wtr.so @@ -10,3 +10,5 @@ wtr_harness # Not sure where these artifacts are coming from. a.out src/Main +build/ +.cache diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..ab7aad2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,50 @@ +cmake_minimum_required(VERSION 3.16) +project(montis LANGUAGES C) + +set(WLROOTS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/wlroots") +set(WLROOTS_BUILD_DIR "${CMAKE_BINARY_DIR}/wlroots") +set(WLROOTS_LIB_STATIC "${WLROOTS_BUILD_DIR}/libwlroots-0.18.a") +set(WLROOTS_LIB_LINK "${WLROOTS_BUILD_DIR}/libwlroots.a") + +add_custom_command( + OUTPUT "${WLROOTS_LIB_LINK}" + COMMAND "${CMAKE_COMMAND}" -E make_directory "${WLROOTS_BUILD_DIR}" + COMMAND meson setup --reconfigure -Ddefault_library=static "${WLROOTS_BUILD_DIR}" "${WLROOTS_SOURCE_DIR}" + COMMAND meson compile -C "${WLROOTS_BUILD_DIR}" + COMMAND "${CMAKE_COMMAND}" -E create_symlink "${WLROOTS_LIB_STATIC}" "${WLROOTS_LIB_LINK}" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Building wlroots via Meson (static)" + VERBATIM +) + +add_custom_target(wlroots_build ALL DEPENDS "${WLROOTS_LIB_LINK}") + +add_subdirectory(rt) +add_dependencies(montis wlroots_build) + +add_custom_target( + plug_build ALL + COMMAND sh -c "if [ -d \"$1\" ] && [ ! -L \"$1\" ]; then rm -rf \"$2\"; mv \"$1\" \"$2\"; fi" sh "${CMAKE_SOURCE_DIR}/plug/.stack-work" "${CMAKE_BINARY_DIR}/stack-work" + COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_BINARY_DIR}/stack-work" + COMMAND "${CMAKE_COMMAND}" -E create_symlink "${CMAKE_BINARY_DIR}/stack-work" "${CMAKE_SOURCE_DIR}/plug/.stack-work" + COMMAND "${CMAKE_COMMAND}" -E chdir "${CMAKE_SOURCE_DIR}/plug" stack build + COMMAND "${CMAKE_COMMAND}" -E rm -f "${CMAKE_SOURCE_DIR}/plug/a.out" + DEPENDS montis + COMMENT "Building Haskell plugin with Stack" + VERBATIM +) + + +install(TARGETS montis RUNTIME DESTINATION bin) + +install(CODE [[ + execute_process( + COMMAND sh -c "find '${CMAKE_BINARY_DIR}/stack-work' -name montis.so -type f | head -n 1" + OUTPUT_VARIABLE _montis_so + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT _montis_so) + message(FATAL_ERROR "montis.so not found in ${CMAKE_BINARY_DIR}/stack-work") + endif() + file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" TYPE FILE FILES "${_montis_so}") +]]) diff --git a/plug/package.yaml b/plug/package.yaml index a9f29ae..d109932 100644 --- a/plug/package.yaml +++ b/plug/package.yaml @@ -63,13 +63,13 @@ executables: - -shared - -dynamic - -no-hs-main - - -lHSrts-1.0.2-ghc9.8.4 + - -lHSrts-1.0.2-ghc9.4.7 - -O3 cc-options: - -g3 - -O2 - -shared - - -I../build/rt/ + - -I../build/ - -I../rt/include/ - -I../wlroots/include - -DWLR_USE_UNSTABLE diff --git a/plug/stack.yaml b/plug/stack.yaml index 2c4375a..0faf47c 100644 --- a/plug/stack.yaml +++ b/plug/stack.yaml @@ -8,7 +8,7 @@ # A snapshot resolver dictates the compiler version and the set of packages # to be used for project dependencies. For example: # -resolver: lts-23.28 +resolver: lts-21.21 # ghc-9.6.4 # lts-21.21 # resolver: nightly-2023-09-24 diff --git a/rt/CMakeLists.txt b/rt/CMakeLists.txt index a7a0a77..22025fb 100644 --- a/rt/CMakeLists.txt +++ b/rt/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10) project ( - wtr_harness + montis VERSION 0.1 LANGUAGES C) @@ -74,11 +74,55 @@ file (GLOB_RECURSE SOURCES src/*.c) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -add_executable (wtr_harness ${SOURCES} ${PLUGIN_LOAD} ${PLUGIN_INTF} +add_executable (montis ${SOURCES} ${PLUGIN_LOAD} ${PLUGIN_INTF} xdg-shell-protocol.c) -target_link_libraries(wtr_harness dl) -target_link_directories(wtr_harness PUBLIC +find_package(PkgConfig REQUIRED) + +pkg_check_modules(WLREQ REQUIRED IMPORTED_TARGET + wayland-server + wayland-client + wayland-egl + wayland-cursor + xkbcommon + pixman-1 + libinput + libudev + libseat + libdrm + gbm + egl + glesv2 +) + +target_link_libraries(montis PRIVATE PkgConfig::WLREQ dl wlroots pthread) + +pkg_check_modules(WLOPT IMPORTED_TARGET + cairo + lcms2 + libdisplay-info + libliftoff + vulkan + xwayland + xcb + xcb-composite + xcb-dri3 + xcb-errors + xcb-ewmh + xcb-icccm + xcb-present + xcb-render + xcb-renderutil + xcb-res + xcb-shm + xcb-xfixes + xcb-xinput +) + +if(WLOPT_FOUND) + target_link_libraries(montis PRIVATE PkgConfig::WLOPT) +endif() + +target_link_directories(montis PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/../wlroots") -target_link_libraries(wtr_harness wlroots-0.18 wayland-server xkbcommon pthread) -target_link_options(wtr_harness PRIVATE -Wl,--wrap=pthread_create) +target_link_options(montis PRIVATE -rdynamic) diff --git a/rt/src/plugin.c b/rt/src/plugin.c index 37a6dd3..0799b9c 100644 --- a/rt/src/plugin.c +++ b/rt/src/plugin.c @@ -116,7 +116,7 @@ static void* plugin_get_seat(void* ctx) { static int load_plugin_from_file_(int argc, char **argv, const char *filename, plugin_t *plugin) { - dlhandle_t lib = dlopen(filename, RTLD_LAZY); + dlhandle_t lib = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); int ec = 0; if (!lib) { |