Skip to content

Commit 8c5e1e2

Browse files
committed
Lua is now required
We are moving to the flex output which always needs Lua. Making Lua optional isn't useful any more and just makes code more complicated. This commit makes Lua non-optional.
1 parent c3b18c7 commit 8c5e1e2

File tree

10 files changed

+121
-206
lines changed

10 files changed

+121
-206
lines changed

.github/actions/build-and-test/action.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ runs:
1616

1717
- name: configure
1818
run: |
19-
CMAKE_OPTIONS="-LA -DBUILD_TESTS=ON"
20-
if [ -z "${LUA_VERSION}" ]; then
21-
CMAKE_OPTIONS="$CMAKE_OPTIONS -DWITH_LUA=OFF"
22-
else
23-
CMAKE_OPTIONS="$CMAKE_OPTIONS -DWITH_LUAJIT=${LUAJIT_OPTION}"
24-
fi
19+
CMAKE_OPTIONS="-LA -DBUILD_TESTS=ON -DWITH_LUAJIT=${LUAJIT_OPTION}"
2520
if [ -n "$WITH_PROJ" ]; then
2621
CMAKE_OPTIONS="$CMAKE_OPTIONS -DWITH_PROJ=$WITH_PROJ"
2722
fi

.github/workflows/ci.yml

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,6 @@ jobs:
215215
- uses: ./.github/actions/ubuntu-prerequisites
216216
- uses: ./.github/actions/build-and-test
217217

218-
ubuntu20-pg13-gcc10-release-nolua:
219-
runs-on: ubuntu-20.04
220-
221-
env:
222-
CC: gcc-10
223-
CXX: g++-10
224-
POSTGRESQL_VERSION: 13
225-
POSTGIS_VERSION: 2.5
226-
BUILD_TYPE: Release
227-
PSYCOPG: 2
228-
229-
steps:
230-
- uses: actions/checkout@v4
231-
- uses: ./.github/actions/ubuntu-prerequisites
232-
- uses: ./.github/actions/build-and-test
233-
234218
ubuntu22-pg16-clang14-jit:
235219
runs-on: ubuntu-22.04
236220

@@ -323,23 +307,6 @@ jobs:
323307
- uses: ./.github/actions/ubuntu-prerequisites
324308
- uses: ./.github/actions/build-and-test
325309

326-
ubuntu22-pg16-gcc12-release-nolua:
327-
runs-on: ubuntu-22.04
328-
329-
env:
330-
CC: gcc-12
331-
CXX: g++-12
332-
EXTRA_FLAGS: -Wno-stringop-overread
333-
POSTGRESQL_VERSION: 16
334-
POSTGIS_VERSION: 3
335-
BUILD_TYPE: Release
336-
PSYCOPG: 2
337-
338-
steps:
339-
- uses: actions/checkout@v4
340-
- uses: ./.github/actions/ubuntu-prerequisites
341-
- uses: ./.github/actions/build-and-test
342-
343310
ubuntu22-pg16-clang15-cpp20:
344311
runs-on: ubuntu-22.04
345312

CMakeLists.txt

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ endif()
2828

2929
option(BUILD_TESTS "Build test suite" OFF)
3030
option(BUILD_COVERAGE "Build with coverage" OFF)
31-
option(WITH_LUA "Build with Lua support" ON)
3231
option(WITH_LUAJIT "Build with LuaJIT support" OFF)
3332
option(WITH_PROJ "Build with Projection support" ON)
3433

@@ -184,23 +183,19 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR})
184183
find_package(Osmium 2.17.3 REQUIRED COMPONENTS io)
185184
include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS} ${PROTOZERO_INCLUDE_DIR} ${FMT_INCLUDE_DIR} ${CLI11_INCLUDE_DIR})
186185

187-
if (WITH_LUA)
188-
if (WITH_LUAJIT)
189-
message(STATUS "Building with LuaJIT support")
190-
find_package(LuaJIT REQUIRED)
191-
include_directories(SYSTEM ${LUAJIT_INCLUDE_DIR})
192-
add_definitions(-DHAVE_LUAJIT=1)
193-
else()
194-
message(STATUS "Building with Lua support")
195-
find_package(Lua REQUIRED)
196-
include_directories(SYSTEM ${LUA_INCLUDE_DIR})
197-
endif()
198-
add_definitions(-DHAVE_LUA=1)
199-
find_program(LUA_EXE NAMES lua lua5.4 lua5.3 lua5.2 lua5.1)
186+
if (WITH_LUAJIT)
187+
message(STATUS "Building with LuaJIT support")
188+
find_package(LuaJIT REQUIRED)
189+
include_directories(SYSTEM ${LUAJIT_INCLUDE_DIR})
190+
add_definitions(-DHAVE_LUAJIT=1)
200191
else()
201-
message(STATUS "Building without Lua support")
192+
message(STATUS "Building with Lua (but not LuaJIT) support")
193+
find_package(Lua REQUIRED)
194+
include_directories(SYSTEM ${LUA_INCLUDE_DIR})
202195
endif()
203196

197+
find_program(LUA_EXE NAMES lua lua5.4 lua5.3 lua5.2 lua5.1)
198+
204199
find_package(Boost 1.50 REQUIRED)
205200
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
206201

@@ -235,7 +230,7 @@ endif()
235230

236231
if (LUAJIT_FOUND)
237232
list(APPEND LIBS ${LUAJIT_LIBRARIES})
238-
elseif (LUA_FOUND)
233+
else()
239234
list(APPEND LIBS ${LUA_LIBRARIES})
240235
endif()
241236

@@ -257,28 +252,24 @@ target_link_libraries(osm2pgsql osm2pgsql_lib ${LIBS})
257252
if (${POTRACE_LIBRARY} STREQUAL "POTRACE_LIBRARY-NOTFOUND" OR NOT OPENCV_CORE_FOUND)
258253
message(STATUS "Did not find opencv and/or potrace library. Not building osm2pgsql-gen.")
259254
else()
260-
if (WITH_LUA)
261-
message(STATUS "Found opencv and potrace library. Building osm2pgsql-gen.")
262-
set(BUILD_GEN 1)
263-
include_directories(SYSTEM ${POTRACE_INCLUDE_DIR})
264-
add_executable(osm2pgsql-gen src/gen/osm2pgsql-gen.cpp
265-
src/gen/canvas.cpp
266-
src/gen/gen-base.cpp
267-
src/gen/gen-create.cpp
268-
src/gen/gen-discrete-isolation.cpp
269-
src/gen/gen-rivers.cpp
270-
src/gen/gen-tile-builtup.cpp
271-
src/gen/gen-tile-raster.cpp
272-
src/gen/gen-tile-sql.cpp
273-
src/gen/gen-tile-vector.cpp
274-
src/gen/gen-tile.cpp
275-
src/gen/params.cpp
276-
src/gen/raster.cpp
277-
src/gen/tracer.cpp)
278-
target_link_libraries(osm2pgsql-gen osm2pgsql_lib ${LIBS} ${POTRACE_LIBRARY} ${OpenCV_LIBS})
279-
else()
280-
message(STATUS "No Lua. Not building osm2pgsql-gen.")
281-
endif()
255+
message(STATUS "Found opencv and potrace library. Building osm2pgsql-gen.")
256+
set(BUILD_GEN 1)
257+
include_directories(SYSTEM ${POTRACE_INCLUDE_DIR})
258+
add_executable(osm2pgsql-gen src/gen/osm2pgsql-gen.cpp
259+
src/gen/canvas.cpp
260+
src/gen/gen-base.cpp
261+
src/gen/gen-create.cpp
262+
src/gen/gen-discrete-isolation.cpp
263+
src/gen/gen-rivers.cpp
264+
src/gen/gen-tile-builtup.cpp
265+
src/gen/gen-tile-raster.cpp
266+
src/gen/gen-tile-sql.cpp
267+
src/gen/gen-tile-vector.cpp
268+
src/gen/gen-tile.cpp
269+
src/gen/params.cpp
270+
src/gen/raster.cpp
271+
src/gen/tracer.cpp)
272+
target_link_libraries(osm2pgsql-gen osm2pgsql_lib ${LIBS} ${POTRACE_LIBRARY} ${OpenCV_LIBS})
282273
endif()
283274

284275
#############################################################

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ Required libraries are
5353
* [OpenCV](https://opencv.org/) (Optional, for generalization only)
5454
* [potrace](https://potrace.sourceforge.net/) (Optional, for generalization only)
5555
* [PostgreSQL](https://www.postgresql.org/) client libraries
56-
* [Lua](https://www.lua.org/) (Optional, used for Lua tag transforms
57-
and the flex output)
56+
* [Lua](https://www.lua.org/)
5857
* [Python](https://python.org/) (only for running tests)
5958
* [Psycopg](https://www.psycopg.org/) (only for running tests)
6059

src/CMakeLists.txt

Lines changed: 58 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -5,71 +5,67 @@ add_library(osm2pgsql_lib STATIC)
55
# binaries that use it.
66
target_compile_features(osm2pgsql_lib PUBLIC cxx_std_17)
77

8+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
9+
"${CMAKE_CURRENT_SOURCE_DIR}/init.lua")
10+
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/init.lua" LUA_INIT_CODE)
11+
configure_file(lua-init.cpp.in lua-init.cpp @ONLY)
12+
813
target_sources(osm2pgsql_lib PRIVATE
9-
command-line-app.cpp
10-
command-line-parser.cpp
11-
db-copy.cpp
12-
debug-output.cpp
13-
expire-tiles.cpp
14-
expire-output.cpp
15-
geom.cpp
16-
geom-box.cpp
17-
geom-from-osm.cpp
18-
geom-functions.cpp
19-
geom-pole-of-inaccessibility.cpp
20-
idlist.cpp
21-
input.cpp
22-
logging.cpp
23-
middle.cpp
24-
middle-pgsql.cpp
25-
middle-ram.cpp
26-
node-locations.cpp
27-
node-persistent-cache.cpp
28-
ordered-index.cpp
29-
osmdata.cpp
30-
output-null.cpp
31-
output-pgsql.cpp
32-
output.cpp
33-
pgsql.cpp
34-
pgsql-capabilities.cpp
35-
pgsql-helper.cpp
36-
progress-display.cpp
37-
properties.cpp
38-
reprojection.cpp
39-
table.cpp
40-
taginfo.cpp
41-
tagtransform-c.cpp
42-
tagtransform.cpp
43-
tile.cpp
44-
thread-pool.cpp
45-
util.cpp
46-
wildcmp.cpp
47-
wkb.cpp
14+
command-line-app.cpp
15+
command-line-parser.cpp
16+
db-copy.cpp
17+
debug-output.cpp
18+
expire-output.cpp
19+
expire-tiles.cpp
20+
flex-index.cpp
21+
flex-lua-expire-output.cpp
22+
flex-lua-geom.cpp
23+
flex-lua-index.cpp
24+
flex-lua-table.cpp
25+
flex-table-column.cpp
26+
flex-table.cpp
27+
flex-write.cpp
28+
geom-box.cpp
29+
geom-from-osm.cpp
30+
geom-functions.cpp
31+
geom-pole-of-inaccessibility.cpp
32+
geom.cpp
33+
idlist.cpp
34+
input.cpp
35+
logging.cpp
36+
lua-setup.cpp
37+
lua-utils.cpp
38+
middle-pgsql.cpp
39+
middle-ram.cpp
40+
middle.cpp
41+
node-locations.cpp
42+
node-persistent-cache.cpp
43+
ordered-index.cpp
44+
osmdata.cpp
45+
output-flex.cpp
46+
output-null.cpp
47+
output-pgsql.cpp
48+
output.cpp
49+
pgsql-capabilities.cpp
50+
pgsql-helper.cpp
51+
pgsql.cpp
52+
progress-display.cpp
53+
properties.cpp
54+
reprojection.cpp
55+
table.cpp
56+
taginfo.cpp
57+
tagtransform-c.cpp
58+
tagtransform-lua.cpp
59+
tagtransform.cpp
60+
thread-pool.cpp
61+
tile.cpp
62+
util.cpp
63+
wildcmp.cpp
64+
wkb.cpp
65+
${CMAKE_CURRENT_BINARY_DIR}/lua-init.cpp
66+
${PROJECT_BINARY_DIR}/src/version.cpp
4867
)
4968

50-
if (WITH_LUA)
51-
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
52-
"${CMAKE_CURRENT_SOURCE_DIR}/init.lua")
53-
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/init.lua" LUA_INIT_CODE)
54-
configure_file(lua-init.cpp.in lua-init.cpp @ONLY)
55-
target_sources(osm2pgsql_lib PRIVATE
56-
flex-index.cpp
57-
flex-table.cpp
58-
flex-table-column.cpp
59-
flex-lua-expire-output.cpp
60-
flex-lua-geom.cpp
61-
flex-lua-index.cpp
62-
flex-lua-table.cpp
63-
flex-write.cpp
64-
lua-setup.cpp
65-
lua-utils.cpp
66-
output-flex.cpp
67-
tagtransform-lua.cpp
68-
${CMAKE_CURRENT_BINARY_DIR}/lua-init.cpp)
69-
endif()
70-
71-
target_sources(osm2pgsql_lib PRIVATE ${PROJECT_BINARY_DIR}/src/version.cpp)
72-
7369
if (HAVE_PROJ6)
7470
target_sources(osm2pgsql_lib PRIVATE reprojection-generic-proj6.cpp)
7571
else()

src/command-line-parser.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222

2323
#include <CLI/CLI.hpp>
2424

25-
#ifdef HAVE_LUA
2625
#include <lua.hpp>
27-
#endif
2826

2927
#include <algorithm>
3028
#include <cstdio>
@@ -118,15 +116,11 @@ void print_version()
118116
fmt::print(stderr, "Compiled using the following library versions:\n");
119117
fmt::print(stderr, "Libosmium {}\n", LIBOSMIUM_VERSION_STRING);
120118
fmt::print(stderr, "Proj {}\n", get_proj_version());
121-
#ifdef HAVE_LUA
122119
#ifdef HAVE_LUAJIT
123120
fmt::print(stderr, "{} ({})\n", LUA_RELEASE, LUAJIT_VERSION);
124121
#else
125122
fmt::print(stderr, "{}\n", LUA_RELEASE);
126123
#endif
127-
#else
128-
fmt::print(stderr, "Lua support not included\n");
129-
#endif
130124
}
131125

132126
static void check_options_non_slim(CLI::App const &app)
@@ -446,15 +440,13 @@ options_t parse_command_line(int argc, char *argv[])
446440
->description("Compute area column using Web Mercator coordinates.")
447441
->group("Pgsql output options");
448442

449-
#ifdef HAVE_LUA
450443
// --tag-transform-script
451444
app.add_option("--tag-transform-script", options.tag_transform_script)
452445
->description(
453446
"Specify a Lua script to handle tag filtering and normalisation.")
454447
->option_text("SCRIPT")
455448
->check(CLI::ExistingFile)
456449
->group("Pgsql output options");
457-
#endif
458450

459451
// ----------------------------------------------------------------------
460452
// Expire options

src/output.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@
1212
#include "db-copy.hpp"
1313
#include "format.hpp"
1414
#include "options.hpp"
15+
#include "output-flex.hpp"
1516
#include "output-null.hpp"
1617
#include "output-pgsql.hpp"
1718

18-
#ifdef HAVE_LUA
19-
# include "output-flex.hpp"
20-
static constexpr char const *const flex_backend = "flex, ";
21-
#else
22-
static constexpr char const *const flex_backend = "";
23-
#endif
24-
2519
#include <stdexcept>
2620
#include <string>
2721
#include <utility>
@@ -36,21 +30,19 @@ output_t::create_output(std::shared_ptr<middle_query_t> const &mid,
3630
options);
3731
}
3832

39-
#ifdef HAVE_LUA
4033
if (options.output_backend == "flex") {
4134
return std::make_shared<output_flex_t>(mid, std::move(thread_pool),
4235
options);
4336
}
44-
#endif
4537

4638
if (options.output_backend == "null") {
4739
return std::make_shared<output_null_t>(mid, std::move(thread_pool),
4840
options);
4941
}
5042

5143
throw fmt_error("Output backend '{}' not recognised. Should be one of"
52-
" [pgsql, {}null].",
53-
options.output_backend, flex_backend);
44+
" [pgsql, flex, null].",
45+
options.output_backend);
5446
}
5547

5648
output_t::output_t(std::shared_ptr<middle_query_t> mid,

0 commit comments

Comments
 (0)