Skip to content

Commit e446b42

Browse files
nschimmeNils Schimmelmann
authored andcommitted
allow default map from local path for Flatpak
1 parent 60ba7b3 commit e446b42

File tree

8 files changed

+81
-37
lines changed

8 files changed

+81
-37
lines changed

.github/workflows/build-flatpak.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ name: build-flatpak
33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- 'v*'
77
branches:
8-
- master
8+
- master
99
pull_request:
1010
workflow_dispatch:
1111

1212
jobs:
1313
build-flatpak:
1414
runs-on: ubuntu-latest
1515
container:
16-
image: bilelmoussaoui/flatpak-github-actions:gnome-47
16+
image: ghcr.io/flathub-infra/flatpak-github-actions:freedesktop-23.08
1717
options: --privileged
1818

1919
steps:
@@ -26,7 +26,9 @@ jobs:
2626
id: git_info
2727
run: |
2828
git config --global --add safe.directory $(pwd)
29-
VERSION=$(git describe --tags --always --long)
29+
VERSION=$(git tag --points-at HEAD | grep '^v' | sed 's/^v//' || true)
30+
VERSION=${VERSION:-$(git rev-parse --short HEAD || true)}
31+
VERSION=${VERSION:-$(cat MMAPPER_VERSION)}
3032
ARCHITECTURE=$(uname -m)
3133
FILE="org.mume.MMapper-${VERSION}-Linux-${ARCHITECTURE}.flatpak"
3234
echo "VERSION=${VERSION}" >> $GITHUB_ENV

CMakeLists.txt

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if(NOT APPLE)
2323
endif()
2424
option(WITH_WEBSOCKET "Allow connecting to MUME over WebSockets" OFF)
2525
option(WITH_QTKEYCHAIN "Use QtKeychain to securely store your account credentials" OFF)
26-
option(WITH_MAP "Download the default map" ON)
26+
option(WITH_MAP "Download the default map or use the provided map path" ON)
2727
option(WITH_TESTS "Compile unit tests" ON)
2828
option(USE_TIDY "Run clang-tidy with the compiler" OFF)
2929
option(USE_IWYU "Run include-what-you-use with the compiler" OFF)
@@ -379,33 +379,7 @@ endif()
379379

380380
# Download arda.mm2
381381
if(WITH_MAP)
382-
set(MMAPPER_MAP_FILE "${CMAKE_BINARY_DIR}/map/arda.mm2")
383-
if(NOT EXISTS ${MMAPPER_MAP_FILE})
384-
set(MMAPPER_MAP_URL "https://github.com/MUME/MMapper/releases/download/v${MMAPPER_VERSION}/arda.mm2")
385-
message(STATUS "Fetching MMapper Map from: ${MMAPPER_MAP_URL}")
386-
387-
file(DOWNLOAD ${MMAPPER_MAP_URL} ${MMAPPER_MAP_FILE} STATUS MMAPPER_MAP_HTTP_STATUS)
388-
list(GET MMAPPER_MAP_HTTP_STATUS 0 MMAPPER_MAP_STATUS)
389-
390-
if(MMAPPER_MAP_STATUS)
391-
file(REMOVE ${MMAPPER_MAP_FILE})
392-
if(GIT_LAST_ANNOTATED_TAG)
393-
set(MMAPPER_MAP_URL "https://github.com/MUME/MMapper/releases/download/${GIT_LAST_ANNOTATED_TAG}/arda.mm2")
394-
message(STATUS "Map not found. Fetching alternative map from: ${MMAPPER_MAP_URL}")
395-
file(DOWNLOAD ${MMAPPER_MAP_URL} ${MMAPPER_MAP_FILE} STATUS MMAPPER_MAP_HTTP_STATUS)
396-
list(GET MMAPPER_MAP_HTTP_STATUS 0 MMAPPER_MAP_STATUS)
397-
endif()
398-
endif()
399-
400-
if(MMAPPER_MAP_STATUS)
401-
file(REMOVE ${MMAPPER_MAP_FILE})
402-
message(FATAL_ERROR "Unable to download map: use `-DWITH_MAP=OFF` to not require a map")
403-
else()
404-
message(STATUS "Downloaded map to: ${MMAPPER_MAP_FILE}")
405-
endif()
406-
else()
407-
message(STATUS "Using cached MMapper map: ${MMAPPER_MAP_FILE}")
408-
endif()
382+
add_subdirectory(external/map)
409383
else()
410384
message(STATUS "Building without default map as a resource")
411385
add_definitions(/DMMAPPER_NO_MAP)

external/map/CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
string(TOUPPER "${WITH_MAP}" WITH_MAP_UPPER)
2+
if(WITH_MAP_UPPER STREQUAL "OFF" OR WITH_MAP_UPPER STREQUAL "FALSE")
3+
message(STATUS "Map is disabled")
4+
else()
5+
set(MAP_DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/map")
6+
file(MAKE_DIRECTORY "${MAP_DOWNLOAD_DIR}")
7+
if(IS_ABSOLUTE "${WITH_MAP}" OR EXISTS "${WITH_MAP}")
8+
get_filename_component(PROVIDED_MAP_ABS "${WITH_MAP}" ABSOLUTE BASE_DIR "${CMAKE_SOURCE_DIR}")
9+
get_filename_component(MAP_FILENAME "${WITH_MAP}" NAME)
10+
set(MMAPPER_MAP_FILE "${MAP_DOWNLOAD_DIR}/${MAP_FILENAME}")
11+
12+
if(NOT EXISTS "${PROVIDED_MAP_ABS}")
13+
message(FATAL_ERROR "Provided map file does not exist: ${PROVIDED_MAP_ABS}")
14+
endif()
15+
16+
add_custom_command(
17+
OUTPUT "${MMAPPER_MAP_FILE}"
18+
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROVIDED_MAP_ABS}" "${MMAPPER_MAP_FILE}"
19+
DEPENDS "${PROVIDED_MAP_ABS}"
20+
COMMENT "Copying provided map to build directory"
21+
VERBATIM
22+
)
23+
add_custom_target(map ALL DEPENDS "${MMAPPER_MAP_FILE}")
24+
else()
25+
set(MMAPPER_MAP_FILENAME "arda.xml")
26+
set(MMAPPER_MAP_SCHEMA "41")
27+
set(MMAPPER_MAP_FILE "${MAP_DOWNLOAD_DIR}/${MMAPPER_MAP_FILENAME}")
28+
include(ExternalProject)
29+
ExternalProject_Add(map
30+
GIT_REPOSITORY "https://github.com/MUME/arda"
31+
GIT_TAG "${MMAPPER_MAP_SCHEMA}"
32+
33+
CONFIGURE_COMMAND ""
34+
BUILD_COMMAND ""
35+
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_if_different <SOURCE_DIR>/${MMAPPER_MAP_FILENAME} ${MMAPPER_MAP_FILE}
36+
37+
UPDATE_COMMAND ""
38+
BUILD_BYPRODUCTS "${MMAPPER_MAP_FILE}"
39+
)
40+
endif()
41+
endif()
42+
43+
message(STATUS "Map will be included: ${MMAPPER_MAP_FILE}")
44+
set(MMAPPER_MAP_FILE "${MMAPPER_MAP_FILE}" PARENT_SCOPE)

manifest.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
"tag": "0.9.9.7"
4040
}
4141
],
42+
"build-options": {
43+
"build-only": true
44+
},
4245
"build-commands": [
4346
"cp -r glm /app/include/"
4447
]
@@ -88,6 +91,23 @@
8891
"-DCMAKE_PREFIX_PATH=/app"
8992
]
9093
},
94+
{
95+
"name": "map",
96+
"buildsystem": "simple",
97+
"sources": [
98+
{
99+
"type": "git",
100+
"url": "https://github.com/MUME/arda.git",
101+
"tag": "41"
102+
}
103+
],
104+
"build-options": {
105+
"build-only": true
106+
},
107+
"build-commands": [
108+
"cp arda.xml /app/"
109+
]
110+
},
91111
{
92112
"name": "mmapper",
93113
"buildsystem": "cmake-ninja",
@@ -102,7 +122,7 @@
102122
"-DCMAKE_BUILD_TYPE=Release",
103123
"-DWITH_WEBSOCKET=ON",
104124
"-DWITH_QTKEYCHAIN=ON",
105-
"-DWITH_MAP=OFF",
125+
"-DWITH_MAP=/app/arda.xml",
106126
"-DWITH_TESTS=OFF",
107127
"-DOPENSSL_ROOT_DIR=/app",
108128
"-DCMAKE_PREFIX_PATH=/app/lib/qt5:/app"

src/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ endif()
536536
list(APPEND mmapper_RCS "resources/macosx/m-${MMAPPER_BRAND_SUFFIX}.icns")
537537

538538
if(WITH_MAP)
539-
configure_file(resources/arda.qrc ${CMAKE_BINARY_DIR}/map/arda.qrc COPYONLY)
539+
configure_file(resources/arda.qrc.in ${CMAKE_BINARY_DIR}/map/arda.qrc)
540540
list(APPEND mmapper_RCS "${CMAKE_BINARY_DIR}/map/arda.qrc")
541541
endif()
542542

@@ -699,6 +699,10 @@ if(WIN32)
699699
target_link_libraries(mmapper PUBLIC ws2_32)
700700
endif()
701701

702+
if(WITH_MAP)
703+
add_dependencies(mmapper map)
704+
endif()
705+
702706
if(WITH_ZLIB)
703707
target_include_directories(mmapper SYSTEM PUBLIC ${ZLIB_INCLUDE_DIRS})
704708
target_include_directories(mm_global SYSTEM PUBLIC ${ZLIB_INCLUDE_DIRS})

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static void tryAutoLoadMap(MainWindow &mw)
138138
&& tryLoad(mw, QDir{settings.lastMapDirectory}, settings.fileName)) {
139139
return;
140140
}
141-
if (!NO_MAP_RESOURCE && tryLoad(mw, QDir(":/"), "arda.mm2")) {
141+
if (!NO_MAP_RESOURCE && tryLoad(mw, QDir(":/"), "arda")) {
142142
return;
143143
}
144144
qInfo() << "[main] Unable to autoload map";

src/preferences/generalpage.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@
252252
</sizepolicy>
253253
</property>
254254
<property name="placeholderText">
255-
<string>:/arda.mm2</string>
255+
<string>:/arda</string>
256256
</property>
257257
</widget>
258258
</item>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- This generated file exists to load the default map as a resource. -->
22
<!DOCTYPE RCC><RCC version="1.0">
33
<qresource>
4-
<file compress-algo="none">arda.mm2</file>
4+
<file compress-algo="best" alias="arda">${MMAPPER_MAP_FILE}</file>
55
</qresource>
66
</RCC>

0 commit comments

Comments
 (0)