Skip to content

Commit

Permalink
Merge pull request #375 from digitall/engineAutoPlug
Browse files Browse the repository at this point in the history
RFC: Pluggable Engines #2 (No Python, just evolution of current configure shell and make code)
  • Loading branch information
lordhoto committed Nov 26, 2013
2 parents e718719 + 6b0f111 commit 0e017f0
Show file tree
Hide file tree
Showing 58 changed files with 456 additions and 549 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -105,6 +105,9 @@ project.xcworkspace

/plugins

/engines/plugins_table.h
/engines/engines.mk

/test/runner
/test/runner.cpp
/test/*.dSYM
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Expand Up @@ -82,7 +82,8 @@ EXECUTABLE := $(EXEPRE)scummvm$(EXEEXT)
include $(srcdir)/Makefile.common

# check if configure has been run or has been changed since last run
config.h config.mk: $(srcdir)/configure $(srcdir)/engines/configure.engines
ENGINE_SUBDIRS_CONFIGURE := $(wildcard $(srcdir)/engines/*/configure.engine)
config.h: $(srcdir)/configure $(ENGINE_SUBDIRS_CONFIGURE)
ifeq "$(findstring config.mk,$(MAKEFILE_LIST))" "config.mk"
@echo "Running $(srcdir)/configure with the last specified parameters"
@sleep 2
Expand All @@ -94,6 +95,14 @@ else
$(error You need to run $(srcdir)/configure before you can run make. Check $(srcdir)/configure --help for a list of parameters)
endif

config.mk engines/plugins_table.h engines/engines.mk: config.h
@if test -f $@; then \
touch $@; \
else \
rm -f config.h; \
$(MAKE) config.h; \
fi

ifneq ($(origin port_mk), undefined)
include $(srcdir)/$(port_mk)
endif
6 changes: 3 additions & 3 deletions Makefile.common
Expand Up @@ -16,7 +16,7 @@ all: $(EXECUTABLE) plugins
PLUGINS :=
MODULES := test devtools base $(MODULES)

-include $(srcdir)/engines/engines.mk
-include engines/engines.mk

# After the game specific modules follow the shared modules
MODULES += \
Expand Down Expand Up @@ -79,7 +79,7 @@ $(EXECUTABLE): $(OBJS)
$(QUIET_LINK)$(LD) $(LDFLAGS) $(PRE_OBJS_FLAGS) $+ $(POST_OBJS_FLAGS) $(LIBS) -o $@

distclean: clean clean-devtools
$(RM) config.h config.mk config.log
$(RM) config.h config.mk config.log engines/engines.mk engines/plugins_table.h

clean:
$(RM_REC) $(DEPDIRS)
Expand Down Expand Up @@ -147,7 +147,7 @@ endif
# recreate them (which it can't), and in particular from looking for potential
# source files. This can save quite a bit of disk access time.
.PHONY: $(wildcard $(addsuffix /*.d,$(DEPDIRS))) $(addprefix $(srcdir)/, $(addsuffix /module.mk,$(MODULES))) \
$(srcdir)/$(port_mk) $(srcdir)/rules.mk $(srcdir)/engines/engines.mk
$(srcdir)/$(port_mk) $(srcdir)/rules.mk

######################################################################
# Get the current version information
Expand Down
72 changes: 70 additions & 2 deletions configure
Expand Up @@ -97,7 +97,9 @@ add_feature() {
_srcdir=`dirname $0`

# Read list of engines
. $_srcdir/engines/configure.engines
for i in $_srcdir/engines/*/configure.engine; do
. "$i"
done

#
# Default settings
Expand Down Expand Up @@ -4197,8 +4199,18 @@ for engine in $_engines; do
fi
done

# Prepare the information to be shown
# Sort engines to place our headline engine at start...
# No technical reason, just historical convention
headline_engine=scumm
_sorted_engines="${headline_engine}"
for engine in $_engines; do
if test "${engine}" != "${headline_engine}" ; then
_sorted_engines="${_sorted_engines} ${engine}"
fi
done

# Prepare the information to be shown
for engine in $_sorted_engines; do
if test "`get_engine_sub $engine`" = "no" ; then
# It's a main engine
prepare_engine_build_strings $engine
Expand Down Expand Up @@ -4380,3 +4392,59 @@ include \$(srcdir)/Makefile
EOF

fi

# Ensure engines folder exists prior to trying to generate
# files into it (used for out-of-tree-builds)
mkdir -p engines

echo "Creating engines/engines.mk"
cat > engines/engines.mk << EOF
# This file is automatically generated by configure
# DO NOT EDIT MANUALLY
# This file is being included by "Makefile.common"
EOF

for engine in $_sorted_engines; do
j=`echo $engine | tr '[:lower:]' '[:upper:]'`
if test "`get_engine_sub $engine`" = "no" ; then
# main engine
cat >> engines/engines.mk << EOF
ifdef ENABLE_$j
DEFINES += -DENABLE_$j=\$(ENABLE_$j)
MODULES += engines/$engine
EOF

for subeng in `get_engine_subengines $engine` ; do
k=`echo $subeng | tr '[:lower:]' '[:upper:]'`
cat >> engines/engines.mk << EOF
ifdef ENABLE_$k
DEFINES += -DENABLE_$k
endif
EOF
done

cat >> engines/engines.mk << EOF
endif
EOF
fi
done

echo "Creating engines/plugins_table.h"
cat > engines/plugins_table.h << EOF
/* This file is automatically generated by configure */
/* DO NOT EDIT MANUALLY */
// This file is being included by "base/plugins.cpp"
EOF

for engine in $_sorted_engines; do
if test "`get_engine_sub $engine`" = "no" ; then
j=`echo $engine | tr '[:lower:]' '[:upper:]'`
cat >> engines/plugins_table.h << EOF
#if PLUGIN_ENABLED_STATIC($j)
LINK_PLUGIN($j)
#endif
EOF
fi
done
1 change: 1 addition & 0 deletions devtools/create_project/codeblocks.cpp
Expand Up @@ -120,6 +120,7 @@ void CodeBlocksProvider::createProjectFile(const std::string &name, const std::s
"\t\t\t\t\t<Add directory=\"..\\..\\engines\" />\n"
"\t\t\t\t\t<Add directory=\"..\\..\\common\" />\n"
"\t\t\t\t\t<Add directory=\"..\\..\" />\n"
"\t\t\t\t\t<Add directory=\".\\\" />\n"
"\t\t\t\t</Compiler>\n";

//////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions devtools/create_project/config.h
Expand Up @@ -27,6 +27,7 @@
#define PROJECT_NAME "scummvm" // Used for folders, icons, resources and project/solution name
#define LIBS_DEFINE "SCUMMVM_LIBS" // Name of the include environment variable
#define REVISION_DEFINE "SCUMMVM_INTERNAL_REVISION"
#define FIRST_ENGINE "scumm" // Name of the engine which should be sorted as first element

#define ENABLE_LANGUAGE_EXTENSIONS "" // Comma separated list of projects that need language extensions
#define DISABLE_EDIT_AND_CONTINUE "tinsel,tony,scummvm" // Comma separated list of projects that need Edit&Continue to be disabled for co-routine support (the main project is automatically added)
Expand Down

0 comments on commit 0e017f0

Please sign in to comment.