From ff5bb2accee87c24ee64e8fdcf5169e674c4b7b4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 8 Sep 2010 21:23:37 +0200 Subject: Add suppor for VC++ build --- build/bootstrap.make | 45 +- common/Makefile.am | 2 + common/auto/driver.cxx | 2 +- common/auto/makefile | 21 +- common/common-vc10.sln | 15 + common/common-vc9.sln | 15 + common/lifecycle/driver.cxx | 2 +- common/lifecycle/makefile | 21 +- common/makefile | 11 +- common/query/driver.cxx | 2 +- common/query/makefile | 23 +- common/schema/driver.cxx | 2 +- common/schema/makefile | 21 +- common/template/Makefile.am | 6 +- common/template/driver.cxx | 2 +- common/template/makefile | 21 +- common/template/template-vc10.vcxproj | 173 +++++ common/template/template-vc10.vcxproj.filters | 24 + common/template/template-vc9.vcproj | 356 +++++++++++ common/test.bat | 48 ++ common/threads/driver.cxx | 2 +- common/threads/makefile | 21 +- configure.ac | 2 +- libcommon/Makefile.am | 7 +- libcommon/common.cxx | 49 -- libcommon/common.hxx | 18 - libcommon/common/Makefile.am | 12 + libcommon/common/common.cxx | 49 ++ libcommon/common/common.hxx | 18 + libcommon/common/config.h.in | 15 + libcommon/common/export.hxx | 39 ++ libcommon/common/libcommon-vc10.vcxproj | 174 ++++++ libcommon/common/libcommon-vc10.vcxproj.filters | 19 + libcommon/common/libcommon-vc9.vcproj | 359 +++++++++++ libcommon/common/makefile | 124 ++++ libcommon/common/options.cli | 58 ++ libcommon/common/options.cxx | 796 ++++++++++++++++++++++++ libcommon/common/options.hxx | 396 ++++++++++++ libcommon/common/options.ixx | 256 ++++++++ libcommon/config.h.in | 15 - libcommon/export.hxx | 39 -- libcommon/libcommon-vc10.sln | 26 + libcommon/libcommon-vc9.sln | 26 + libcommon/makefile | 121 +--- libcommon/options.cli | 58 -- libcommon/options.cxx | 796 ------------------------ libcommon/options.hxx | 396 ------------ libcommon/options.ixx | 256 -------- makefile | 2 +- mysql/Makefile.am | 1 + mysql/makefile | 8 + mysql/mysql-vc10.sln | 15 + mysql/mysql-vc9.sln | 15 + mysql/template/Makefile.am | 6 +- mysql/template/driver.cxx | 2 +- mysql/template/makefile | 25 +- mysql/template/template-vc10.vcxproj | 176 ++++++ mysql/template/template-vc10.vcxproj.filters | 25 + mysql/template/template-vc9.vcproj | 357 +++++++++++ mysql/truncation/driver.cxx | 2 +- mysql/truncation/makefile | 25 +- mysql/types/driver.cxx | 4 +- mysql/types/makefile | 25 +- test.bat | 48 ++ tester.bat | 54 ++ tester.in | 3 + tracer/Makefile.am | 1 + tracer/makefile | 9 + tracer/object/makefile | 15 +- tracer/template/Makefile.am | 4 +- tracer/template/makefile | 15 +- tracer/template/template-vc10.vcxproj | 172 +++++ tracer/template/template-vc10.vcxproj.filters | 25 + tracer/template/template-vc9.vcproj | 353 +++++++++++ tracer/tracer-vc10.sln | 15 + tracer/tracer-vc9.sln | 15 + tracer/transaction/makefile | 14 +- tracer/types/makefile | 15 +- 78 files changed, 4571 insertions(+), 1834 deletions(-) create mode 100644 common/common-vc10.sln create mode 100644 common/common-vc9.sln create mode 100644 common/template/template-vc10.vcxproj create mode 100644 common/template/template-vc10.vcxproj.filters create mode 100644 common/template/template-vc9.vcproj create mode 100644 common/test.bat delete mode 100644 libcommon/common.cxx delete mode 100644 libcommon/common.hxx create mode 100644 libcommon/common/Makefile.am create mode 100644 libcommon/common/common.cxx create mode 100644 libcommon/common/common.hxx create mode 100644 libcommon/common/config.h.in create mode 100644 libcommon/common/export.hxx create mode 100644 libcommon/common/libcommon-vc10.vcxproj create mode 100644 libcommon/common/libcommon-vc10.vcxproj.filters create mode 100644 libcommon/common/libcommon-vc9.vcproj create mode 100644 libcommon/common/makefile create mode 100644 libcommon/common/options.cli create mode 100644 libcommon/common/options.cxx create mode 100644 libcommon/common/options.hxx create mode 100644 libcommon/common/options.ixx delete mode 100644 libcommon/config.h.in delete mode 100644 libcommon/export.hxx create mode 100644 libcommon/libcommon-vc10.sln create mode 100644 libcommon/libcommon-vc9.sln delete mode 100644 libcommon/options.cli delete mode 100644 libcommon/options.cxx delete mode 100644 libcommon/options.hxx delete mode 100644 libcommon/options.ixx create mode 100644 mysql/mysql-vc10.sln create mode 100644 mysql/mysql-vc9.sln create mode 100644 mysql/template/template-vc10.vcxproj create mode 100644 mysql/template/template-vc10.vcxproj.filters create mode 100644 mysql/template/template-vc9.vcproj create mode 100644 test.bat create mode 100644 tester.bat create mode 100644 tracer/template/template-vc10.vcxproj create mode 100644 tracer/template/template-vc10.vcxproj.filters create mode 100644 tracer/template/template-vc9.vcproj create mode 100644 tracer/tracer-vc10.sln create mode 100644 tracer/tracer-vc9.sln diff --git a/build/bootstrap.make b/build/bootstrap.make index 59a62a2..8cff938 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -45,12 +45,53 @@ clean: $(out_base)/.clean endif -# Make sure the distribution prefix is set if the goal is dist. +# Dist setup. # ifneq ($(filter $(MAKECMDGOALS),dist),) + +# Make sure the distribution prefix is set if the goal is dist. +# ifeq ($(dist_prefix),) $(error dist_prefix is not set) endif + +databases := mysql pgsql +$(dist): databases := $(databases) + +# $1 project template without the -vcN.vc[x]proj suffix. +# $2 project name without the -vcN.vc[x]proj suffix. +# +$(dist): meta-vc9projs = \ +$(foreach d,$(databases),$(call \ +meta-vc9proj,$1-vc9.vcproj,$(if $2,$2,$(notdir \ +$1))-$d-vc9.vcproj,database,$d)$(literal_newline)$(literal_tab))@: + +$(dist): meta-vc10projs = \ +$(foreach d,$(databases),$(call \ +meta-vc10proj,$1-vc10.vcxproj,$(if $2,$2,$(notdir \ +$1))-$d-vc10.vcxproj,database,$d)$(literal_newline)$(literal_tab))@: + +# $1 project name without the -vcN.vc[x]proj suffix. +# +vc9projs = $(addprefix $1-,$(addsuffix -vc9.vcproj,$(databases))) +vc10projs = $(addprefix $1-,$(addsuffix -vc10.vcxproj,$(databases))) \ +$(addprefix $1-,$(addsuffix -vc10.vcxproj.filters,$(databases))) + +# $1 solution name without the -vcN.sln suffix. +# +$(dist): meta-vc9slns = \ +$(foreach d,$(databases),$(call \ +meta-vc9sln,$1-vc9.sln,$1-$d-vc9.sln,-$d-vc9.vcproj,database,$d)$(literal_newline)\ +$(literal_tab))@: + +$(dist): meta-vc10slns = \ +$(foreach d,$(databases),$(call \ +meta-vc10sln,$1-vc10.sln,$1-$d-vc10.sln,-$d-vc10.vcxproj,database,$d)$(literal_newline)\ +$(literal_tab))@: + +vc9slns = $(addprefix $1-,$(addsuffix -vc9.sln,$(databases))) +vc10slns = $(addprefix $1-,$(addsuffix -vc10.sln,$(databases))) + endif # If we don't have dependency auto-generation then we need to manually @@ -74,7 +115,7 @@ endif # Don't include dependency info for certain targets. # -ifneq ($(filter $(MAKECMDGOALS),clean disfigure),) +ifneq ($(filter $(MAKECMDGOALS),clean disfigure dist),) include-dep = endif diff --git a/common/Makefile.am b/common/Makefile.am index a526e4c..00c4ef0 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -8,3 +8,5 @@ SUBDIRS = __path__(dirs) if ODB_TESTS_THREADS SUBDIRS += __path__(thread_dirs) endif + +EXTRA_DIST = __file__(extra_dist) diff --git a/common/auto/driver.cxx b/common/auto/driver.cxx index 423254e..4a65725 100644 --- a/common/auto/driver.cxx +++ b/common/auto/driver.cxx @@ -13,7 +13,7 @@ #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" diff --git a/common/auto/makefile b/common/auto/makefile index b39759a..e4cdffd 100644 --- a/common/auto/makefile +++ b/common/auto/makefile @@ -10,8 +10,8 @@ odb_hdr := test.hxx cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) cxx_od := $(cxx_obj:.o=.o.d) -common.l := $(out_root)/libcommon/common.l -common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options driver := $(out_base)/driver dist := $(out_base)/.dist @@ -47,11 +47,20 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std +name := $(notdir $(src_base)) + $(dist): db_id := @database@ +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(name) +$(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \ +$(call vc10projs,$(name)) $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake,$(src_root)/common/template/Makefile.am) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9projs,../template/template,$(name)) + $(call meta-vc10projs,../template/template,$(name)) # Test. # @@ -82,6 +91,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/common/common-vc10.sln b/common/common-vc10.sln new file mode 100644 index 0000000..9a5dc32 --- /dev/null +++ b/common/common-vc10.sln @@ -0,0 +1,15 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +__projects__ +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution +__solution_configurations__ + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution +__project_configurations__ + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/common/common-vc9.sln b/common/common-vc9.sln new file mode 100644 index 0000000..2ec9432 --- /dev/null +++ b/common/common-vc9.sln @@ -0,0 +1,15 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +__projects__ +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution +__solution_configurations__ + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution +__project_configurations__ + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/common/lifecycle/driver.cxx b/common/lifecycle/driver.cxx index ef5a4aa..a7be6d4 100644 --- a/common/lifecycle/driver.cxx +++ b/common/lifecycle/driver.cxx @@ -13,7 +13,7 @@ #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" diff --git a/common/lifecycle/makefile b/common/lifecycle/makefile index 73cc2e4..b2a6875 100644 --- a/common/lifecycle/makefile +++ b/common/lifecycle/makefile @@ -10,8 +10,8 @@ odb_hdr := test.hxx cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) cxx_od := $(cxx_obj:.o=.o.d) -common.l := $(out_root)/libcommon/common.l -common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options driver := $(out_base)/driver dist := $(out_base)/.dist @@ -47,11 +47,20 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std +name := $(notdir $(src_base)) + $(dist): db_id := @database@ +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(name) +$(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \ +$(call vc10projs,$(name)) $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake,$(src_root)/common/template/Makefile.am) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9projs,../template/template,$(name)) + $(call meta-vc10projs,../template/template,$(name)) # Test. # @@ -82,6 +91,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/common/makefile b/common/makefile index ef085e9..f575f74 100644 --- a/common/makefile +++ b/common/makefile @@ -24,15 +24,24 @@ clean := $(out_base)/.clean $(default): $(addprefix $(out_base)/,$(addsuffix /,$(build_tests))) +name := $(notdir $(src_base)) +$(dist): name := $(name) $(dist): export dirs := $(tests) $(dist): export thread_dirs := $(thread_tests) +$(dist): export extra_dist := $(call vc9slns,$(name)) $(call vc10slns,$(name)) $(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(all_tests))) $(call meta-automake) + $(call meta-vc9slns,$(name)) + $(call meta-vc10slns,$(name)) + $(call meta-vctest,$(name)-mysql-vc10.sln,test.bat) $(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(build_tests))) $(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(all_tests))) -$(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9sln.make) +$(call include,$(bld_root)/meta/vc10sln.make) +$(call include,$(bld_root)/meta/vctest.make) +$(call include,$(bld_root)/meta/automake.make) ifneq ($(filter $(MAKECMDGOALS),dist clean),) $(foreach t,$(all_tests),$(call import,$(src_base)/$t/makefile)) diff --git a/common/query/driver.cxx b/common/query/driver.cxx index 2573d7e..eede6d8 100644 --- a/common/query/driver.cxx +++ b/common/query/driver.cxx @@ -13,7 +13,7 @@ #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" diff --git a/common/query/makefile b/common/query/makefile index 27e19e8..08eb33d 100644 --- a/common/query/makefile +++ b/common/query/makefile @@ -10,8 +10,8 @@ odb_hdr := test.hxx cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) cxx_od := $(cxx_obj:.o=.o.d) -common.l := $(out_root)/libcommon/common.l -common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options driver := $(out_base)/driver dist := $(out_base)/.dist @@ -48,12 +48,21 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) traits.hxx test.std -$(dist): export extra_headers := traits.hxx +name := $(notdir $(src_base)) + $(dist): db_id := @database@ +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): export extra_headers := traits.hxx +$(dist): data_dist := test.std +$(dist): export name := $(name) +$(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \ +$(call vc10projs,$(name)) $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake,$(src_root)/common/template/Makefile.am) + $(call dist-data,$(sources) $(headers) $(extra_headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9projs,../template/template,$(name)) + $(call meta-vc10projs,../template/template,$(name)) # Test. # @@ -84,6 +93,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/common/schema/driver.cxx b/common/schema/driver.cxx index 2647d8c..e189b23 100644 --- a/common/schema/driver.cxx +++ b/common/schema/driver.cxx @@ -13,7 +13,7 @@ #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" diff --git a/common/schema/makefile b/common/schema/makefile index de22c01..5c71905 100644 --- a/common/schema/makefile +++ b/common/schema/makefile @@ -10,8 +10,8 @@ odb_hdr := test.hxx cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) cxx_od := $(cxx_obj:.o=.o.d) -common.l := $(out_root)/libcommon/common.l -common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options driver := $(out_base)/driver dist := $(out_base)/.dist @@ -47,11 +47,20 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std +name := $(notdir $(src_base)) + $(dist): db_id := @database@ +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(name) +$(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \ +$(call vc10projs,$(name)) $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake,$(src_root)/common/template/Makefile.am) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9projs,../template/template,$(name)) + $(call meta-vc10projs,../template/template,$(name)) # Test. # @@ -82,6 +91,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/common/template/Makefile.am b/common/template/Makefile.am index b2fc122..ca3a3d5 100644 --- a/common/template/Makefile.am +++ b/common/template/Makefile.am @@ -3,13 +3,15 @@ # copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file +EXTRA_DIST = __file__(extra_dist) + noinst_PROGRAMS = driver driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers) -driver_LDADD = $(top_builddir)/libcommon/libcommon.la +driver_LDADD = $(top_builddir)/libcommon/common/libcommon.la driver_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon' TESTS=$(top_builddir)/tester -TESTS_ENVIRONMENT=top_builddir=$(top_builddir); +TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir; # ODB compilation. # diff --git a/common/template/driver.cxx b/common/template/driver.cxx index 08e4196..495365b 100644 --- a/common/template/driver.cxx +++ b/common/template/driver.cxx @@ -13,7 +13,7 @@ #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" diff --git a/common/template/makefile b/common/template/makefile index cdc8f91..cff4185 100644 --- a/common/template/makefile +++ b/common/template/makefile @@ -10,8 +10,8 @@ odb_hdr := test.hxx cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) cxx_od := $(cxx_obj:.o=.o.d) -common.l := $(out_root)/libcommon/common.l -common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options driver := $(out_base)/driver dist := $(out_base)/.dist @@ -47,11 +47,20 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std +name := $(notdir $(src_base)) + $(dist): db_id := @database@ +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(name) +$(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \ +$(call vc10projs,$(name)) $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9projs,../template/template,$(name)) + $(call meta-vc10projs,../template/template,$(name)) # Test. # @@ -82,6 +91,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/common/template/template-vc10.vcxproj b/common/template/template-vc10.vcxproj new file mode 100644 index 0000000..5e1936f --- /dev/null +++ b/common/template/template-vc10.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\libcommon + + + ..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\libcommon + + + ..\..\libcommon\lib\common-d.lib;odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\libcommon + + + ..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\libcommon + + + ..\..\libcommon\lib\common.lib;odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), @database@, __value__(database)))) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + + +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + + + + diff --git a/common/template/template-vc10.vcxproj.filters b/common/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..f3ee658 --- /dev/null +++ b/common/template/template-vc10.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +__source_filter_entry__(test-odb.cxx) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/common/template/template-vc9.vcproj b/common/template/template-vc9.vcproj new file mode 100644 index 0000000..0cf2bc4 --- /dev/null +++ b/common/template/template-vc9.vcproj @@ -0,0 +1,356 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +__source_entry__(test-odb.cxx) +__source_entries__(extra_sources) + + +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(m4_patsubst(__value__(odb_options), @database@, __value__(database)))) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx) +__file_entries__(extra_headers) + + + + + diff --git a/common/test.bat b/common/test.bat new file mode 100644 index 0000000..678e678 --- /dev/null +++ b/common/test.bat @@ -0,0 +1,48 @@ +@echo off +rem file : common/test.bat +rem author : Boris Kolpackov +rem copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +rem license : GNU GPL v2; see accompanying LICENSE file + +setlocal + +set "tests=__path__(dirs) __path__(thread_dirs)" +set "confs=__path__(configurations)" +set "topdir=__path__(topdir)\.." + +goto start + +:run_test + cd %1 + + if exist %2\driver.exe ( + echo %1\%2 + call %topdir%\tester.bat tracer %2 + if errorlevel 1 ( + set "failed=%failed% %1\%2" + ) + ) + + cd .. +goto :eof + +:start + +for %%t in (%tests%) do ( + for %%c in (%confs%) do ( + call :run_test %%t %%c + ) +) + +if not "_%failed%_" == "__" goto error + +echo ALL TESTS PASSED +goto end + +:error +for %%t in (%failed%) do echo FAILED: %%t +exit /b 1 +goto end + +:end +endlocal diff --git a/common/threads/driver.cxx b/common/threads/driver.cxx index c883bba..dd2d9f6 100644 --- a/common/threads/driver.cxx +++ b/common/threads/driver.cxx @@ -17,7 +17,7 @@ #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" diff --git a/common/threads/makefile b/common/threads/makefile index 6a8c802..73174d9 100644 --- a/common/threads/makefile +++ b/common/threads/makefile @@ -10,8 +10,8 @@ odb_hdr := test.hxx cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) cxx_od := $(cxx_obj:.o=.o.d) -common.l := $(out_root)/libcommon/common.l -common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options driver := $(out_base)/driver dist := $(out_base)/.dist @@ -48,11 +48,20 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std +name := $(notdir $(src_base)) + $(dist): db_id := @database@ +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(name) +$(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \ +$(call vc10projs,$(name)) $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake,$(src_root)/common/template/Makefile.am) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9projs,../template/template,$(name)) + $(call meta-vc10projs,../template/template,$(name)) # Test. # @@ -83,6 +92,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/configure.ac b/configure.ac index bdc5afa..bb0932c 100644 --- a/configure.ac +++ b/configure.ac @@ -61,7 +61,7 @@ STATIC_LIB([LIBCOMMON_STATIC_LIB], [Static library interface.]) # Output. # -AC_CONFIG_HEADERS([config.h libcommon/config.h]) +AC_CONFIG_HEADERS([config.h libcommon/common/config.h]) AC_CONFIG_FILES([__path__(config_files)]) AC_CONFIG_COMMANDS([tester-mode], [chmod +x tester]) AC_OUTPUT diff --git a/libcommon/Makefile.am b/libcommon/Makefile.am index d42cff2..e498e3b 100644 --- a/libcommon/Makefile.am +++ b/libcommon/Makefile.am @@ -3,10 +3,5 @@ # copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file -noinst_LTLIBRARIES = libcommon.la -libcommon_la_SOURCES = __path__(sources) __path__(headers) - +SUBDIRS = __path__(dirs) EXTRA_DIST = __file__(extra_dist) - -libcommon_la_CPPFLAGS= -I'$(builddir)' -I'$(srcdir)' -DLIBCOMMON_DYNAMIC_LIB -libcommon_la_LDFLAGS = -no-undefined -rpath '$(libdir)' diff --git a/libcommon/common.cxx b/libcommon/common.cxx deleted file mode 100644 index 0c88818..0000000 --- a/libcommon/common.cxx +++ /dev/null @@ -1,49 +0,0 @@ -// file : libcommon/common.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#include // std::exit -#include - -#ifndef _MSC_VER -# include -#endif - -#ifdef DB_ID_MYSQL -# include -#endif - -#include "common.hxx" -#include "options.hxx" - -using namespace std; -using namespace odb; - -auto_ptr -create_database (int argc, char* argv[]) -{ -#ifdef DB_ID_MYSQL - cli::argv_file_scanner scan (argc, argv, "--options-file"); - cli::mysql_options ops (scan); - - if (ops.help ()) - { - cerr << "Usage: " << argv[0] << " [options]" << endl - << "Options:" << endl; - cli::mysql_options::print_usage (cerr); - exit (0); - } - - return auto_ptr ( - new mysql::database ( - ops.user (), - ops.passwd_specified () ? &ops.passwd () : 0, - ops.db_name (), - ops.host (), - ops.port (), - ops.socket_specified () ? &ops.socket () : 0)); -#else - return auto_ptr (0); -#endif -} diff --git a/libcommon/common.hxx b/libcommon/common.hxx deleted file mode 100644 index 411ece5..0000000 --- a/libcommon/common.hxx +++ /dev/null @@ -1,18 +0,0 @@ -// file : libcommon/common.hxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_COMMON_HXX -#define LIBCOMMON_COMMON_HXX - -#include // std::auto_ptr - -#include - -#include - -LIBCOMMON_EXPORT std::auto_ptr -create_database (int argc, char* argv[]); - -#endif // LIBCOMMON_COMMON_HXX diff --git a/libcommon/common/Makefile.am b/libcommon/common/Makefile.am new file mode 100644 index 0000000..6712eaa --- /dev/null +++ b/libcommon/common/Makefile.am @@ -0,0 +1,12 @@ +# file : libcommon/common/Makefile.am +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +noinst_LTLIBRARIES = libcommon.la +libcommon_la_SOURCES = __path__(sources) __path__(headers) + +EXTRA_DIST = __file__(extra_dist) + +libcommon_la_CPPFLAGS= -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon' -DLIBCOMMON_DYNAMIC_LIB +libcommon_la_LDFLAGS = -no-undefined -rpath '$(libdir)' diff --git a/libcommon/common/common.cxx b/libcommon/common/common.cxx new file mode 100644 index 0000000..d68d579 --- /dev/null +++ b/libcommon/common/common.cxx @@ -0,0 +1,49 @@ +// file : libcommon/common/common.cxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#include // std::exit +#include + +#ifndef _MSC_VER +# include +#endif + +#ifdef DB_ID_MYSQL +# include +#endif + +#include +#include + +using namespace std; +using namespace odb; + +auto_ptr +create_database (int argc, char* argv[]) +{ +#ifdef DB_ID_MYSQL + cli::argv_file_scanner scan (argc, argv, "--options-file"); + cli::mysql_options ops (scan); + + if (ops.help ()) + { + cerr << "Usage: " << argv[0] << " [options]" << endl + << "Options:" << endl; + cli::mysql_options::print_usage (cerr); + exit (0); + } + + return auto_ptr ( + new mysql::database ( + ops.user (), + ops.passwd_specified () ? &ops.passwd () : 0, + ops.db_name (), + ops.host (), + ops.port (), + ops.socket_specified () ? &ops.socket () : 0)); +#else + return auto_ptr (0); +#endif +} diff --git a/libcommon/common/common.hxx b/libcommon/common/common.hxx new file mode 100644 index 0000000..87b08f0 --- /dev/null +++ b/libcommon/common/common.hxx @@ -0,0 +1,18 @@ +// file : libcommon/common/common.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBCOMMON_COMMON_COMMON_HXX +#define LIBCOMMON_COMMON_COMMON_HXX + +#include // std::auto_ptr + +#include + +#include + +LIBCOMMON_EXPORT std::auto_ptr +create_database (int argc, char* argv[]); + +#endif // LIBCOMMON_COMMON_COMMON_HXX diff --git a/libcommon/common/config.h.in b/libcommon/common/config.h.in new file mode 100644 index 0000000..06318c4 --- /dev/null +++ b/libcommon/common/config.h.in @@ -0,0 +1,15 @@ +/* file : libcommon/common/config.h.in + * author : Boris Kolpackov + * copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* This file is automatically processed by configure. */ + +#ifndef LIBCOMMON_COMMON_CONFIG_H +#define LIBCOMMON_COMMON_CONFIG_H + +#undef DB_ID_MYSQL +#undef LIBCOMMON_STATIC_LIB + +#endif /* LIBCOMMON_COMMON_CONFIG_H */ diff --git a/libcommon/common/export.hxx b/libcommon/common/export.hxx new file mode 100644 index 0000000..4ea2d33 --- /dev/null +++ b/libcommon/common/export.hxx @@ -0,0 +1,39 @@ +// file : libcommon/common/export.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef LIBCOMMON_COMMON_EXPORT_HXX +#define LIBCOMMON_COMMON_EXPORT_HXX + +#ifndef _MSC_VER +# include +#endif + +#ifdef LIBCOMMON_STATIC_LIB +# define LIBCOMMON_EXPORT +#else +# ifdef _WIN32 +# ifdef _MSC_VER +# ifdef LIBCOMMON_DYNAMIC_LIB +# define LIBCOMMON_EXPORT __declspec(dllexport) +# else +# define LIBCOMMON_EXPORT __declspec(dllimport) +# endif +# else +# ifdef LIBCOMMON_DYNAMIC_LIB +# ifdef DLL_EXPORT +# define LIBCOMMON_EXPORT __declspec(dllexport) +# else +# define LIBCOMMON_EXPORT +# endif +# else +# define LIBCOMMON_EXPORT __declspec(dllimport) +# endif +# endif +# else +# define LIBCOMMON_EXPORT +# endif +#endif + +#endif // LIBCOMMON_COMMON_EXPORT_HXX diff --git a/libcommon/common/libcommon-vc10.vcxproj b/libcommon/common/libcommon-vc10.vcxproj new file mode 100644 index 0000000..74d704b --- /dev/null +++ b/libcommon/common/libcommon-vc10.vcxproj @@ -0,0 +1,174 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {019C2E51-BF41-4490-AB96-4156741B8CC9} + Win32Proj + libcommon + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + ..\bin\ + common-d + + + true + ..\bin64\ + common-d + + + false + ..\bin\ + common + + + false + ..\bin64\ + common + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) + .. + 4355;4800;4290;4251;%(DisableSpecificWarnings) + + + odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) + Windows + true + $(TargetPath) + ..\lib\common-d.lib + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) + .. + 4355;4800;4290;4251;%(DisableSpecificWarnings) + + + odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies) + Windows + true + $(TargetPath) + ..\lib64\common-d.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) + .. + 4355;4800;4290;4251;%(DisableSpecificWarnings) + + + odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) + Windows + true + true + true + $(TargetPath) + ..\lib\common.lib + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions) + .. + 4355;4800;4290;4251;%(DisableSpecificWarnings) + + + odb-__value__(database).lib;odb.lib;%(AdditionalDependencies) + Windows + true + true + true + $(TargetPath) + ..\lib64\common.lib + + + +__header_entries__(headers) + + +__source_entries__(sources) + + + + + diff --git a/libcommon/common/libcommon-vc10.vcxproj.filters b/libcommon/common/libcommon-vc10.vcxproj.filters new file mode 100644 index 0000000..ecc3613 --- /dev/null +++ b/libcommon/common/libcommon-vc10.vcxproj.filters @@ -0,0 +1,19 @@ + + + + + {6B7BDACA-0BDC-48B2-B5BD-BEFC5826ABC9} + cxx + + + {F2B8743C-E39C-4FE0-AA8F-FF7FA2DA7191} + h;hxx;ixx;txx + + + +__header_filter_entries__(headers) + + +__source_filter_entries__(sources) + + diff --git a/libcommon/common/libcommon-vc9.vcproj b/libcommon/common/libcommon-vc9.vcproj new file mode 100644 index 0000000..412480b --- /dev/null +++ b/libcommon/common/libcommon-vc9.vcproj @@ -0,0 +1,359 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entries__(sources) + + +__file_entries__(headers) + + + + + diff --git a/libcommon/common/makefile b/libcommon/common/makefile new file mode 100644 index 0000000..2987959 --- /dev/null +++ b/libcommon/common/makefile @@ -0,0 +1,124 @@ +# file : libcommon/common/makefile +# author : Boris Kolpackov +# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make + +# Options file. +# +cli_tun := options.cli +cxx_tun := common.cxx + +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(cli_tun:.cli=.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +common.l := $(out_base)/common.l +common.l.cpp-options := $(out_base)/common.l.cpp-options + +default := $(out_base)/ +dist := $(out_base)/.dist +clean := $(out_base)/.clean + +# Import. +# +$(call import,\ + $(scf_root)/import/cli/stub.make,\ + cli: cli,cli-rules: cli_rules) + +$(call import,\ + $(scf_root)/import/libodb/stub.make,\ + l: odb.l,cpp-options: odb.l.cpp-options) + +ifdef db_id +$(call import,\ + $(scf_root)/import/libodb-$(db_id)/stub.make,\ + l: odb_db.l,cpp-options: odb_db.l.cpp-options) +endif + +ifeq ($(odb_db.l.cpp-options),) +odb_db.l.cpp-options := $(out_base)/.unbuildable +endif + +# Build. +# +$(common.l): $(cxx_obj) $(odb.l) $(odb_db.l) + +$(cxx_obj) $(cxx_od): $(common.l.cpp-options) $(out_base)/config.h +$(common.l.cpp-options): value := -I$(out_root)/libcommon -I$(src_root)/libcommon +$(common.l.cpp-options): $(odb_db.l.cpp-options) $(odb.l.cpp-options) + +genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): $(cli) +$(gen): cli := $(cli) +$(gen): cli_options += \ +--generate-specifier \ +--generate-file-scanner \ +--guard-prefix LIBCOMMON_COMMON + +$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) + +$(out_base)/config.h: $(dcf_root)/configuration-dynamic.make + @echo '// file : libcommon/config.h' >$@ + @echo '// author : automatically generated' >>$@ + @echo '' >>$@ + @echo '#ifndef LIBCOMMON_COMMON_CONFIG_H' >>$@ + @echo '#define LIBCOMMON_COMMON_CONFIG_H' >>$@ + @echo '' >>$@ +ifeq ($(db_id),mysql) + @echo '#define DB_ID_MYSQL 1' >>$@ +endif + @echo '' >>$@ + @echo '#endif // LIBCOMMON_COMMON_CONFIG_H' >>$@ + +# Convenience alias for default target. +# +$(out_base)/: $(common.l) + +# Dist. +# +$(dist): export sources := $(cxx_tun) $(cli_tun:.cli=.cxx) +$(dist): export headers = $(subst $(src_base)/,,$(shell find $(src_base) \ +-name '*.hxx' -o -name '*.ixx' -o -name '*.txx')) +$(dist): data_dist := $(cli_tun) +$(dist): export extra_dist := $(data_dist) $(call vc9projs,libcommon) \ +$(call vc10projs,libcommon) + +$(dist): $(gen) + $(call dist-data,$(sources) $(headers) $(data_dist) config.h.in) + $(call meta-automake) + $(call meta-vc9projs,libcommon) + $(call meta-vc10projs,libcommon) + +# Clean. +# +$(clean): $(common.l).o.clean \ + $(common.l.cpp-options).clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) + $(call message,rm $$1,rm -f $$1,$(out_base)/config.h) + +# Generated .gitignore. +# +ifeq ($(out_base),$(src_base)) +$(common.l): | $(out_base)/.gitignore + +$(out_base)/.gitignore: files := config.h +$(clean): $(out_base)/.gitignore.clean + +$(call include,$(bld_root)/git/gitignore.make) +endif + +# How to. +# +$(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) +$(call include,$(bld_root)/meta/automake.make) + +$(call include,$(cli_rules)) +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/o-l.make) diff --git a/libcommon/common/options.cli b/libcommon/common/options.cli new file mode 100644 index 0000000..5b87d70 --- /dev/null +++ b/libcommon/common/options.cli @@ -0,0 +1,58 @@ +// file : libcommon/common/options.cli +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +include ; + +namespace cli +{ + class mysql_options + { + bool --help {"Print usage information and exit."}; + + std::string --user + { + "", + "MySQL database user." + }; + + std::string --passwd + { + "", + "MySQL database password" + }; + + std::string --db-name + { + "", + "MySQL database name." + }; + + std::string --host + { + "", + "MySQL database host name or address (localhost by default)." + }; + + unsigned int --port = 0 + { + "", + "MySQL database port number." + }; + + std::string --socket + { + "", + "MySQL database socket name." + }; + + std::string --options-file + { + "", + "Read additional options from . Each option appearing on a separate + line optionally followed by space and an option value. Empty lines and + lines starting with \cb{#} are ignored." + }; + }; +} diff --git a/libcommon/common/options.cxx b/libcommon/common/options.cxx new file mode 100644 index 0000000..9d15251 --- /dev/null +++ b/libcommon/common/options.cxx @@ -0,0 +1,796 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +#include "options.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace cli +{ + // unknown_option + // + unknown_option:: + ~unknown_option () throw () + { + } + + void unknown_option:: + print (std::ostream& os) const + { + os << "unknown option '" << option () << "'"; + } + + const char* unknown_option:: + what () const throw () + { + return "unknown option"; + } + + // unknown_argument + // + unknown_argument:: + ~unknown_argument () throw () + { + } + + void unknown_argument:: + print (std::ostream& os) const + { + os << "unknown argument '" << argument () << "'"; + } + + const char* unknown_argument:: + what () const throw () + { + return "unknown argument"; + } + + // missing_value + // + missing_value:: + ~missing_value () throw () + { + } + + void missing_value:: + print (std::ostream& os) const + { + os << "missing value for option '" << option () << "'"; + } + + const char* missing_value:: + what () const throw () + { + return "missing option value"; + } + + // invalid_value + // + invalid_value:: + ~invalid_value () throw () + { + } + + void invalid_value:: + print (std::ostream& os) const + { + os << "invalid value '" << value () << "' for option '" + << option () << "'"; + } + + const char* invalid_value:: + what () const throw () + { + return "invalid option value"; + } + + // eos_reached + // + void eos_reached:: + print (std::ostream& os) const + { + os << what (); + } + + const char* eos_reached:: + what () const throw () + { + return "end of argument stream reached"; + } + + // file_io_failure + // + file_io_failure:: + ~file_io_failure () throw () + { + } + + void file_io_failure:: + print (std::ostream& os) const + { + os << "unable to open file '" << file () << "' or read failure"; + } + + const char* file_io_failure:: + what () const throw () + { + return "unable to open file or read failure"; + } + + // unmatched_quote + // + unmatched_quote:: + ~unmatched_quote () throw () + { + } + + void unmatched_quote:: + print (std::ostream& os) const + { + os << "unmatched quote in argument '" << argument () << "'"; + } + + const char* unmatched_quote:: + what () const throw () + { + return "unmatched quote"; + } + + // scanner + // + scanner:: + ~scanner () + { + } + + // argv_scanner + // + bool argv_scanner:: + more () + { + return i_ < argc_; + } + + const char* argv_scanner:: + peek () + { + if (i_ < argc_) + return argv_[i_]; + else + throw eos_reached (); + } + + const char* argv_scanner:: + next () + { + if (i_ < argc_) + { + const char* r (argv_[i_]); + + if (erase_) + { + for (int i (i_ + 1); i < argc_; ++i) + argv_[i - 1] = argv_[i]; + + --argc_; + argv_[argc_] = 0; + } + else + ++i_; + + return r; + } + else + throw eos_reached (); + } + + void argv_scanner:: + skip () + { + if (i_ < argc_) + ++i_; + else + throw eos_reached (); + } + + // argv_file_scanner + // + bool argv_file_scanner:: + more () + { + if (!args_.empty ()) + return true; + + while (base::more ()) + { + // See if the next argument is the file option. + // + const char* a (base::peek ()); + + if (!skip_ && a == option_) + { + base::next (); + + if (!base::more ()) + throw missing_value (option_); + + load (base::next ()); + + if (!args_.empty ()) + return true; + } + else + { + if (!skip_) + skip_ = (std::strcmp (a, "--") == 0); + + return true; + } + } + + return false; + } + + const char* argv_file_scanner:: + peek () + { + if (!more ()) + throw eos_reached (); + + return args_.empty () ? base::peek () : args_.front ().c_str (); + } + + const char* argv_file_scanner:: + next () + { + if (!more ()) + throw eos_reached (); + + if (args_.empty ()) + return base::next (); + else + { + hold_.swap (args_.front ()); + args_.pop_front (); + return hold_.c_str (); + } + } + + void argv_file_scanner:: + skip () + { + if (!more ()) + throw eos_reached (); + + if (args_.empty ()) + return base::skip (); + else + args_.pop_front (); + } + + void argv_file_scanner:: + load (const char* file) + { + using namespace std; + + ifstream is (file); + + if (!is.is_open ()) + throw file_io_failure (file); + + while (!is.eof ()) + { + string line; + getline (is, line); + + if (is.fail () && !is.eof ()) + throw file_io_failure (file); + + string::size_type n (line.size ()); + + // Trim the line from leading and trailing whitespaces. + // + if (n != 0) + { + const char* f (line.c_str ()); + const char* l (f + n); + + const char* of (f); + while (f < l && (*f == ' ' || *f == '\t' || *f == '\r')) + ++f; + + --l; + + const char* ol (l); + while (l > f && (*l == ' ' || *l == '\t' || *l == '\r')) + --l; + + if (f != of || l != ol) + line = f <= l ? string (f, l - f + 1) : string (); + } + + // Ignore empty lines, those that start with #. + // + if (line.empty () || line[0] == '#') + continue; + + string::size_type p (line.find (' ')); + + if (p == string::npos) + { + if (!skip_) + skip_ = (line == "--"); + + args_.push_back (line); + } + else + { + string s1 (line, 0, p); + + // Skip leading whitespaces in the argument. + // + n = line.size (); + for (++p; p < n; ++p) + { + char c (line[p]); + + if (c != ' ' && c != '\t' && c != '\r') + break; + } + + string s2 (line, p); + + // If the string is wrapped in quotes, remove them. + // + n = s2.size (); + char cf (s2[0]), cl (s2[n - 1]); + + if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'') + { + if (n == 1 || cf != cl) + throw unmatched_quote (s2); + + s2 = string (s2, 1, n - 2); + } + + if (!skip_ && s1 == option_) + load (s2.c_str ()); + else + { + args_.push_back (s1); + args_.push_back (s2); + } + } + } + } + + template + struct parser + { + static void + parse (X& x, bool& xs, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + { + const char* v (s.next ()); + std::istringstream is (v); + if (!(is >> x && is.eof ())) + throw invalid_value (o, v); + } + else + throw missing_value (o); + + xs = true; + } + }; + + template <> + struct parser + { + static void + parse (bool& x, scanner& s) + { + s.next (); + x = true; + } + }; + + template <> + struct parser + { + static void + parse (std::string& x, bool& xs, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + x = s.next (); + else + throw missing_value (o); + + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::vector& c, bool& xs, scanner& s) + { + X x; + bool dummy; + parser::parse (x, dummy, s); + c.push_back (x); + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::set& c, bool& xs, scanner& s) + { + X x; + bool dummy; + parser::parse (x, dummy, s); + c.insert (x); + xs = true; + } + }; + + template + struct parser > + { + static void + parse (std::map& m, bool& xs, scanner& s) + { + const char* o (s.next ()); + + if (s.more ()) + { + std::string ov (s.next ()); + std::string::size_type p = ov.find ('='); + + if (p == std::string::npos) + { + K k = K (); + + if (!ov.empty ()) + { + std::istringstream ks (ov); + + if (!(ks >> k && ks.eof ())) + throw invalid_value (o, ov); + } + + m[k] = V (); + } + else + { + K k = K (); + V v = V (); + std::string kstr (ov, 0, p); + std::string vstr (ov, p + 1); + + if (!kstr.empty ()) + { + std::istringstream ks (kstr); + + if (!(ks >> k && ks.eof ())) + throw invalid_value (o, ov); + } + + if (!vstr.empty ()) + { + std::istringstream vs (vstr); + + if (!(vs >> v && vs.eof ())) + throw invalid_value (o, ov); + } + + m[k] = v; + } + } + else + throw missing_value (o); + + xs = true; + } + }; + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, s); + } + + template + void + thunk (X& x, scanner& s) + { + parser::parse (x.*M, x.*S, s); + } +} + +#include +#include + +namespace cli +{ + // mysql_options + // + + mysql_options:: + mysql_options (int& argc, + char** argv, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : help_ (), + user_ (), + user_specified_ (false), + passwd_ (), + passwd_specified_ (false), + db_name_ (), + db_name_specified_ (false), + host_ (), + host_specified_ (false), + port_ (0), + port_specified_ (false), + socket_ (), + socket_specified_ (false), + options_file_ (), + options_file_specified_ (false) + { + ::cli::argv_scanner s (argc, argv, erase); + _parse (s, opt, arg); + } + + mysql_options:: + mysql_options (int start, + int& argc, + char** argv, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : help_ (), + user_ (), + user_specified_ (false), + passwd_ (), + passwd_specified_ (false), + db_name_ (), + db_name_specified_ (false), + host_ (), + host_specified_ (false), + port_ (0), + port_specified_ (false), + socket_ (), + socket_specified_ (false), + options_file_ (), + options_file_specified_ (false) + { + ::cli::argv_scanner s (start, argc, argv, erase); + _parse (s, opt, arg); + } + + mysql_options:: + mysql_options (int& argc, + char** argv, + int& end, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : help_ (), + user_ (), + user_specified_ (false), + passwd_ (), + passwd_specified_ (false), + db_name_ (), + db_name_specified_ (false), + host_ (), + host_specified_ (false), + port_ (0), + port_specified_ (false), + socket_ (), + socket_specified_ (false), + options_file_ (), + options_file_specified_ (false) + { + ::cli::argv_scanner s (argc, argv, erase); + _parse (s, opt, arg); + end = s.end (); + } + + mysql_options:: + mysql_options (int start, + int& argc, + char** argv, + int& end, + bool erase, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : help_ (), + user_ (), + user_specified_ (false), + passwd_ (), + passwd_specified_ (false), + db_name_ (), + db_name_specified_ (false), + host_ (), + host_specified_ (false), + port_ (0), + port_specified_ (false), + socket_ (), + socket_specified_ (false), + options_file_ (), + options_file_specified_ (false) + { + ::cli::argv_scanner s (start, argc, argv, erase); + _parse (s, opt, arg); + end = s.end (); + } + + mysql_options:: + mysql_options (::cli::scanner& s, + ::cli::unknown_mode opt, + ::cli::unknown_mode arg) + : help_ (), + user_ (), + user_specified_ (false), + passwd_ (), + passwd_specified_ (false), + db_name_ (), + db_name_specified_ (false), + host_ (), + host_specified_ (false), + port_ (0), + port_specified_ (false), + socket_ (), + socket_specified_ (false), + options_file_ (), + options_file_specified_ (false) + { + _parse (s, opt, arg); + } + + void mysql_options:: + print_usage (::std::ostream& os) + { + os << "--help Print usage information and exit." << ::std::endl; + + os << "--user MySQL database user." << ::std::endl; + + os << "--passwd MySQL database password" << ::std::endl; + + os << "--db-name MySQL database name." << ::std::endl; + + os << "--host MySQL database host name or address (localhost by" << ::std::endl + << " default)." << ::std::endl; + + os << "--port MySQL database port number." << ::std::endl; + + os << "--socket MySQL database socket name." << ::std::endl; + + os << "--options-file Read additional options from ." << ::std::endl; + } + + typedef + std::map + _cli_mysql_options_map; + + static _cli_mysql_options_map _cli_mysql_options_map_; + + struct _cli_mysql_options_map_init + { + _cli_mysql_options_map_init () + { + _cli_mysql_options_map_["--help"] = + &::cli::thunk< mysql_options, bool, &mysql_options::help_ >; + _cli_mysql_options_map_["--user"] = + &::cli::thunk< mysql_options, std::string, &mysql_options::user_, + &mysql_options::user_specified_ >; + _cli_mysql_options_map_["--passwd"] = + &::cli::thunk< mysql_options, std::string, &mysql_options::passwd_, + &mysql_options::passwd_specified_ >; + _cli_mysql_options_map_["--db-name"] = + &::cli::thunk< mysql_options, std::string, &mysql_options::db_name_, + &mysql_options::db_name_specified_ >; + _cli_mysql_options_map_["--host"] = + &::cli::thunk< mysql_options, std::string, &mysql_options::host_, + &mysql_options::host_specified_ >; + _cli_mysql_options_map_["--port"] = + &::cli::thunk< mysql_options, unsigned int, &mysql_options::port_, + &mysql_options::port_specified_ >; + _cli_mysql_options_map_["--socket"] = + &::cli::thunk< mysql_options, std::string, &mysql_options::socket_, + &mysql_options::socket_specified_ >; + _cli_mysql_options_map_["--options-file"] = + &::cli::thunk< mysql_options, std::string, &mysql_options::options_file_, + &mysql_options::options_file_specified_ >; + } + } _cli_mysql_options_map_init_; + + void mysql_options:: + _parse (::cli::scanner& s, + ::cli::unknown_mode opt_mode, + ::cli::unknown_mode arg_mode) + { + bool opt = true; + + while (s.more ()) + { + const char* o = s.peek (); + + if (std::strcmp (o, "--") == 0) + { + s.skip (); + opt = false; + continue; + } + + _cli_mysql_options_map::const_iterator i ( + opt ? _cli_mysql_options_map_.find (o) : _cli_mysql_options_map_.end ()); + + if (i != _cli_mysql_options_map_.end ()) + { + (*(i->second)) (*this, s); + } + else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0') + { + switch (opt_mode) + { + case ::cli::unknown_mode::skip: + { + s.skip (); + continue; + } + case ::cli::unknown_mode::stop: + { + break; + } + case ::cli::unknown_mode::fail: + { + throw ::cli::unknown_option (o); + } + } + + break; + } + else + { + switch (arg_mode) + { + case ::cli::unknown_mode::skip: + { + s.skip (); + continue; + } + case ::cli::unknown_mode::stop: + { + break; + } + case ::cli::unknown_mode::fail: + { + throw ::cli::unknown_argument (o); + } + } + + break; + } + } + } +} + diff --git a/libcommon/common/options.hxx b/libcommon/common/options.hxx new file mode 100644 index 0000000..7d043a3 --- /dev/null +++ b/libcommon/common/options.hxx @@ -0,0 +1,396 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +#ifndef LIBCOMMON_COMMON_OPTIONS_HXX +#define LIBCOMMON_COMMON_OPTIONS_HXX + +#include +#include +#include +#include + +namespace cli +{ + class unknown_mode + { + public: + enum value + { + skip, + stop, + fail + }; + + unknown_mode (value v); + + operator value () const + { + return v_; + } + + private: + value v_; + }; + + // Exceptions. + // + + class exception: public std::exception + { + public: + virtual void + print (std::ostream&) const = 0; + }; + + std::ostream& + operator<< (std::ostream&, const exception&); + + class unknown_option: public exception + { + public: + virtual + ~unknown_option () throw (); + + unknown_option (const std::string& option); + + const std::string& + option () const; + + virtual void + print (std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string option_; + }; + + class unknown_argument: public exception + { + public: + virtual + ~unknown_argument () throw (); + + unknown_argument (const std::string& argument); + + const std::string& + argument () const; + + virtual void + print (std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string argument_; + }; + + class missing_value: public exception + { + public: + virtual + ~missing_value () throw (); + + missing_value (const std::string& option); + + const std::string& + option () const; + + virtual void + print (std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string option_; + }; + + class invalid_value: public exception + { + public: + virtual + ~invalid_value () throw (); + + invalid_value (const std::string& option, + const std::string& value); + + const std::string& + option () const; + + const std::string& + value () const; + + virtual void + print (std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string option_; + std::string value_; + }; + + class eos_reached: public exception + { + public: + virtual void + print (std::ostream&) const; + + virtual const char* + what () const throw (); + }; + + class file_io_failure: public exception + { + public: + virtual + ~file_io_failure () throw (); + + file_io_failure (const std::string& file); + + const std::string& + file () const; + + virtual void + print (std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string file_; + }; + + class unmatched_quote: public exception + { + public: + virtual + ~unmatched_quote () throw (); + + unmatched_quote (const std::string& argument); + + const std::string& + argument () const; + + virtual void + print (std::ostream&) const; + + virtual const char* + what () const throw (); + + private: + std::string argument_; + }; + + class scanner + { + public: + virtual + ~scanner (); + + virtual bool + more () = 0; + + virtual const char* + peek () = 0; + + virtual const char* + next () = 0; + + virtual void + skip () = 0; + }; + + class argv_scanner: public scanner + { + public: + argv_scanner (int& argc, char** argv, bool erase = false); + argv_scanner (int start, int& argc, char** argv, bool erase = false); + + int + end () const; + + virtual bool + more (); + + virtual const char* + peek (); + + virtual const char* + next (); + + virtual void + skip (); + + private: + int i_; + int& argc_; + char** argv_; + bool erase_; + }; + + class argv_file_scanner: public argv_scanner + { + public: + argv_file_scanner (int& argc, + char** argv, + const std::string& file_option, + bool erase = false); + + argv_file_scanner (int start, + int& argc, + char** argv, + const std::string& file_option, + bool erase = false); + + virtual bool + more (); + + virtual const char* + peek (); + + virtual const char* + next (); + + virtual void + skip (); + + private: + void + load (const char* file); + + typedef argv_scanner base; + + const std::string option_; + std::string hold_; + std::deque args_; + bool skip_; + }; +} + +#include + +namespace cli +{ + class mysql_options + { + public: + + mysql_options (int& argc, + char** argv, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + mysql_options (int start, + int& argc, + char** argv, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + mysql_options (int& argc, + char** argv, + int& end, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + mysql_options (int start, + int& argc, + char** argv, + int& end, + bool erase = false, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + mysql_options (::cli::scanner&, + ::cli::unknown_mode option = ::cli::unknown_mode::fail, + ::cli::unknown_mode argument = ::cli::unknown_mode::stop); + + // Option accessors. + // + + const bool& + help () const; + + const std::string& + user () const; + + bool + user_specified () const; + + const std::string& + passwd () const; + + bool + passwd_specified () const; + + const std::string& + db_name () const; + + bool + db_name_specified () const; + + const std::string& + host () const; + + bool + host_specified () const; + + const unsigned int& + port () const; + + bool + port_specified () const; + + const std::string& + socket () const; + + bool + socket_specified () const; + + const std::string& + options_file () const; + + bool + options_file_specified () const; + + // Print usage information. + // + static void + print_usage (::std::ostream&); + + private: + void + _parse (::cli::scanner&, + ::cli::unknown_mode option, + ::cli::unknown_mode argument); + + public: + bool help_; + std::string user_; + bool user_specified_; + std::string passwd_; + bool passwd_specified_; + std::string db_name_; + bool db_name_specified_; + std::string host_; + bool host_specified_; + unsigned int port_; + bool port_specified_; + std::string socket_; + bool socket_specified_; + std::string options_file_; + bool options_file_specified_; + }; +} + +#include "options.ixx" + +#endif // LIBCOMMON_COMMON_OPTIONS_HXX diff --git a/libcommon/common/options.ixx b/libcommon/common/options.ixx new file mode 100644 index 0000000..0fa60e5 --- /dev/null +++ b/libcommon/common/options.ixx @@ -0,0 +1,256 @@ +// This code was generated by CLI, a command line interface +// compiler for C++. +// + +namespace cli +{ + // unknown_mode + // + inline unknown_mode:: + unknown_mode (value v) + : v_ (v) + { + } + + // exception + // + inline std::ostream& + operator<< (std::ostream& os, const exception& e) + { + e.print (os); + return os; + } + + // unknown_option + // + inline unknown_option:: + unknown_option (const std::string& option) + : option_ (option) + { + } + + inline const std::string& unknown_option:: + option () const + { + return option_; + } + + // unknown_argument + // + inline unknown_argument:: + unknown_argument (const std::string& argument) + : argument_ (argument) + { + } + + inline const std::string& unknown_argument:: + argument () const + { + return argument_; + } + + // missing_value + // + inline missing_value:: + missing_value (const std::string& option) + : option_ (option) + { + } + + inline const std::string& missing_value:: + option () const + { + return option_; + } + + // invalid_value + // + inline invalid_value:: + invalid_value (const std::string& option, + const std::string& value) + : option_ (option), value_ (value) + { + } + + inline const std::string& invalid_value:: + option () const + { + return option_; + } + + inline const std::string& invalid_value:: + value () const + { + return value_; + } + + // file_io_failure + // + inline file_io_failure:: + file_io_failure (const std::string& file) + : file_ (file) + { + } + + inline const std::string& file_io_failure:: + file () const + { + return file_; + } + + // unmatched_quote + // + inline unmatched_quote:: + unmatched_quote (const std::string& argument) + : argument_ (argument) + { + } + + inline const std::string& unmatched_quote:: + argument () const + { + return argument_; + } + + // argv_scanner + // + inline argv_scanner:: + argv_scanner (int& argc, char** argv, bool erase) + : i_ (1), argc_ (argc), argv_ (argv), erase_ (erase) + { + } + + inline argv_scanner:: + argv_scanner (int start, int& argc, char** argv, bool erase) + : i_ (start), argc_ (argc), argv_ (argv), erase_ (erase) + { + } + + inline int argv_scanner:: + end () const + { + return i_; + } + + // argv_file_scanner + // + inline argv_file_scanner:: + argv_file_scanner (int& argc, + char** argv, + const std::string& option, + bool erase) + : argv_scanner (argc, argv, erase), + option_ (option), + skip_ (false) + { + } + + inline argv_file_scanner:: + argv_file_scanner (int start, + int& argc, + char** argv, + const std::string& option, + bool erase) + : argv_scanner (start, argc, argv, erase), + option_ (option), + skip_ (false) + { + } +} + +namespace cli +{ + // mysql_options + // + + inline const bool& mysql_options:: + help () const + { + return this->help_; + } + + inline const std::string& mysql_options:: + user () const + { + return this->user_; + } + + inline bool mysql_options:: + user_specified () const + { + return this->user_specified_; + } + + inline const std::string& mysql_options:: + passwd () const + { + return this->passwd_; + } + + inline bool mysql_options:: + passwd_specified () const + { + return this->passwd_specified_; + } + + inline const std::string& mysql_options:: + db_name () const + { + return this->db_name_; + } + + inline bool mysql_options:: + db_name_specified () const + { + return this->db_name_specified_; + } + + inline const std::string& mysql_options:: + host () const + { + return this->host_; + } + + inline bool mysql_options:: + host_specified () const + { + return this->host_specified_; + } + + inline const unsigned int& mysql_options:: + port () const + { + return this->port_; + } + + inline bool mysql_options:: + port_specified () const + { + return this->port_specified_; + } + + inline const std::string& mysql_options:: + socket () const + { + return this->socket_; + } + + inline bool mysql_options:: + socket_specified () const + { + return this->socket_specified_; + } + + inline const std::string& mysql_options:: + options_file () const + { + return this->options_file_; + } + + inline bool mysql_options:: + options_file_specified () const + { + return this->options_file_specified_; + } +} + diff --git a/libcommon/config.h.in b/libcommon/config.h.in deleted file mode 100644 index 9d18901..0000000 --- a/libcommon/config.h.in +++ /dev/null @@ -1,15 +0,0 @@ -/* file : libcommon/config.h.in - * author : Boris Kolpackov - * copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC - * license : GNU GPL v2; see accompanying LICENSE file - */ - -/* This file is automatically processed by configure. */ - -#ifndef LIBCOMMON_CONFIG_H -#define LIBCOMMON_CONFIG_H - -#undef DB_ID_MYSQL -#undef LIBCOMMON_STATIC_LIB - -#endif /* LIBCOMMON_CONFIG_H */ diff --git a/libcommon/export.hxx b/libcommon/export.hxx deleted file mode 100644 index 8bbb96c..0000000 --- a/libcommon/export.hxx +++ /dev/null @@ -1,39 +0,0 @@ -// file : libcommon/export.hxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef LIBCOMMON_EXPORT_HXX -#define LIBCOMMON_EXPORT_HXX - -#ifndef _MSC_VER -# include -#endif - -#ifdef LIBCOMMON_STATIC_LIB -# define LIBCOMMON_EXPORT -#else -# ifdef _WIN32 -# ifdef _MSC_VER -# ifdef LIBCOMMON_DYNAMIC_LIB -# define LIBCOMMON_EXPORT __declspec(dllexport) -# else -# define LIBCOMMON_EXPORT __declspec(dllimport) -# endif -# else -# ifdef LIBCOMMON_DYNAMIC_LIB -# ifdef DLL_EXPORT -# define LIBCOMMON_EXPORT __declspec(dllexport) -# else -# define LIBCOMMON_EXPORT -# endif -# else -# define LIBCOMMON_EXPORT __declspec(dllimport) -# endif -# endif -# else -# define LIBCOMMON_EXPORT -# endif -#endif - -#endif // LIBCOMMON_EXPORT_HXX diff --git a/libcommon/libcommon-vc10.sln b/libcommon/libcommon-vc10.sln new file mode 100644 index 0000000..9042eed --- /dev/null +++ b/libcommon/libcommon-vc10.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcommon", "common\libcommon-__value__(database)-vc10.vcxproj", "{019C2E51-BF41-4490-AB96-4156741B8CC9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {019C2E51-BF41-4490-AB96-4156741B8CC9}.Debug|Win32.ActiveCfg = Debug|Win32 + {019C2E51-BF41-4490-AB96-4156741B8CC9}.Debug|Win32.Build.0 = Debug|Win32 + {019C2E51-BF41-4490-AB96-4156741B8CC9}.Debug|x64.ActiveCfg = Debug|x64 + {019C2E51-BF41-4490-AB96-4156741B8CC9}.Debug|x64.Build.0 = Debug|x64 + {019C2E51-BF41-4490-AB96-4156741B8CC9}.Release|Win32.ActiveCfg = Release|Win32 + {019C2E51-BF41-4490-AB96-4156741B8CC9}.Release|Win32.Build.0 = Release|Win32 + {019C2E51-BF41-4490-AB96-4156741B8CC9}.Release|x64.ActiveCfg = Release|x64 + {019C2E51-BF41-4490-AB96-4156741B8CC9}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libcommon/libcommon-vc9.sln b/libcommon/libcommon-vc9.sln new file mode 100644 index 0000000..e12c11d --- /dev/null +++ b/libcommon/libcommon-vc9.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcommon", "common\libcommon-__value__(database)-vc9.vcproj", "{8575F058-1BD6-4F97-8901-83D0110C2B6B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8575F058-1BD6-4F97-8901-83D0110C2B6B}.Debug|Win32.ActiveCfg = Debug|Win32 + {8575F058-1BD6-4F97-8901-83D0110C2B6B}.Debug|Win32.Build.0 = Debug|Win32 + {8575F058-1BD6-4F97-8901-83D0110C2B6B}.Debug|x64.ActiveCfg = Debug|x64 + {8575F058-1BD6-4F97-8901-83D0110C2B6B}.Debug|x64.Build.0 = Debug|x64 + {8575F058-1BD6-4F97-8901-83D0110C2B6B}.Release|Win32.ActiveCfg = Release|Win32 + {8575F058-1BD6-4F97-8901-83D0110C2B6B}.Release|Win32.Build.0 = Release|Win32 + {8575F058-1BD6-4F97-8901-83D0110C2B6B}.Release|x64.ActiveCfg = Release|x64 + {8575F058-1BD6-4F97-8901-83D0110C2B6B}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libcommon/makefile b/libcommon/makefile index cdb57bc..8f72324 100644 --- a/libcommon/makefile +++ b/libcommon/makefile @@ -1,119 +1,30 @@ # file : libcommon/makefile # author : Boris Kolpackov # copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC -# license : GNU GPL v2; see accompanying LICENSE file +# license : GNU GPL; see accompanying LICENSE file include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make -# Options file. -# -cli_tun := options.cli -cxx_tun := common.cxx +dirs := common -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(cli_tun:.cli=.o)) -cxx_od := $(cxx_obj:.o=.o.d) +default := $(out_base)/ +dist := $(out_base)/.dist +clean := $(out_base)/.clean -common.l := $(out_base)/common.l -common.l.cpp-options := $(out_base)/common.l.cpp-options +$(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) -default := $(out_base)/ -dist := $(out_base)/.dist -clean := $(out_base)/.clean - -# Import. -# -$(call import,\ - $(scf_root)/import/cli/stub.make,\ - cli: cli,cli-rules: cli_rules) - -$(call import,\ - $(scf_root)/import/libodb/stub.make,\ - l: odb.l,cpp-options: odb.l.cpp-options) - -ifdef db_id -$(call import,\ - $(scf_root)/import/libodb-$(db_id)/stub.make,\ - l: odb_db.l,cpp-options: odb_db.l.cpp-options) -endif - -ifeq ($(odb_db.l.cpp-options),) -odb_db.l.cpp-options := $(out_base)/.unbuildable -endif - -# Build. -# -$(common.l): $(cxx_obj) $(odb.l) $(odb_db.l) - -$(cxx_obj) $(cxx_od): $(common.l.cpp-options) $(out_base)/config.h -$(common.l.cpp-options): value := -I$(out_base) -I$(src_base) -$(common.l.cpp-options): $(odb_db.l.cpp-options) $(odb.l.cpp-options) - -genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx) -gen := $(addprefix $(out_base)/,$(genf)) - -$(gen): $(cli) -$(gen): cli := $(cli) -$(gen): cli_options += \ ---generate-specifier \ ---generate-file-scanner \ ---guard-prefix LIBCOMMON - -$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) - -$(out_base)/config.h: $(dcf_root)/configuration-dynamic.make - @echo '// file : libcommon/config.h' >$@ - @echo '// author : automatically generated' >>$@ - @echo '' >>$@ - @echo '#ifndef LIBCOMMON_CONFIG_H' >>$@ - @echo '#define LIBCOMMON_CONFIG_H' >>$@ - @echo '' >>$@ -ifeq ($(db_id),mysql) - @echo '#define DB_ID_MYSQL 1' >>$@ -endif - @echo '' >>$@ - @echo '#endif // LIBCOMMON_CONFIG_H' >>$@ - -# Convenience alias for default target. -# -$(out_base)/: $(common.l) - -# Dist. -# -$(dist): export sources := $(cxx_tun) $(cli_tun:.cli=.cxx) -$(dist): export headers = $(subst $(src_base)/,,$(shell find $(src_base) \ --name '*.hxx' -o -name '*.ixx' -o -name '*.txx')) -$(dist): data_dist := $(cli_tun) -$(dist): export extra_dist := $(data_dist) - -$(dist): $(gen) - $(call dist-data,$(sources) $(headers) $(data_dist) config.h.in) +$(dist): export dirs := $(dirs) +$(dist): export extra_dist := $(call vc9slns,libcommon) \ +$(call vc10slns,libcommon) +$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(dirs))) $(call meta-automake) + $(call meta-vc9slns,libcommon) + $(call meta-vc10slns,libcommon) -# Clean. -# -$(clean): $(common.l).o.clean \ - $(common.l.cpp-options).clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) - $(call message,rm $$1,rm -f $$1,$(out_base)/config.h) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(common.l): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := config.h -$(clean): $(out_base)/.gitignore.clean - -$(call include,$(bld_root)/git/gitignore.make) -endif +$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(dirs))) -# How to. -# -$(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9sln.make) +$(call include,$(bld_root)/meta/vc10sln.make) $(call include,$(bld_root)/meta/automake.make) -$(call include,$(cli_rules)) -$(call include,$(bld_root)/cxx/cxx-d.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/o-l.make) +$(foreach d,$(dirs),$(call import,$(src_base)/$d/makefile)) diff --git a/libcommon/options.cli b/libcommon/options.cli deleted file mode 100644 index a16c5b0..0000000 --- a/libcommon/options.cli +++ /dev/null @@ -1,58 +0,0 @@ -// file : libcommon/options.cli -// author : Boris Kolpackov -// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -include ; - -namespace cli -{ - class mysql_options - { - bool --help {"Print usage information and exit."}; - - std::string --user - { - "", - "MySQL database user." - }; - - std::string --passwd - { - "", - "MySQL database password" - }; - - std::string --db-name - { - "", - "MySQL database name." - }; - - std::string --host - { - "", - "MySQL database host name or address (localhost by default)." - }; - - unsigned int --port = 0 - { - "", - "MySQL database port number." - }; - - std::string --socket - { - "", - "MySQL database socket name." - }; - - std::string --options-file - { - "", - "Read additional options from . Each option appearing on a separate - line optionally followed by space and an option value. Empty lines and - lines starting with \cb{#} are ignored." - }; - }; -} diff --git a/libcommon/options.cxx b/libcommon/options.cxx deleted file mode 100644 index 9d15251..0000000 --- a/libcommon/options.cxx +++ /dev/null @@ -1,796 +0,0 @@ -// This code was generated by CLI, a command line interface -// compiler for C++. -// - -#include "options.hxx" - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace cli -{ - // unknown_option - // - unknown_option:: - ~unknown_option () throw () - { - } - - void unknown_option:: - print (std::ostream& os) const - { - os << "unknown option '" << option () << "'"; - } - - const char* unknown_option:: - what () const throw () - { - return "unknown option"; - } - - // unknown_argument - // - unknown_argument:: - ~unknown_argument () throw () - { - } - - void unknown_argument:: - print (std::ostream& os) const - { - os << "unknown argument '" << argument () << "'"; - } - - const char* unknown_argument:: - what () const throw () - { - return "unknown argument"; - } - - // missing_value - // - missing_value:: - ~missing_value () throw () - { - } - - void missing_value:: - print (std::ostream& os) const - { - os << "missing value for option '" << option () << "'"; - } - - const char* missing_value:: - what () const throw () - { - return "missing option value"; - } - - // invalid_value - // - invalid_value:: - ~invalid_value () throw () - { - } - - void invalid_value:: - print (std::ostream& os) const - { - os << "invalid value '" << value () << "' for option '" - << option () << "'"; - } - - const char* invalid_value:: - what () const throw () - { - return "invalid option value"; - } - - // eos_reached - // - void eos_reached:: - print (std::ostream& os) const - { - os << what (); - } - - const char* eos_reached:: - what () const throw () - { - return "end of argument stream reached"; - } - - // file_io_failure - // - file_io_failure:: - ~file_io_failure () throw () - { - } - - void file_io_failure:: - print (std::ostream& os) const - { - os << "unable to open file '" << file () << "' or read failure"; - } - - const char* file_io_failure:: - what () const throw () - { - return "unable to open file or read failure"; - } - - // unmatched_quote - // - unmatched_quote:: - ~unmatched_quote () throw () - { - } - - void unmatched_quote:: - print (std::ostream& os) const - { - os << "unmatched quote in argument '" << argument () << "'"; - } - - const char* unmatched_quote:: - what () const throw () - { - return "unmatched quote"; - } - - // scanner - // - scanner:: - ~scanner () - { - } - - // argv_scanner - // - bool argv_scanner:: - more () - { - return i_ < argc_; - } - - const char* argv_scanner:: - peek () - { - if (i_ < argc_) - return argv_[i_]; - else - throw eos_reached (); - } - - const char* argv_scanner:: - next () - { - if (i_ < argc_) - { - const char* r (argv_[i_]); - - if (erase_) - { - for (int i (i_ + 1); i < argc_; ++i) - argv_[i - 1] = argv_[i]; - - --argc_; - argv_[argc_] = 0; - } - else - ++i_; - - return r; - } - else - throw eos_reached (); - } - - void argv_scanner:: - skip () - { - if (i_ < argc_) - ++i_; - else - throw eos_reached (); - } - - // argv_file_scanner - // - bool argv_file_scanner:: - more () - { - if (!args_.empty ()) - return true; - - while (base::more ()) - { - // See if the next argument is the file option. - // - const char* a (base::peek ()); - - if (!skip_ && a == option_) - { - base::next (); - - if (!base::more ()) - throw missing_value (option_); - - load (base::next ()); - - if (!args_.empty ()) - return true; - } - else - { - if (!skip_) - skip_ = (std::strcmp (a, "--") == 0); - - return true; - } - } - - return false; - } - - const char* argv_file_scanner:: - peek () - { - if (!more ()) - throw eos_reached (); - - return args_.empty () ? base::peek () : args_.front ().c_str (); - } - - const char* argv_file_scanner:: - next () - { - if (!more ()) - throw eos_reached (); - - if (args_.empty ()) - return base::next (); - else - { - hold_.swap (args_.front ()); - args_.pop_front (); - return hold_.c_str (); - } - } - - void argv_file_scanner:: - skip () - { - if (!more ()) - throw eos_reached (); - - if (args_.empty ()) - return base::skip (); - else - args_.pop_front (); - } - - void argv_file_scanner:: - load (const char* file) - { - using namespace std; - - ifstream is (file); - - if (!is.is_open ()) - throw file_io_failure (file); - - while (!is.eof ()) - { - string line; - getline (is, line); - - if (is.fail () && !is.eof ()) - throw file_io_failure (file); - - string::size_type n (line.size ()); - - // Trim the line from leading and trailing whitespaces. - // - if (n != 0) - { - const char* f (line.c_str ()); - const char* l (f + n); - - const char* of (f); - while (f < l && (*f == ' ' || *f == '\t' || *f == '\r')) - ++f; - - --l; - - const char* ol (l); - while (l > f && (*l == ' ' || *l == '\t' || *l == '\r')) - --l; - - if (f != of || l != ol) - line = f <= l ? string (f, l - f + 1) : string (); - } - - // Ignore empty lines, those that start with #. - // - if (line.empty () || line[0] == '#') - continue; - - string::size_type p (line.find (' ')); - - if (p == string::npos) - { - if (!skip_) - skip_ = (line == "--"); - - args_.push_back (line); - } - else - { - string s1 (line, 0, p); - - // Skip leading whitespaces in the argument. - // - n = line.size (); - for (++p; p < n; ++p) - { - char c (line[p]); - - if (c != ' ' && c != '\t' && c != '\r') - break; - } - - string s2 (line, p); - - // If the string is wrapped in quotes, remove them. - // - n = s2.size (); - char cf (s2[0]), cl (s2[n - 1]); - - if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'') - { - if (n == 1 || cf != cl) - throw unmatched_quote (s2); - - s2 = string (s2, 1, n - 2); - } - - if (!skip_ && s1 == option_) - load (s2.c_str ()); - else - { - args_.push_back (s1); - args_.push_back (s2); - } - } - } - } - - template - struct parser - { - static void - parse (X& x, bool& xs, scanner& s) - { - const char* o (s.next ()); - - if (s.more ()) - { - const char* v (s.next ()); - std::istringstream is (v); - if (!(is >> x && is.eof ())) - throw invalid_value (o, v); - } - else - throw missing_value (o); - - xs = true; - } - }; - - template <> - struct parser - { - static void - parse (bool& x, scanner& s) - { - s.next (); - x = true; - } - }; - - template <> - struct parser - { - static void - parse (std::string& x, bool& xs, scanner& s) - { - const char* o (s.next ()); - - if (s.more ()) - x = s.next (); - else - throw missing_value (o); - - xs = true; - } - }; - - template - struct parser > - { - static void - parse (std::vector& c, bool& xs, scanner& s) - { - X x; - bool dummy; - parser::parse (x, dummy, s); - c.push_back (x); - xs = true; - } - }; - - template - struct parser > - { - static void - parse (std::set& c, bool& xs, scanner& s) - { - X x; - bool dummy; - parser::parse (x, dummy, s); - c.insert (x); - xs = true; - } - }; - - template - struct parser > - { - static void - parse (std::map& m, bool& xs, scanner& s) - { - const char* o (s.next ()); - - if (s.more ()) - { - std::string ov (s.next ()); - std::string::size_type p = ov.find ('='); - - if (p == std::string::npos) - { - K k = K (); - - if (!ov.empty ()) - { - std::istringstream ks (ov); - - if (!(ks >> k && ks.eof ())) - throw invalid_value (o, ov); - } - - m[k] = V (); - } - else - { - K k = K (); - V v = V (); - std::string kstr (ov, 0, p); - std::string vstr (ov, p + 1); - - if (!kstr.empty ()) - { - std::istringstream ks (kstr); - - if (!(ks >> k && ks.eof ())) - throw invalid_value (o, ov); - } - - if (!vstr.empty ()) - { - std::istringstream vs (vstr); - - if (!(vs >> v && vs.eof ())) - throw invalid_value (o, ov); - } - - m[k] = v; - } - } - else - throw missing_value (o); - - xs = true; - } - }; - - template - void - thunk (X& x, scanner& s) - { - parser::parse (x.*M, s); - } - - template - void - thunk (X& x, scanner& s) - { - parser::parse (x.*M, x.*S, s); - } -} - -#include -#include - -namespace cli -{ - // mysql_options - // - - mysql_options:: - mysql_options (int& argc, - char** argv, - bool erase, - ::cli::unknown_mode opt, - ::cli::unknown_mode arg) - : help_ (), - user_ (), - user_specified_ (false), - passwd_ (), - passwd_specified_ (false), - db_name_ (), - db_name_specified_ (false), - host_ (), - host_specified_ (false), - port_ (0), - port_specified_ (false), - socket_ (), - socket_specified_ (false), - options_file_ (), - options_file_specified_ (false) - { - ::cli::argv_scanner s (argc, argv, erase); - _parse (s, opt, arg); - } - - mysql_options:: - mysql_options (int start, - int& argc, - char** argv, - bool erase, - ::cli::unknown_mode opt, - ::cli::unknown_mode arg) - : help_ (), - user_ (), - user_specified_ (false), - passwd_ (), - passwd_specified_ (false), - db_name_ (), - db_name_specified_ (false), - host_ (), - host_specified_ (false), - port_ (0), - port_specified_ (false), - socket_ (), - socket_specified_ (false), - options_file_ (), - options_file_specified_ (false) - { - ::cli::argv_scanner s (start, argc, argv, erase); - _parse (s, opt, arg); - } - - mysql_options:: - mysql_options (int& argc, - char** argv, - int& end, - bool erase, - ::cli::unknown_mode opt, - ::cli::unknown_mode arg) - : help_ (), - user_ (), - user_specified_ (false), - passwd_ (), - passwd_specified_ (false), - db_name_ (), - db_name_specified_ (false), - host_ (), - host_specified_ (false), - port_ (0), - port_specified_ (false), - socket_ (), - socket_specified_ (false), - options_file_ (), - options_file_specified_ (false) - { - ::cli::argv_scanner s (argc, argv, erase); - _parse (s, opt, arg); - end = s.end (); - } - - mysql_options:: - mysql_options (int start, - int& argc, - char** argv, - int& end, - bool erase, - ::cli::unknown_mode opt, - ::cli::unknown_mode arg) - : help_ (), - user_ (), - user_specified_ (false), - passwd_ (), - passwd_specified_ (false), - db_name_ (), - db_name_specified_ (false), - host_ (), - host_specified_ (false), - port_ (0), - port_specified_ (false), - socket_ (), - socket_specified_ (false), - options_file_ (), - options_file_specified_ (false) - { - ::cli::argv_scanner s (start, argc, argv, erase); - _parse (s, opt, arg); - end = s.end (); - } - - mysql_options:: - mysql_options (::cli::scanner& s, - ::cli::unknown_mode opt, - ::cli::unknown_mode arg) - : help_ (), - user_ (), - user_specified_ (false), - passwd_ (), - passwd_specified_ (false), - db_name_ (), - db_name_specified_ (false), - host_ (), - host_specified_ (false), - port_ (0), - port_specified_ (false), - socket_ (), - socket_specified_ (false), - options_file_ (), - options_file_specified_ (false) - { - _parse (s, opt, arg); - } - - void mysql_options:: - print_usage (::std::ostream& os) - { - os << "--help Print usage information and exit." << ::std::endl; - - os << "--user MySQL database user." << ::std::endl; - - os << "--passwd MySQL database password" << ::std::endl; - - os << "--db-name MySQL database name." << ::std::endl; - - os << "--host MySQL database host name or address (localhost by" << ::std::endl - << " default)." << ::std::endl; - - os << "--port MySQL database port number." << ::std::endl; - - os << "--socket MySQL database socket name." << ::std::endl; - - os << "--options-file Read additional options from ." << ::std::endl; - } - - typedef - std::map - _cli_mysql_options_map; - - static _cli_mysql_options_map _cli_mysql_options_map_; - - struct _cli_mysql_options_map_init - { - _cli_mysql_options_map_init () - { - _cli_mysql_options_map_["--help"] = - &::cli::thunk< mysql_options, bool, &mysql_options::help_ >; - _cli_mysql_options_map_["--user"] = - &::cli::thunk< mysql_options, std::string, &mysql_options::user_, - &mysql_options::user_specified_ >; - _cli_mysql_options_map_["--passwd"] = - &::cli::thunk< mysql_options, std::string, &mysql_options::passwd_, - &mysql_options::passwd_specified_ >; - _cli_mysql_options_map_["--db-name"] = - &::cli::thunk< mysql_options, std::string, &mysql_options::db_name_, - &mysql_options::db_name_specified_ >; - _cli_mysql_options_map_["--host"] = - &::cli::thunk< mysql_options, std::string, &mysql_options::host_, - &mysql_options::host_specified_ >; - _cli_mysql_options_map_["--port"] = - &::cli::thunk< mysql_options, unsigned int, &mysql_options::port_, - &mysql_options::port_specified_ >; - _cli_mysql_options_map_["--socket"] = - &::cli::thunk< mysql_options, std::string, &mysql_options::socket_, - &mysql_options::socket_specified_ >; - _cli_mysql_options_map_["--options-file"] = - &::cli::thunk< mysql_options, std::string, &mysql_options::options_file_, - &mysql_options::options_file_specified_ >; - } - } _cli_mysql_options_map_init_; - - void mysql_options:: - _parse (::cli::scanner& s, - ::cli::unknown_mode opt_mode, - ::cli::unknown_mode arg_mode) - { - bool opt = true; - - while (s.more ()) - { - const char* o = s.peek (); - - if (std::strcmp (o, "--") == 0) - { - s.skip (); - opt = false; - continue; - } - - _cli_mysql_options_map::const_iterator i ( - opt ? _cli_mysql_options_map_.find (o) : _cli_mysql_options_map_.end ()); - - if (i != _cli_mysql_options_map_.end ()) - { - (*(i->second)) (*this, s); - } - else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0') - { - switch (opt_mode) - { - case ::cli::unknown_mode::skip: - { - s.skip (); - continue; - } - case ::cli::unknown_mode::stop: - { - break; - } - case ::cli::unknown_mode::fail: - { - throw ::cli::unknown_option (o); - } - } - - break; - } - else - { - switch (arg_mode) - { - case ::cli::unknown_mode::skip: - { - s.skip (); - continue; - } - case ::cli::unknown_mode::stop: - { - break; - } - case ::cli::unknown_mode::fail: - { - throw ::cli::unknown_argument (o); - } - } - - break; - } - } - } -} - diff --git a/libcommon/options.hxx b/libcommon/options.hxx deleted file mode 100644 index d9e3ab8..0000000 --- a/libcommon/options.hxx +++ /dev/null @@ -1,396 +0,0 @@ -// This code was generated by CLI, a command line interface -// compiler for C++. -// - -#ifndef LIBCOMMON_OPTIONS_HXX -#define LIBCOMMON_OPTIONS_HXX - -#include -#include -#include -#include - -namespace cli -{ - class unknown_mode - { - public: - enum value - { - skip, - stop, - fail - }; - - unknown_mode (value v); - - operator value () const - { - return v_; - } - - private: - value v_; - }; - - // Exceptions. - // - - class exception: public std::exception - { - public: - virtual void - print (std::ostream&) const = 0; - }; - - std::ostream& - operator<< (std::ostream&, const exception&); - - class unknown_option: public exception - { - public: - virtual - ~unknown_option () throw (); - - unknown_option (const std::string& option); - - const std::string& - option () const; - - virtual void - print (std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string option_; - }; - - class unknown_argument: public exception - { - public: - virtual - ~unknown_argument () throw (); - - unknown_argument (const std::string& argument); - - const std::string& - argument () const; - - virtual void - print (std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string argument_; - }; - - class missing_value: public exception - { - public: - virtual - ~missing_value () throw (); - - missing_value (const std::string& option); - - const std::string& - option () const; - - virtual void - print (std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string option_; - }; - - class invalid_value: public exception - { - public: - virtual - ~invalid_value () throw (); - - invalid_value (const std::string& option, - const std::string& value); - - const std::string& - option () const; - - const std::string& - value () const; - - virtual void - print (std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string option_; - std::string value_; - }; - - class eos_reached: public exception - { - public: - virtual void - print (std::ostream&) const; - - virtual const char* - what () const throw (); - }; - - class file_io_failure: public exception - { - public: - virtual - ~file_io_failure () throw (); - - file_io_failure (const std::string& file); - - const std::string& - file () const; - - virtual void - print (std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string file_; - }; - - class unmatched_quote: public exception - { - public: - virtual - ~unmatched_quote () throw (); - - unmatched_quote (const std::string& argument); - - const std::string& - argument () const; - - virtual void - print (std::ostream&) const; - - virtual const char* - what () const throw (); - - private: - std::string argument_; - }; - - class scanner - { - public: - virtual - ~scanner (); - - virtual bool - more () = 0; - - virtual const char* - peek () = 0; - - virtual const char* - next () = 0; - - virtual void - skip () = 0; - }; - - class argv_scanner: public scanner - { - public: - argv_scanner (int& argc, char** argv, bool erase = false); - argv_scanner (int start, int& argc, char** argv, bool erase = false); - - int - end () const; - - virtual bool - more (); - - virtual const char* - peek (); - - virtual const char* - next (); - - virtual void - skip (); - - private: - int i_; - int& argc_; - char** argv_; - bool erase_; - }; - - class argv_file_scanner: public argv_scanner - { - public: - argv_file_scanner (int& argc, - char** argv, - const std::string& file_option, - bool erase = false); - - argv_file_scanner (int start, - int& argc, - char** argv, - const std::string& file_option, - bool erase = false); - - virtual bool - more (); - - virtual const char* - peek (); - - virtual const char* - next (); - - virtual void - skip (); - - private: - void - load (const char* file); - - typedef argv_scanner base; - - const std::string option_; - std::string hold_; - std::deque args_; - bool skip_; - }; -} - -#include - -namespace cli -{ - class mysql_options - { - public: - - mysql_options (int& argc, - char** argv, - bool erase = false, - ::cli::unknown_mode option = ::cli::unknown_mode::fail, - ::cli::unknown_mode argument = ::cli::unknown_mode::stop); - - mysql_options (int start, - int& argc, - char** argv, - bool erase = false, - ::cli::unknown_mode option = ::cli::unknown_mode::fail, - ::cli::unknown_mode argument = ::cli::unknown_mode::stop); - - mysql_options (int& argc, - char** argv, - int& end, - bool erase = false, - ::cli::unknown_mode option = ::cli::unknown_mode::fail, - ::cli::unknown_mode argument = ::cli::unknown_mode::stop); - - mysql_options (int start, - int& argc, - char** argv, - int& end, - bool erase = false, - ::cli::unknown_mode option = ::cli::unknown_mode::fail, - ::cli::unknown_mode argument = ::cli::unknown_mode::stop); - - mysql_options (::cli::scanner&, - ::cli::unknown_mode option = ::cli::unknown_mode::fail, - ::cli::unknown_mode argument = ::cli::unknown_mode::stop); - - // Option accessors. - // - - const bool& - help () const; - - const std::string& - user () const; - - bool - user_specified () const; - - const std::string& - passwd () const; - - bool - passwd_specified () const; - - const std::string& - db_name () const; - - bool - db_name_specified () const; - - const std::string& - host () const; - - bool - host_specified () const; - - const unsigned int& - port () const; - - bool - port_specified () const; - - const std::string& - socket () const; - - bool - socket_specified () const; - - const std::string& - options_file () const; - - bool - options_file_specified () const; - - // Print usage information. - // - static void - print_usage (::std::ostream&); - - private: - void - _parse (::cli::scanner&, - ::cli::unknown_mode option, - ::cli::unknown_mode argument); - - public: - bool help_; - std::string user_; - bool user_specified_; - std::string passwd_; - bool passwd_specified_; - std::string db_name_; - bool db_name_specified_; - std::string host_; - bool host_specified_; - unsigned int port_; - bool port_specified_; - std::string socket_; - bool socket_specified_; - std::string options_file_; - bool options_file_specified_; - }; -} - -#include "options.ixx" - -#endif // LIBCOMMON_OPTIONS_HXX diff --git a/libcommon/options.ixx b/libcommon/options.ixx deleted file mode 100644 index 0fa60e5..0000000 --- a/libcommon/options.ixx +++ /dev/null @@ -1,256 +0,0 @@ -// This code was generated by CLI, a command line interface -// compiler for C++. -// - -namespace cli -{ - // unknown_mode - // - inline unknown_mode:: - unknown_mode (value v) - : v_ (v) - { - } - - // exception - // - inline std::ostream& - operator<< (std::ostream& os, const exception& e) - { - e.print (os); - return os; - } - - // unknown_option - // - inline unknown_option:: - unknown_option (const std::string& option) - : option_ (option) - { - } - - inline const std::string& unknown_option:: - option () const - { - return option_; - } - - // unknown_argument - // - inline unknown_argument:: - unknown_argument (const std::string& argument) - : argument_ (argument) - { - } - - inline const std::string& unknown_argument:: - argument () const - { - return argument_; - } - - // missing_value - // - inline missing_value:: - missing_value (const std::string& option) - : option_ (option) - { - } - - inline const std::string& missing_value:: - option () const - { - return option_; - } - - // invalid_value - // - inline invalid_value:: - invalid_value (const std::string& option, - const std::string& value) - : option_ (option), value_ (value) - { - } - - inline const std::string& invalid_value:: - option () const - { - return option_; - } - - inline const std::string& invalid_value:: - value () const - { - return value_; - } - - // file_io_failure - // - inline file_io_failure:: - file_io_failure (const std::string& file) - : file_ (file) - { - } - - inline const std::string& file_io_failure:: - file () const - { - return file_; - } - - // unmatched_quote - // - inline unmatched_quote:: - unmatched_quote (const std::string& argument) - : argument_ (argument) - { - } - - inline const std::string& unmatched_quote:: - argument () const - { - return argument_; - } - - // argv_scanner - // - inline argv_scanner:: - argv_scanner (int& argc, char** argv, bool erase) - : i_ (1), argc_ (argc), argv_ (argv), erase_ (erase) - { - } - - inline argv_scanner:: - argv_scanner (int start, int& argc, char** argv, bool erase) - : i_ (start), argc_ (argc), argv_ (argv), erase_ (erase) - { - } - - inline int argv_scanner:: - end () const - { - return i_; - } - - // argv_file_scanner - // - inline argv_file_scanner:: - argv_file_scanner (int& argc, - char** argv, - const std::string& option, - bool erase) - : argv_scanner (argc, argv, erase), - option_ (option), - skip_ (false) - { - } - - inline argv_file_scanner:: - argv_file_scanner (int start, - int& argc, - char** argv, - const std::string& option, - bool erase) - : argv_scanner (start, argc, argv, erase), - option_ (option), - skip_ (false) - { - } -} - -namespace cli -{ - // mysql_options - // - - inline const bool& mysql_options:: - help () const - { - return this->help_; - } - - inline const std::string& mysql_options:: - user () const - { - return this->user_; - } - - inline bool mysql_options:: - user_specified () const - { - return this->user_specified_; - } - - inline const std::string& mysql_options:: - passwd () const - { - return this->passwd_; - } - - inline bool mysql_options:: - passwd_specified () const - { - return this->passwd_specified_; - } - - inline const std::string& mysql_options:: - db_name () const - { - return this->db_name_; - } - - inline bool mysql_options:: - db_name_specified () const - { - return this->db_name_specified_; - } - - inline const std::string& mysql_options:: - host () const - { - return this->host_; - } - - inline bool mysql_options:: - host_specified () const - { - return this->host_specified_; - } - - inline const unsigned int& mysql_options:: - port () const - { - return this->port_; - } - - inline bool mysql_options:: - port_specified () const - { - return this->port_specified_; - } - - inline const std::string& mysql_options:: - socket () const - { - return this->socket_; - } - - inline bool mysql_options:: - socket_specified () const - { - return this->socket_specified_; - } - - inline const std::string& mysql_options:: - options_file () const - { - return this->options_file_; - } - - inline bool mysql_options:: - options_file_specified () const - { - return this->options_file_specified_; - } -} - diff --git a/makefile b/makefile index aba3aee..213bab2 100644 --- a/makefile +++ b/makefile @@ -19,7 +19,7 @@ clean := $(out_base)/.clean $(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) -$(dist): data_dist := GPLv2 LICENSE README version +$(dist): data_dist := GPLv2 LICENSE README version tester.bat $(dist): exec_dist := bootstrap tester.in $(dist): export extra_dist := $(data_dist) $(exec_dist) $(dist): export version = $(shell cat $(src_root)/version) diff --git a/mysql/Makefile.am b/mysql/Makefile.am index 1e8c1c0..d07384b 100644 --- a/mysql/Makefile.am +++ b/mysql/Makefile.am @@ -4,3 +4,4 @@ # license : GNU GPL v2; see accompanying LICENSE file SUBDIRS = __path__(dirs) +EXTRA_DIST = __file__(extra_dist) diff --git a/mysql/makefile b/mysql/makefile index 53dd049..4b94e4c 100644 --- a/mysql/makefile +++ b/mysql/makefile @@ -17,13 +17,21 @@ clean := $(out_base)/.clean $(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) +$(dist): name := $(notdir $(src_base)) $(dist): export dirs := $(tests) +$(dist): export extra_dist := $(name)-vc9.sln $(name)-vc10.sln tests.bat $(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(tests))) $(call meta-automake) + $(call meta-vc9sln,$(name)-vc9.sln) + $(call meta-vc10sln,$(name)-vc10.sln) + $(call meta-vctest,$(name)-vc10.sln,$(src_root)/test.bat) $(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) $(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) +$(call include,$(bld_root)/meta/vc9sln.make) +$(call include,$(bld_root)/meta/vc10sln.make) +$(call include,$(bld_root)/meta/vctest.make) $(call include,$(bld_root)/meta/automake.make) $(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/mysql/mysql-vc10.sln b/mysql/mysql-vc10.sln new file mode 100644 index 0000000..9a5dc32 --- /dev/null +++ b/mysql/mysql-vc10.sln @@ -0,0 +1,15 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +__projects__ +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution +__solution_configurations__ + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution +__project_configurations__ + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/mysql/mysql-vc9.sln b/mysql/mysql-vc9.sln new file mode 100644 index 0000000..2ec9432 --- /dev/null +++ b/mysql/mysql-vc9.sln @@ -0,0 +1,15 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +__projects__ +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution +__solution_configurations__ + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution +__project_configurations__ + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/mysql/template/Makefile.am b/mysql/template/Makefile.am index 46c3bae..229e071 100644 --- a/mysql/template/Makefile.am +++ b/mysql/template/Makefile.am @@ -3,13 +3,15 @@ # copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file +EXTRA_DIST = __file__(extra_dist) + noinst_PROGRAMS = driver driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers) -driver_LDADD = $(top_builddir)/libcommon/libcommon.la +driver_LDADD = $(top_builddir)/libcommon/common/libcommon.la driver_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon' TESTS=$(top_builddir)/tester -TESTS_ENVIRONMENT=top_builddir=$(top_builddir); +TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir; m4_ifelse(__value__(odb_options),,, diff --git a/mysql/template/driver.cxx b/mysql/template/driver.cxx index 4f1bb52..45a73eb 100644 --- a/mysql/template/driver.cxx +++ b/mysql/template/driver.cxx @@ -13,7 +13,7 @@ #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" diff --git a/mysql/template/makefile b/mysql/template/makefile index 28146f4..d634728 100644 --- a/mysql/template/makefile +++ b/mysql/template/makefile @@ -10,20 +10,14 @@ odb_hdr := test.hxx cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) cxx_od := $(cxx_obj:.o=.o.d) -common.l := $(out_root)/libcommon/common.l -common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options driver := $(out_base)/driver dist := $(out_base)/.dist test := $(out_base)/.test clean := $(out_base)/.clean -ifdef db_id -ifneq ($(db_id),mysql) -$(error trying to build a MySQL-specific test with $(db_id)) -endif -endif - # Import. # $(call import,\ @@ -53,10 +47,17 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(notdir $(src_base)) +$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \ +$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj) + $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj) # Test. # @@ -87,6 +88,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/mysql/template/template-vc10.vcxproj b/mysql/template/template-vc10.vcxproj new file mode 100644 index 0000000..a6f172c --- /dev/null +++ b/mysql/template/template-vc10.vcxproj @@ -0,0 +1,176 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\libcommon + + + ..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\libcommon + + + ..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\libcommon + + + ..\..\libcommon\lib\common.lib;odb-mysql.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\..\libcommon + + + ..\..\libcommon\lib\common.lib;odb-mysql.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +m4_ifelse(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options))) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +m4_ifelse(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +m4_ifelse(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/mysql/template/template-vc10.vcxproj.filters b/mysql/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..951015b --- /dev/null +++ b/mysql/template/template-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +m4_ifelse(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +m4_ifelse(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/mysql/template/template-vc9.vcproj b/mysql/template/template-vc9.vcproj new file mode 100644 index 0000000..a8dbd23 --- /dev/null +++ b/mysql/template/template-vc9.vcproj @@ -0,0 +1,357 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +m4_ifelse(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +m4_ifelse(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options))) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/mysql/truncation/driver.cxx b/mysql/truncation/driver.cxx index 2117a9e..46350d6 100644 --- a/mysql/truncation/driver.cxx +++ b/mysql/truncation/driver.cxx @@ -13,7 +13,7 @@ #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" diff --git a/mysql/truncation/makefile b/mysql/truncation/makefile index f0d475d..a798c8d 100644 --- a/mysql/truncation/makefile +++ b/mysql/truncation/makefile @@ -10,20 +10,14 @@ odb_hdr := test.hxx cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) cxx_od := $(cxx_obj:.o=.o.d) -common.l := $(out_root)/libcommon/common.l -common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options driver := $(out_base)/driver dist := $(out_base)/.dist test := $(out_base)/.test clean := $(out_base)/.clean -ifdef db_id -ifneq ($(db_id),mysql) -$(error trying to build a MySQL-specific test with $(db_id)) -endif -endif - # Import. # $(call import,\ @@ -53,10 +47,17 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(notdir $(src_base)) +$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \ +$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake,$(src_root)/mysql/template/Makefile.am) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj) + $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj) # Test. # @@ -87,6 +88,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/mysql/types/driver.cxx b/mysql/types/driver.cxx index e0d6b42..2a6c94e 100644 --- a/mysql/types/driver.cxx +++ b/mysql/types/driver.cxx @@ -13,7 +13,7 @@ #include #include -#include +#include #include "test.hxx" #include "test-odb.hxx" @@ -42,7 +42,7 @@ main (int argc, char* argv[]) o.long_long_ = -123456; o.ulong_long_ = 123456; - o.float_ = 1.123; + o.float_ = 1.123F; o.double_ = 1.123; o.decimal_ = "123.456"; diff --git a/mysql/types/makefile b/mysql/types/makefile index 859ef29..60ee402 100644 --- a/mysql/types/makefile +++ b/mysql/types/makefile @@ -10,20 +10,14 @@ odb_hdr := test.hxx cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) cxx_od := $(cxx_obj:.o=.o.d) -common.l := $(out_root)/libcommon/common.l -common.l.cpp-options := $(out_root)/libcommon/common.l.cpp-options +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options driver := $(out_base)/driver dist := $(out_base)/.dist test := $(out_base)/.test clean := $(out_base)/.clean -ifdef db_id -ifneq ($(db_id),mysql) -$(error trying to build a MySQL-specific test with $(db_id)) -endif -endif - # Import. # $(call import,\ @@ -55,11 +49,18 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) traits.hxx test.std +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) $(dist): export extra_headers := traits.hxx +$(dist): data_dist := test.std +$(dist): export name := $(notdir $(src_base)) +$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \ +$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake,$(src_root)/mysql/template/Makefile.am) + $(call dist-data,$(sources) $(headers) $(extra_headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj) + $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj) # Test. # @@ -90,6 +91,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/test.bat b/test.bat new file mode 100644 index 0000000..9c72b2d --- /dev/null +++ b/test.bat @@ -0,0 +1,48 @@ +@echo off +rem file : test.bat +rem author : Boris Kolpackov +rem copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +rem license : GNU GPL v2; see accompanying LICENSE file + +setlocal + +set "tests=__path__(dirs)" +set "confs=__path__(configurations)" +set "topdir=__path__(topdir)\.." + +goto start + +:run_test + cd %1 + + if exist %2\driver.exe ( + echo %1\%2 + call %topdir%\tester.bat tracer %2 + if errorlevel 1 ( + set "failed=%failed% %1\%2" + ) + ) + + cd .. +goto :eof + +:start + +for %%t in (%tests%) do ( + for %%c in (%confs%) do ( + call :run_test %%t %%c + ) +) + +if not "_%failed%_" == "__" goto error + +echo ALL TESTS PASSED +goto end + +:error +for %%t in (%failed%) do echo FAILED: %%t +exit /b 1 +goto end + +:end +endlocal diff --git a/tester.bat b/tester.bat new file mode 100644 index 0000000..9d812ac --- /dev/null +++ b/tester.bat @@ -0,0 +1,54 @@ +@echo off +rem file : tester.bat +rem author : Boris Kolpackov +rem copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +rem license : GNU GPL v2; see accompanying LICENSE file + +rem Run an ODB test. The test directory is the current directory. +rem %1 database id, for example, mysql +rem %2 configuration, for example, Debug or x64/Debug +rem topdir variable containing the path to top project directory + +rem clear errorlevel +rem setlocal & endlocal + +rem echo %1 +rem echo %2 +rem echo "%topdir%" + +if "_%DIFF%_" == "__" set DIFF=fc + +if exist test.sql ( + %topdir%\%1-driver test.sql + if errorlevel 1 goto error +) + +rem echo %2\driver.exe --options-file %topdir%\%1.options + +if exist test.std ( + %2\driver.exe --options-file %topdir%\%1.options >test.out + if errorlevel 1 goto error + %DIFF% test.std test.out + + if errorlevel 1 ( + del /f test.out + goto error + ) + + del /f test.out + goto end + +) else ( + + %2\driver.exe --options-file %topdir%\%1.options + if errorlevel 1 goto error +) + +goto end + + +:error +exit /b 1 +goto end + +:end diff --git a/tester.in b/tester.in index b34c6ab..34e31a5 100755 --- a/tester.in +++ b/tester.in @@ -26,6 +26,9 @@ if test -f "$srcdir/test.std"; then fi @DIFF@ @DIFFFLAGS@ "$srcdir/test.std" test.out + r=$? + rm -f test.out + exit $r else ./driver --options-file "$top_builddir/db.options" fi diff --git a/tracer/Makefile.am b/tracer/Makefile.am index 32feb34..395bd7c 100644 --- a/tracer/Makefile.am +++ b/tracer/Makefile.am @@ -4,3 +4,4 @@ # license : GNU GPL v2; see accompanying LICENSE file SUBDIRS = __path__(dirs) +EXTRA_DIST = __file__(extra_dist) \ No newline at end of file diff --git a/tracer/makefile b/tracer/makefile index 731573a..3d40a9a 100644 --- a/tracer/makefile +++ b/tracer/makefile @@ -18,13 +18,22 @@ clean := $(out_base)/.clean $(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) +$(dist): name := $(notdir $(src_base)) $(dist): export dirs := $(tests) +$(dist): export extra_dist := $(name)-vc9.sln $(name)-vc10.sln tests.bat $(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(tests))) $(call meta-automake) + $(call meta-vc9sln,$(name)-vc9.sln) + $(call meta-vc10sln,$(name)-vc10.sln) + $(call meta-vctest,$(name)-vc10.sln,$(src_root)/test.bat) + $(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) $(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) +$(call include,$(bld_root)/meta/vc9sln.make) +$(call include,$(bld_root)/meta/vc10sln.make) +$(call include,$(bld_root)/meta/vctest.make) $(call include,$(bld_root)/meta/automake.make) $(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/tracer/object/makefile b/tracer/object/makefile index 1fd819b..b74ece7 100644 --- a/tracer/object/makefile +++ b/tracer/object/makefile @@ -52,10 +52,17 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(notdir $(src_base)) +$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \ +$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake,$(src_root)/tracer/template/Makefile.am) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj) + $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj) # Test. # @@ -84,6 +91,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/tracer/template/Makefile.am b/tracer/template/Makefile.am index 09e4f09..a3bed1e 100644 --- a/tracer/template/Makefile.am +++ b/tracer/template/Makefile.am @@ -3,11 +3,13 @@ # copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC # license : GNU GPL v2; see accompanying LICENSE file +EXTRA_DIST = __file__(extra_dist) + noinst_PROGRAMS = driver driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers) TESTS=$(top_builddir)/tester -TESTS_ENVIRONMENT=top_builddir=$(top_builddir); +TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir; m4_ifelse(__value__(odb_options),,, diff --git a/tracer/template/makefile b/tracer/template/makefile index b7b82b7..4403281 100644 --- a/tracer/template/makefile +++ b/tracer/template/makefile @@ -52,10 +52,17 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(notdir $(src_base)) +$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \ +$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj) + $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj) # Test. # @@ -84,6 +91,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) diff --git a/tracer/template/template-vc10.vcxproj b/tracer/template/template-vc10.vcxproj new file mode 100644 index 0000000..2be749a --- /dev/null +++ b/tracer/template/template-vc10.vcxproj @@ -0,0 +1,172 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {__uuid__()} + Win32Proj + __value__(name) + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(Configuration)\ + driver + + + true + $(Platform)\$(Configuration)\ + driver + + + false + $(Configuration)\ + driver + + + false + $(Platform)\$(Configuration)\ + driver + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + odb-tracer-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + odb-tracer-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + odb-tracer.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + odb-tracer.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + +m4_ifelse(__value__(odb_options),,, +m4_dnl + +__custom_build_entry__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options))) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) + ) + +m4_ifelse(__value__(odb_options),,, +__header_entry__(test-odb.hxx) +__header_entry__(test-odb.ixx)) +__header_entries__(extra_headers) + + +__source_entry__(driver.cxx) +m4_ifelse(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + + + + diff --git a/tracer/template/template-vc10.vcxproj.filters b/tracer/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..951015b --- /dev/null +++ b/tracer/template/template-vc10.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {__uuid__()} + cxx + + + {__uuid__()} + h;hxx;ixx;txx + + + +m4_ifelse(__value__(odb_options),,, +__header_filter_entry__(test.hxx) +__header_filter_entry__(test-odb.hxx) +__header_filter_entry__(test-odb.ixx)) +__header_filter_entries__(extra_headers) + + +__source_filter_entry__(driver.cxx) +m4_ifelse(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx)) +__source_filter_entries__(extra_sources) + + \ No newline at end of file diff --git a/tracer/template/template-vc9.vcproj b/tracer/template/template-vc9.vcproj new file mode 100644 index 0000000..527a9d7 --- /dev/null +++ b/tracer/template/template-vc9.vcproj @@ -0,0 +1,353 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__source_entry__(driver.cxx) +m4_ifelse(__value__(odb_options),,,__source_entry__(test-odb.cxx)) +__source_entries__(extra_sources) + + +m4_ifelse(__value__(odb_options),,, +__file_entry_custom_build__( +test.hxx, +odb test.hxx, +odb.exe __xml__(__shell_quotes__(__value__(odb_options))) test.hxx, +test-odb.hxx;test-odb.ixx;test-odb.cxx) +__file_entry__(test-odb.hxx) +__file_entry__(test-odb.ixx)) +__file_entries__(extra_headers) + + + + + diff --git a/tracer/tracer-vc10.sln b/tracer/tracer-vc10.sln new file mode 100644 index 0000000..9a5dc32 --- /dev/null +++ b/tracer/tracer-vc10.sln @@ -0,0 +1,15 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +__projects__ +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution +__solution_configurations__ + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution +__project_configurations__ + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tracer/tracer-vc9.sln b/tracer/tracer-vc9.sln new file mode 100644 index 0000000..2ec9432 --- /dev/null +++ b/tracer/tracer-vc9.sln @@ -0,0 +1,15 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +__projects__ +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution +__solution_configurations__ + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution +__project_configurations__ + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tracer/transaction/makefile b/tracer/transaction/makefile index fd1d698..12ca226 100644 --- a/tracer/transaction/makefile +++ b/tracer/transaction/makefile @@ -38,10 +38,16 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) test.std +$(dist): sources := $(cxx_tun) +$(dist): data_dist := test.std +$(dist): export name := $(notdir $(src_base)) +$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \ +$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake,$(src_root)/tracer/template/Makefile.am) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj) + $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj) # Test. # @@ -69,6 +75,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(bld_root)/cxx/cxx-d.make) diff --git a/tracer/types/makefile b/tracer/types/makefile index f042476..474681d 100644 --- a/tracer/types/makefile +++ b/tracer/types/makefile @@ -52,10 +52,17 @@ $(out_base)/: $(driver) # Dist # -$(dist): data_dist := $(cxx_tun) $(odb_hdr) test.std +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(notdir $(src_base)) +$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \ +$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters $(dist): - $(call dist-data,$(data_dist)) - $(call meta-automake,$(src_root)/tracer/template/Makefile.am) + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj) + $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj) # Test. # @@ -84,6 +91,8 @@ endif # How to. # $(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) $(call include,$(bld_root)/meta/automake.make) $(call include,$(odb_rules)) -- cgit v1.1