diff --git a/sourcepawn/compiler/AMBuilder b/sourcepawn/compiler/AMBuilder index c8ddd554..ddb0685b 100644 --- a/sourcepawn/compiler/AMBuilder +++ b/sourcepawn/compiler/AMBuilder @@ -1,6 +1,39 @@ # vim: set ts=2 sw=2 tw=99 noet ft=python: import os +# Build the packing binary garbage. +scpack = SM.Program(builder, 'scpack') +scpack.sources = ['scpack.c'] +scpack = builder.Add(scpack) + +# Generate pack files. +packed_files = ['sc5', 'sc7'] +packed_includes = [] +for packed_file in packed_files: + # The absolute path to sc5-in.scp etc. + in_path = os.path.join(builder.currentSourcePath, '{0}-in.scp'.format(packed_file)) + + # The output file relative to the output folder, i.e. sourcepawn/compiler/sc5.scp. + out_path = os.path.join(builder.buildFolder, '{0}.scp'.format(packed_file)) + + # The absolute path to the build folder, i.e. /Users/.../sourcepawn/compiler. + build_folder = os.path.join(builder.buildPath, builder.buildFolder) + + # scpack runs in ./sourcepawn/compiler/scpack/ so we build relative paths + # from there. + scpack_argv = [ + os.path.join(builder.buildPath, scpack.binary.path), + os.path.relpath(in_path, build_folder), + os.path.relpath(os.path.join(builder.buildPath, out_path), build_folder), + ] + + _, (entry,) = builder.AddCommand( + inputs = [scpack.binary, in_path], + argv = scpack_argv, + outputs = ['{0}.scp'.format(packed_file)], + ) + packed_includes += [entry] + binary = SM.Program(builder, 'spcomp') compiler = binary.compiler compiler.includes += [ @@ -8,7 +41,9 @@ compiler.includes += [ os.path.join(builder.sourcePath, 'public', 'sourcepawn'), os.path.join(builder.sourcePath, 'sourcepawn', 'compiler'), os.path.join(builder.buildPath, 'includes'), + os.path.join(builder.buildPath, builder.buildFolder), ] +compiler.sourcedeps += packed_includes if compiler.cc.behavior == 'gcc': compiler.cflags += ['-std=c99', '-Wno-format'] diff --git a/sourcepawn/compiler/sc5.scp b/sourcepawn/compiler/sc5-in.scp similarity index 100% rename from sourcepawn/compiler/sc5.scp rename to sourcepawn/compiler/sc5-in.scp diff --git a/sourcepawn/compiler/sc5.c b/sourcepawn/compiler/sc5.c index 6b44e527..96d5740b 100644 --- a/sourcepawn/compiler/sc5.c +++ b/sourcepawn/compiler/sc5.c @@ -42,7 +42,7 @@ #pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */ #endif -#include "sc5.scp" +#include #if defined _MSC_VER #pragma warning(pop) diff --git a/sourcepawn/compiler/sc7.scp b/sourcepawn/compiler/sc7-in.scp similarity index 100% rename from sourcepawn/compiler/sc7.scp rename to sourcepawn/compiler/sc7-in.scp diff --git a/sourcepawn/compiler/sc7.c b/sourcepawn/compiler/sc7.c index 4272fe26..61f095d8 100644 --- a/sourcepawn/compiler/sc7.c +++ b/sourcepawn/compiler/sc7.c @@ -62,7 +62,7 @@ #pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */ #endif -#include "sc7.scp" +#include #if defined _MSC_VER #pragma warning(pop)