From ad368596075ba62f89531bcda05671f2868fa951 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 8 Feb 2014 12:42:00 -0800 Subject: [PATCH] Port plugin building to AMBuild. Former-commit-id: 9ac73de5b247da341b0b4cdf00ec3c7e0472be82 --- AMBuildScript | 3 + compiler/amxxpc/AMBuilder | 2 +- compiler/libpc300/AMBuilder | 2 +- compiler/libpc300/sc.h | 1 + compiler/libpc300/sc1.c | 3 + compiler/libpc300/sc2.c | 3 + compiler/libpc300/scvars.c | 1 + plugins/AMBuilder | 112 ++++++++++++++++++++++++++++++++++++ 8 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 plugins/AMBuilder diff --git a/AMBuildScript b/AMBuildScript index 9c1dd5c9..f356c67a 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -5,7 +5,9 @@ class AMXXConfig(object): def __init__(self): self.binaries = [] self.modules = [] + self.plugins = {} self.libpc300 = None + self.amxxpc = None self.metamod_path = None self.hlsdk_path = None self.mysql_path = None @@ -253,6 +255,7 @@ builder.RunBuildScripts( 'dlls/tfcx/AMBuilder', 'dlls/ts/tsfun/AMBuilder', 'dlls/ts/tsx/AMBuilder', + 'plugins/AMBuilder', ], { 'AMXX': AMXX diff --git a/compiler/amxxpc/AMBuilder b/compiler/amxxpc/AMBuilder index 5cac7eb1..00c36774 100644 --- a/compiler/amxxpc/AMBuilder +++ b/compiler/amxxpc/AMBuilder @@ -23,4 +23,4 @@ binary.sources = [ 'Binary.cpp', ] -AMXX.modules += [builder.Add(binary)] +AMXX.amxxpc = builder.Add(binary) diff --git a/compiler/libpc300/AMBuilder b/compiler/libpc300/AMBuilder index cad9cc6f..a0637c8b 100644 --- a/compiler/libpc300/AMBuilder +++ b/compiler/libpc300/AMBuilder @@ -35,4 +35,4 @@ binary.sources = [ 'memfile.c', ] -AMXX.libpc300 = [builder.Add(binary)] +AMXX.libpc300 = builder.Add(binary) diff --git a/compiler/libpc300/sc.h b/compiler/libpc300/sc.h index 02bb9053..69479cab 100755 --- a/compiler/libpc300/sc.h +++ b/compiler/libpc300/sc.h @@ -763,6 +763,7 @@ SC_VDECL int sc_needsemicolon;/* semicolon required to terminate expressions? */ SC_VDECL int sc_dataalign; /* data alignment value */ SC_VDECL int sc_alignnext; /* must frame of the next function be aligned? */ SC_VDECL int pc_docexpr; /* must expression be attached to documentation comment? */ +SC_VDECL int sc_showincludes; /* show include files? */ SC_VDECL int curseg; /* 1 if currently parsing CODE, 2 if parsing DATA */ SC_VDECL cell sc_stksize; /* stack size */ SC_VDECL cell sc_amxlimit; /* abstract machine size limit */ diff --git a/compiler/libpc300/sc1.c b/compiler/libpc300/sc1.c index 54702e23..83fd68ae 100755 --- a/compiler/libpc300/sc1.c +++ b/compiler/libpc300/sc1.c @@ -1013,6 +1013,9 @@ static void parseoptions(int argc,char **argv,char *oname,char *ename,char *pnam hwndFinish=(HWND)0; break; #endif + case 'h': + sc_showincludes = 1; + break; case 'i': strncpy(str,option_value(ptr),sizeof str); /* set name of include directory */ str[sizeof(str)-1]='\0'; diff --git a/compiler/libpc300/sc2.c b/compiler/libpc300/sc2.c index 79451d19..f6961e39 100755 --- a/compiler/libpc300/sc2.c +++ b/compiler/libpc300/sc2.c @@ -142,6 +142,9 @@ static char *extensions[] = { ".inc", ".p", ".pawn" }; *ext='\0'; /* restore filename */ return FALSE; } /* if */ + if (sc_showincludes && sc_status==statFIRST) { + fprintf(stdout, "Note: including file: %s\n", name); + } PUSHSTK_P(inpf); PUSHSTK_P(inpfname); /* pointer to current file name */ PUSHSTK_P(curlibrary); diff --git a/compiler/libpc300/scvars.c b/compiler/libpc300/scvars.c index 0da106f2..f265f184 100755 --- a/compiler/libpc300/scvars.c +++ b/compiler/libpc300/scvars.c @@ -85,6 +85,7 @@ SC_VDEFINE int sc_rationaltag=0; /* tag for rational numbers */ SC_VDEFINE int rational_digits=0; /* number of fractional digits */ SC_VDEFINE int sc_allowproccall=0; /* allow/detect tagnames in lex() */ SC_VDEFINE short sc_is_utf8=FALSE; /* is this source file in UTF-8 encoding */ +SC_VDEFINE int sc_showincludes=0; /* show include files */ SC_VDEFINE constvalue sc_automaton_tab = { NULL, "", 0, 0}; /* automaton table */ SC_VDEFINE constvalue sc_state_tab = { NULL, "", 0, 0}; /* state table */ diff --git a/plugins/AMBuilder b/plugins/AMBuilder new file mode 100644 index 00000000..91aae367 --- /dev/null +++ b/plugins/AMBuilder @@ -0,0 +1,112 @@ +# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python: +import os + +files = [ + 'adminchat.sma', + 'admincmd.sma', + 'adminhelp.sma', + 'adminslots.sma', + 'adminvote.sma', + 'antiflood.sma', + 'imessage.sma', + 'mapchooser.sma', + 'mapsmenu.sma', + 'menufront.sma', + 'multilingual.sma', + 'nextmap.sma', + 'pausecfg.sma', + 'plmenu.sma', + 'scrollmsg.sma', + 'statscfg.sma', + 'telemenu.sma', + 'timeleft.sma', + 'cmdmenu.sma', + 'pluginmenu.sma', + 'cstrike/csstats.sma', + 'cstrike/miscstats.sma', + 'cstrike/restmenu.sma', + 'cstrike/stats_logging.sma', + 'cstrike/statsx.sma', + 'dod/dodstats.sma', + 'dod/plmenu.sma', + 'dod/stats.sma', + 'dod/stats_logging.sma', + 'dod/statssounds.sma', + 'esf/EvolutionX.Core.sma', + 'ns/idlekicker.sma', + 'ns/mapchooser.sma', + 'ns/nextmap.sma', + 'ns/nscommands.sma', + 'ns/timeleft.sma', + 'ns/unstuck.sma', + 'ns/plmenu.sma', + 'tfc/plmenu.sma', + 'tfc/stats.sma', + 'tfc/stats_logging.sma', + 'tfc/statssounds.sma', + 'tfc/tfcstats.sma', + 'ts/stats.sma', + 'ts/stats_logging.sma', + 'ts/statssounds.sma', + 'ts/tsstats.sma', +] + +_, (libpc300,) = builder.AddCopy(AMXX.libpc300.binary, builder.localFolder) +_, (amxxpc,) = builder.AddCopy(AMXX.amxxpc.binary, builder.localFolder) + +amxxpc_argv = [ + os.path.join(os.curdir, 'amxxpc'), + '-i' + os.path.relpath(os.path.join(builder.buildPath, 'includes'), + os.path.join(builder.buildPath, builder.buildFolder)), + '-i' + os.path.relpath(os.path.join(builder.sourcePath, 'plugins', 'include'), + os.path.join(builder.buildPath, builder.buildFolder)), + '-h', +] + +def build_plugin(script_path, amxx_file, extra_argv = []): + script_folder = os.path.dirname(amxx_file) + if len(script_folder): + builder.AddFolder(script_folder) + + inputs = [ + # Note, use the ones we locally copied, not the originals! Otherwise they + # could copy out of order. + amxxpc, + libpc300, + script_path, + ] + outputs = [ + amxx_file + ] + + argv = amxxpc_argv + extra_argv + [ + script_path, + '-o' + amxx_file, + ] + + cmd_entry, (amx_entry,) = builder.AddCommand( + inputs = inputs, + argv = argv, + outputs = outputs, + dep_type = 'msvc' + ) + AMXX.plugins[amxx_file] = amx_entry + +for script_file in files: + script_path = os.path.join(builder.currentSourcePath, script_file) + amxx_file = os.path.splitext(script_file)[0] + '.amxx' + + build_plugin(script_path, amxx_file) + +# admin_sql.amxx is generated from admin.sma. +build_plugin( + script_path = os.path.join(builder.currentSourcePath, 'admin.sma'), + amxx_file = 'admin_sql.amxx', + extra_argv = ['USING_SQL=1'] +) + +# amxmod_compat is multi-file. +build_plugin( + script_path = os.path.join(builder.currentSourcePath, 'amxmod_compat', 'amxmod_compat.sma'), + amxx_file = 'amxmod_compat.amxx' +)