Skip to content

Commit

Permalink
CONFIGURE: Added possibility to define engine components. Turn lua in…
Browse files Browse the repository at this point in the history
…to component

Components are parts of ScummVM common code that could be optionally
built only when the relevant engines are enabled
  • Loading branch information
sev- committed Dec 1, 2024
1 parent 6f4ffe3 commit 1301cd0
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 21 deletions.
23 changes: 11 additions & 12 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ add_engine() {
set_var _engine_${1}_subengines "${4}"
set_var _engine_${1}_base "${5}"
set_var _engine_${1}_deps "${6}"
set_var _engine_${1}_components "${7}"
for sub in ${4}; do
set_var _engine_${sub}_sub "yes"
set_var _engine_${sub}_parent "${1}"
Expand All @@ -122,6 +123,14 @@ add_feature() {
set_var _feature_${1}_settings "${3}"
}

# Add a component: id name settings-list
add_component() {
_components="${_components} ${1}"

set_var _component_${1}_name "${2}"
set_var _component_${1}_settings "${3}"
}

_srcdir=`dirname $0`

# Read list of engines
Expand Down Expand Up @@ -189,7 +198,6 @@ _verbose_build=no
_werror_build=no
_text_console=no
_mt32emu=yes
_lua=yes
_build_scalers=yes
_build_hq_scalers=yes
_build_edge_scalers=yes
Expand Down Expand Up @@ -302,11 +310,12 @@ add_feature tinygl "TinyGL" "_tinygl"
add_feature vpx "libvpx" "_vpx"
add_feature vorbis "Vorbis file support" "_vorbis _tremor"
add_feature zlib "zlib" "_zlib"
add_feature lua "lua" "_lua"
add_feature fribidi "FriBidi" "_fribidi"
add_feature test_cxx11 "Test C++11" "_test_cxx11"
add_feature imgui "imgui" "_imgui"

add_component lua "lua" "USE_LUA"

# Directories for installing ScummVM.
# This list is closely based on what GNU autoconf does,
# although the default value for datadir differs.
Expand Down Expand Up @@ -3582,7 +3591,6 @@ if test -n "$_host"; then
_nuked_opl=no
_tinygl=no
_bink=no
_lua=no
_png=no
_freetype2=no
_port_mk="backends/platform/ds/ds.mk"
Expand Down Expand Up @@ -4962,11 +4970,6 @@ echo "$_detection_features_full"
#
define_in_config_if_yes "$_mt32emu" 'USE_MT32EMU'

#
# Check whether Lua support is requested
#
define_in_config_if_yes "$_lua" 'USE_LUA'

#
# Check whether Nuked OPL emulator support is disabled
#
Expand Down Expand Up @@ -7150,10 +7153,6 @@ if test "$_mt32emu" = yes ; then
echo_n ", MT-32 emulator"
fi

if test "$_lua" = yes ; then
echo_n ", Lua"
fi

if test "$_nuked_opl" = yes ; then
echo_n ", Nuked OPL emulator"
fi
Expand Down
58 changes: 58 additions & 0 deletions engines.awk
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ function add_to_config_h_if_yes(value, define) {
print("/* " define " */") >> config_h
}

function add_line_to_config_h(line) {
print(line) >> config_h
}

#
# Feature handling functions
#
Expand Down Expand Up @@ -85,6 +89,11 @@ function get_engine_dependencies(engine, deps) {
return get_values("_engine_" engine "_deps", deps)
}

# Get the components
function get_engine_components(engine, deps) {
return get_values("_engine_" engine "_components", components)
}

# Get the base engine game support description
function get_engine_base(engine) {
return ENVIRON["_engine_" engine "_base"]
Expand All @@ -107,6 +116,18 @@ function disable_engine(engine) {
ENVIRON["_engine_" engine "_build"] = "no"
}

function enable_component(comp) {
ENVIRON["_component_" comp "_enabled"] = "yes"
}

function get_component_enabled(comp) {
return ENVIRON["_component_" comp "_enabled"]
}

function get_component_settings(comp) {
return ENVIRON["_component_" comp "_settings"]
}

function check_engine_deps(engine) {
unmet_deps = ""

Expand All @@ -127,6 +148,17 @@ function check_engine_deps(engine) {
}
}

function check_engine_components(engine) {
# Check whether the engine is enabled
if (get_engine_build(engine) != "no") {
# Collect components
compcount = get_engine_components(engine, components)
for (c = 1; c <= compcount; c++) {
enable_component(components[c])
}
}
}

# Prepare the strings about the engines to build
function prepare_engine_build_strings(engine) {
if (string = get_engine_build_string(engine, "static"))
Expand Down Expand Up @@ -267,6 +299,7 @@ END {
for (e = 1; e <= engine_count; e++) {
engine = engines[e]
check_engine_deps(engine)
check_engine_components(engine)
if (get_engine_sub(engine) == "no") {
# It's a main engine
if (get_engine_build(engine) == "no") {
Expand Down Expand Up @@ -342,6 +375,31 @@ END {
print_engines("Engines Skipped:", _engines_skipped, _skipped)
print_engines("WARNING: This ScummVM build contains the following UNSTABLE engines:", _engines_built_wip, _wip)

#
# Process components
#
add_line_to_config_h("\n/* componenst */")
add_line_to_config_mk("\n# components")
components_count = get_values("_components", components)
comp_enabled = ""
for (c = 1; c <= components_count; c++) {
setting = get_component_settings(components[c])
add_to_config_h_if_yes(get_component_enabled(components[c]), "#define " setting)

if (get_component_enabled(components[c]) == "yes") {
add_line_to_config_mk(setting "=1")
comp_enabled = comp_enabled components[c] " "
} else {
add_line_to_config_mk("# " setting)
}
}
add_line_to_config_h("/* end componenst */")
add_line_to_config_mk("# end componenst")

if (comp_enabled == "")
comp_enabled = "<none>"
print("\nComponents Enabled: " comp_enabled)

# Ensure engines folder exists prior to trying to generate
# files into it (used for out-of-tree-builds)
system("mkdir -p engines")
Expand Down
4 changes: 2 additions & 2 deletions engines/hdb/configure.engine
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
add_engine hdb "Hyperspace Delivery Boy!" yes "" "" "16bit highres lua"
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] [components]
add_engine hdb "Hyperspace Delivery Boy!" yes "" "" "16bit highres" "lua"
4 changes: 2 additions & 2 deletions engines/sword25/configure.engine
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
add_engine sword25 "Broken Sword 2.5" yes "" "" "png 16bit highres lua theoradec"
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] [components]
add_engine sword25 "Broken Sword 2.5" yes "" "" "png 16bit highres theoradec" "lua"
4 changes: 2 additions & 2 deletions engines/tetraedge/configure.engine
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
add_engine tetraedge "Tetraedge" yes "" "" "highres 3d freetype2 vorbis png jpeg lua theoradec"
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] [components]
add_engine tetraedge "Tetraedge" yes "" "" "highres 3d freetype2 vorbis png jpeg theoradec" "lua"
6 changes: 3 additions & 3 deletions engines/ultima/configure.engine
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] [components]
add_engine ultima "Ultima" yes "ultima1 ultima4 ultima6 ultima8"
add_engine ultima1 "Ultima I - The First Age of Darkness" no "" "" ""
add_engine ultima1 "Ultima I - The First Age of Darkness" no "" "" ""
add_engine ultima4 "Ultima IV - Quest of the Avatar" yes "" "" "16bit"
add_engine ultima6 "Ultima VI = The False Prophet" yes "" "" "highres 16bit lua"
add_engine ultima6 "Ultima VI = The False Prophet" yes "" "" "highres 16bit" "lua"
add_engine ultima8 "Ultima VIII - Pagan" yes "" "" "highres 16bit"

0 comments on commit 1301cd0

Please sign in to comment.