From 242363e630f2f541bcf1b7133f21ab2730587c4f Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Fri, 25 Mar 2011 17:52:14 +0200 Subject: Update directory structure for Qt test --- qt/Makefile.am | 12 + qt/build.bat | 109 +++++++ qt/makefile | 39 +-- qt/mysql/Makefile.am | 7 + qt/mysql/core/driver.cxx | 58 ++++ qt/mysql/core/makefile | 114 ++++++++ qt/mysql/core/test.hxx | 40 +++ qt/mysql/core/test.std | 0 qt/mysql/driver.cxx | 57 ---- qt/mysql/makefile | 124 ++------ qt/mysql/qt-mysql-vc10.sln | 15 + qt/mysql/qt-mysql-vc9.sln | 15 + qt/mysql/template/Makefile.am | 31 ++ qt/mysql/template/driver.cxx | 44 +++ qt/mysql/template/makefile | 110 ++++++++ qt/mysql/template/template-vc10.vcxproj | 180 ++++++++++++ qt/mysql/template/template-vc10.vcxproj.filters | 25 ++ qt/mysql/template/template-vc9.vcproj | 361 ++++++++++++++++++++++++ qt/mysql/template/test.hxx | 27 ++ qt/mysql/template/test.std | 1 + qt/mysql/test.bat | 70 +++++ qt/mysql/test.hxx | 26 -- qt/mysql/test.std | 0 23 files changed, 1263 insertions(+), 202 deletions(-) create mode 100644 qt/Makefile.am create mode 100644 qt/build.bat create mode 100644 qt/mysql/Makefile.am create mode 100644 qt/mysql/core/driver.cxx create mode 100644 qt/mysql/core/makefile create mode 100644 qt/mysql/core/test.hxx create mode 100644 qt/mysql/core/test.std delete mode 100644 qt/mysql/driver.cxx create mode 100644 qt/mysql/qt-mysql-vc10.sln create mode 100644 qt/mysql/qt-mysql-vc9.sln create mode 100644 qt/mysql/template/Makefile.am create mode 100644 qt/mysql/template/driver.cxx create mode 100644 qt/mysql/template/makefile create mode 100644 qt/mysql/template/template-vc10.vcxproj create mode 100644 qt/mysql/template/template-vc10.vcxproj.filters create mode 100644 qt/mysql/template/template-vc9.vcproj create mode 100644 qt/mysql/template/test.hxx create mode 100644 qt/mysql/template/test.std create mode 100644 qt/mysql/test.bat delete mode 100644 qt/mysql/test.hxx delete mode 100644 qt/mysql/test.std (limited to 'qt') diff --git a/qt/Makefile.am b/qt/Makefile.am new file mode 100644 index 0000000..177f205 --- /dev/null +++ b/qt/Makefile.am @@ -0,0 +1,12 @@ +# file : qt/Makefile.am +# author : Constantin Michael +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +SUBDIRS = + +if DATABASE_MYSQL +SUBDIRS += mysql +endif + +EXTRA_DIST = __file__(extra_dist) diff --git a/qt/build.bat b/qt/build.bat new file mode 100644 index 0000000..fd83e05 --- /dev/null +++ b/qt/build.bat @@ -0,0 +1,109 @@ +@echo off +rem file : qt/build.bat +rem author : Constantin Michael +rem copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +rem license : GNU GPL v2; see accompanying LICENSE file + +rem +rem Build Qt tests using the VC++ batch mode compilation. +rem +rem build.bat database vc-version conf plat [/Build|/Clean|/Rebuild] +rem +rem conf: {Debug,Release}|all +rem plat: {Win32,x64}|all +rem + +setlocal + +if "_%1_" == "__" ( + echo no database specified + goto usage +) + +if "_%2_" == "__" ( + echo no VC++ version specified + goto usage +) + +if "_%~3_" == "__" ( + echo no configuration specified + goto usage +) + +if "_%~4_" == "__" ( + echo no platform specified + goto usage +) + +set "failed=" + +if "_%2_" == "_9_" set "vcver=9" +if "_%2_" == "_10_" set "vcver=10" + +if "_%vcver%_" == "__" ( + echo unknown VC++ version %2 + goto usage +) + +set "confs=%~3" +set "plats=%~4" + +if "_%confs%_" == "_all_" set "confs=__path__(configurations)" +if "_%plats%_" == "_all_" set "plats=__path__(platforms)" + +set "action=%5" +if "_%action%_" == "__" set "action=/Build" + +set "devenv=%DEVENV%" +if "_%devenv%_" == "__" set "devenv=devenv.com" + +goto start + +rem +rem %1 - solution name +rem %2 - configuration to build +rem %3 - platform to build +rem +:run_build + echo. + echo building qt/%1 %3 %2 + "%devenv%" %1 %action% "%2|%3" 2>&1 + if errorlevel 1 set "failed=%failed% qt/%1\%3\%2" +goto :eof + +:start + +for %%d in (%1) do ( + for %%c in (%confs%) do ( + for %%p in (%plats%) do ( + call :run_build %%d/qt-%%d-vc%vcver%.sln %%c %%p + ) + ) +) + +if not "_%failed%_" == "__" goto error + +echo. +echo ALL BUILDS SUCCEEDED +echo. +goto end + +:usage +echo. +echo usage: build.bat database vc-version conf plat [action] +echo valid configurations are: {Debug,Release}|all +echo valid platforms are: {Win32,x64}|all +echo valid actions are: /Build (default), /Clean, and /Rebuild +echo. + +:error +if not "_%failed%_" == "__" ( + echo. + for %%t in (%failed%) do echo FAILED: %%t + echo. +) +endlocal +exit /b 1 + +:end +endlocal diff --git a/qt/makefile b/qt/makefile index edbb5dc..5520b8a 100644 --- a/qt/makefile +++ b/qt/makefile @@ -5,30 +5,33 @@ include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make -tests := mysql +all_dirs := mysql +dirs := -default := $(out_base)/ -dist := $(out_base)/.dist -test := $(out_base)/.test -clean := $(out_base)/.clean +ifeq ($(db_id),mysql) +dirs += mysql +endif -$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) +default := $(out_base)/ +dist := $(out_base)/.dist +test := $(out_base)/.test +clean := $(out_base)/.clean -$(dist): name := qt -$(dist): export dirs := $(tests) -$(dist): export extra_dist := $(name)-vc9.sln $(name)-vc10.sln test.bat -$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(tests))) +$(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) + +$(dist): export extra_dist := build.bat +$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(all_dirs))) $(call meta-automake) - $(call meta-vc9sln,$(name)-vc9.sln) - $(call meta-vc10sln,$(name)-vc10.sln) - $(call meta-vctest,$(name)-vc10.sln,test.bat) -$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) -$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) +$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(dirs))) +$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(all_dirs))) -$(call include,$(bld_root)/meta/vc9sln.make) -$(call include,$(bld_root)/meta/vc10sln.make) +$(call include,$(bld_root)/dist.make) $(call include,$(bld_root)/meta/vctest.make) $(call include,$(bld_root)/meta/automake.make) -$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) +ifneq ($(filter $(MAKECMDGOALS),dist clean),) +$(foreach d,$(all_dirs),$(call import,$(src_base)/$d/makefile)) +else +$(foreach d,$(dirs),$(call import,$(src_base)/$d/makefile)) +endif diff --git a/qt/mysql/Makefile.am b/qt/mysql/Makefile.am new file mode 100644 index 0000000..dec2a28 --- /dev/null +++ b/qt/mysql/Makefile.am @@ -0,0 +1,7 @@ +# file : qt/mysql/Makefile.am +# author : Constantin Michael +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +SUBDIRS = __path__(dirs) +EXTRA_DIST = __file__(extra_dist) diff --git a/qt/mysql/core/driver.cxx b/qt/mysql/core/driver.cxx new file mode 100644 index 0000000..3c693a0 --- /dev/null +++ b/qt/mysql/core/driver.cxx @@ -0,0 +1,58 @@ +// file : qt/mysql/core/driver.cxx +// author : Constantin Michael +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +// Test Qt core type persistence. MySQL version. +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + person p1; + p1.name = "Constantin Michael"; + p1.date_of_birth.setDate (1979, 03, 07); + + // Persist. + // + { + transaction t (db->begin ()); + db->persist (p1); + t.commit (); + } + + // Load. + // + { + transaction t (db->begin ()); + person* pl = db->load (p1.name); + t.commit (); + + assert (*pl == p1); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/qt/mysql/core/makefile b/qt/mysql/core/makefile new file mode 100644 index 0000000..67f2e94 --- /dev/null +++ b/qt/mysql/core/makefile @@ -0,0 +1,114 @@ +# file : qt/mysql/core/makefile +# author : Constantin Michael +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make + +cxx_tun := driver.cxx +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/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 + +# Import. +# +$(call import,\ + $(scf_root)/import/odb/stub.make,\ + odb: odb,odb-rules: odb_rules) + +$(call import,\ + $(scf_root)/import/libodb-qt/stub.make,\ + l: odb_qt.l,cpp-options: odb_qt.l.cpp-options) + +$(call import,\ + $(scf_root)/import/libqt/core/stub.make,\ + l: qt_core.l) + +# Build. +# +$(driver): $(cxx_obj) $(odb_qt.l) $(common.l) $(qt_core.l) +$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) +$(cxx_obj) $(cxx_od): $(common.l.cpp-options) $(odb_qt.l.cpp-options) + +genf := $(addprefix $(odb_hdr:.hxx=-odb),.hxx .ixx .cxx) $(odb_hdr:.hxx=.sql) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): $(odb) +$(gen): odb := $(odb) +$(gen) $(dist): export odb_options += --database mysql --profile qt \ +--generate-schema +$(gen): cpp_options := -I$(out_base) +$(gen): $(common.l.cpp-options) $(odb_qt.l.cpp-options) + +$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) + +# Alias for default target. +# +$(out_base)/: $(driver) + +# Dist +# +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(subst /,-,$(subst $(src_root)/qt/mysql/,,$(src_base))) +$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \ +$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters +$(dist): + $(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. +# +$(test): $(driver) $(src_base)/test.std + $(call message,sql $$1,$(dcf_root)/db-driver $$1, $(src_base)/test.sql) + $(call message,test $<,$< --options-file $(dcf_root)/db.options \ +>$(out_base)/test.out) + $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out) + $(call message,,rm -f $(out_base)/test.out) + +# Clean. +# +$(clean): \ + $(driver).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) \ + $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean)) + $(call message,,rm -f $(out_base)/test.out) + +# Generated .gitignore. +# +ifeq ($(out_base),$(src_base)) +$(driver): | $(out_base)/.gitignore + +$(out_base)/.gitignore: files := driver $(genf) +$(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,$(odb_rules)) +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/o-e.make) + +# Dependencies. +# +$(call import,$(src_root)/libcommon/makefile) diff --git a/qt/mysql/core/test.hxx b/qt/mysql/core/test.hxx new file mode 100644 index 0000000..cc8e02d --- /dev/null +++ b/qt/mysql/core/test.hxx @@ -0,0 +1,40 @@ +// file : qt/mysql/core/test.hxx +// author : Constantin Michael +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include +#include + +#pragma db object +struct time_punchcard +{ + #pragma db id auto + unsigned long id; + + QDateTime date_time; +}; + +#pragma db object +struct person +{ + bool + operator== (const person& x) const + { + return name == x.name && + date_of_birth == x.date_of_birth && + time_of_birth == x.time_of_birth; + } + + #pragma db id + QString name; + + #pragma db type("DATE NOT NULL") + QDate date_of_birth; + QTime time_of_birth; +}; + +#endif // TEST_HXX diff --git a/qt/mysql/core/test.std b/qt/mysql/core/test.std new file mode 100644 index 0000000..e69de29 diff --git a/qt/mysql/driver.cxx b/qt/mysql/driver.cxx deleted file mode 100644 index 9ff3445..0000000 --- a/qt/mysql/driver.cxx +++ /dev/null @@ -1,57 +0,0 @@ -// file : qt/mysql/driver.cxx -// author : Constantin Michael -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -// Test Qt core type persistence. MySQL version. -// - -#include // std::auto_ptr -#include -#include - -#include -#include - -#include - -#include "test.hxx" -#include "test-odb.hxx" - -using namespace std; -using namespace odb::core; - -int -main (int argc, char* argv[]) -{ - try - { - auto_ptr db (create_database (argc, argv)); - - person p; - p.name = "John Doe"; - - // Persist. - // - { - transaction t (db->begin ()); - db->persist (p); - t.commit (); - } - - // Load. - // - { - transaction t (db->begin ()); - person* pl = db->load (p.id); - t.commit (); - - assert (*pl == p); - } - } - catch (const odb::exception& e) - { - cerr << e.what () << endl; - return 1; - } -} diff --git a/qt/mysql/makefile b/qt/mysql/makefile index 69b70aa..5c7fffc 100644 --- a/qt/mysql/makefile +++ b/qt/mysql/makefile @@ -1,114 +1,36 @@ # file : qt/mysql/makefile # author : Constantin Michael # copyright : Copyright (c) 2009-2011 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 -cxx_tun := driver.cxx -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) +tests := \ +core \ +template -common.l := $(out_root)/libcommon/common/common.l -common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options +default := $(out_base)/ +dist := $(out_base)/.dist +test := $(out_base)/.test +clean := $(out_base)/.clean -driver := $(out_base)/driver -dist := $(out_base)/.dist -test := $(out_base)/.test -clean := $(out_base)/.clean +$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests))) -# Import. -# -$(call import,\ - $(scf_root)/import/odb/stub.make,\ - odb: odb,odb-rules: odb_rules) +$(dist): name := qt-mysql +$(dist): export dirs := $(tests) +$(dist): export extra_dist := $(name)-vc9.sln $(name)-vc10.sln test.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,test.bat) -$(call import,\ - $(scf_root)/import/libodb-qt/stub.make,\ - l: odb_qt.l,cpp-options: odb_qt.l.cpp-options) +$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests))) +$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests))) -$(call import,\ - $(scf_root)/import/libqt/core/stub.make,\ - l: qt_core.l) - -# Build. -# -$(driver): $(cxx_obj) $(odb_qt.l) $(common.l) $(qt_core.l) -$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -$(cxx_obj) $(cxx_od): $(common.l.cpp-options) $(odb_qt.l.cpp-options) - -genf := $(addprefix $(odb_hdr:.hxx=-odb),.hxx .ixx .cxx) $(odb_hdr:.hxx=.sql) -gen := $(addprefix $(out_base)/,$(genf)) - -$(gen): $(odb) -$(gen): odb := $(odb) -$(gen) $(dist): export odb_options += --database mysql --profile qt \ ---generate-schema -$(gen): cpp_options := -I$(out_base) -$(gen): $(common.l.cpp-options) $(odb_qt.l.cpp-options) - -$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) - -# Alias for default target. -# -$(out_base)/: $(driver) - -# Dist -# -$(dist): sources := $(cxx_tun) -$(dist): headers := $(odb_hdr) -$(dist): data_dist := test.std -$(dist): export name := $(subst /,-,$(subst $(src_root)/qt/mysql/,,$(src_base))) -$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \ -$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters -$(dist): - $(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. -# -$(test): $(driver) $(src_base)/test.std - $(call message,sql $$1,$(dcf_root)/db-driver $$1, $(src_base)/test.sql) - $(call message,test $<,$< --options-file $(dcf_root)/db.options \ ->$(out_base)/test.out) - $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out) - $(call message,,rm -f $(out_base)/test.out) - -# Clean. -# -$(clean): \ - $(driver).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) \ - $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean)) - $(call message,,rm -f $(out_base)/test.out) - -# Generated .gitignore. -# -ifeq ($(out_base),$(src_base)) -$(driver): | $(out_base)/.gitignore - -$(out_base)/.gitignore: files := driver $(genf) -$(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/vc9sln.make) +$(call include,$(bld_root)/meta/vc10sln.make) +$(call include,$(bld_root)/meta/vctest.make) $(call include,$(bld_root)/meta/automake.make) -$(call include,$(odb_rules)) -$(call include,$(bld_root)/cxx/cxx-d.make) -$(call include,$(bld_root)/cxx/cxx-o.make) -$(call include,$(bld_root)/cxx/o-e.make) - -# Dependencies. -# -$(call import,$(src_root)/libcommon/makefile) +$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile)) diff --git a/qt/mysql/qt-mysql-vc10.sln b/qt/mysql/qt-mysql-vc10.sln new file mode 100644 index 0000000..9a5dc32 --- /dev/null +++ b/qt/mysql/qt-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/qt/mysql/qt-mysql-vc9.sln b/qt/mysql/qt-mysql-vc9.sln new file mode 100644 index 0000000..2ec9432 --- /dev/null +++ b/qt/mysql/qt-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/qt/mysql/template/Makefile.am b/qt/mysql/template/Makefile.am new file mode 100644 index 0000000..1948cb1 --- /dev/null +++ b/qt/mysql/template/Makefile.am @@ -0,0 +1,31 @@ +# file : qt/mysql/template/Makefile.am +# author : Constantin Michael +# copyright : Copyright (c) 2009-2011 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) +LDADD = $(top_builddir)/libcommon/common/libcommon.la +AM_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon' + +TESTS=$(top_builddir)/tester +TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir; + +m4_ifelse(__value__(odb_options),,, + +# ODB compilation. +# +driver_SOURCES += test.hxx +nodist_driver_SOURCES = test-odb.cxx +BUILT_SOURCES = test-odb.hxx +CLEANFILES = test-odb.hxx test-odb.ixx test-odb.cxx + +ODB = @ODB@ +ODBFLAGS = @ODBFLAGS@ +ODBCPPFLAGS = @ODBCPPFLAGS@ + +test-odb.hxx: test.hxx + $(ODB) $(AM_CPPFLAGS) $(ODBCPPFLAGS) $(CPPFLAGS) $(ODBFLAGS) __value__(odb_options) $< +) diff --git a/qt/mysql/template/driver.cxx b/qt/mysql/template/driver.cxx new file mode 100644 index 0000000..c94096b --- /dev/null +++ b/qt/mysql/template/driver.cxx @@ -0,0 +1,44 @@ +// file : qt/mysql/template/driver.cxx +// author : Constantin Michael +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +// PLACE TEST DESCRIPTION HERE +// + +#include // std::auto_ptr +#include +#include + +#include +#include + +#include + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr db (create_database (argc, argv)); + + // + // + cout << "test 001" << endl; + { + transaction t (db->begin ()); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/qt/mysql/template/makefile b/qt/mysql/template/makefile new file mode 100644 index 0000000..fbe0460 --- /dev/null +++ b/qt/mysql/template/makefile @@ -0,0 +1,110 @@ +# file : qt/mysql/template/makefile +# author : Constantin Michael +# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make + +cxx_tun := driver.cxx +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/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 + +# Import. +# +$(call import,\ + $(scf_root)/import/odb/stub.make,\ + odb: odb,odb-rules: odb_rules) + +$(call import,\ + $(scf_root)/import/libodb-qt/stub.make,\ + l: odb_qt.l,cpp-options: odb_qt.l.cpp-options) + +#Build. +# +$(driver): $(cxx_obj) $(odb_qt.l) $(common.l) +$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) +$(cxx_obj) $(cxx_od): $(common.l.cpp-options) $(odb_qt.l.cpp-options) + +genf := $(addprefix $(odb_hdr:.hxx=-odb),.hxx .ixx .cxx) $(odb_hdr:.hxx=.sql) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): $(odb) +$(gen): odb := $(odb) +$(gen) $(dist): export odb_options += --database mysql --profile qt \ +--generate-schema +$(gen): cpp_options := -I$(out_base) +$(gen): $(common.l.cpp-options) $(odb_qt.l.cpp-options) + +$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) + +# Alias for default target. +# +$(out_base)/: $(driver) + +# Dist +# +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(subst /,-,$(subst $(src_root)/qt/mysql/,,$(src_base))) +$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \ +$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters +$(dist): + $(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. +# +$(test): $(driver) $(src_base)/test.std + $(call message,sql $$1,$(dcf_root)/db-driver $$1, $(src_base)/test.sql) + $(call message,test $<,$< --options-file $(dcf_root)/db.options \ +>$(out_base)/test.out) + $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out) + $(call message,,rm -f $(out_base)/test.out) + +# Clean. +# +$(clean): \ + $(driver).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) \ + $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean)) + $(call message,,rm -f $(out_base)/test.out) + +# Generated .gitignore. +# +ifeq ($(out_base),$(src_base)) +$(driver): | $(out_base)/.gitignore + +$(out_base)/.gitignore: files := driver $(genf) +$(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,$(odb_rules)) +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/o-e.make) + +# Dependencies. +# +$(call import,$(src_root)/libcommon/makefile) diff --git a/qt/mysql/template/template-vc10.vcxproj b/qt/mysql/template/template-vc10.vcxproj new file mode 100644 index 0000000..be0135e --- /dev/null +++ b/qt/mysql/template/template-vc10.vcxproj @@ -0,0 +1,180 @@ + + + + + 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;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common-d.lib;odb-mysql-d.lib;odb-qt-d.lib;odb-d.lib;%(AdditionalDependencies) + Console + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib\common.lib;odb-mysql.lib;odb-qt.lib;odb.lib;%(AdditionalDependencies) + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions) + $(SolutionDir)\..\..\libcommon + 4068;4355;4800;4290;%(DisableSpecificWarnings) + + + $(SolutionDir)\..\..\libcommon\lib64\common.lib;odb-mysql.lib;odb-qt.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) -DHAVE_CONFIG_VC_H -I$(SolutionDir)\..\..\libcommon)) 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/qt/mysql/template/template-vc10.vcxproj.filters b/qt/mysql/template/template-vc10.vcxproj.filters new file mode 100644 index 0000000..951015b --- /dev/null +++ b/qt/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/qt/mysql/template/template-vc9.vcproj b/qt/mysql/template/template-vc9.vcproj new file mode 100644 index 0000000..c679db9 --- /dev/null +++ b/qt/mysql/template/template-vc9.vcproj @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__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) -DHAVE_CONFIG_VC_H -I$(SolutionDir)\..\..\libcommon)) 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/qt/mysql/template/test.hxx b/qt/mysql/template/test.hxx new file mode 100644 index 0000000..e6ca8ba --- /dev/null +++ b/qt/mysql/template/test.hxx @@ -0,0 +1,27 @@ +// file : qt/mysql/template/test.hxx +// author : Constantin Michael +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include + +#pragma db object +struct object +{ + object (unsigned long id) + : id_ (id) + { + } + + object () + { + } + + #pragma db id + unsigned long id_; +}; + +#endif // TEST_HXX diff --git a/qt/mysql/template/test.std b/qt/mysql/template/test.std new file mode 100644 index 0000000..af8d8e7 --- /dev/null +++ b/qt/mysql/template/test.std @@ -0,0 +1 @@ +test 001 diff --git a/qt/mysql/test.bat b/qt/mysql/test.bat new file mode 100644 index 0000000..96f88be --- /dev/null +++ b/qt/mysql/test.bat @@ -0,0 +1,70 @@ +@echo off +rem file : qt/mysql/test.bat +rem author : Constantin Michael +rem copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +rem license : GNU GPL v2; see accompanying LICENSE file + +setlocal + +set "tests=__path__(dirs)" +set "confs=__path__(configurations)" +set "plats=__path__(platforms)" +set "curdir=%CD%" +set "topdir=%curdir%\..\.." +set "failed=" + +goto start + +rem +rem %1 - test directory +rem %2 - configuration +rem %3 - platform +rem +:run_test + cd %1 + + if "_%3_" == "_Win32_" ( + set "dir=%2" + ) else ( + set "dir=%3\%2" + ) + + if exist %dir%\driver.exe ( + echo %1\%3\%2 + call %topdir%\tester.bat mysql %2 %3 + if errorlevel 1 ( + set "failed=%failed% %1\%3\%2" + ) + ) + + cd %curdir% +goto :eof + +:start + +for %%t in (%tests%) do ( + for %%c in (%confs%) do ( + for %%p in (%plats%) do ( + call :run_test %%t %%c %%p + ) + ) +) + +if not "_%failed%_" == "__" goto error + +echo. +echo ALL TESTS PASSED +echo. +goto end + +:error +if not "_%failed%_" == "__" ( + echo. + for %%t in (%failed%) do echo FAILED: %%t + echo. +) +endlocal +exit /b 1 + +:end +endlocal diff --git a/qt/mysql/test.hxx b/qt/mysql/test.hxx deleted file mode 100644 index bcbabfa..0000000 --- a/qt/mysql/test.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// file : qt/mysql/test.hxx -// author : Constantin Michael -// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC -// license : GNU GPL v2; see accompanying LICENSE file - -#ifndef TEST_HXX -#define TEST_HXX - -#include - -#pragma db object -struct person -{ - bool - operator== (const person& x) const - { - return id == x.id && name == x.name; - } - - #pragma db id auto - unsigned long id; - - QString name; -}; - -#endif // TEST_HXX diff --git a/qt/mysql/test.std b/qt/mysql/test.std deleted file mode 100644 index e69de29..0000000 -- cgit v1.1