From 92f1ccd7d51fb49e778dbd904729645156f04434 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 5 Oct 2006 06:22:25 +0000 Subject: [PATCH] Change genmodule to parse through the Makefile (or Makefile.am) looking for YASM_MODULES, rather than simply taking a list of modules on the command line. This allows significant improvement of the behavior when used with Visual Studio, as the "old" way of doing this with Visual Studio build files was to scan through the .c files; this brought up things that were actually disabled in the build. Also incorporate a patch by Charles Bailey to make the VC8 build less noisy, and allow use of Win32 Bison if it's installed. Instructions updated as well. svn path=/trunk/yasm/; revision=1642 --- Makefile.am | 2 + Mkfiles/Makefile.dj | 2 +- Mkfiles/Makefile.flat | 2 +- Mkfiles/vc/genmodule/run.bat | 5 +- Mkfiles/vc8/bison.rules | 32 +++++ Mkfiles/vc8/config.h | 2 - Mkfiles/vc8/crt_secure_no_deprecate.vsprops | 11 ++ Mkfiles/vc8/gap/gap.vcproj | 2 + Mkfiles/vc8/genmacro/genmacro.vcproj | 2 + Mkfiles/vc8/genmodule/genmodule.vcproj | 3 + Mkfiles/vc8/genmodule/run.bat | 5 +- Mkfiles/vc8/genstring/genstring.vcproj | 2 + Mkfiles/vc8/genversion/genversion.vcproj | 2 + Mkfiles/vc8/libyasm/libyasm.vcproj | 18 ++- Mkfiles/vc8/modules/modules.vcproj | 115 +++++++++++++-- Mkfiles/vc8/re2c/re2c.vcproj | 33 +++++ Mkfiles/vc8/readme.vc8.txt | 19 ++- Mkfiles/vc8/yasm.sln | 3 +- Mkfiles/vc8/yasm.vcproj | 6 +- libyasm/Makefile.inc | 2 +- libyasm/genmodule.c | 148 +++++++++++++++----- 21 files changed, 348 insertions(+), 68 deletions(-) create mode 100644 Mkfiles/vc8/bison.rules create mode 100644 Mkfiles/vc8/crt_secure_no_deprecate.vsprops diff --git a/Makefile.am b/Makefile.am index a2d9322f..0bc3572e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -75,6 +75,8 @@ EXTRA_DIST += Mkfiles/vc/re2c/re2c.vcproj EXTRA_DIST += Mkfiles/vc/re2c/run.bat EXTRA_DIST += Mkfiles/vc/gap/gap.vcproj EXTRA_DIST += Mkfiles/vc/gap/run.bat +EXTRA_DIST += Mkfiles/vc8/bison.rules +EXTRA_DIST += Mkfiles/vc8/crt_secure_no_deprecate.vsprops EXTRA_DIST += Mkfiles/vc8/yasm.sln EXTRA_DIST += Mkfiles/vc8/yasm.vcproj EXTRA_DIST += Mkfiles/vc8/config.h diff --git a/Mkfiles/Makefile.dj b/Mkfiles/Makefile.dj index 5006a1be..352cd697 100644 --- a/Mkfiles/Makefile.dj +++ b/Mkfiles/Makefile.dj @@ -163,7 +163,7 @@ genmodule: libyasm/genmodule.c $(BUILDCC) -o $@ $< module.c: libyasm/module.in genmodule - ./genmodule libyasm/module.in $(YASM_MODULES) + ./genmodule libyasm/module.in Mkfiles/Makefile.dj x86parse.c: modules/arch/x86/x86parse.gap gap ./gap modules/arch/x86/x86parse.gap $@ diff --git a/Mkfiles/Makefile.flat b/Mkfiles/Makefile.flat index a0d32abf..be3339c4 100644 --- a/Mkfiles/Makefile.flat +++ b/Mkfiles/Makefile.flat @@ -166,7 +166,7 @@ genmodule: libyasm/genmodule.c $(BUILDCC) -o $@ $< module.c: libyasm/module.in genmodule - ./genmodule libyasm/module.in $(YASM_MODULES) + ./genmodule libyasm/module.in Mkfiles/Makefile.flat x86parse.c: modules/arch/x86/x86parse.gap gap ./gap modules/arch/x86/x86parse.gap $@ diff --git a/Mkfiles/vc/genmodule/run.bat b/Mkfiles/vc/genmodule/run.bat index f1d4ea34..e34a4169 100644 --- a/Mkfiles/vc/genmodule/run.bat +++ b/Mkfiles/vc/genmodule/run.bat @@ -1,6 +1,3 @@ @echo off cd ..\..\.. -echo "" >temp.txt -for /R modules %%n in (*.c) do find "_LTX_" "%%n" | find "_module" | find "= {" >>temp.txt -type temp.txt | %1 libyasm\module.in -del temp.txt +%1 libyasm\module.in Makefile.am diff --git a/Mkfiles/vc8/bison.rules b/Mkfiles/vc8/bison.rules new file mode 100644 index 00000000..f8ce0f48 --- /dev/null +++ b/Mkfiles/vc8/bison.rules @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/Mkfiles/vc8/config.h b/Mkfiles/vc8/config.h index 9beb4772..ef786024 100644 --- a/Mkfiles/vc8/config.h +++ b/Mkfiles/vc8/config.h @@ -4,8 +4,6 @@ #define yasm__abspath(path) yasm__abspath_win(path) #define yasm__combpath(from, to) yasm__combpath_win(from, to) -#define _CRT_SECURE_NO_DEPRECATE 1 - /* */ /* #undef ENABLE_NLS */ diff --git a/Mkfiles/vc8/crt_secure_no_deprecate.vsprops b/Mkfiles/vc8/crt_secure_no_deprecate.vsprops new file mode 100644 index 00000000..d61ba30a --- /dev/null +++ b/Mkfiles/vc8/crt_secure_no_deprecate.vsprops @@ -0,0 +1,11 @@ + + + + diff --git a/Mkfiles/vc8/gap/gap.vcproj b/Mkfiles/vc8/gap/gap.vcproj index 19bb8719..9ba90035 100644 --- a/Mkfiles/vc8/gap/gap.vcproj +++ b/Mkfiles/vc8/gap/gap.vcproj @@ -20,6 +20,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" + InheritedPropertySheets="..\crt_secure_no_deprecate.vsprops" CharacterSet="2" > @@ -19,6 +20,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" + InheritedPropertySheets="..\crt_secure_no_deprecate.vsprops" CharacterSet="2" > temp.txt -for /R modules %%n in (*.c) do find "_LTX_" "%%n" | find "_module" | find "= {" >>temp.txt -type temp.txt | %1 libyasm\module.in -del temp.txt +%1 libyasm\module.in Makefile.am diff --git a/Mkfiles/vc8/genstring/genstring.vcproj b/Mkfiles/vc8/genstring/genstring.vcproj index 7722dfd2..9910c8b4 100644 --- a/Mkfiles/vc8/genstring/genstring.vcproj +++ b/Mkfiles/vc8/genstring/genstring.vcproj @@ -20,6 +20,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" + InheritedPropertySheets="..\crt_secure_no_deprecate.vsprops" CharacterSet="2" > - - @@ -357,6 +355,10 @@ RelativePath="..\..\..\libyasm\bc-reserve.c" > + + @@ -559,6 +561,10 @@ > + + diff --git a/Mkfiles/vc8/modules/modules.vcproj b/Mkfiles/vc8/modules/modules.vcproj index 4351a4f6..68b03f7c 100644 --- a/Mkfiles/vc8/modules/modules.vcproj +++ b/Mkfiles/vc8/modules/modules.vcproj @@ -15,6 +15,9 @@ /> + + @@ -96,7 +103,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\crt_secure_no_deprecate.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" @@ -108,6 +115,9 @@ + @@ -173,6 +183,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="4" + InheritedPropertySheets="..\crt_secure_no_deprecate.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" @@ -183,6 +194,9 @@ + @@ -246,7 +260,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="4" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;..\crt_secure_no_deprecate.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" @@ -257,6 +271,9 @@ + @@ -352,27 +369,27 @@ Name="dbgfmts" > @@ -451,6 +468,44 @@ RelativePath="..\..\..\gas-bison.h" > + + + + + + + + + + + + + + @@ -475,6 +530,44 @@ RelativePath="..\..\..\nasm-bison.h" > + + + + + + + + + + + + + + diff --git a/Mkfiles/vc8/re2c/re2c.vcproj b/Mkfiles/vc8/re2c/re2c.vcproj index 4e2e9f87..4e689057 100644 --- a/Mkfiles/vc8/re2c/re2c.vcproj +++ b/Mkfiles/vc8/re2c/re2c.vcproj @@ -13,6 +13,9 @@ /> + + @@ -101,6 +108,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" + InheritedPropertySheets="..\crt_secure_no_deprecate.vsprops" CharacterSet="2" > + @@ -214,6 +225,28 @@ RelativePath="..\..\..\re2c-parser.h" > + + + + + + + + diff --git a/Mkfiles/vc8/readme.vc8.txt b/Mkfiles/vc8/readme.vc8.txt index 05c2a39e..0b817a92 100644 --- a/Mkfiles/vc8/readme.vc8.txt +++ b/Mkfiles/vc8/readme.vc8.txt @@ -13,9 +13,9 @@ the Visual Studio 2005 64-bit tools, which are not installed by default. 2. YASM Download ---------------- -The following files are not built on VC++ and are not contained in the -YASM subversion repository (but they are included in the nightly YASM -snapshots): +The following files are not built by default on VC++ and are not contained +in the YASM subversion repository (but they are included in the nightly +YASM snapshots): gas-bison.c gas-bison.h @@ -24,6 +24,19 @@ snapshots): re2c-parser.c re2c-parser.h +However, if you want to build these files from source, follow these step: + 1) Install bison. This can be done in a number of ways, the easiest is + probably to download and run the Win32 Bison Setup program from + http://gnuwin32.sourceforge.net/packages/bison.htm + 2) In Visual Studio, go to Tools|Options, + Projects and Solutions|VC++ Directories, and add the directory where + you installed Bison to the list of directories. + 3) For each of the .y files in the build, right click, select Properties, + and change the "Excluded From Build" setting to No. These files are: + re2c/Source Files/re2c-parser.y + modules/Source Files/gas-bison.y + modules/Source Files/nasm-bison.y + If you wish to build from the latest files in the subversion repository, you will need to add these files from the latest snapshot to the repository files. They should be placed in the YASM root directory. diff --git a/Mkfiles/vc8/yasm.sln b/Mkfiles/vc8/yasm.sln index 3d14dcd4..6717facf 100644 --- a/Mkfiles/vc8/yasm.sln +++ b/Mkfiles/vc8/yasm.sln @@ -15,9 +15,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modules", "modules\modules. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "yasm", "yasm.vcproj", "{34EB1BEB-C2D6-4A52-82B7-7ACD714A30D5}" ProjectSection(ProjectDependencies) = postProject + {021CEB0A-F721-4F59-B349-9CEEAF244459} = {021CEB0A-F721-4F59-B349-9CEEAF244459} {29FE7874-1256-4AD6-B889-68E399DC9608} = {29FE7874-1256-4AD6-B889-68E399DC9608} {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6} = {D715A3D4-EFAA-442E-AD8B-5B4FF64E1DD6} - {021CEB0A-F721-4F59-B349-9CEEAF244459} = {021CEB0A-F721-4F59-B349-9CEEAF244459} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genmacro", "genmacro\genmacro.vcproj", "{225700A5-07B8-434E-AD61-555278BF6733}" @@ -37,6 +37,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genstring", "genstring\gens EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{825AC694-358C-4D8D-92DE-33A2691978CE}" ProjectSection(SolutionItems) = preProject + crt_secure_no_deprecate.vsprops = crt_secure_no_deprecate.vsprops readme.vc8.txt = readme.vc8.txt EndProjectSection EndProject diff --git a/Mkfiles/vc8/yasm.vcproj b/Mkfiles/vc8/yasm.vcproj index be94afed..ef4eab3a 100644 --- a/Mkfiles/vc8/yasm.vcproj +++ b/Mkfiles/vc8/yasm.vcproj @@ -22,6 +22,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" + InheritedPropertySheets=".\crt_secure_no_deprecate.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" @@ -111,7 +112,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;.\crt_secure_no_deprecate.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" @@ -202,6 +203,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" + InheritedPropertySheets=".\crt_secure_no_deprecate.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" @@ -293,7 +295,7 @@ OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops;.\crt_secure_no_deprecate.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" diff --git a/libyasm/Makefile.inc b/libyasm/Makefile.inc index 8d0384bb..fb757157 100644 --- a/libyasm/Makefile.inc +++ b/libyasm/Makefile.inc @@ -32,7 +32,7 @@ libyasm_a_SOURCES += libyasm/xstrdup.c libyasm_a_SOURCES += module.c module.c: $(top_srcdir)/libyasm/module.in genmodule$(EXEEXT) Makefile - $(top_builddir)/genmodule$(EXEEXT) $(top_srcdir)/libyasm/module.in $(YASM_MODULES) + $(top_builddir)/genmodule$(EXEEXT) $(top_srcdir)/libyasm/module.in Makefile BUILT_SOURCES += module.c CLEANFILES += module.c diff --git a/libyasm/genmodule.c b/libyasm/genmodule.c index 03fa6128..f34fa1c7 100644 --- a/libyasm/genmodule.c +++ b/libyasm/genmodule.c @@ -1,6 +1,6 @@ /* $Id$ * - * Generate module.c from module.in and list of modules. + * Generate module.c from module.in and Makefile.am or Makefile. * * Copyright (C) 2004 Peter Johnson * @@ -28,10 +28,20 @@ #include #include #include +#include + +#include "compat-queue.h" #define OUTPUT "module.c" +#define MAXNAME 128 #define MAXLINE 1024 #define MAXMODULES 128 +#define MAXINCLUDES 256 + +typedef struct include { + STAILQ_ENTRY(include) link; + char *filename; +} include; int main(int argc, char *argv[]) @@ -39,47 +49,121 @@ main(int argc, char *argv[]) FILE *in, *out; char *str; int i; - int len; + size_t len; char *strp; char *modules[MAXMODULES]; int num_modules = 0; + STAILQ_HEAD(includehead, include) includes = + STAILQ_HEAD_INITIALIZER(includes); + include *inc; + int isam = 0; + int linecont = 0; - if (argc < 2) { - fprintf(stderr, "Usage: %s [module_name ...]\n", argv[0]); + if (argc != 3) { + fprintf(stderr, "Usage: %s \n", argv[0]); return EXIT_FAILURE; } str = malloc(MAXLINE); -#ifdef FILTERMODE - while (fgets(str, MAXLINE, stdin)) { - if (strlen(str) < 6) - continue; - modules[num_modules] = malloc(strlen(str+5)+1); /* excessive */ - strp = str+5; /* skip past the "yasm_" */ - i = 0; - /* copy the module type */ - while (*strp != '_') - modules[num_modules][i++] = *strp++; - modules[num_modules][i++] = *strp++; /* copy the following _ */ - /* find the next _ */ - while (*strp++ != '_') - {} - /* copy it up until the next _ */ - do { - modules[num_modules][i++] = *strp++; - } while (*strp != '_'); - /* terminate string */ - modules[num_modules][i] = '\0'; - num_modules++; - } -#else - num_modules = argc-2; - for (i=2; i or + * YASM_MODULES += . Note this currently doesn't handle + * a relative starting path. + */ + len = strlen(argv[2]); + inc = malloc(sizeof(include)); + inc->filename = malloc(len+1); + strcpy(inc->filename, argv[2]); + STAILQ_INSERT_TAIL(&includes, inc, link); + + isam = argv[2][len-2] == 'a' && argv[2][len-1] == 'm'; + + while (!STAILQ_EMPTY(&includes)) { + inc = STAILQ_FIRST(&includes); + STAILQ_REMOVE_HEAD(&includes, link); + in = fopen(inc->filename, "rt"); + if (!in) { + fprintf(stderr, "Could not open `%s'.\n", inc->filename); + return EXIT_FAILURE; + } + free(inc->filename); + free(inc); + + while (fgets(str, MAXLINE, in)) { + /* Strip off any trailing whitespace */ + len = strlen(str); + strp = &str[len-1]; + while (isspace(*strp)) { + *strp-- = '\0'; + len--; + } + + strp = str; + + /* Skip whitespace */ + while (isspace(*strp)) + strp++; + + /* Skip comments */ + if (*strp == '#') + continue; + + /* If line continuation, skip to continue copy */ + if (linecont) + goto keepgoing; + + /* Check for include if original input is .am file */ + if (isam && strncmp(strp, "include", 7) == 0 && isspace(strp[7])) { + strp += 7; + while (isspace(*strp)) + strp++; + /* Build new include and add to end of list */ + inc = malloc(sizeof(include)); + inc->filename = malloc(strlen(strp)+1); + strcpy(inc->filename, strp); + STAILQ_INSERT_TAIL(&includes, inc, link); + continue; + } + + /* Check for YASM_MODULES = or += */ + if (strncmp(strp, "YASM_MODULES", 12) != 0) + continue; + strp += 12; + while (isspace(*strp)) + strp++; + if (strncmp(strp, "+=", 2) != 0 && *strp != '=') + continue; + if (*strp == '+') + strp++; + strp++; + while (isspace(*strp)) + strp++; + +keepgoing: + /* Check for continuation */ + if (str[len-1] == '\\') { + str[len-1] = '\0'; + while (isspace(*strp)) + *strp-- = '\0'; + linecont = 1; + } else + linecont = 0; + + while (*strp != '\0') { + /* Copy module name */ + modules[num_modules] = malloc(MAXNAME); + len = 0; + while (*strp != '\0' && !isspace(*strp)) + modules[num_modules][len++] = *strp++; + modules[num_modules][len] = '\0'; + num_modules++; + + while (isspace(*strp)) + strp++; + } + } + fclose(in); } -#endif out = fopen(OUTPUT, "wt"); -- 2.40.0