Merge lp:~zorba-coders/zorba/module-schema-tools into lp:zorba

Proposed by Cezar Andrei
Status: Merged
Approved by: Chris Hillery
Approved revision: 10663
Merged at revision: 10777
Proposed branch: lp:~zorba-coders/zorba/module-schema-tools
Merge into: lp:zorba
Diff against target: 2449 lines (+1366/-217)
36 files modified
ChangeLog (+2/-0)
NOTICE.txt (+18/-0)
NOTICE.xml (+16/-0)
bin/path_util.cpp (+19/-2)
bin/path_util.h (+6/-0)
bin/zorbacmd.cpp (+8/-0)
bin/zorbacmdproperties.cpp (+5/-0)
bin/zorbacmdproperties.h (+3/-0)
bin/zorbacmdproperties.txt (+1/-0)
bin/zorbacmdproperties_base.h (+133/-72)
cmake_modules/ZorbaModule.cmake (+132/-44)
config/ExternalModuleConfig.cmake.in (+26/-9)
config/ZorbaUse.cmake (+0/-4)
include/zorba/properties_base.h (+37/-1)
include/zorba/util/file.h (+2/-0)
include/zorba/zorba.h (+15/-5)
modules/CMakeLists.txt (+113/-30)
modules/ExternalModules.conf (+2/-0)
scripts/CMakeLists.txt (+4/-2)
src/api/zorbaimpl.cpp (+10/-0)
src/api/zorbaimpl.h (+2/-0)
src/context/dynamic_loader.cpp (+41/-26)
src/context/dynamic_loader.h (+10/-5)
src/system/properties.h (+21/-0)
src/system/zorba_properties.h (+67/-17)
src/system/zorba_properties.txt (+1/-0)
src/util/file.cpp (+12/-0)
src/util/fs_util.cpp (+24/-0)
src/util/fs_util.h (+28/-0)
src/util/win32/dirent.h (+372/-0)
swig/java/CMakeLists.txt (+1/-0)
swig/various.i (+184/-0)
swig/zorba_api.i (+2/-0)
test/rbkt/modules/CMakeLists.txt (+2/-0)
test/rbkt/modules/java/CMakeLists.txt (+40/-0)
test/rbkt/modules/java/Test.java (+7/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/module-schema-tools
Reviewer Review Type Date Requested Status
Chris Hillery Approve
Matthias Brantner Approve
Cezar Andrei Approve
Review via email: mp+102377@code.launchpad.net

This proposal supersedes a proposal from 2012-04-14.

Commit message

Add java classpath to zorbacmd and to Zorba API.
Fix dynamic libraries loading.
Tested it works on Windows with both xsl-fo and xmlbeans modules. All tests are passing.

Fixed ExternalModule integration, fixed comment and indentation of previously property generated files: src/system/zorba_properties.h and bin/zorbacmdproperties_base.h.

Description of the change

Add java classpath to zorbacmd and to Zorba API.
Fix dynamic libraries loading.
Tested it works on Windows with both xsl-fo and xmlbeans modules. All tests are passing.

Fixed ExternalModule integration, fixed comment and indentation of previously property generated files: src/system/zorba_properties.h and bin/zorbacmdproperties_base.h.

Removed swig IStream class and references.

Added util-jvm module which implements the link to the jvm.

Solved merge conflict.

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in modules/ExternalModules.conf

Revision history for this message
Matthias Brantner (matthias-brantner) wrote : Posted in a previous version of this proposal

- In DynamicLoader::loadModule the code to create the Module is redundant and should be factorized
- Why is DECLARE_ZORBA_JAR in cmake_modules/ZorbaModule.cmake commented out? Should it be removed?
- Why did the file src/store/naive/store_properties.h change? I think Markos has disabled the generation in the trunk. We have to be careful that nothing is removed by this merge (same for all properties).
  For example,
88 -"--no-copy-optim\napply the no-copy optimization (1=enabled (default), 0=off)\n\n"
1089 -"--serialize-only-query\nserialize-only-query (<0=unknown (default), 1=enabled, 0=off)\n\n"
1090 +"--no-copy-optim\nno copy optim (1=enabled (default), 0=off)\n\n"
1091 +"--serialize-only-query\nserialize-only query (1=true, 0=false (default))\n\n"

causes the unknown option for the serialize-only-query param to disappear

- commit of src/util/win32/dirent.h should be mentioned in NOTICE.xml
- I don't really like the name serializeToOutputStream. Why can't it just be serialize with one parameter?
- there is a todo left "# todo cezar compile and jar it up"
- I didn't find a test for the new serializeToOutputStream or getStream functions? I think it would be good to have some tests.

review: Needs Fixing
Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

Agreed with Matthias's comments.

Regarding DECLARE_ZORBA_JAR(), it looks like the commented-out macro is an older version, and the newer version is not commented-out. The older one should just be deleted.

Couple more comments:

- Do we also need to mention the addition of swig/various.i in NOTICE.xml? It has a comment saying it's from the SWIG package directly.

- Wasn't the class name "IStream" causing a build conflict on Windows?

- The call to init_val() in zorbacmdproperties_base.h should be on a separate line. (I know it was cut-and-pasted from above, but ugh.)

- Why is the method for retrieving the PropertiesGlobal* called "getProperties()"? Shouldn't that be getProperiesGlobal()? (Or, IMHO, getGlobalProperties() and rename the class to GlobalProperties.)

- Similarly, why is the factory method for PropertiesGlobal "Properties::instance()"? (The Zorba Properties stuff has always seemed like a mishmash to me; this isn't helping.)

- Need to fix the conflict in ExternalModules.conf.

- Typo: "singelton" in zorba.h.

review: Needs Fixing
Revision history for this message
Cezar Andrei (cezar-andrei) wrote : Posted in a previous version of this proposal

I fixed all of the comments, execept:
- the ones related to swig:
    - the changes are not required, right now but they required for optimizing XQJ, to make swig play nice with streams it's quite a chlange, would be a petty to loose them
    - I don't think various.i should be specified in NOTICE.xml since we already have swig and various.i is part of swig.
- about Properties it's not really the most intuitive way of representing it but I do think PropertiesGlobal is a good name, many projects use kind after the base to explain what it is. I call Properties::instance() because that is the private instantiable implementation class that extends ZorbaProperties which is based on PropertiesGlobal.

Revision history for this message
Cezar Andrei (cezar-andrei) wrote : Posted in a previous version of this proposal

See my prevoius comment for fixes in this proposal.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Validation queue job module-schema-tools-2012-03-16T20-15-10.551Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 3 Pending.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Matthias Brantner (matthias-brantner) wrote : Posted in a previous version of this proposal

- I think you reverted the changes that have been made in modules/ExternalModules.conf.
- The file src/system/zorba_properties.h also contains changes that have been reverted. For example,

1058 -"--no-copy-optim\napply the no-copy optimization (1=enabled (default), 0=off)\n\n"
1059 -"--serialize-only-query\nserialize-only-query (<0=unknown (default), 1=enabled, 0=off)\n\n"
1060 +"--no-copy-optim\nno copy optim (1=enabled (default), 0=off)\n\n"
1061 +"--serialize-only-query\nserialize-only query (1=true, 0=false (default))\n\n"

review: Needs Fixing
Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

It looks like you didn't fix the indentation of calls to init_val() in zorbacmdproperties_base.h, and in fact it looks like you moved a number of other instances of calls to that method onto the ends of earlier lines of code in zorba_properties.h. It's just not good readability. To be clear, I'm talking about lines like this:

   if (*argv == NULL) { result = "No value given for --classpath option"; break; } init_val (*argv, theClasspath, d);

There's no reason to have that call to init_val() hanging out over there. I count 9 places where this is done, most of which were put that way with this change.

You also didn't rename the class "IStream". Rodolfo reported that that class name conflicted with a Windows class, making the code not compile on Windows. It's not clear to me if this is one of the changes for "optimizing XQJ" you mentioned, but if it actually causes a compilation failure it must be changed.

review: Needs Fixing
Revision history for this message
Cezar Andrei (cezar-andrei) wrote : Posted in a previous version of this proposal

> It looks like you didn't fix the indentation of calls to init_val() in
> zorbacmdproperties_base.h, and in fact it looks like you moved a number of
> other instances of calls to that method onto the ends of earlier lines of code
> in zorba_properties.h. It's just not good readability. To be clear, I'm
> talking about lines like this:
>
> if (*argv == NULL) { result = "No value given for --classpath option";
> break; } init_val (*argv, theClasspath, d);
>
> There's no reason to have that call to init_val() hanging out over there. I
> count 9 places where this is done, most of which were put that way with this
> change.

If you take a look at the file there are many places where this strange indentation occurs. Check out the top of the file: THIS IS A GENERATED FILE. DO NOT EDIT!

>
>
> You also didn't rename the class "IStream". Rodolfo reported that that class
> name conflicted with a Windows class, making the code not compile on Windows.
> It's not clear to me if this is one of the changes for "optimizing XQJ" you
> mentioned, but if it actually causes a compilation failure it must be changed.

Rodolfo, checked out the full build and tests on windows, there is no problem with it. I sent an email to clarify it.

Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

> If you take a look at the file there are many places where this strange
> indentation occurs. Check out the top of the file: THIS IS A GENERATED FILE.
> DO NOT EDIT!

My understanding is that this isn't true anymore, though. Markos removed the script to generate this file, and said that in future changes should be made directly to it. If that's correct, clearly he should have removed the above comment as well.

Did you run a script to generate these files, Cezar? If so, that would explain Matthias's problem as well (about changes to the property descriptions that seem to have been reverted by you).

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Cezar Andrei (cezar-andrei) wrote : Posted in a previous version of this proposal

I didn't know Markos removed the scripts after I made the changes. But I removed the comment and I fixed the indentation of init_val lines.

I also fixed the ExternalModules.config wrong merge, and checked src/system/zorba_properties.h contains changes only related to CLASSPATH and indentation.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Validation queue job module-schema-tools-2012-03-19T16-20-06.136Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 3 Pending.

Revision history for this message
Cezar Andrei (cezar-andrei) wrote : Posted in a previous version of this proposal

Removed IStream swig class and references.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Validation queue job module-schema-tools-2012-03-20T19-01-23.283Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 3 Pending.

Revision history for this message
Cezar Andrei (cezar-andrei) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Chris Hillery (ceejatec) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Cezar Andrei (cezar-andrei) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Chris Hillery (ceejatec) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) wrote : Posted in a previous version of this proposal

Should the classpath in the static context be serialized? I forgot our decision, is this member needed at all?

review: Needs Information
Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

It looks like the classpath in static_context is orphaned; nothing sets it or references it. I'll take that out.

Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

Removed. Matthias, if that was your only comment, go ahead and vote Approve.

Revision history for this message
Matthias Brantner (matthias-brantner) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

I'll need Cezar to set the commit message; I'm not sure if he just copied
the Description or not. Unfortunately if you go back to the previous
revision of the Proposal it doesn't show the commit message from that
version...

Revision history for this message
Cezar Andrei (cezar-andrei) wrote : Posted in a previous version of this proposal

I've set the commit message, but build is not triggered, do I need to resubmit the proposal?

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in ChangeLog
text conflict in src/api/staticcontextimpl.h
text conflict in src/precompiled/stdafx.h

Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

I merged from the trunk, but I wasn't totally sure that I did the right thing with stdafx.h. So I re-submitted the proposal so Matthias and Cezar could have a chance to re-review.

As far as I can tell, stdafx.h was never explicitly changed on the module-schema-tools branch; the only commits which affected it were merges from the trunk. So I don't know why there were merge conflicts now. But I just made it identical to the current trunk. If that's OK, then you two should go ahead and re-approve.

review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~zorba-coders/zorba/module-schema-tools into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job module-schema-tools-2012-04-14T07-27-03.74Z is
  finished. The final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

There is a feature in CMake that DECLARE_ZORBA_JAR(..TARGET..) depends on which, it turns out, was only implemented correctly as of CMake 2.8.4. (See http://public.kitware.com/Bug/view.php?id=11332 .) The remote queue was running CMake 2.8.2, which is why the build failed.

I have upgraded the queue to run CMake 2.8.7, so hopefully it'll work this time.

I note that there doesn't appear to be any documentation for this new Java stuff as yet, but wherever it ends up, it should be noted that CMake >= 2.8.4 is required.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~zorba-coders/zorba/module-schema-tools into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job module-schema-tools-2012-04-14T08-25-03.504Z is
  finished. The final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~zorba-coders/zorba/module-schema-tools into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job module-schema-tools-2012-04-14T08-42-58.716Z is
  finished. The final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Chris Hillery (ceejatec) wrote : Posted in a previous version of this proposal

Grumble. Sometimes I hate CMake. This stuff works just fine on my machine, but for whatever reason the dependencies just aren't working out right on the remote queue machine. I've spent the last hour trying to make it work right and have so far failed. I'll have to take another crack at it either over the weekend or on Monday; sorry.

By the by, if I manually run "make" again, it gets past this point. However, then it gets a bunch of SWIG errors:

In file included from /home/ceej/zo/testing/zorbatest/tester/remotequeue/module-schema-tools-2012-04-14T08-42-58.716Z/bzr/zorba/build/swig/python/zorba_apiPYTHON_wrap.cxx:3478:
/home/ceej/zo/testing/zorbatest/tester/remotequeue/module-schema-tools-2012-04-14T08-42-58.716Z/bzr/zorba/build/swig/python/StaticContext.h:115: error: ‘TypeIdentifier’ does not name a type
/home/ceej/zo/testing/zorbatest/tester/remotequeue/module-schema-tools-2012-04-14T08-42-58.716Z/bzr/zorba/build/swig/python/StaticContext.h:116: error: ‘TypeIdentifier’ does not name a type
/home/ceej/zo/testing/zorbatest/tester/remotequeue/module-schema-tools-2012-04-14T08-42-58.716Z/bzr/zorba/build/swig/python/StaticContext.h:117: error: ‘TypeIdentifier’ does not name a type
/home/ceej/zo/testing/zorbatest/tester/remotequeue/module-schema-tools-2012-04-14T08-42-58.716Z/bzr/zorba/build/swig/python/StaticContext.h:119: error: expected ‘,’ or ‘...’ before ‘&’ token
/home/ceej/zo/testing/zorbatest/tester/remotequeue/module-schema-tools-2012-04-14T08-42-58.716Z/bzr/zorba/build/swig/python/StaticContext.h:119: error: ISO C++ forbids declaration of ‘TypeIdentifier’ with no type

and a bunch more like that. That doesn't have anything to do with my CMake changes, and will have to be solved as well. Any ideas?

Revision history for this message
Cezar Andrei (cezar-andrei) wrote : Posted in a previous version of this proposal

Unless when you updated cmake you updated swig too, no other idea comes to mind.

I have cmake 2.8.5 and swig 1.3.40 on my box and works fine.

> That doesn't have anything to do with my CMake
> changes, and will have to be solved as well. Any ideas?

Revision history for this message
Matthias Brantner (matthias-brantner) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Cezar Andrei (cezar-andrei) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

The attempt to merge lp:~zorba-coders/zorba/module-schema-tools into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job module-schema-tools-2012-04-17T15-15-59.439Z is
  finished. The final status was:

  No tests were run - build or configure step must have failed.

  Not commiting changes.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Cezar Andrei (cezar-andrei) wrote : Posted in a previous version of this proposal

Chris, can you check the cmake build dependencies for util-jvm module. I see the same error on my box when I use make -j12.

[ 95%] Built target modlib69_xqxq.xq
[ 95%] Built target modlib56_hmac.xq
Scanning dependencies of target modlib70_util-jvm.xq
[ 95%] Scanning dependencies of target modlib71_schema-tools.xq
.Building CXX object zorba_modules/zorba_util-jvm_module/src/CMakeFiles/modlib70_util-jvm.xq.dir/util-jvm.xq.src/util-jvm.cpp.o
make[2]: *** No rule to make target `LIB_PATH/com/zorba-xquery/www/modules/libutil-jvm_1.0.so', needed by `LIB_PATH/com/zorba-xquery/www/modules/libschema-tools_1.0.so'. Stop.
make[2]: *** Waiting for unfinished jobs....
[ 95%] Building CXX object zorba_modules/zorba_schema-tools_module/src/CMakeFiles/modlib71_schema-tools.xq.dir/schema-tools.xq.src/schema-tools.cpp.o
[ 95%] Building CXX object zorba_modules/zorba_util-jvm_module/src/CMakeFiles/modlib70_util-jvm.xq.dir/util-jvm.xq.src/JavaVMSingleton.cpp.o
Linking CXX shared library ../../../LIB_PATH/com/zorba-xquery/www/modules/libutil-jvm_1.0.so
make[1]: *** [zorba_modules/zorba_schema-tools_module/src/CMakeFiles/modlib71_schema-tools.xq.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote : Posted in a previous version of this proposal

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Revision history for this message
Cezar Andrei (cezar-andrei) wrote :

Fixed erroneous merging of swig files.

review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/module-schema-tools into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job module-schema-tools-2012-04-17T19-20-05.192Z is
  finished. The final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Attempt to merge into lp:zorba failed due to conflicts:

text conflict in cmake_modules/ZorbaModule.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/module-schema-tools into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job module-schema-tools-2012-04-18T07-13-04.737Z is
  finished. The final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~zorba-coders/zorba/module-schema-tools into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:274 (message):
  Validation queue job module-schema-tools-2012-04-18T08-39-07.752Z is
  finished. The final status was:

  3 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job module-schema-tools-2012-04-18T09-15-58.572Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 2 Pending.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Chris Hillery (ceejatec) wrote :

Think I finally got the dependency tracking working. It's ugly but at least works.

review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Attempt to merge into lp:zorba failed due to conflicts:

contents conflict in NOTICE.txt

Revision history for this message
Chris Hillery (ceejatec) wrote :

Aie... it's the merge proposal that will never die!

I'm doing a trunk merge now.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job module-schema-tools-2012-04-18T15-58-07.886Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Chris Hillery (ceejatec) wrote :

Hooray!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2012-04-18 11:34:17 +0000
+++ ChangeLog 2012-04-18 15:53:24 +0000
@@ -9,6 +9,7 @@
9 * fn:unparsed-text9 * fn:unparsed-text
10 * fn:unparsed-text-available10 * fn:unparsed-text-available
11 * Extended API for Python, Java, PHP and Ruby.11 * Extended API for Python, Java, PHP and Ruby.
12 * Add jvm classpath to zorbacmd and to Zorba API. Tracked by #931816
12 * Added support for NO_ICU (to not use ICU for unicode processing)13 * Added support for NO_ICU (to not use ICU for unicode processing)
1314
14Optimization:15Optimization:
@@ -30,6 +31,7 @@
30 * Fixed bug #921458 (file:read-text-lines() blocking)31 * Fixed bug #921458 (file:read-text-lines() blocking)
31 * Fixed bug #980526 (no-copy rule bug due to global var being set in "distant" udf)32 * Fixed bug #980526 (no-copy rule bug due to global var being set in "distant" udf)
32 * Fixed bug #949910 (has-children may be invoked on all nodes). Internally, zorba::store::Item::getChildren() now returns NULL on node classes without offspring (instead of raising an error).33 * Fixed bug #949910 (has-children may be invoked on all nodes). Internally, zorba::store::Item::getChildren() now returns NULL on node classes without offspring (instead of raising an error).
34 * Fixed Bug #933490: Error ItemFactoryImpl::createBase64Binary with istream
3335
3436
35version 2.237version 2.2
3638
=== modified file 'NOTICE.txt'
--- NOTICE.txt 2012-04-12 18:14:55 +0000
+++ NOTICE.txt 2012-04-18 15:53:24 +0000
@@ -459,6 +459,24 @@
459 suitability of this software for any purpose. It is provided "as is"459 suitability of this software for any purpose. It is provided "as is"
460 without express or implied warranty.460 without express or implied warranty.
461 461
462----------------------------------------------------
463
464src/util/win32/dirent.h
465
466Copyright: 2006 Toni Ronkko
467
468
469 Permission is hereby granted, free of charge, to any person obtaining
470 a copy of this software and associated documentation files (the
471 ``Software''), to deal in the Software without restriction, including
472 without limitation the rights to use, copy, modify, merge, publish,
473 distribute, sublicense, and/or sell copies of the Software, and to
474 permit persons to whom the Software is furnished to do so, subject to
475 the following conditions:
476
477 The above copyright notice and this permission notice shall be included
478 in all copies or substantial portions of the Software.
479
462480
463External libraries used by this project:481External libraries used by this project:
464----------------------------------------------------482----------------------------------------------------
465483
=== modified file 'NOTICE.xml'
--- NOTICE.xml 2012-04-16 20:56:43 +0000
+++ NOTICE.xml 2012-04-18 15:53:24 +0000
@@ -423,6 +423,22 @@
423 without express or implied warranty.423 without express or implied warranty.
424 </foreign-notice>424 </foreign-notice>
425 </foreign-files>425 </foreign-files>
426 <foreign-files>
427 <file>src/util/win32/dirent.h</file>
428 <copyright>2006 Toni Ronkko</copyright>
429 <foreign-notice>
430 Permission is hereby granted, free of charge, to any person obtaining
431 a copy of this software and associated documentation files (the
432 ``Software''), to deal in the Software without restriction, including
433 without limitation the rights to use, copy, modify, merge, publish,
434 distribute, sublicense, and/or sell copies of the Software, and to
435 permit persons to whom the Software is furnished to do so, subject to
436 the following conditions:
437
438 The above copyright notice and this permission notice shall be included
439 in all copies or substantial portions of the Software.
440 </foreign-notice>
441 </foreign-files>
426442
427 <external-lib mandatory="true">443 <external-lib mandatory="true">
428 <name>LIBXML2</name>444 <name>LIBXML2</name>
429445
=== modified file 'bin/path_util.cpp'
--- bin/path_util.cpp 2012-04-16 20:56:43 +0000
+++ bin/path_util.cpp 2012-04-18 15:53:24 +0000
@@ -49,7 +49,7 @@
49}49}
5050
5151
52static void52void
53tokenizePath(53tokenizePath(
54 const std::string& aPathStr,54 const std::string& aPathStr,
55 std::vector<String>& aResult)55 std::vector<String>& aResult)
@@ -66,6 +66,23 @@
66 }66 }
67}67}
6868
69
70String
71concatenatePaths( const std::vector<String>& aPathList)
72{
73 String delimiter(filesystem_path::get_path_separator());
74
75 String lResult;
76 for (std::vector<String>::const_iterator lIter = aPathList.begin();
77 lIter != aPathList.end(); ++lIter)
78 {
79 lResult += delimiter + *lIter;
80 }
81
82 return lResult;
83}
84
85
69void86void
70setPathsOnContext(87setPathsOnContext(
71 const ZorbaCMDProperties& aProperties,88 const ZorbaCMDProperties& aProperties,
@@ -101,8 +118,8 @@
101 // Compute and set lib path118 // Compute and set lib path
102 aProperties.getLibPath(lPathStr);119 aProperties.getLibPath(lPathStr);
103 tokenizePath(lPathStr, lPath);120 tokenizePath(lPathStr, lPath);
121 lPath.push_back(lCWD.get_path());
104 lEnvStr = getPathFromEnvironment("ZORBA_LIB_PATH");122 lEnvStr = getPathFromEnvironment("ZORBA_LIB_PATH");
105 lPath.push_back(lCWD.get_path());
106 tokenizePath(lEnvStr, lPath);123 tokenizePath(lEnvStr, lPath);
107 aStaticCtx->setLibPath(lPath);124 aStaticCtx->setLibPath(lPath);
108 }125 }
109126
=== modified file 'bin/path_util.h'
--- bin/path_util.h 2012-04-16 20:56:43 +0000
+++ bin/path_util.h 2012-04-18 15:53:24 +0000
@@ -32,6 +32,12 @@
32 setPathsOnContext(const ZorbaCMDProperties& aProperties,32 setPathsOnContext(const ZorbaCMDProperties& aProperties,
33 zorba::StaticContext_t& aStaticCtx);33 zorba::StaticContext_t& aStaticCtx);
3434
35 void
36 tokenizePath(const std::string& aPathStr, std::vector<String>& aResult);
37
38
39 String
40 concatenatePaths( const std::vector<String>& aPathList);
3541
36 }42 }
37} /* namespace zorba */43} /* namespace zorba */
3844
=== modified file 'bin/zorbacmd.cpp'
--- bin/zorbacmd.cpp 2012-04-16 20:56:43 +0000
+++ bin/zorbacmd.cpp 2012-04-18 15:53:24 +0000
@@ -787,6 +787,14 @@
787 return 3;787 return 3;
788 }788 }
789789
790 // Add command line --classpath option in front of config/env CLASSPATH
791 Properties* globalProperties = Properties::instance();
792 std::string cmdJvmClassPath;
793 lProperties.getJVMClassPath(cmdJvmClassPath);
794 std::string configJvmClassPath;
795 globalProperties->getJVMClassPath(configJvmClassPath);
796 globalProperties->setJVMClassPath(cmdJvmClassPath +
797 filesystem_path::get_path_separator() + configJvmClassPath);
790798
791 // Start the engine799 // Start the engine
792800
793801
=== modified file 'bin/zorbacmdproperties.cpp'
--- bin/zorbacmdproperties.cpp 2012-04-16 20:56:43 +0000
+++ bin/zorbacmdproperties.cpp 2012-04-18 15:53:24 +0000
@@ -181,6 +181,11 @@
181 aPath = theLibPath;181 aPath = theLibPath;
182}182}
183183
184void ZorbaCMDProperties::getJVMClassPath(std::string& aPath) const
185{
186 aPath = theClasspath;
187}
188
184std::vector<std::pair<std::string,std::string> > ZorbaCMDProperties::getSerializerParameters() const189std::vector<std::pair<std::string,std::string> > ZorbaCMDProperties::getSerializerParameters() const
185{190{
186 std::vector<std::pair<std::string,std::string> > lResult;191 std::vector<std::pair<std::string,std::string> > lResult;
187192
=== modified file 'bin/zorbacmdproperties.h'
--- bin/zorbacmdproperties.h 2012-04-16 20:56:43 +0000
+++ bin/zorbacmdproperties.h 2012-04-18 15:53:24 +0000
@@ -92,6 +92,9 @@
92 void92 void
93 getLibPath(std::string&) const;93 getLibPath(std::string&) const;
9494
95 void
96 getJVMClassPath(std::string&) const;
97
95 bool isDebug(){ return theDebug; }98 bool isDebug(){ return theDebug; }
9699
97 bool hasNoLogo(){ return theNoLogo; }100 bool hasNoLogo(){ return theNoLogo; }
98101
=== modified file 'bin/zorbacmdproperties.txt'
--- bin/zorbacmdproperties.txt 2012-04-16 20:56:43 +0000
+++ bin/zorbacmdproperties.txt 2012-04-18 15:53:24 +0000
@@ -31,6 +31,7 @@
31("uri-path", po::value<std::string>(), "URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.")31("uri-path", po::value<std::string>(), "URI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.")
32("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")32("lib-path", po::value<std::string>(), "Library path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.")
33("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")33("module-path", po::value<std::string>(), "Path (list of directories) to add to both the URI and Library paths.")
34("classpath", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
34("option", po::value<std::vector<std::string> >(), "Set an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value").35("option", po::value<std::vector<std::string> >(), "Set an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value").
35("trailing-nl", "Output a trailing newline after the result of the query.")36("trailing-nl", "Output a trailing newline after the result of the query.")
36("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")37("stop-words", po::value<std::vector<std::string> >(), "Mapping specifying a stop-words URI to another.")
3738
=== modified file 'bin/zorbacmdproperties_base.h'
--- bin/zorbacmdproperties_base.h 2012-04-16 20:56:43 +0000
+++ bin/zorbacmdproperties_base.h 2012-04-18 15:53:24 +0000
@@ -15,13 +15,6 @@
15 */15 */
16/* vim:set et sw=2 ts=2: */16/* vim:set et sw=2 ts=2: */
1717
18// ******************************************
19// * *
20// * THIS IS A GENERATED FILE. DO NOT EDIT! *
21// * SEE .txt FILE WITH SAME NAME *
22// * *
23// ******************************************
24
25#include <string>18#include <string>
26#include <sstream>19#include <sstream>
27#include <zorba/config.h>20#include <zorba/config.h>
@@ -30,13 +23,29 @@
3023
31#ifndef ZORBACMD_ZORBACMDPROPERTIESBASE24#ifndef ZORBACMD_ZORBACMDPROPERTIESBASE
32#define ZORBACMD_ZORBACMDPROPERTIESBASE25#define ZORBACMD_ZORBACMDPROPERTIESBASE
33namespace zorbacmd { 26namespace zorbacmd
34class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase {27{
28
29class ZorbaCMDPropertiesBase : public ::zorba::PropertiesBase
30{
35protected:31protected:
36 const char **get_all_options () const {32 const char **get_all_options () const
37 static const char *result [] = { "--timing", "--output-file", "--serialization-parameter", "--serialize-html", "--serialize-text", "--indent", "--print-query", "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration", "--base-uri", "--boundary-space", "--default-collation", "--construction-mode", "--ordering-mode", "--multiple", "--query", "--as-files", "--external-variable", "--context-item", "--optimization-level", "--lib-module", "--parse-only", "--compile-only", "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo", "--timeout", "--uri-path", "--lib-path", "--module-path", "--option", "--trailing-nl", "--stop-words", "--thesaurus", "--compile-plan", "--execute-plan", NULL };33 {
34 static const char *result [] = {
35 "--timing", "--output-file", "--serialization-parameter",
36 "--serialize-html", "--serialize-text", "--indent", "--print-query",
37 "--print-errors-as-xml", "--byte-order-mark", "--omit-xml-declaration",
38 "--base-uri", "--boundary-space", "--default-collation",
39 "--construction-mode", "--ordering-mode", "--multiple", "--query",
40 "--as-files", "--external-variable", "--context-item",
41 "--optimization-level", "--lib-module", "--parse-only", "--compile-only",
42 "--no-serializer", "--debug", "--debug-host", "--debug-port", "--no-logo",
43 "--timeout", "--uri-path", "--lib-path", "--module-path", "--classpath",
44 "--option", "--trailing-nl", "--stop-words", "--thesaurus",
45 "--compile-plan", "--execute-plan", NULL };
38 return result;46 return result;
39 }47 }
48
40 bool theTiming;49 bool theTiming;
41 std::string theOutputFile;50 std::string theOutputFile;
42 std::vector<std::string> theSerializationParameter;51 std::vector<std::string> theSerializationParameter;
@@ -70,6 +79,7 @@
70 std::string theUriPath;79 std::string theUriPath;
71 std::string theLibPath;80 std::string theLibPath;
72 std::string theModulePath;81 std::string theModulePath;
82 std::string theClasspath;
73 std::vector<std::string> theOption;83 std::vector<std::string> theOption;
74 bool theTrailingNl;84 bool theTrailingNl;
75 std::vector<std::string> theStopWords;85 std::vector<std::string> theStopWords;
@@ -136,6 +146,7 @@
136 const std::string &uriPath () const { return theUriPath; }146 const std::string &uriPath () const { return theUriPath; }
137 const std::string &libPath () const { return theLibPath; }147 const std::string &libPath () const { return theLibPath; }
138 const std::string &modulePath () const { return theModulePath; }148 const std::string &modulePath () const { return theModulePath; }
149 const std::string &classpath () const { return theClasspath; }
139 const std::vector<std::string> &option () const { return theOption; }150 const std::vector<std::string> &option () const { return theOption; }
140 const bool &trailingNl () const { return theTrailingNl; }151 const bool &trailingNl () const { return theTrailingNl; }
141 const std::vector<std::string> &stopWords () const { return theStopWords; }152 const std::vector<std::string> &stopWords () const { return theStopWords; }
@@ -158,12 +169,16 @@
158 else if (strcmp (*argv, "--output-file") == 0 || strncmp (*argv, "-o", 2) == 0) {169 else if (strcmp (*argv, "--output-file") == 0 || strncmp (*argv, "-o", 2) == 0) {
159 int d = 2;170 int d = 2;
160 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }171 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
161 if (*argv == NULL) { result = "No value given for --output-file option"; break; } init_val (*argv, theOutputFile, d);172 if (*argv == NULL) { result = "No value given for --output-file option"; break; }
173
174 init_val (*argv, theOutputFile, d);
162 }175 }
163 else if (strcmp (*argv, "--serialization-parameter") == 0 || strncmp (*argv, "-z", 2) == 0) {176 else if (strcmp (*argv, "--serialization-parameter") == 0 || strncmp (*argv, "-z", 2) == 0) {
164 int d = 2;177 int d = 2;
165 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }178 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
166 if (*argv == NULL) { result = "No value given for --serialization-parameter option"; break; } init_val (*argv, theSerializationParameter, d);179 if (*argv == NULL) { result = "No value given for --serialization-parameter option"; break; }
180
181 init_val (*argv, theSerializationParameter, d);
167 }182 }
168 else if (strcmp (*argv, "--serialize-html") == 0) {183 else if (strcmp (*argv, "--serialize-html") == 0) {
169 theSerializeHtml = true;184 theSerializeHtml = true;
@@ -189,37 +204,51 @@
189 else if (strcmp (*argv, "--base-uri") == 0) {204 else if (strcmp (*argv, "--base-uri") == 0) {
190 int d = 2;205 int d = 2;
191 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }206 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
192 if (*argv == NULL) { result = "No value given for --base-uri option"; break; } init_val (*argv, theBaseUri, d);207 if (*argv == NULL) { result = "No value given for --base-uri option"; break; }
208
209 init_val (*argv, theBaseUri, d);
193 }210 }
194 else if (strcmp (*argv, "--boundary-space") == 0) {211 else if (strcmp (*argv, "--boundary-space") == 0) {
195 int d = 2;212 int d = 2;
196 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }213 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
197 if (*argv == NULL) { result = "No value given for --boundary-space option"; break; } init_val (*argv, theBoundarySpace, d);214 if (*argv == NULL) { result = "No value given for --boundary-space option"; break; }
215
216 init_val (*argv, theBoundarySpace, d);
198 }217 }
199 else if (strcmp (*argv, "--default-collation") == 0) {218 else if (strcmp (*argv, "--default-collation") == 0) {
200 int d = 2;219 int d = 2;
201 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }220 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
202 if (*argv == NULL) { result = "No value given for --default-collation option"; break; } init_val (*argv, theDefaultCollation, d);221 if (*argv == NULL) { result = "No value given for --default-collation option"; break; }
222
223 init_val (*argv, theDefaultCollation, d);
203 }224 }
204 else if (strcmp (*argv, "--construction-mode") == 0) {225 else if (strcmp (*argv, "--construction-mode") == 0) {
205 int d = 2;226 int d = 2;
206 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }227 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
207 if (*argv == NULL) { result = "No value given for --construction-mode option"; break; } init_val (*argv, theConstructionMode, d);228 if (*argv == NULL) { result = "No value given for --construction-mode option"; break; }
229
230 init_val (*argv, theConstructionMode, d);
208 }231 }
209 else if (strcmp (*argv, "--ordering-mode") == 0) {232 else if (strcmp (*argv, "--ordering-mode") == 0) {
210 int d = 2;233 int d = 2;
211 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }234 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
212 if (*argv == NULL) { result = "No value given for --ordering-mode option"; break; } init_val (*argv, theOrderingMode, d);235 if (*argv == NULL) { result = "No value given for --ordering-mode option"; break; }
236
237 init_val (*argv, theOrderingMode, d);
213 }238 }
214 else if (strcmp (*argv, "--multiple") == 0 || strncmp (*argv, "-m", 2) == 0) {239 else if (strcmp (*argv, "--multiple") == 0 || strncmp (*argv, "-m", 2) == 0) {
215 int d = 2;240 int d = 2;
216 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }241 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
217 if (*argv == NULL) { result = "No value given for --multiple option"; break; } init_val (*argv, theMultiple, d);242 if (*argv == NULL) { result = "No value given for --multiple option"; break; }
243
244 init_val (*argv, theMultiple, d);
218 }245 }
219 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-q", 2) == 0) {246 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-q", 2) == 0) {
220 int d = 2;247 int d = 2;
221 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }248 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
222 if (*argv == NULL) { result = "No value given for --query option"; break; } init_val (*argv, theQueriesOrFiles, d);249 if (*argv == NULL) { result = "No value given for --query option"; break; }
250
251 init_val (*argv, theQueriesOrFiles, d);
223 }252 }
224 else if (strcmp (*argv, "--as-files") == 0 || strncmp (*argv, "-f", 2) == 0) {253 else if (strcmp (*argv, "--as-files") == 0 || strncmp (*argv, "-f", 2) == 0) {
225 theAsFiles = true;254 theAsFiles = true;
@@ -227,17 +256,23 @@
227 else if (strcmp (*argv, "--external-variable") == 0 || strncmp (*argv, "-e", 2) == 0) {256 else if (strcmp (*argv, "--external-variable") == 0 || strncmp (*argv, "-e", 2) == 0) {
228 int d = 2;257 int d = 2;
229 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }258 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
230 if (*argv == NULL) { result = "No value given for --external-variable option"; break; } init_val (*argv, theExternalVariable, d);259 if (*argv == NULL) { result = "No value given for --external-variable option"; break; }
260
261 init_val (*argv, theExternalVariable, d);
231 }262 }
232 else if (strcmp (*argv, "--context-item") == 0) {263 else if (strcmp (*argv, "--context-item") == 0) {
233 int d = 2;264 int d = 2;
234 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }265 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
235 if (*argv == NULL) { result = "No value given for --context-item option"; break; } init_val (*argv, theContextItem, d);266 if (*argv == NULL) { result = "No value given for --context-item option"; break; }
267
268 init_val (*argv, theContextItem, d);
236 }269 }
237 else if (strcmp (*argv, "--optimization-level") == 0) {270 else if (strcmp (*argv, "--optimization-level") == 0) {
238 int d = 2;271 int d = 2;
239 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }272 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
240 if (*argv == NULL) { result = "No value given for --optimization-level option"; break; } init_val (*argv, theOptimizationLevel, d);273 if (*argv == NULL) { result = "No value given for --optimization-level option"; break; }
274
275 init_val (*argv, theOptimizationLevel, d);
241 }276 }
242 else if (strcmp (*argv, "--lib-module") == 0 || strncmp (*argv, "-l", 2) == 0) {277 else if (strcmp (*argv, "--lib-module") == 0 || strncmp (*argv, "-l", 2) == 0) {
243 theLibModule = true;278 theLibModule = true;
@@ -257,12 +292,16 @@
257 else if (strcmp (*argv, "--debug-host") == 0 || strncmp (*argv, "-h", 2) == 0) {292 else if (strcmp (*argv, "--debug-host") == 0 || strncmp (*argv, "-h", 2) == 0) {
258 int d = 2;293 int d = 2;
259 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }294 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
260 if (*argv == NULL) { result = "No value given for --debug-host option"; break; } init_val (*argv, theDebugHost, d);295 if (*argv == NULL) { result = "No value given for --debug-host option"; break; }
296
297 init_val (*argv, theDebugHost, d);
261 }298 }
262 else if (strcmp (*argv, "--debug-port") == 0 || strncmp (*argv, "-p", 2) == 0) {299 else if (strcmp (*argv, "--debug-port") == 0 || strncmp (*argv, "-p", 2) == 0) {
263 int d = 2;300 int d = 2;
264 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }301 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
265 if (*argv == NULL) { result = "No value given for --debug-port option"; break; } init_val (*argv, theDebugPort, d);302 if (*argv == NULL) { result = "No value given for --debug-port option"; break; }
303
304 init_val (*argv, theDebugPort, d);
266 }305 }
267 else if (strcmp (*argv, "--no-logo") == 0) {306 else if (strcmp (*argv, "--no-logo") == 0) {
268 theNoLogo = true;307 theNoLogo = true;
@@ -270,27 +309,44 @@
270 else if (strcmp (*argv, "--timeout") == 0) {309 else if (strcmp (*argv, "--timeout") == 0) {
271 int d = 2;310 int d = 2;
272 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }311 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
273 if (*argv == NULL) { result = "No value given for --timeout option"; break; } init_val (*argv, theTimeout, d);312 if (*argv == NULL) { result = "No value given for --timeout option"; break; }
313
314 init_val (*argv, theTimeout, d);
274 }315 }
275 else if (strcmp (*argv, "--uri-path") == 0) {316 else if (strcmp (*argv, "--uri-path") == 0) {
276 int d = 2;317 int d = 2;
277 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }318 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
278 if (*argv == NULL) { result = "No value given for --uri-path option"; break; } init_val (*argv, theUriPath, d);319 if (*argv == NULL) { result = "No value given for --uri-path option"; break; }
320
321 init_val (*argv, theUriPath, d);
279 }322 }
280 else if (strcmp (*argv, "--lib-path") == 0) {323 else if (strcmp (*argv, "--lib-path") == 0) {
281 int d = 2;324 int d = 2;
282 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }325 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
283 if (*argv == NULL) { result = "No value given for --lib-path option"; break; } init_val (*argv, theLibPath, d);326 if (*argv == NULL) { result = "No value given for --lib-path option"; break; }
327
328 init_val (*argv, theLibPath, d);
284 }329 }
285 else if (strcmp (*argv, "--module-path") == 0) {330 else if (strcmp (*argv, "--module-path") == 0) {
286 int d = 2;331 int d = 2;
287 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }332 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
288 if (*argv == NULL) { result = "No value given for --module-path option"; break; } init_val (*argv, theModulePath, d);333 if (*argv == NULL) { result = "No value given for --module-path option"; break; }
334
335 init_val (*argv, theModulePath, d);
336 }
337 else if (strcmp (*argv, "--classpath") == 0) {
338 int d = 2;
339 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
340 if (*argv == NULL) { result = "No value given for --classpath option"; break; }
341
342 init_val (*argv, theClasspath, d);
289 }343 }
290 else if (strcmp (*argv, "--option") == 0) {344 else if (strcmp (*argv, "--option") == 0) {
291 int d = 2;345 int d = 2;
292 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }346 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
293 if (*argv == NULL) { result = "No value given for --option option"; break; } init_val (*argv, theOption, d);347 if (*argv == NULL) { result = "No value given for --option option"; break; }
348
349 init_val (*argv, theOption, d);
294 }350 }
295 else if (strcmp (*argv, "--trailing-nl") == 0) {351 else if (strcmp (*argv, "--trailing-nl") == 0) {
296 theTrailingNl = true;352 theTrailingNl = true;
@@ -298,12 +354,16 @@
298 else if (strcmp (*argv, "--stop-words") == 0) {354 else if (strcmp (*argv, "--stop-words") == 0) {
299 int d = 2;355 int d = 2;
300 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }356 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
301 if (*argv == NULL) { result = "No value given for --stop-words option"; break; } init_val (*argv, theStopWords, d);357 if (*argv == NULL) { result = "No value given for --stop-words option"; break; }
358
359 init_val (*argv, theStopWords, d);
302 }360 }
303 else if (strcmp (*argv, "--thesaurus") == 0) {361 else if (strcmp (*argv, "--thesaurus") == 0) {
304 int d = 2;362 int d = 2;
305 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }363 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
306 if (*argv == NULL) { result = "No value given for --thesaurus option"; break; } init_val (*argv, theThesaurus, d);364 if (*argv == NULL) { result = "No value given for --thesaurus option"; break; }
365
366 init_val (*argv, theThesaurus, d);
307 }367 }
308 else if (strcmp (*argv, "--compile-plan") == 0 || strncmp (*argv, "-c", 2) == 0) {368 else if (strcmp (*argv, "--compile-plan") == 0 || strncmp (*argv, "-c", 2) == 0) {
309 theCompilePlan = true;369 theCompilePlan = true;
@@ -327,46 +387,47 @@
327387
328 const char *get_help_msg () const {388 const char *get_help_msg () const {
329 return389 return
330"--timing, -t\nPrint timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.\n\n"390 "--timing, -t\nPrint timing information. In case of multiple queries the timing information is provided per each query. Both wallclock time and user time (which excludes I/O, network delays and other kernel waits) are shown.\n\n"
331"--output-file, -o\nWrite the result to the given file.\n\n"391 "--output-file, -o\nWrite the result to the given file.\n\n"
332"--serialization-parameter, -z\nSet serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"392 "--serialization-parameter, -z\nSet serialization parameter in the form of a parameter=value pair (see http://www.w3.org/TR/xslt-xquery-serialization/#serparam, e.g.: -z method=xhtml -z doctype-system=DTD/xhtml1-strict.dtd -z indent=yes).\n\n"
333"--serialize-html\nSerialize the result as HTML.\n\n"393 "--serialize-html\nSerialize the result as HTML.\n\n"
334"--serialize-text\nSerialize the result as Text.\n\n"394 "--serialize-text\nSerialize the result as Text.\n\n"
335"--indent, -i\nIndent output.\n\n"395 "--indent, -i\nIndent output.\n\n"
336"--print-query\nPrint the queries.\n\n"396 "--print-query\nPrint the queries.\n\n"
337"--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"397 "--print-errors-as-xml, -x\nPrint the errors as XML.\n\n"
338"--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"398 "--byte-order-mark\nSet the byte-order-mark for the serializer.\n\n"
339"--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"399 "--omit-xml-declaration, -r\nOmit the XML declaration from the result.\n\n"
340"--base-uri\nSet the base URI property of the static context.\n\n"400 "--base-uri\nSet the base URI property of the static context.\n\n"
341"--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"401 "--boundary-space\nSet the boundary-space policy ('strip' or 'preserve') in the static context.\n\n"
342"--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"402 "--default-collation\nAdd the given collation and set the value of the default collation in the static context to the given collation.\n\n"
343"--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"403 "--construction-mode\nSet the construction mode ('strip' or 'preserve') in the static context.\n\n"
344"--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"404 "--ordering-mode\nSet the ordering mode ('ordered' or 'unordered') in the static context.\n\n"
345"--multiple, -m\nExecute the given queries multiple times.\n\n"405 "--multiple, -m\nExecute the given queries multiple times.\n\n"
346"--query, -q\nQuery test or file URI (file://...)\n\n"406 "--query, -q\nQuery test or file URI (file://...)\n\n"
347"--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries.\n\n"407 "--as-files, -f\nTreat all -q arguments as file paths instead of URIs or inline queries.\n\n"
348"--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"408 "--external-variable, -e\nProvide the value for a variable given a file (name=file) or a value (name:=value)\n\n"
349"--context-item\nSet the context item to the XML document in a given file.\n\n"409 "--context-item\nSet the context item to the XML document in a given file.\n\n"
350"--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"410 "--optimization-level\nOptimization level for the query compiler (O0, O1 or O2 - default: O1)\n\n"
351"--lib-module, -l\nQuery compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"411 "--lib-module, -l\nQuery compiler option to treat the query as a library module. If this is set --compile-only option is also set to true.\n\n"
352"--parse-only\nStop after parsing the query.\n\n"412 "--parse-only\nStop after parsing the query.\n\n"
353"--compile-only\nOnly compile (don't execute)\n\n"413 "--compile-only\nOnly compile (don't execute)\n\n"
354"--no-serializer\nDo not serialize (discard) result.\n\n"414 "--no-serializer\nDo not serialize (discard) result.\n\n"
355"--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"415 "--debug, -d\nLaunch the Zorba debugger server and connect to a DBGP-enabled debugger client.\n\n"
356"--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"416 "--debug-host, -h\nThe host where the DBGP-enabled debugger client listens for connections. Defaults to: 127.0.0.1\n\n"
357"--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"417 "--debug-port, -p\nThe port on which the DBGP-enabled debugger client listens for connections. Defaults to: 28028\n\n"
358"--no-logo\nPrint no logo when starting.\n\n"418 "--no-logo\nPrint no logo when starting.\n\n"
359"--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"419 "--timeout\nSpecify a timeout in seconds. After the specified time, the execution of the query will be aborted.\n\n"
360"--uri-path\nURI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.\n\n"420 "--uri-path\nURI path (list of directories) added to the built-in URI resolver, i.e. where to find modules/schemas to import.\n\n"
361"--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"421 "--lib-path\nLibrary path (list of directories) where Zorba will look for dynamic libraries (e.g., module external function implementations.\n\n"
362"--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"422 "--module-path\nPath (list of directories) to add to both the URI and Library paths.\n\n"
363"--option\nSet an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value\n\n"423 "--classpath\nJVM classpath to be used by modules using Java implementations\n\n"
364"--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"424 "--option\nSet an XQuery option in the static context. The QName of the option is passed as a string in the notation by James Clark (i.e. {namespace}localname). For example, --option {http://www.zorba-xquery.com}option=value\n\n"
365"--stop-words\nMapping specifying a stop-words URI to another.\n\n"425 "--trailing-nl\nOutput a trailing newline after the result of the query.\n\n"
366"--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"426 "--stop-words\nMapping specifying a stop-words URI to another.\n\n"
367"--compile-plan, -c\nOutput the query plan as binary.\n\n"427 "--thesaurus\nMapping specifying a thesaurus URI to another.\n\n"
368"--execute-plan\nTake a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.\n\n"428 "--compile-plan, -c\nOutput the query plan as binary.\n\n"
369;429 "--execute-plan\nTake a query plan as binary and execute it. Binary query plans can be generated using the --compile-plan option.\n\n"
430 ;
370 }431 }
371432
372 static const ZorbaCMDPropertiesBase *instance () {433 static const ZorbaCMDPropertiesBase *instance () {
373434
=== modified file 'cmake_modules/ZorbaModule.cmake'
--- cmake_modules/ZorbaModule.cmake 2012-04-17 22:40:48 +0000
+++ cmake_modules/ZorbaModule.cmake 2012-04-18 15:53:24 +0000
@@ -140,7 +140,6 @@
140 ENDIF (NOT IS_ABSOLUTE "${MODULE_FILE}")140 ENDIF (NOT IS_ABSOLUTE "${MODULE_FILE}")
141 GET_FILENAME_COMPONENT (module_name "${MODULE_FILE}" NAME)141 GET_FILENAME_COMPONENT (module_name "${MODULE_FILE}" NAME)
142142
143
144 MANGLE_URI (${MODULE_URI} ".xq" module_path module_filename)143 MANGLE_URI (${MODULE_URI} ".xq" module_path module_filename)
145144
146 # Compute a CMake-symbol-safe version of the target URI, for storing145 # Compute a CMake-symbol-safe version of the target URI, for storing
@@ -267,6 +266,14 @@
267 SET (module_filewe "${module_filewe}_${MODULE_VERSION}")266 SET (module_filewe "${module_filewe}_${MODULE_VERSION}")
268 ENDIF (MODULE_VERSION)267 ENDIF (MODULE_VERSION)
269268
269 # Compute the output path for the library. Note: This is copied
270 # from ADD_COPY_RULE(); probably should refactor this logic.
271 IF (${MODULE_TEST_ONLY} EQUAL 1)
272 SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_LIB_PATH")
273 ELSE (${MODULE_TEST_ONLY} EQUAL 1)
274 SET (_output_basedir "${CMAKE_BINARY_DIR}/LIB_PATH")
275 ENDIF (${MODULE_TEST_ONLY} EQUAL 1)
276
270 # It seems like it would be nice to set the VERSION and/or277 # It seems like it would be nice to set the VERSION and/or
271 # SOVERSION target properties here. However: On Windows, it278 # SOVERSION target properties here. However: On Windows, it
272 # doesn't seem to do anything (the .rc file configured above279 # doesn't seem to do anything (the .rc file configured above
@@ -278,12 +285,44 @@
278 # FOLDER is to group IDE projects into folders.285 # FOLDER is to group IDE projects into folders.
279 SET_TARGET_PROPERTIES (${module_lib_target} PROPERTIES286 SET_TARGET_PROPERTIES (${module_lib_target} PROPERTIES
280 OUTPUT_NAME "${module_filewe}${SUFFIX}"287 OUTPUT_NAME "${module_filewe}${SUFFIX}"
281 ${target_type}_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module_name}.src"288 ${target_type}_OUTPUT_DIRECTORY "${_output_basedir}/${module_path}"
282 FOLDER "Modules"289 FOLDER "Modules"
283 )290 )
284 TARGET_LINK_LIBRARIES(${module_lib_target}291 TARGET_LINK_LIBRARIES(${module_lib_target} zorba_${ZORBA_STORE_NAME})
285 zorba_${ZORBA_STORE_NAME} ${MODULE_LINK_LIBRARIES})292
286293 # Ridiculous hack: CMake doesn't seem to (reliably) set up
294 # dependencies if you specify a library to TARGET_LINK_LIBRARIES()
295 # which is the output of some other ADD_LIBRARY(). We can't solve
296 # this problem in the general case. We can work around it,
297 # however, in the specific case where the target library was
298 # generated by an earlier call to DECLARE_ZORBA_MODULE() - by
299 # remembering that output library's path and its corresponding
300 # target in a global property.
301 FOREACH (_lib ${MODULE_LINK_LIBRARIES})
302 GET_PROPERTY (_targetname GLOBAL PROPERTY "${_lib}_TARGET")
303 IF ("${_targetname}" STREQUAL "")
304 TARGET_LINK_LIBRARIES(${module_lib_target} "${_lib}")
305 ELSE ("${_targetname}" STREQUAL "")
306 TARGET_LINK_LIBRARIES(${module_lib_target} "${_targetname}")
307 ENDIF ("${_targetname}" STREQUAL "")
308 ENDFOREACH (_lib)
309
310 # Remember this library for the auto-generated module Config.cmake
311 # file. Also remember the target name for the hack mentioned
312 # above. QQQ and what about the installed version?
313 GET_TARGET_PROPERTY (_lib_location "${module_lib_target}" LOCATION)
314 SET_PROPERTY (GLOBAL APPEND PROPERTY "${PROJECT_NAME}_LIBRARIES"
315 "${_lib_location}")
316 SET_PROPERTY (GLOBAL PROPERTY "${_lib_location}_TARGET"
317 "${module_lib_target}")
318
319 # If this is a core module, remember the target that builds the
320 # library so zorbacmd can depend on it.
321 IF (${PROJECT_NAME} STREQUAL "zorba")
322 SET_PROPERTY (GLOBAL APPEND PROPERTY ZORBA_CORE_MODULE_LIB_TARGETS
323 "${module_lib_target}")
324 ENDIF (${PROJECT_NAME} STREQUAL "zorba")
325
287 # Install the library, if it's not a TEST_ONLY module326 # Install the library, if it's not a TEST_ONLY module
288 IF (NOT MODULE_TEST_ONLY)327 IF (NOT MODULE_TEST_ONLY)
289 IF(NOT ${PROJECT_NAME} STREQUAL "zorba")328 IF(NOT ${PROJECT_NAME} STREQUAL "zorba")
@@ -314,17 +353,9 @@
314 ENDIF (MODULE_VERSION)353 ENDIF (MODULE_VERSION)
315 FOREACH (version_infix "" ${version_infixes})354 FOREACH (version_infix "" ${version_infixes})
316 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${module_path}/${module_filename}"355 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${module_path}/${module_filename}"
317 "${version_infix}" "" "${MODULE_TEST_ONLY}")356 "${version_infix}" "" 1 "${MODULE_TEST_ONLY}")
318 ENDFOREACH (version_infix)357 ENDFOREACH (version_infix)
319358
320 # Also copy the dynamic library from the location it was built.
321 IF (module_lib_target)
322 GET_TARGET_PROPERTY (lib_location "${module_lib_target}" LOCATION)
323 GET_FILENAME_COMPONENT (lib_filename "${lib_location}" NAME)
324 ADD_COPY_RULE ("LIB" "${lib_location}" "${module_path}/${lib_filename}"
325 "" "${module_lib_target}" "${MODULE_TEST_ONLY}")
326 ENDIF (module_lib_target)
327
328 # Last but not least, whip up a test case that ensures the module359 # Last but not least, whip up a test case that ensures the module
329 # can at least be compiled. Don't bother for test-only modules360 # can at least be compiled. Don't bother for test-only modules
330 # (presumably they're there to be tested!).361 # (presumably they're there to be tested!).
@@ -375,7 +406,7 @@
375 ENDIF (NOT SCHEMA_TEST_ONLY)406 ENDIF (NOT SCHEMA_TEST_ONLY)
376407
377 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${schema_path}/${schema_filename}"408 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${schema_path}/${schema_filename}"
378 "" "" "${SCHEMA_TEST_ONLY}")409 "" "" 1 "${SCHEMA_TEST_ONLY}")
379410
380ENDMACRO (DECLARE_ZORBA_SCHEMA)411ENDMACRO (DECLARE_ZORBA_SCHEMA)
381412
@@ -407,25 +438,74 @@
407 MANGLE_URI (${URI_FILE_URI} "" uri_file_path uri_file_filename)438 MANGLE_URI (${URI_FILE_URI} "" uri_file_path uri_file_filename)
408439
409 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${uri_file_path}/${uri_file_filename}"440 ADD_COPY_RULE ("URI" "${SOURCE_FILE}" "${uri_file_path}/${uri_file_filename}"
410 "" "" "${URI_FILE_TEST_ONLY}")441 "" "" 1 "${URI_FILE_TEST_ONLY}")
411442
412ENDMACRO (DECLARE_ZORBA_URI_FILE)443ENDMACRO (DECLARE_ZORBA_URI_FILE)
413444
445
446# Inform Zorba of a .jar file that should be made available on the CLASSPATH
447# of the JVM, should the JVM be started. QQQ more doc needed
448#
449# Args: FILE - path to file(s) (must be absolute)
450# TARGET - (optional) a CMake target that must be executed in order
451# for FILEs to be generated
452# EXTERNAL - (optional) FILE specifies a path that should be added
453# to CLASSPATH as-is
454# TEST_ONLY - (optional) Jar file is for testcases only and should not
455# be installed
456#
457# Must supply at least one value to FILE or TARGET.
458MACRO (DECLARE_ZORBA_JAR)
459 PARSE_ARGUMENTS (JAR "FILE;TARGET" "TARGET" "TEST_ONLY;EXTERNAL" ${ARGN})
460 IF (NOT JAR_FILE)
461 MESSAGE (FATAL_ERROR "'FILE' argument is required for DECLARE_ZORBA_JAR")
462 ENDIF (NOT JAR_FILE)
463
464 # Initialize classpath file and set up copy rule (once per project)
465 SET (_CP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-classpath.txt")
466 GET_PROPERTY (_known_project GLOBAL PROPERTY "${PROJECT_NAME}-jars")
467 IF (NOT _known_project)
468 FILE (REMOVE "${_CP_FILE}")
469 SET_PROPERTY (GLOBAL PROPERTY "${PROJECT_NAME}-jars" 1)
470 ADD_COPY_RULE ("LIB" "${_CP_FILE}" "jars/${PROJECT_NAME}-classpath.txt"
471 "" "" 1 "${JAR_TEST_ONLY}")
472 ENDIF (NOT _known_project)
473
474 # Iterate over all supplied jar files
475 FOREACH (_jar_file ${JAR_FILE})
476
477 IF (JAR_EXTERNAL)
478 # Put absolute path into classpath file
479 FILE (APPEND "${_CP_FILE}" "${_jar_file}\n")
480 ELSE (JAR_EXTERNAL)
481 # Copy jar to jars/ directory and add relative path to classpath file
482 GET_FILENAME_COMPONENT (_output_filename "${_jar_file}" NAME)
483 ADD_COPY_RULE ("LIB" "${_jar_file}" "jars/${_output_filename}" ""
484 "${JAR_TARGET}" 1 "${JAR_TEST_ONLY}")
485 FILE (APPEND "${_CP_FILE}" "${_output_filename}\n")
486 ENDIF (JAR_EXTERNAL)
487
488 ENDFOREACH (_jar_file)
489ENDMACRO (DECLARE_ZORBA_JAR)
490
491
414# Utility macro for setting up a build rule to copy a file to a492# Utility macro for setting up a build rule to copy a file to a
415# particular (possibly versioned) file in a shared directory if such a file has493# particular (possibly versioned) file in a shared directory if such a
416# not already been output.494# file has not already been output.
495#
417# FILE_TYPE: Either "URI" or "LIB"; will be used to determine which shared496# FILE_TYPE: Either "URI" or "LIB"; will be used to determine which shared
418# directory to place output in (URI_PATH or LIB_PATH). Also, "URI" files497# directory to place output in (URI_PATH or LIB_PATH).
419# will have an INSTALL() directive to put them in the install image.
420# INPUT_FILE: Absolute path to file to copy.498# INPUT_FILE: Absolute path to file to copy.
421# OUTPUT_FILE: Relative path to output file (relative to URI_PATH).499# OUTPUT_FILE: Relative path to output file (relative to URI_PATH).
422# VERSION_ARG: Version; may be "" for non-versioned files.500# VERSION_ARG: Version; may be "" for non-versioned files.
423# DEPEND_TARGET: A CMake target name upon which the copy rule should depend;501# DEPEND_TARGET: A CMake target name upon which the copy rule should depend;
424# may be "".502# may be "".
503# INSTALL: If 1, an INSTALL() directive will be executed to put the
504# file into the install image.
425# TEST_ONLY: If 1, file is for testcases only; will be copied into505# TEST_ONLY: If 1, file is for testcases only; will be copied into
426# TEST_URI_PATH/TEST_LIB_PATH and will not be installed506# TEST_URI_PATH/TEST_LIB_PATH and will not be installed.
427MACRO (ADD_COPY_RULE FILE_TYPE INPUT_FILE OUTPUT_FILE VERSION_ARG507MACRO (ADD_COPY_RULE FILE_TYPE INPUT_FILE OUTPUT_FILE VERSION_ARG
428 DEPEND_TARGET TEST_ONLY)508 DEPEND_TARGET INSTALL TEST_ONLY)
429 # Choose output base directory509 # Choose output base directory
430 IF (${TEST_ONLY} EQUAL 1)510 IF (${TEST_ONLY} EQUAL 1)
431 SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_${FILE_TYPE}_PATH")511 SET (_output_basedir "${CMAKE_BINARY_DIR}/TEST_${FILE_TYPE}_PATH")
@@ -470,13 +550,13 @@
470 SET_PROPERTY (GLOBAL APPEND PROPERTY ZORBA_URI_FILES550 SET_PROPERTY (GLOBAL APPEND PROPERTY ZORBA_URI_FILES
471 "${INPUT_FILE}" "${_output_file}" "${DEPEND_TARGET}" "${_is_core}")551 "${INPUT_FILE}" "${_output_file}" "${DEPEND_TARGET}" "${_is_core}")
472552
473 # Also set up an INSTALL rule (unless TEST_ONLY or LIB).553 # Also set up an INSTALL rule (unless TEST_ONLY).
474 IF ( (NOT "${FILE_TYPE}" STREQUAL "LIB") AND (NOT ${TEST_ONLY} EQUAL 1) )554 IF ( (${INSTALL} EQUAL 1) AND (NOT ${TEST_ONLY} EQUAL 1) )
475 555
476 IF(NOT _is_core)556 IF(NOT _is_core)
477 STRING(REPLACE "-" "_" component_name ${PROJECT_NAME}) 557 STRING(REPLACE "-" "_" component_name ${PROJECT_NAME})
478 INSTALL (FILES "${INPUT_FILE}"558 INSTALL (FILES "${INPUT_FILE}"
479 DESTINATION "${ZORBA_NONCORE_URI_DIR}/${_output_path}"559 DESTINATION "${ZORBA_NONCORE_${FILE_TYPE}_DIR}/${_output_path}"
480 RENAME "${_output_filename}"560 RENAME "${_output_filename}"
481 COMPONENT "${component_name}")561 COMPONENT "${component_name}")
482 562
@@ -496,11 +576,11 @@
496 576
497 ELSE(NOT _is_core)577 ELSE(NOT _is_core)
498 INSTALL (FILES "${INPUT_FILE}"578 INSTALL (FILES "${INPUT_FILE}"
499 DESTINATION "${ZORBA_CORE_URI_DIR}/${_output_path}"579 DESTINATION "${ZORBA_CORE_${FILE_TYPE}_DIR}/${_output_path}"
500 RENAME "${_output_filename}")580 RENAME "${_output_filename}")
501 ENDIF(NOT _is_core)581 ENDIF(NOT _is_core)
502 582
503 ENDIF ( (NOT "${FILE_TYPE}" STREQUAL "LIB") AND (NOT ${TEST_ONLY} EQUAL 1) )583 ENDIF ( (${INSTALL} EQUAL 1) AND (NOT ${TEST_ONLY} EQUAL 1) )
504 ENDIF (file_found EQUAL -1)584 ENDIF (file_found EQUAL -1)
505ENDMACRO (ADD_COPY_RULE)585ENDMACRO (ADD_COPY_RULE)
506586
@@ -535,6 +615,8 @@
535# files to their corresponding output directories, with appropriate615# files to their corresponding output directories, with appropriate
536# dependencies. This macro will only have any effect when called by616# dependencies. This macro will only have any effect when called by
537# the top-level project in a build.617# the top-level project in a build.
618# Also, this function automatically generates a CMake projectConfig.cmake
619# file for the project, based on config/ExternalModuleConfig.cmake.in.
538MACRO (DONE_DECLARING_ZORBA_URIS)620MACRO (DONE_DECLARING_ZORBA_URIS)
539 IF (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)621 IF (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
540 # Close out the zorba modules and schemas manifests622 # Close out the zorba modules and schemas manifests
@@ -553,9 +635,10 @@
553 LIST (GET copy_rules 2 _depend_target)635 LIST (GET copy_rules 2 _depend_target)
554 LIST (GET copy_rules 3 _is_core)636 LIST (GET copy_rules 3 _is_core)
555 LIST (REMOVE_AT copy_rules 0 1 2 3)637 LIST (REMOVE_AT copy_rules 0 1 2 3)
556 SET (_depends "${_input_file}")
557 IF (_depend_target)638 IF (_depend_target)
558 LIST (APPEND _depends "${_depend_target}")639 SET (_depends "${_depend_target}")
640 ELSE (_depend_target)
641 SET (_depends "${_input_file}")
559 ENDIF (_depend_target)642 ENDIF (_depend_target)
560 ADD_CUSTOM_COMMAND (OUTPUT "${_output_file}"643 ADD_CUSTOM_COMMAND (OUTPUT "${_output_file}"
561 COMMAND "${CMAKE_COMMAND}" -E copy644 COMMAND "${CMAKE_COMMAND}" -E copy
@@ -571,7 +654,8 @@
571654
572 # Targets and dependencies:655 # Targets and dependencies:
573 # ALL depends on check_uris; check_uris depends on check_core_uris;656 # ALL depends on check_uris; check_uris depends on check_core_uris;
574 # zorbacmd depends on check_core_uris.657 # zorbacmd depends on check_core_uris as well as all core module
658 # library targets.
575 ADD_CUSTOM_TARGET (check_uris ALL659 ADD_CUSTOM_TARGET (check_uris ALL
576 DEPENDS ${_noncore_output_files} VERBATIM)660 DEPENDS ${_noncore_output_files} VERBATIM)
577 SET_TARGET_PROPERTIES(check_uris PROPERTIES FOLDER "Modules")661 SET_TARGET_PROPERTIES(check_uris PROPERTIES FOLDER "Modules")
@@ -584,6 +668,8 @@
584 DEPENDS ${_core_output_files} VERBATIM)668 DEPENDS ${_core_output_files} VERBATIM)
585 ADD_DEPENDENCIES(check_uris check_core_uris)669 ADD_DEPENDENCIES(check_uris check_core_uris)
586 ADD_DEPENDENCIES(zorbacmd check_core_uris)670 ADD_DEPENDENCIES(zorbacmd check_core_uris)
671 GET_PROPERTY (_corelibs GLOBAL PROPERTY ZORBA_CORE_MODULE_LIB_TARGETS)
672 ADD_DEPENDENCIES(zorbacmd ${_corelibs})
587 SET_TARGET_PROPERTIES(check_core_uris PROPERTIES FOLDER "Modules")673 SET_TARGET_PROPERTIES(check_core_uris PROPERTIES FOLDER "Modules")
588 ENDIF (_num_core GREATER 0)674 ENDIF (_num_core GREATER 0)
589 SET_PROPERTY (GLOBAL PROPERTY ZORBA_URI_FILES)675 SET_PROPERTY (GLOBAL PROPERTY ZORBA_URI_FILES)
@@ -591,6 +677,18 @@
591 #add 'xqdoc' and 'xqdoc-xml' targets677 #add 'xqdoc' and 'xqdoc-xml' targets
592 ADD_XQDOC_TARGETS()678 ADD_XQDOC_TARGETS()
593 ENDIF (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)679 ENDIF (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
680
681 # Now, do things that should be done at the end of *any* project, not
682 # just the top-level project.
683
684 # Generate project's projectConfig.cmake file.
685 # QQQ need to create an installable version of this too, once we know
686 # how installing a module package should work.
687 GET_PROPERTY (ZORBA_PROJECT_LIBRARIES
688 GLOBAL PROPERTY "${PROJECT_NAME}_LIBRARIES")
689 CONFIGURE_FILE("${Zorba_EXTERNALMODULECONFIG_FILE}"
690 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY)
691
594ENDMACRO (DONE_DECLARING_ZORBA_URIS)692ENDMACRO (DONE_DECLARING_ZORBA_URIS)
595693
596# Initialize expected failures and zorba modules output files when694# Initialize expected failures and zorba modules output files when
@@ -696,10 +794,12 @@
696 IF (WIN32 AND (${_crash_idx} GREATER -1) )794 IF (WIN32 AND (${_crash_idx} GREATER -1) )
697 MESSAGE (STATUS "WARNING: Skipping test case ${TESTNAME} which is expected to crash - bug ${_crash_bugid}")795 MESSAGE (STATUS "WARNING: Skipping test case ${TESTNAME} which is expected to crash - bug ${_crash_bugid}")
698 ELSE (WIN32 AND (${_crash_idx} GREATER -1) )796 ELSE (WIN32 AND (${_crash_idx} GREATER -1) )
797 # DEPENDENCY_MODULE_PATH will always start with an appropriate
798 # path separator
699 ADD_TEST(${TESTNAME} "${Zorba_TESTDRIVER}"799 ADD_TEST(${TESTNAME} "${Zorba_TESTDRIVER}"
700 "--rbkt-src" "${TEST_DIR}"800 "--rbkt-src" "${TEST_DIR}"
701 "--module-path"801 "--module-path"
702 "${CMAKE_BINARY_DIR}/URI_PATH/${PATH_SEP}${SECONDARY_MODULE_PATHS}"802 "${CMAKE_BINARY_DIR}/URI_PATH/${PATH_SEP}${DEPENDENCY_MODULE_PATH}"
703 "${TESTFILE}")803 "${TESTFILE}")
704804
705 # On non-Windows, call EXPECTED_FAILURE() for known crashes805 # On non-Windows, call EXPECTED_FAILURE() for known crashes
@@ -727,18 +827,6 @@
727 MESSAGE(STATUS "Added ${TESTCOUNTER} tests in ${TEST_DIR}")827 MESSAGE(STATUS "Added ${TESTCOUNTER} tests in ${TEST_DIR}")
728ENDMACRO (ADD_TEST_DIRECTORY)828ENDMACRO (ADD_TEST_DIRECTORY)
729829
730# Macro to install a basic CMake config file for a module. Provide a
731# source and binary directory. Result will be installed in binary
732# directory. This is a macro because it is called from two different
733# places: ZorbaUse.cmake, and Zorba's modules/CMakeLists.txt.
734MACRO(CREATE_MODULE_CONFIG name src_dir bin_dir)
735 # Set variables referenced in ExternalModuleConfig.cmake.in
736 SET(MODULE_SOURCE_DIR ${src_dir})
737 SET(MODULE_BINARY_DIR ${bin_dir})
738 CONFIGURE_FILE("${Zorba_EXTERNALMODULECONFIG_FILE}"
739 "${MODULE_BINARY_DIR}/${name}Config.cmake" @ONLY)
740ENDMACRO(CREATE_MODULE_CONFIG)
741
742# This macro easies the process of adding test for store dependent830# This macro easies the process of adding test for store dependent
743# executables. It has the same naming convection for the target as the831# executables. It has the same naming convection for the target as the
744# macro that is used to generated store dependent executables (thus,832# macro that is used to generated store dependent executables (thus,
745833
=== modified file 'config/ExternalModuleConfig.cmake.in'
--- config/ExternalModuleConfig.cmake.in 2012-04-16 20:56:43 +0000
+++ config/ExternalModuleConfig.cmake.in 2012-04-18 15:53:24 +0000
@@ -12,12 +12,29 @@
12# See the License for the specific language governing permissions and12# See the License for the specific language governing permissions and
13# limitations under the License.13# limitations under the License.
1414
15IF(WIN32)15IF (WIN32)
16 SET(PATH_SEP ",")16 SET (PATH_SEP ",")
17ELSE(WIN32)17ELSE (WIN32)
18 SET(PATH_SEP ":")18 SET (PATH_SEP ":")
19ENDIF(WIN32)19ENDIF (WIN32)
2020
21# QQQ When all the module versioning and external-module work is21# Probably should have separate URI and LIB paths here someday; will
22# complete, this should contain ONLY MODULE_BINARY_DIR/modules.22# require testdriver to accept --uri-path and --lib-path args
23SET(SECONDARY_MODULE_PATHS "${SECONDARY_MODULE_PATHS}${PATH_SEP}@MODULE_SOURCE_DIR@/src/${PATH_SEP}@MODULE_BINARY_DIR@/src/${PATH_SEP}@MODULE_BINARY_DIR@/modules/")23# Note that this path is meaningless if the module is installed; see
24# bug 966999.
25SET (DEPENDENCY_MODULE_PATH
26 "${DEPENDENCY_MODULE_PATH}${PATH_SEP}@PROJECT_BINARY_DIR@/URI_PATH/${PATH_SEP}${DEPENDENCY_LIB_PATH}${PATH_SEP}@PROJECT_BINARY_DIR@/LIB_PATH/")
27
28# Dynamic libraries created by this project to link against
29SET (@PROJECT_NAME@_LIBRARIES @ZORBA_PROJECT_LIBRARIES@)
30
31# Include directories exported by this project
32SET (@PROJECT_NAME@_INCLUDE_DIRS @ZORBA_PROJECT_INCLUDE_DIRS@)
33
34# Offer a "use file" to the user of this module. For most module
35# packages, this is unnecessary. However it can be utilized by
36# advanced packages which wish to, for example, export a C++ header
37# file to dependent packages. As above, note that this currently is
38# non-functional if this module package is installed; this will only
39# work from a project build directory.
40SET (@PROJECT_NAME@_USE_FILE "@ZORBA_PROJECT_USE_FILE@")
2441
=== modified file 'config/ZorbaUse.cmake'
--- config/ZorbaUse.cmake 2012-04-16 20:56:43 +0000
+++ config/ZorbaUse.cmake 2012-04-18 15:53:24 +0000
@@ -31,7 +31,3 @@
31 # Load Zorba module support macros.31 # Load Zorba module support macros.
32 INCLUDE("${Zorba_CMAKE_MODULES_DIR}/Windows/ProxyFindModule.cmake")32 INCLUDE("${Zorba_CMAKE_MODULES_DIR}/Windows/ProxyFindModule.cmake")
33ENDIF(WIN32)33ENDIF(WIN32)
34
35# Generate project's projectConfig.cmake file.
36CREATE_MODULE_CONFIG(${PROJECT_NAME} "${PROJECT_SOURCE_DIR}"
37 "${PROJECT_BINARY_DIR}")
3834
=== modified file 'include/zorba/properties_base.h'
--- include/zorba/properties_base.h 2012-04-16 20:56:43 +0000
+++ include/zorba/properties_base.h 2012-04-18 15:53:24 +0000
@@ -101,8 +101,44 @@
101 std::vector<std::string>& val,101 std::vector<std::string>& val,
102 unsigned delta);102 unsigned delta);
103103
104/**
105 * \brief This class provides access to global properties.
106 *
107 * This class provides access to global properties set for Zorba in environment
108 * and configuration file.
109 * It is available using Zorba.getProperties() method.
110 * \see { Zorba::getProperties() }
111 */
112class ZORBA_DLL_PUBLIC PropertiesGlobal : public PropertiesBase
113{
114public:
115 virtual ~PropertiesGlobal() {}
116
117 /**
118 * \brief Get global JVM classpath property.
119 *
120 * Before the JVM is started this will return the classpath set by
121 * command line option, the CLASSPATH environment variable and in Zorba
122 * config file.
123 *
124 * After the JVM is started this will contain in addition the paths to jars
125 * used by modules that make use of the JVM.
126 */
127 virtual void getJVMClassPath(std::string & jvmClasspath) {}
128
129 /**
130 * \brief Set global JVM classpath property.
131 *
132 * This method should be used to set additional JVM classpath for modules
133 * that make use of JVM. This will overide the classpath set by CLASSPATH
134 * environment variable or Zorba config file.
135 *
136 * Once the JVM is started this method doesn't have any effect.
137 */
138 virtual void setJVMClassPath(const std::string & jvmClasspath) {}
139};
140
104}141}
105
106#endif // ZORBA_PROPERTIES_BASE_H142#endif // ZORBA_PROPERTIES_BASE_H
107/*143/*
108 * Local variables:144 * Local variables:
109145
=== modified file 'include/zorba/util/file.h'
--- include/zorba/util/file.h 2012-04-16 20:56:43 +0000
+++ include/zorba/util/file.h 2012-04-18 15:53:24 +0000
@@ -24,6 +24,7 @@
24#include <cstdio>24#include <cstdio>
25#include <string>25#include <string>
26#include <time.h>26#include <time.h>
27#include <vector>
2728
28#include <zorba/config.h>29#include <zorba/config.h>
29#include <zorba/file.h>30#include <zorba/file.h>
@@ -84,6 +85,7 @@
84 void mkdir();85 void mkdir();
85 void deep_mkdir();86 void deep_mkdir();
86 void rmdir(bool ignore = true);87 void rmdir(bool ignore = true);
88 void lsdir(std::vector<std::string> &list);
87#ifndef _WIN32_WCE89#ifndef _WIN32_WCE
88 void chdir();90 void chdir();
89#endif91#endif
9092
=== modified file 'include/zorba/zorba.h'
--- include/zorba/zorba.h 2012-04-16 20:56:43 +0000
+++ include/zorba/zorba.h 2012-04-18 15:53:24 +0000
@@ -34,14 +34,18 @@
34#include <zorba/xquery.h>34#include <zorba/xquery.h>
35#include <zorba/zorba_string.h>35#include <zorba/zorba_string.h>
36#include <zorba/iterator.h>36#include <zorba/iterator.h>
37#include <zorba/properties_base.h>
3738
38namespace zorba {39namespace zorba {
3940
40/**41/**
41 * The Zorba class is the single point of access to the %Zorba engine.42 * The Zorba class is the single point of access to the %Zorba engine.
42 * There exists one instance of the Zorba class per process.43 * There exists one instance of the Zorba class per process.
43 * It can be used to (1) create and compile queries, (2) create static contexts,44 * It can be used to (1) create and compile queries,
44 * (3) provides access to the XmlDataManager, and (4) provides access to the ItemFactory.45 * (2) create static contexts,
46 * (3) provides access to the XmlDataManager,
47 * (4) provides access to the ItemFactory, and
48 * (5) provides access to the PropertiesGlobal.
45 */49 */
46class ZORBA_DLL_PUBLIC Zorba50class ZORBA_DLL_PUBLIC Zorba
47{51{
@@ -301,7 +305,7 @@
301 virtual StaticContext_t305 virtual StaticContext_t
302 createStaticContext(DiagnosticHandler* aDiagnosticHandler = 0) = 0;306 createStaticContext(DiagnosticHandler* aDiagnosticHandler = 0) = 0;
303307
304 /** \brief Gets the singelton instance of the ItemFactory.308 /** \brief Gets the singleton instance of the ItemFactory.
305 *309 *
306 * @return ItemFactory the singleton instance of the ItemFactory.310 * @return ItemFactory the singleton instance of the ItemFactory.
307 */311 */
@@ -310,18 +314,24 @@
310314
311 /** \brief Gets the singleton instance of the XmlDataManager object.315 /** \brief Gets the singleton instance of the XmlDataManager object.
312 *316 *
313 * @return XmlDataManager the singelton instance of the XmlDataManager.317 * @return XmlDataManager the singleton instance of the XmlDataManager.
314 */318 */
315 virtual XmlDataManager*319 virtual XmlDataManager*
316 getXmlDataManager() = 0;320 getXmlDataManager() = 0;
317321
318 /** \brief Gets the singleton instance of Zorba's audit provider object.322 /** \brief Gets the singleton instance of Zorba's audit provider object.
319 *323 *
320 * @return audit::Provider the singelton instance of Zorba's audit provider.324 * @return audit::Provider the singeleton instance of Zorba's audit provider.
321 */325 */
322 virtual audit::Provider*326 virtual audit::Provider*
323 getAuditProvider() = 0;327 getAuditProvider() = 0;
324328
329 /** \brief Gets the singleton instance of Zorba's properties object.
330 *
331 * @return zorba::Properties the singleton instance of Zorba's properties object.
332 */
333 virtual PropertiesGlobal* getPropertiesGlobal() = 0;
334
325}; /* class Zorba */335}; /* class Zorba */
326336
327337
328338
=== modified file 'modules/CMakeLists.txt'
--- modules/CMakeLists.txt 2012-04-16 20:56:43 +0000
+++ modules/CMakeLists.txt 2012-04-18 15:53:24 +0000
@@ -21,13 +21,19 @@
21# named "zorba_modules" as a sibling to the main Zorba source21# named "zorba_modules" as a sibling to the main Zorba source
22# directory.22# directory.
2323
24# First, configure the moduleConfig.cmake file for each module24# This is complicated and more than a little hacky. We need to add all
25# project. We must do this "manually" before doing any25# the module subdirectories, but some may depend on others so we can't
26# ADD_SUBDIRECTORY()s, so that all the config files are built and26# simply add them alphabetically. Here we determine their project
27# ready for other modules' FIND_PACKAGE() calls. We also add all27# names and dependencies by manually reading their CMakeLists.txt
28# module build dirs to CMAKE_PREFIX_PATH for the same reason.28# files (as text files). We form a directed graph (which isn't easy in
29SET (project_regex "[Pp][Rr][Oo][Jj][Ee][Cc][Tt]")29# CMake) then produce a topological sort to load the modules in
30FILE (GLOB modules_dir_items RELATIVE "${ZORBA_MODULES_DIR}" "${ZORBA_MODULES_DIR}/[a-zA-Z0-9]*")30# order. Note that this will not work if there are cyclical
31# dependencies between modules; if we ever need that ability, this
32# will get more complicated.
33
34FILE (GLOB modules_dir_items
35 RELATIVE "${ZORBA_MODULES_DIR}"
36 "${ZORBA_MODULES_DIR}/[a-zA-Z0-9]*")
3137
32# Filter out non-directories38# Filter out non-directories
33SET (module_dirs)39SET (module_dirs)
@@ -37,19 +43,27 @@
37 ENDIF (IS_DIRECTORY "${ZORBA_MODULES_DIR}/${module_dir}")43 ENDIF (IS_DIRECTORY "${ZORBA_MODULES_DIR}/${module_dir}")
38ENDFOREACH (module_dir)44ENDFOREACH (module_dir)
3945
46# First, form a simple list of all known module projects in the
47# variable "module_projects". Also, for each project, set a variable
48# named eg. "zorba-email-module_DIR" with the path to that project's
49# directory, relative to ZORBA_MODULES_DIR.
50SET (project_regex "[Pp][Rr][Oo][Jj][Ee][Cc][Tt] *\\( *([^ )]*)")
51SET (module_projects)
40FOREACH (module_dir ${module_dirs})52FOREACH (module_dir ${module_dirs})
41 # This is really kind of hacky, but I don't know a better solution without
42 # introducing some sort of inter-module dependency tracking and requiring
43 # consistent directory naming for external modules. What we do here is
44 # read the module's CMakeLists.txt (as a text file), searching for the
45 # PROJECT() declaration, so we can extract the name of the CMake project.
46 SET (module_project)53 SET (module_project)
47 SET (cmakelists)54 SET (cmakelists_file "${ZORBA_MODULES_DIR}/${module_dir}/CMakeLists.txt")
48 FILE (STRINGS "${ZORBA_MODULES_DIR}/${module_dir}/CMakeLists.txt" cmakelists55 FILE (STRINGS "${cmakelists_file}" cmakelists REGEX "${project_regex}")
49 REGEX ${project_regex})
50 FOREACH (line ${cmakelists})56 FOREACH (line ${cmakelists})
51 IF (line MATCHES "${project_regex} *\\(([^)]*)\\)")57
52 SET (module_project ${CMAKE_MATCH_1})58 IF (line MATCHES "${project_regex}")
59 IF (NOT "${module_project}" STREQUAL "")
60 MESSAGE (FATAL_ERROR
61 "${cmakelists_file} contains duplicate PROJECT() statements - "
62 "cannot parse!")
63 ENDIF (NOT "${module_project}" STREQUAL "")
64 SET (module_project "${CMAKE_MATCH_1}")
65 LIST (APPEND module_projects "${module_project}")
66 SET ("${module_project}_DIR" "${module_dir}")
5367
54 # Print the found module name68 # Print the found module name
55 SET (status "Found module project ${module_project}")69 SET (status "Found module project ${module_project}")
@@ -63,8 +77,7 @@
63 MESSAGE (STATUS "${status}")77 MESSAGE (STATUS "${status}")
64 MESSAGE (STATUS "${border}")78 MESSAGE (STATUS "${border}")
6579
66 BREAK ()80 ENDIF (line MATCHES "${project_regex}")
67 ENDIF (line MATCHES "${project_regex} *\\(([^)]*)\\)")
68 ENDFOREACH (line)81 ENDFOREACH (line)
6982
70 IF (NOT module_project)83 IF (NOT module_project)
@@ -72,14 +85,77 @@
72 "does not contain a recognizable CMake project.")85 "does not contain a recognizable CMake project.")
73 ENDIF (NOT module_project)86 ENDIF (NOT module_project)
7487
75 SET (module_builddir "${CMAKE_BINARY_DIR}/zorba_modules/${module_project}")88ENDFOREACH (module_dir)
76 FILE (MAKE_DIRECTORY "${module_builddir}")89
77 CREATE_MODULE_CONFIG (${module_project} "${ZORBA_MODULES_DIR}/${module_dir}"90# Next, form the DAG. This comprises one list containing only those
78 "${module_builddir}")91# module projects that some other module project depends on
79 LIST (APPEND CMAKE_PREFIX_PATH "${module_builddir}")92# (dep_module_projects), and a series of CMake variables named
80 #SET (ZORBA_EXTERNAL_MODULES_SRCS ${ZORBA_EXTERNAL_MODULES_SRCS} ${ZORBA_MODULES_DIR}/${module_dir}/src)93# eg. "zorba-email-module_DEPS" containing the module projects that
81ENDFOREACH (module_dir)94# the named project depends on. Doing this unfortunately requires us
82#SET (ZORBA_EXTERNAL_MODULES_SRCS ${ZORBA_EXTERNAL_MODULES_SRCS} PARENT_SCOPE)95# to read through all CMakeLists.txt files again.
96SET (find_package_regex
97 "[Ff][Ii][Nn][Dd]_[Pp][Aa][Cc][Kk][Aa][Gg][Ee] *\\( *([^ )]*)")
98SET (dep_module_projects)
99FOREACH (module_dir ${module_dirs})
100 SET (module_project)
101 SET (cmakelists_file "${ZORBA_MODULES_DIR}/${module_dir}/CMakeLists.txt")
102 FILE (STRINGS "${cmakelists_file}" cmakelists
103 REGEX "${project_regex}|${find_package_regex}")
104 FOREACH (line ${cmakelists})
105 IF (line MATCHES "${project_regex}")
106 # Don't have to do error checking here; was done in last pass.
107 SET (module_project "${CMAKE_MATCH_1}")
108 ELSEIF (line MATCHES "${find_package_regex}")
109 SET (dependee ${CMAKE_MATCH_1})
110 # Ensure this dependency is a known module project, and not some
111 # other dependency like "Zorba" - don't want those in the DAG.
112 LIST (FIND module_projects "${dependee}" is_known)
113 IF (is_known GREATER -1)
114 message (STATUS "${module_project} depends on ${dependee}")
115 # Save the dependency in a variable based on the current project
116 LIST (APPEND "${module_project}_DEPS" ${dependee})
117 # Also add this dependee to dep_module_projects
118 LIST (APPEND dep_module_projects ${dependee})
119 ENDIF (is_known GREATER -1)
120 ENDIF (line MATCHES "${project_regex}")
121 ENDFOREACH (line)
122
123ENDFOREACH (module_dir)
124
125
126# Now, transform the DAG into a dependency-ordered list. See
127# http://en.wikipedia.org/wiki/Topological_sorting .
128SET (no_deps)
129SET (visited)
130SET (ordered_modules)
131MACRO (VISIT mod_name)
132 LIST (FIND visited "${mod_name}" is_visited)
133 IF (is_visited EQUAL -1)
134 # Haven't seen this module before; iterate through modules that depend on it
135 LIST (APPEND visited "${mod_name}")
136 FOREACH (depender ${${mod_name}_DEPS})
137 VISIT ("${depender}")
138 ENDFOREACH (depender)
139 # Now that all modules that depend on it have been added, add this one
140 LIST (APPEND ordered_modules "${mod_name}")
141 ELSE (is_visited EQUAL -1)
142 ENDIF (is_visited EQUAL -1)
143ENDMACRO (VISIT)
144# Annoying - LIST(REMOVE_DUPLICATES) dies if the list is empty.
145LIST (LENGTH dep_module_projects num_deps)
146IF (num_deps GREATER 0)
147 LIST (REMOVE_DUPLICATES dep_module_projects)
148ENDIF (num_deps GREATER 0)
149FOREACH (module_project ${module_projects})
150 # Only initially visit those modules projects that do NOT have any
151 # module projects depending on them; that is, only visit those module
152 # projects that are NOT in dep_module_projects.
153 LIST (FIND dep_module_projects "${module_project}" is_dep)
154 IF (is_dep EQUAL -1)
155 VISIT (${module_project})
156 ENDIF (is_dep EQUAL -1)
157
158ENDFOREACH (module_project)
83159
84# Each of these projects will also want to be able to160# Each of these projects will also want to be able to
85# FIND_PACKAGE(Zorba), so add our own build dir to the CMake module161# FIND_PACKAGE(Zorba), so add our own build dir to the CMake module
@@ -89,9 +165,16 @@
89# Now, iterate through all the module projects again and actually add165# Now, iterate through all the module projects again and actually add
90# them to this Zorba project. Create a binary directory for them166# them to this Zorba project. Create a binary directory for them
91# inside our own.167# inside our own.
92FOREACH (module_dir ${module_dirs})168FOREACH (module_project ${ordered_modules})
169 # Create the module binary directory and add it to CMAKE_PREFIX_PATH
170 # so other modules can find it. Then, add the module project
171 # directory.
172 SET (module_dir "${${module_project}_DIR}")
173 SET (module_builddir "${CMAKE_BINARY_DIR}/zorba_modules/${module_project}")
174 FILE (MAKE_DIRECTORY "${module_builddir}")
175 LIST (APPEND CMAKE_PREFIX_PATH "${module_builddir}")
93 ADD_SUBDIRECTORY("${ZORBA_MODULES_DIR}/${module_dir}"176 ADD_SUBDIRECTORY("${ZORBA_MODULES_DIR}/${module_dir}"
94 "${CMAKE_BINARY_DIR}/zorba_modules/zorba_${module_dir}_module")177 "${CMAKE_BINARY_DIR}/zorba_modules/${module_project}")
95ENDFOREACH (module_dir)178ENDFOREACH (module_project)
96179
97MESSAGE(STATUS "End modules")180MESSAGE(STATUS "End modules")
98181
=== modified file 'modules/ExternalModules.conf'
--- modules/ExternalModules.conf 2012-04-17 22:40:48 +0000
+++ modules/ExternalModules.conf 2012-04-18 15:53:24 +0000
@@ -40,3 +40,5 @@
40system bzr lp:zorba/system-module zorba-2.2 40system bzr lp:zorba/system-module zorba-2.2
41xqxq bzr lp:zorba/xqxq-module zorba-2.2 41xqxq bzr lp:zorba/xqxq-module zorba-2.2
42email bzr lp:zorba/email-module zorba-2.2 42email bzr lp:zorba/email-module zorba-2.2
43util-jvm bzr lp:zorba/util-jvm-module
44schema-tools bzr lp:zorba/schema-tools-module
4345
=== modified file 'scripts/CMakeLists.txt'
--- scripts/CMakeLists.txt 2012-04-16 20:56:43 +0000
+++ scripts/CMakeLists.txt 2012-04-18 15:53:24 +0000
@@ -52,9 +52,11 @@
52 ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_SOURCE_DIR}/NOTICE.txt"52 ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_SOURCE_DIR}/NOTICE.txt"
53 COMMAND "${ZORBA_EXE}" "-q" "${CMAKE_CURRENT_BINARY_DIR}/notice-generator.xq" "-f" "--omit-xml-declaration"53 COMMAND "${ZORBA_EXE}" "-q" "${CMAKE_CURRENT_BINARY_DIR}/notice-generator.xq" "-f" "--omit-xml-declaration"
54 MAIN_DEPENDENCY "${CMAKE_CURRENT_BINARY_DIR}/notice-generator.xq" 54 MAIN_DEPENDENCY "${CMAKE_CURRENT_BINARY_DIR}/notice-generator.xq"
55 DEPENDS "${CMAKE_SOURCE_DIR}/NOTICE.xml" "${CMAKE_SOURCE_DIR}/CMakeLists.txt")55 DEPENDS "${CMAKE_SOURCE_DIR}/NOTICE.xml"
56 "${CMAKE_SOURCE_DIR}/CMakeLists.txt"
57 zorbacmd)
56 ADD_CUSTOM_TARGET(NOTICE ALL58 ADD_CUSTOM_TARGET(NOTICE ALL
57 DEPENDS "${CMAKE_SOURCE_DIR}/NOTICE.txt" zorbacmd59 DEPENDS "${CMAKE_SOURCE_DIR}/NOTICE.txt"
58 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}60 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
59 )61 )
6062
6163
=== modified file 'src/api/zorbaimpl.cpp'
--- src/api/zorbaimpl.cpp 2012-04-16 20:56:43 +0000
+++ src/api/zorbaimpl.cpp 2012-04-18 15:53:24 +0000
@@ -35,6 +35,7 @@
35#include "diagnostics/xquery_diagnostics.h"35#include "diagnostics/xquery_diagnostics.h"
3636
37#include "system/globalenv.h"37#include "system/globalenv.h"
38#include "system/properties.h"
3839
39#include "context/static_context.h"40#include "context/static_context.h"
4041
@@ -269,6 +270,15 @@
269}270}
270271
271272
273/*******************************************************************************
274
275********************************************************************************/
276PropertiesGlobal* ZorbaImpl::getPropertiesGlobal()
277{
278 return Properties::instance();
279}
280
281
272void ZorbaImpl::notifyError( DiagnosticHandler *eh, ZorbaException const &ze ) {282void ZorbaImpl::notifyError( DiagnosticHandler *eh, ZorbaException const &ze ) {
273 eh->error( ze );283 eh->error( ze );
274}284}
275285
=== modified file 'src/api/zorbaimpl.h'
--- src/api/zorbaimpl.h 2012-04-16 20:56:43 +0000
+++ src/api/zorbaimpl.h 2012-04-18 15:53:24 +0000
@@ -134,6 +134,8 @@
134134
135 audit::Provider* getAuditProvider();135 audit::Provider* getAuditProvider();
136136
137 PropertiesGlobal* getPropertiesGlobal();
138
137protected:139protected:
138 ZorbaImpl();140 ZorbaImpl();
139141
140142
=== modified file 'src/context/dynamic_loader.cpp'
--- src/context/dynamic_loader.cpp 2012-04-16 20:56:43 +0000
+++ src/context/dynamic_loader.cpp 2012-04-18 15:53:24 +0000
@@ -132,8 +132,15 @@
132ExternalModule*132ExternalModule*
133DynamicLoader::loadModule(const zstring& aFile) const133DynamicLoader::loadModule(const zstring& aFile) const
134{134{
135 // function pointer to create a module135 handle_t handle;
136 ExternalModule* (*createModule)() = NULL;136 std::map<const zstring, handle_t>::const_iterator lIter;
137
138 lIter = theLibraries.find(aFile);
139 if (lIter != theLibraries.end())
140 {
141 handle = lIter->second;
142 return createModule(handle, aFile);
143 }
137144
138#ifdef WIN32145#ifdef WIN32
139 WCHAR wpath_str[1024];146 WCHAR wpath_str[1024];
@@ -146,43 +153,51 @@
146 0, aFile.c_str(), -1,153 0, aFile.c_str(), -1,
147 wpath_str, sizeof(wpath_str)/sizeof(WCHAR));154 wpath_str, sizeof(wpath_str)/sizeof(WCHAR));
148 }155 }
149 HMODULE handle = LoadLibraryW(wpath_str);156
157 handle = LoadLibraryW(wpath_str);
150 if (!handle)158 if (!handle)
151 throw ZORBA_EXCEPTION(159 throw ZORBA_EXCEPTION(
152 zerr::ZOSE0005_DLL_LOAD_FAILED,160 zerr::ZOSE0005_DLL_LOAD_FAILED,
153 ERROR_PARAMS( aFile, os_error::get_err_string() )161 ERROR_PARAMS( aFile, os_error::get_err_string() )
154 );162 );
155163#else
164 handle = dlopen(aFile.c_str(), RTLD_NOW);
165 if (!handle)
166 throw ZORBA_EXCEPTION(
167 zerr::ZOSE0005_DLL_LOAD_FAILED, ERROR_PARAMS( aFile, zstring(dlerror()) )
168 );
169#endif
170
171 theLibraries[aFile] = handle;
172 return createModule(handle, aFile);
173}
174
175
176ExternalModule*
177DynamicLoader::createModule(handle_t handle, const zstring& aFile) const
178{
179 // function pointer to create a module
180 ExternalModule* (*createModuleFunction)() = NULL;
181
182#ifdef WIN32
156 createModule = (ExternalModule* (*)())GetProcAddress(handle, "createModule");183 createModule = (ExternalModule* (*)())GetProcAddress(handle, "createModule");
157 if (createModule == NULL)184 if (createModuleFunction == NULL)
158 throw ZORBA_EXCEPTION(185 throw ZORBA_EXCEPTION(
159 zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,186 zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,
160 ERROR_PARAMS( aFile, os_error::get_err_string() )187 ERROR_PARAMS( aFile, os_error::get_err_string() )
161 );188 );
162
163#else189#else
164 void* handle = dlopen(aFile.c_str(), RTLD_NOW);190 createModuleFunction = (ExternalModule* (*)()) dlsym(handle, "createModule");
165 if (!handle)191 if (createModuleFunction == NULL)
166 throw ZORBA_EXCEPTION(
167 zerr::ZOSE0005_DLL_LOAD_FAILED, ERROR_PARAMS( aFile, zstring(dlerror()) )
168 );
169
170 createModule = (ExternalModule* (*)()) dlsym(handle, "createModule");
171 if (createModule == NULL)
172 {192 {
173 dlclose(handle);193 dlclose(handle);
174 throw ZORBA_EXCEPTION(194 throw ZORBA_EXCEPTION(
175 zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,195 zerr::ZAPI0015_CREATEMODULE_NOT_FOUND,
176 ERROR_PARAMS( aFile, dlerror() )196 ERROR_PARAMS( aFile, dlerror() )
177 );197 );
178 }198 }
179#endif199#endif
180 if (theLibraries.find(handle) == theLibraries.end())200 return createModuleFunction();
181 {
182 theLibraries.insert(handle);
183 }
184
185 return createModule();
186}201}
187202
188203
@@ -193,13 +208,13 @@
193208
194DynamicLoader::~DynamicLoader()209DynamicLoader::~DynamicLoader()
195{210{
196 for (LibrarySet_t::const_iterator lIter = theLibraries.begin();211 for (LibraryMap_t::const_iterator lIter = theLibraries.begin();
197 lIter != theLibraries.end(); ++lIter)212 lIter != theLibraries.end(); ++lIter)
198 {213 {
199#ifdef WIN32214#ifdef WIN32
200 FreeLibrary(*lIter);215 FreeLibrary(lIter->second);
201#else216#else
202 dlclose(*lIter);217 dlclose(lIter->second);
203#endif218#endif
204 }219 }
205}220}
206221
=== modified file 'src/context/dynamic_loader.h'
--- src/context/dynamic_loader.h 2012-04-16 20:56:43 +0000
+++ src/context/dynamic_loader.h 2012-04-18 15:53:24 +0000
@@ -18,7 +18,7 @@
18#define ZORBA_DYNAMIC_LOADER_H18#define ZORBA_DYNAMIC_LOADER_H
1919
20#include "common/common.h"20#include "common/common.h"
21#include <set>21#include <map>
22#include "common/shared_types.h"22#include "common/shared_types.h"
2323
24namespace zorba {24namespace zorba {
@@ -40,15 +40,20 @@
4040
41 ~DynamicLoader();41 ~DynamicLoader();
4242
43 ExternalModule* loadModule(const zstring& aFile) const;
4443
45#ifdef WIN3244#ifdef WIN32
46 typedef std::set<HMODULE> LibrarySet_t;45 typedef HMODULE handle_t;
47#else46#else
48 typedef std::set<void*> LibrarySet_t;47 typedef void * handle_t;
49#endif48#endif
5049
51 mutable LibrarySet_t theLibraries;50 ExternalModule* loadModule(const zstring& aFile) const;
51 ExternalModule* createModule(handle_t handle, const zstring& aFile) const;
52
53
54 typedef std::map<const zstring, handle_t> LibraryMap_t;
55
56 mutable LibraryMap_t theLibraries;
52};57};
5358
54} /* namespace zorba */59} /* namespace zorba */
5560
=== modified file 'src/system/properties.h'
--- src/system/properties.h 2012-04-16 20:56:43 +0000
+++ src/system/properties.h 2012-04-18 15:53:24 +0000
@@ -67,6 +67,27 @@
6767
68 std::ostream& debug_out() { return *debug_stream; }68 std::ostream& debug_out() { return *debug_stream; }
6969
70 /**
71 * Before the JVM is started this will return the classpath set by
72 * command line option, the CLASSPATH environment variable and in Zorba
73 * config file.
74 *
75 * After the JVM is started this will contain in addition the paths to jars
76 * used by modules that make use of the JVM.
77 */
78 void getJVMClassPath(std::string & jvmClasspath)
79 { jvmClasspath = theCLASSPATH ; }
80
81 /**
82 * This method should be used to set additional JVM classpath for modules
83 * that make use of JVM. This will overide the classpath set by CLASSPATH
84 * environment variable or Zorba config file.
85 *
86 * Once the JVM is started this method doesn't have any effect.
87 */
88 void setJVMClassPath(const std::string & jvmClasspath)
89 { theCLASSPATH = jvmClasspath; }
90
70 protected:91 protected:
71 /**92 /**
72 * Gets the Operation System folder where the properties of the current 93 * Gets the Operation System folder where the properties of the current
7394
=== modified file 'src/system/zorba_properties.h'
--- src/system/zorba_properties.h 2012-04-16 20:56:43 +0000
+++ src/system/zorba_properties.h 2012-04-18 15:53:24 +0000
@@ -26,13 +26,25 @@
26namespace zorba 26namespace zorba
27{ 27{
2828
29class ZORBA_DLL_PUBLIC ZorbaProperties : public ::zorba::PropertiesBase 29class ZORBA_DLL_PUBLIC ZorbaProperties : public ::zorba::PropertiesGlobal
30{30{
31protected:31protected:
32 const char** get_all_options() const 32 const char** get_all_options() const
33 {33 {
34 static const char* result [] = 34 static const char* result [] = {
35 { "--trace-parsing", "--trace-scanning", "--use-serializer", "--optimizer", "--result-file", "--debug-file", "--abort", "--query", "--print-query", "--print-time", "--print-ast", "--print-xqdoc", "--print-translated", "--print-normalized", "--print-optimized", "--print-iterator-tree", "--print-item-flow", "--print-static-types", "--dump-lib", "--stable-iterator-ids", "--no-tree-ids", "--print-intermediate-opt", "--print-locations", "--force-gflwor", "--reorder-globals", "--specialize-num", "--specialize-cmp", "--inline-udf", "--loop-hoisting", "--infer-joins", "--no-copy-optim", "--serialize-only-query", "--trace-translator", "--trace-codegen", "--trace-fulltext", "--debug", "--compile-only", "--tz", "--external-var", "--serializer-param", "--iter-plan-test", "--dot-plan-file", "--max-udf-call-depth", NULL };35 "--trace-parsing", "--trace-scanning", "--use-serializer", "--optimizer",
36 "--result-file", "--debug-file", "--abort", "--query", "--print-query",
37 "--print-time", "--print-ast", "--print-xqdoc", "--print-translated",
38 "--print-normalized", "--print-optimized", "--print-iterator-tree",
39 "--print-item-flow", "--print-static-types", "--dump-lib",
40 "--stable-iterator-ids", "--no-tree-ids", "--print-intermediate-opt",
41 "--print-locations", "--force-gflwor", "--reorder-globals",
42 "--specialize-num", "--specialize-cmp", "--inline-udf", "--loop-hoisting",
43 "--infer-joins", "--no-copy-optim", "--serialize-only-query",
44 "--trace-translator", "--trace-codegen", "--trace-fulltext", "--debug",
45 "--compile-only", "--tz", "--external-var", "--serializer-param",
46 "--iter-plan-test", "--dot-plan-file", "--max-udf-call-depth",
47 "--CLASSPATH", NULL };
3648
37 return result;49 return result;
38 }50 }
@@ -80,6 +92,7 @@
80 bool theIterPlanTest;92 bool theIterPlanTest;
81 std::string theDotPlanFile;93 std::string theDotPlanFile;
82 uint32_t theMaxUdfCallDepth;94 uint32_t theMaxUdfCallDepth;
95 std::string theCLASSPATH;
8396
84 void initialize() 97 void initialize()
85 {98 {
@@ -165,6 +178,7 @@
165 const bool &iterPlanTest () const { return theIterPlanTest; }178 const bool &iterPlanTest () const { return theIterPlanTest; }
166 const std::string &dotPlanFile () const { return theDotPlanFile; }179 const std::string &dotPlanFile () const { return theDotPlanFile; }
167 const uint32_t &maxUdfCallDepth () const { return theMaxUdfCallDepth; }180 const uint32_t &maxUdfCallDepth () const { return theMaxUdfCallDepth; }
181 const std::string &CLASSPATH () const { return theCLASSPATH; }
168182
169 std::string load_argv (int argc, const char **argv) 183 std::string load_argv (int argc, const char **argv)
170 {184 {
@@ -200,7 +214,9 @@
200 else if (strcmp (*argv, "--debug-file") == 0) {214 else if (strcmp (*argv, "--debug-file") == 0) {
201 int d = 2;215 int d = 2;
202 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }216 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
203 if (*argv == NULL) { result = "No value given for --debug-file option"; break; } init_val (*argv, theDebugFile, d);217 if (*argv == NULL) { result = "No value given for --debug-file option"; break; }
218
219 init_val (*argv, theDebugFile, d);
204 }220 }
205 else if (strcmp (*argv, "--abort") == 0) {221 else if (strcmp (*argv, "--abort") == 0) {
206 theAbort = true;222 theAbort = true;
@@ -208,7 +224,9 @@
208 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-e", 2) == 0) {224 else if (strcmp (*argv, "--query") == 0 || strncmp (*argv, "-e", 2) == 0) {
209 int d = 2;225 int d = 2;
210 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }226 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
211 if (*argv == NULL) { result = "No value given for --query option"; break; } init_val (*argv, theQuery, d);227 if (*argv == NULL) { result = "No value given for --query option"; break; }
228
229 init_val (*argv, theQuery, d);
212 }230 }
213 else if (strcmp (*argv, "--print-query") == 0 || strncmp (*argv, "-q", 2) == 0) {231 else if (strcmp (*argv, "--print-query") == 0 || strncmp (*argv, "-q", 2) == 0) {
214 thePrintQuery = true;232 thePrintQuery = true;
@@ -240,7 +258,9 @@
240 else if (strcmp (*argv, "--print-static-types") == 0) {258 else if (strcmp (*argv, "--print-static-types") == 0) {
241 int d = 2;259 int d = 2;
242 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }260 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
243 if (*argv == NULL) { result = "No value given for --print-static-types option"; break; } init_val (*argv, thePrintStaticTypes, d);261 if (*argv == NULL) { result = "No value given for --print-static-types option"; break; }
262
263 init_val (*argv, thePrintStaticTypes, d);
244 }264 }
245 else if (strcmp (*argv, "--dump-lib") == 0) {265 else if (strcmp (*argv, "--dump-lib") == 0) {
246 theDumpLib = true;266 theDumpLib = true;
@@ -263,32 +283,44 @@
263 else if (strcmp (*argv, "--reorder-globals") == 0) {283 else if (strcmp (*argv, "--reorder-globals") == 0) {
264 int d = 2;284 int d = 2;
265 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }285 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
266 if (*argv == NULL) { result = "No value given for --reorder-globals option"; break; } init_val (*argv, theReorderGlobals, d);286 if (*argv == NULL) { result = "No value given for --reorder-globals option"; break; }
287
288 init_val (*argv, theReorderGlobals, d);
267 }289 }
268 else if (strcmp (*argv, "--specialize-num") == 0) {290 else if (strcmp (*argv, "--specialize-num") == 0) {
269 int d = 2;291 int d = 2;
270 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }292 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
271 if (*argv == NULL) { result = "No value given for --specialize-num option"; break; } init_val (*argv, theSpecializeNum, d);293 if (*argv == NULL) { result = "No value given for --specialize-num option"; break; }
294
295 init_val (*argv, theSpecializeNum, d);
272 }296 }
273 else if (strcmp (*argv, "--specialize-cmp") == 0) {297 else if (strcmp (*argv, "--specialize-cmp") == 0) {
274 int d = 2;298 int d = 2;
275 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }299 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
276 if (*argv == NULL) { result = "No value given for --specialize-cmp option"; break; } init_val (*argv, theSpecializeCmp, d);300 if (*argv == NULL) { result = "No value given for --specialize-cmp option"; break; }
301
302 init_val (*argv, theSpecializeCmp, d);
277 }303 }
278 else if (strcmp (*argv, "--inline-udf") == 0) {304 else if (strcmp (*argv, "--inline-udf") == 0) {
279 int d = 2;305 int d = 2;
280 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }306 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
281 if (*argv == NULL) { result = "No value given for --inline-udf option"; break; } init_val (*argv, theInlineUdf, d);307 if (*argv == NULL) { result = "No value given for --inline-udf option"; break; }
308
309 init_val (*argv, theInlineUdf, d);
282 }310 }
283 else if (strcmp (*argv, "--loop-hoisting") == 0) {311 else if (strcmp (*argv, "--loop-hoisting") == 0) {
284 int d = 2;312 int d = 2;
285 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }313 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
286 if (*argv == NULL) { result = "No value given for --loop-hoisting option"; break; } init_val (*argv, theLoopHoisting, d);314 if (*argv == NULL) { result = "No value given for --loop-hoisting option"; break; }
315
316 init_val (*argv, theLoopHoisting, d);
287 }317 }
288 else if (strcmp (*argv, "--infer-joins") == 0) {318 else if (strcmp (*argv, "--infer-joins") == 0) {
289 int d = 2;319 int d = 2;
290 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }320 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
291 if (*argv == NULL) { result = "No value given for --infer-joins option"; break; } init_val (*argv, theInferJoins, d);321 if (*argv == NULL) { result = "No value given for --infer-joins option"; break; }
322
323 init_val (*argv, theInferJoins, d);
292 }324 }
293 else if (strcmp (*argv, "--no-copy-optim") == 0)325 else if (strcmp (*argv, "--no-copy-optim") == 0)
294 {326 {
@@ -325,17 +357,23 @@
325 else if (strcmp (*argv, "--tz") == 0) {357 else if (strcmp (*argv, "--tz") == 0) {
326 int d = 2;358 int d = 2;
327 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }359 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
328 if (*argv == NULL) { result = "No value given for --tz option"; break; } init_val (*argv, theTz, d);360 if (*argv == NULL) { result = "No value given for --tz option"; break; }
361
362 init_val (*argv, theTz, d);
329 }363 }
330 else if (strcmp (*argv, "--external-var") == 0 || strncmp (*argv, "-x", 2) == 0) {364 else if (strcmp (*argv, "--external-var") == 0 || strncmp (*argv, "-x", 2) == 0) {
331 int d = 2;365 int d = 2;
332 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }366 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
333 if (*argv == NULL) { result = "No value given for --external-var option"; break; } init_val (*argv, theExternalVar, d);367 if (*argv == NULL) { result = "No value given for --external-var option"; break; }
368
369 init_val (*argv, theExternalVar, d);
334 }370 }
335 else if (strcmp (*argv, "--serializer-param") == 0 || strncmp (*argv, "-z", 2) == 0) {371 else if (strcmp (*argv, "--serializer-param") == 0 || strncmp (*argv, "-z", 2) == 0) {
336 int d = 2;372 int d = 2;
337 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }373 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
338 if (*argv == NULL) { result = "No value given for --serializer-param option"; break; } init_val (*argv, theSerializerParam, d);374 if (*argv == NULL) { result = "No value given for --serializer-param option"; break; }
375
376 init_val (*argv, theSerializerParam, d);
339 }377 }
340 else if (strcmp (*argv, "--iter-plan-test") == 0) {378 else if (strcmp (*argv, "--iter-plan-test") == 0) {
341 theIterPlanTest = true;379 theIterPlanTest = true;
@@ -343,12 +381,23 @@
343 else if (strcmp (*argv, "--dot-plan-file") == 0) {381 else if (strcmp (*argv, "--dot-plan-file") == 0) {
344 int d = 2;382 int d = 2;
345 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }383 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
346 if (*argv == NULL) { result = "No value given for --dot-plan-file option"; break; } init_val (*argv, theDotPlanFile, d);384 if (*argv == NULL) { result = "No value given for --dot-plan-file option"; break; }
385
386 init_val (*argv, theDotPlanFile, d);
347 }387 }
348 else if (strcmp (*argv, "--max-udf-call-depth") == 0) {388 else if (strcmp (*argv, "--max-udf-call-depth") == 0) {
349 int d = 2;389 int d = 2;
350 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }390 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
351 if (*argv == NULL) { result = "No value given for --max-udf-call-depth option"; break; } init_val (*argv, theMaxUdfCallDepth, d);391 if (*argv == NULL) { result = "No value given for --max-udf-call-depth option"; break; }
392
393 init_val (*argv, theMaxUdfCallDepth, d);
394 }
395 else if (strcmp (*argv, "--CLASSPATH") == 0) {
396 int d = 2;
397 if ((*argv) [1] == '-' || (*argv) [2] == '\0') { d = 0; ++argv; }
398 if (*argv == NULL) { result = "No value given for --CLASSPATH option"; break; }
399
400 init_val (*argv, theCLASSPATH, d);
352 }401 }
353 else if (strcmp (*argv, "--") == 0) {402 else if (strcmp (*argv, "--") == 0) {
354 copy_args (++argv);403 copy_args (++argv);
@@ -413,6 +462,7 @@
413"--iter-plan-test\nrun as iterator plan test\n\n"462"--iter-plan-test\nrun as iterator plan test\n\n"
414"--dot-plan-file\ngenerate the dot iterator plan\n\n"463"--dot-plan-file\ngenerate the dot iterator plan\n\n"
415"--max-udf-call-depth\nmaximum stack depth of udf function calls\n\n"464"--max-udf-call-depth\nmaximum stack depth of udf function calls\n\n"
465"--CLASSPATH\nJVM classpath to be used by modules using Java implementations\n\n"
416;466;
417 }467 }
418468
419469
=== modified file 'src/system/zorba_properties.txt'
--- src/system/zorba_properties.txt 2012-04-16 20:56:43 +0000
+++ src/system/zorba_properties.txt 2012-04-18 15:53:24 +0000
@@ -43,3 +43,4 @@
43 ("iter-plan-test", "run as iterator plan test")43 ("iter-plan-test", "run as iterator plan test")
44 ("dot-plan-file", po::value<std::string>(), "generate the dot iterator plan")44 ("dot-plan-file", po::value<std::string>(), "generate the dot iterator plan")
45 ("max-udf-call-depth", po::value<uint32_t>()->default_value(1024), "maximum stack depth of udf function calls")45 ("max-udf-call-depth", po::value<uint32_t>()->default_value(1024), "maximum stack depth of udf function calls")
46 ("CLASSPATH", po::value<std::string>(), "JVM classpath to be used by modules using Java implementations")
46\ No newline at end of file47\ No newline at end of file
4748
=== modified file 'src/util/file.cpp'
--- src/util/file.cpp 2012-04-16 20:56:43 +0000
+++ src/util/file.cpp 2012-04-18 15:53:24 +0000
@@ -277,6 +277,18 @@
277#endif277#endif
278}278}
279279
280void file::lsdir(std::vector<std::string> &list) {
281#ifdef ZORBA_WITH_FILE_ACCESS
282 try {
283 fs::lsdir( c_str(), list );
284 set_filetype( type_directory );
285 }
286 catch ( fs::exception const &e ) {
287 throw ZORBA_IO_EXCEPTION( e.function(), e.path() );
288 }
289#endif
290}
291
280void file::deep_mkdir() {292void file::deep_mkdir() {
281#ifdef ZORBA_WITH_FILE_ACCESS293#ifdef ZORBA_WITH_FILE_ACCESS
282 vector<file> files;294 vector<file> files;
283295
=== modified file 'src/util/fs_util.cpp'
--- src/util/fs_util.cpp 2012-04-16 20:56:43 +0000
+++ src/util/fs_util.cpp 2012-04-18 15:53:24 +0000
@@ -277,6 +277,30 @@
277#endif277#endif
278}278}
279279
280void lsdir( char const *path, std::vector<std::string> &list )
281{
282 DIR *dir;
283 struct dirent *ent;
284
285 dir = opendir (path);
286 if (dir != NULL)
287 {
288 /* print all the files and directories within directory */
289 while ((ent = readdir (dir)) != NULL)
290 {
291 //printf ("%s\n", ent->d_name);
292 std::string item(ent->d_name);
293 list.push_back(item);
294 }
295 closedir (dir);
296 }
297 else
298 {
299 /* could not open directory */
300 throw fs::exception( "lsdir()", path );
301 }
302}
303
280bool remove( char const *path ) {304bool remove( char const *path ) {
281#ifndef WIN32305#ifndef WIN32
282 return ::remove( path ) == 0;306 return ::remove( path ) == 0;
283307
=== modified file 'src/util/fs_util.h'
--- src/util/fs_util.h 2012-04-16 20:56:43 +0000
+++ src/util/fs_util.h 2012-04-18 15:53:24 +0000
@@ -17,6 +17,14 @@
17#ifndef ZORBA_FS_UTIL_H17#ifndef ZORBA_FS_UTIL_H
18#define ZORBA_FS_UTIL_H18#define ZORBA_FS_UTIL_H
1919
20#include <vector>
21
22#ifdef WIN32
23# include "win32/dirent.h"
24#else
25# include <dirent.h> /* for implementing lsdir */
26#endif /* WIN32 */
27
20#include <zorba/config.h>28#include <zorba/config.h>
2129
22#include <stdexcept>30#include <stdexcept>
@@ -144,6 +152,26 @@
144 mkdir( path.c_str() );152 mkdir( path.c_str() );
145}153}
146154
155/**
156 * List files in dir
157 *
158 * @param path The full path of the directory to list.
159 * @throws fs::exception if the list fails.
160 */
161void lsdir( char const *path, std::vector<std::string> & list );
162
163/**
164 * List files in dir
165 *
166 * @tparam PathStringType The \a path string type.
167 * @param path The full path of the directory to list.
168 * @throws fs::exception if the list fails.
169 */
170template<class PathStringType> inline
171void lsdir( PathStringType const &path, std::vector<std::string> & list ) {
172 lsdir( path.c_str(), list );
173}
174
147#endif /* ZORBA_WITH_FILE_ACCESS */175#endif /* ZORBA_WITH_FILE_ACCESS */
148176
149////////// File creation //////////////////////////////////////////////////////177////////// File creation //////////////////////////////////////////////////////
150178
=== added file 'src/util/win32/dirent.h'
--- src/util/win32/dirent.h 1970-01-01 00:00:00 +0000
+++ src/util/win32/dirent.h 2012-04-18 15:53:24 +0000
@@ -0,0 +1,372 @@
1/*****************************************************************************
2 * dirent.h - dirent API for Microsoft Visual Studio
3 *
4 * Copyright (C) 2006 Toni Ronkko
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * ``Software''), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 *
25 * Mar 15, 2011, Toni Ronkko
26 * Defined FILE_ATTRIBUTE_DEVICE for MSVC 6.0.
27 *
28 * Aug 11, 2010, Toni Ronkko
29 * Added d_type and d_namlen fields to dirent structure. The former is
30 * especially useful for determining whether directory entry represents a
31 * file or a directory. For more information, see
32 * http://www.delorie.com/gnu/docs/glibc/libc_270.html
33 *
34 * Aug 11, 2010, Toni Ronkko
35 * Improved conformance to the standards. For example, errno is now set
36 * properly on failure and assert() is never used. Thanks to Peter Brockam
37 * for suggestions.
38 *
39 * Aug 11, 2010, Toni Ronkko
40 * Fixed a bug in rewinddir(): when using relative directory names, change
41 * of working directory no longer causes rewinddir() to fail.
42 *
43 * Dec 15, 2009, John Cunningham
44 * Added rewinddir member function
45 *
46 * Jan 18, 2008, Toni Ronkko
47 * Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string
48 * between multi-byte and unicode representations. This makes the
49 * code simpler and also allows the code to be compiled under MingW. Thanks
50 * to Azriel Fasten for the suggestion.
51 *
52 * Mar 4, 2007, Toni Ronkko
53 * Bug fix: due to the strncpy_s() function this file only compiled in
54 * Visual Studio 2005. Using the new string functions only when the
55 * compiler version allows.
56 *
57 * Nov 2, 2006, Toni Ronkko
58 * Major update: removed support for Watcom C, MS-DOS and Turbo C to
59 * simplify the file, updated the code to compile cleanly on Visual
60 * Studio 2005 with both unicode and multi-byte character strings,
61 * removed rewinddir() as it had a bug.
62 *
63 * Aug 20, 2006, Toni Ronkko
64 * Removed all remarks about MSVC 1.0, which is antiqued now. Simplified
65 * comments by removing SGML tags.
66 *
67 * May 14 2002, Toni Ronkko
68 * Embedded the function definitions directly to the header so that no
69 * source modules need to be included in the Visual Studio project. Removed
70 * all the dependencies to other projects so that this very header can be
71 * used independently.
72 *
73 * May 28 1998, Toni Ronkko
74 * First version.
75 *****************************************************************************/
76#ifndef DIRENT_H
77#define DIRENT_H
78
79#define WIN32_LEAN_AND_MEAN
80#include <windows.h>
81#include <string.h>
82#include <stdlib.h>
83#include <sys/types.h>
84#include <sys/stat.h>
85#include <errno.h>
86
87/* Entries missing from MSVC 6.0 */
88#if !defined(FILE_ATTRIBUTE_DEVICE)
89# define FILE_ATTRIBUTE_DEVICE 0x40
90#endif
91
92/* File type and permission flags for stat() */
93#if defined(_MSC_VER) && !defined(S_IREAD)
94# define S_IFMT _S_IFMT /* file type mask */
95# define S_IFDIR _S_IFDIR /* directory */
96# define S_IFCHR _S_IFCHR /* character device */
97# define S_IFFIFO _S_IFFIFO /* pipe */
98# define S_IFREG _S_IFREG /* regular file */
99# define S_IREAD _S_IREAD /* read permission */
100# define S_IWRITE _S_IWRITE /* write permission */
101# define S_IEXEC _S_IEXEC /* execute permission */
102#endif
103#define S_IFBLK 0 /* block device */
104#define S_IFLNK 0 /* link */
105#define S_IFSOCK 0 /* socket */
106
107#if defined(_MSC_VER)
108# define S_IRUSR S_IREAD /* read, user */
109# define S_IWUSR S_IWRITE /* write, user */
110# define S_IXUSR 0 /* execute, user */
111# define S_IRGRP 0 /* read, group */
112# define S_IWGRP 0 /* write, group */
113# define S_IXGRP 0 /* execute, group */
114# define S_IROTH 0 /* read, others */
115# define S_IWOTH 0 /* write, others */
116# define S_IXOTH 0 /* execute, others */
117#endif
118
119/* Indicates that d_type field is available in dirent structure */
120#define _DIRENT_HAVE_D_TYPE
121
122/* File type flags for d_type */
123#define DT_UNKNOWN 0
124#define DT_REG S_IFREG
125#define DT_DIR S_IFDIR
126#define DT_FIFO S_IFFIFO
127#define DT_SOCK S_IFSOCK
128#define DT_CHR S_IFCHR
129#define DT_BLK S_IFBLK
130
131/* Macros for converting between st_mode and d_type */
132#define IFTODT(mode) ((mode) & S_IFMT)
133#define DTTOIF(type) (type)
134
135/*
136 * File type macros. Note that block devices, sockets and links cannot be
137 * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
138 * only defined for compatibility. These macros should always return false
139 * on Windows.
140 */
141#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
142#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
143#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
144#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
145#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
146#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
147#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
148
149#ifdef __cplusplus
150extern "C" {
151#endif
152
153
154typedef struct dirent
155{
156 char d_name[MAX_PATH + 1]; /* File name */
157 size_t d_namlen; /* Length of name without \0 */
158 int d_type; /* File type */
159} dirent;
160
161
162typedef struct DIR
163{
164 dirent curentry; /* Current directory entry */
165 WIN32_FIND_DATAA find_data; /* Private file data */
166 int cached; /* True if data is valid */
167 HANDLE search_handle; /* Win32 search handle */
168 char patt[MAX_PATH + 3]; /* Initial directory name */
169} DIR;
170
171
172/* Forward declarations */
173static DIR *opendir(const char *dirname);
174static struct dirent *readdir(DIR *dirp);
175static int closedir(DIR *dirp);
176static void rewinddir(DIR* dirp);
177
178
179/* Use the new safe string functions introduced in Visual Studio 2005 */
180#if defined(_MSC_VER) && _MSC_VER >= 1400
181# define DIRENT_STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
182#else
183# define DIRENT_STRNCPY(dest,src,size) strncpy((dest),(src),(size))
184#endif
185
186/* Set errno variable */
187#if defined(_MSC_VER)
188#define DIRENT_SET_ERRNO(x) _set_errno (x)
189#else
190#define DIRENT_SET_ERRNO(x) (errno = (x))
191#endif
192
193
194/*****************************************************************************
195 * Open directory stream DIRNAME for read and return a pointer to the
196 * internal working area that is used to retrieve individual directory
197 * entries.
198 */
199static DIR *opendir(const char *dirname)
200{
201 DIR *dirp;
202
203 /* ensure that the resulting search pattern will be a valid file name */
204 if (dirname == NULL) {
205 DIRENT_SET_ERRNO (ENOENT);
206 return NULL;
207 }
208 if (strlen (dirname) + 3 >= MAX_PATH) {
209 DIRENT_SET_ERRNO (ENAMETOOLONG);
210 return NULL;
211 }
212
213 /* construct new DIR structure */
214 dirp = (DIR*) malloc (sizeof (struct DIR));
215 if (dirp != NULL) {
216 int error;
217
218 /*
219 * Convert relative directory name to an absolute one. This
220 * allows rewinddir() to function correctly when the current working
221 * directory is changed between opendir() and rewinddir().
222 */
223 if (GetFullPathNameA (dirname, MAX_PATH, dirp->patt, NULL)) {
224 char *p;
225
226 /* append the search pattern "\\*\0" to the directory name */
227 p = strchr (dirp->patt, '\0');
228 if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') {
229 *p++ = '\\';
230 }
231 *p++ = '*';
232 *p = '\0';
233
234 /* open directory stream and retrieve the first entry */
235 dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
236 if (dirp->search_handle != INVALID_HANDLE_VALUE) {
237 /* a directory entry is now waiting in memory */
238 dirp->cached = 1;
239 error = 0;
240 } else {
241 /* search pattern is not a directory name? */
242 DIRENT_SET_ERRNO (ENOENT);
243 error = 1;
244 }
245 } else {
246 /* buffer too small */
247 DIRENT_SET_ERRNO (ENOMEM);
248 error = 1;
249 }
250
251 if (error) {
252 free (dirp);
253 dirp = NULL;
254 }
255 }
256
257 return dirp;
258}
259
260
261/*****************************************************************************
262 * Read a directory entry, and return a pointer to a dirent structure
263 * containing the name of the entry in d_name field. Individual directory
264 * entries returned by this very function include regular files,
265 * sub-directories, pseudo-directories "." and "..", but also volume labels,
266 * hidden files and system files may be returned.
267 */
268static struct dirent *readdir(DIR *dirp)
269{
270 DWORD attr;
271 if (dirp == NULL) {
272 /* directory stream did not open */
273 DIRENT_SET_ERRNO (EBADF);
274 return NULL;
275 }
276
277 /* get next directory entry */
278 if (dirp->cached != 0) {
279 /* a valid directory entry already in memory */
280 dirp->cached = 0;
281 } else {
282 /* get the next directory entry from stream */
283 if (dirp->search_handle == INVALID_HANDLE_VALUE) {
284 return NULL;
285 }
286 if (FindNextFileA (dirp->search_handle, &dirp->find_data) == FALSE) {
287 /* the very last entry has been processed or an error occured */
288 FindClose (dirp->search_handle);
289 dirp->search_handle = INVALID_HANDLE_VALUE;
290 return NULL;
291 }
292 }
293
294 /* copy as a multibyte character string */
295 DIRENT_STRNCPY ( dirp->curentry.d_name,
296 dirp->find_data.cFileName,
297 sizeof(dirp->curentry.d_name) );
298 dirp->curentry.d_name[MAX_PATH] = '\0';
299
300 /* compute the length of name */
301 dirp->curentry.d_namlen = strlen (dirp->curentry.d_name);
302
303 /* determine file type */
304 attr = dirp->find_data.dwFileAttributes;
305 if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
306 dirp->curentry.d_type = DT_CHR;
307 } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
308 dirp->curentry.d_type = DT_DIR;
309 } else {
310 dirp->curentry.d_type = DT_REG;
311 }
312 return &dirp->curentry;
313}
314
315
316/*****************************************************************************
317 * Close directory stream opened by opendir() function. Close of the
318 * directory stream invalidates the DIR structure as well as any previously
319 * read directory entry.
320 */
321static int closedir(DIR *dirp)
322{
323 if (dirp == NULL) {
324 /* invalid directory stream */
325 DIRENT_SET_ERRNO (EBADF);
326 return -1;
327 }
328
329 /* release search handle */
330 if (dirp->search_handle != INVALID_HANDLE_VALUE) {
331 FindClose (dirp->search_handle);
332 dirp->search_handle = INVALID_HANDLE_VALUE;
333 }
334
335 /* release directory structure */
336 free (dirp);
337 return 0;
338}
339
340
341/*****************************************************************************
342 * Resets the position of the directory stream to which dirp refers to the
343 * beginning of the directory. It also causes the directory stream to refer
344 * to the current state of the corresponding directory, as a call to opendir()
345 * would have done. If dirp does not refer to a directory stream, the effect
346 * is undefined.
347 */
348static void rewinddir(DIR* dirp)
349{
350 if (dirp != NULL) {
351 /* release search handle */
352 if (dirp->search_handle != INVALID_HANDLE_VALUE) {
353 FindClose (dirp->search_handle);
354 }
355
356 /* open new search handle and retrieve the first entry */
357 dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->find_data);
358 if (dirp->search_handle != INVALID_HANDLE_VALUE) {
359 /* a directory entry is now waiting in memory */
360 dirp->cached = 1;
361 } else {
362 /* failed to re-open directory: no directory entry in memory */
363 dirp->cached = 0;
364 }
365 }
366}
367
368
369#ifdef __cplusplus
370}
371#endif
372#endif /*DIRENT_H*/
0373
=== modified file 'swig/java/CMakeLists.txt'
--- swig/java/CMakeLists.txt 2012-04-16 20:56:43 +0000
+++ swig/java/CMakeLists.txt 2012-04-18 15:53:24 +0000
@@ -102,6 +102,7 @@
102 ENDIF(NOT WIN32)102 ENDIF(NOT WIN32)
103 ENDIF ( APPLE )103 ENDIF ( APPLE )
104104
105
105ELSE (JAVA_INCLUDE_PATH)106ELSE (JAVA_INCLUDE_PATH)
106 MESSAGE ( STATUS "SWIG Java: not generating JAVA API because jni headers not found.")107 MESSAGE ( STATUS "SWIG Java: not generating JAVA API because jni headers not found.")
107ENDIF (JAVA_INCLUDE_PATH)108ENDIF (JAVA_INCLUDE_PATH)
108109
=== added file 'swig/various.i'
--- swig/various.i 1970-01-01 00:00:00 +0000
+++ swig/various.i 2012-04-18 15:53:24 +0000
@@ -0,0 +1,184 @@
1/* This is from http://www.opensource.apple.com/source/swig/swig-6/swig/Lib/java/various.i?txt */
2
3/* -----------------------------------------------------------------------------
4 * See the LICENSE file for information on copyright, usage and redistribution
5 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
6 *
7 * various.i
8 *
9 * SWIG Typemap library for Java.
10 * Various useful typemaps.
11 * ----------------------------------------------------------------------------- */
12
13#ifdef SWIGJAVA
14
15/*
16 * char **STRING_ARRAY typemaps.
17 * These typemaps are for C String arrays which are NULL terminated.
18 * char *values[] = { "one", "two", "three", NULL }; // note NULL
19 * char ** is mapped to a Java String[].
20 *
21 * Example usage wrapping:
22 * %apply char **STRING_ARRAY { char **input };
23 * char ** foo(char **input);
24 *
25 * Java usage:
26 * String numbers[] = { "one", "two", "three" };
27 * String[] ret = modulename.foo( numbers };
28 */
29%typemap(jni) char **STRING_ARRAY "jobjectArray"
30%typemap(jtype) char **STRING_ARRAY "String[]"
31%typemap(jstype) char **STRING_ARRAY "String[]"
32%typemap(in) char **STRING_ARRAY (jint size) {
33 int i = 0;
34 size = JCALL1(GetArrayLength, jenv, $input);
35#ifdef __cplusplus
36 $1 = new char*[size+1];
37#else
38 $1 = (char **)calloc(size+1, sizeof(char *));
39#endif
40 for (i = 0; i<size; i++) {
41 jstring j_string = (jstring)JCALL2(GetObjectArrayElement, jenv, $input, i);
42 const char *c_string = JCALL2(GetStringUTFChars, jenv, j_string, 0);
43#ifdef __cplusplus
44 $1[i] = new char [strlen(c_string)+1];
45#else
46 $1[i] = (char *)calloc(strlen(c_string)+1, sizeof(const char *));
47#endif
48 strcpy($1[i], c_string);
49 JCALL2(ReleaseStringUTFChars, jenv, j_string, c_string);
50 JCALL1(DeleteLocalRef, jenv, j_string);
51 }
52 $1[i] = 0;
53}
54
55%typemap(freearg) char **STRING_ARRAY {
56 int i;
57 for (i=0; i<size$argnum-1; i++)
58#ifdef __cplusplus
59 delete[] $1[i];
60 delete[] $1;
61#else
62 free($1[i]);
63 free($1);
64#endif
65}
66
67%typemap(out) char **STRING_ARRAY {
68 int i;
69 int len=0;
70 jstring temp_string;
71 const jclass clazz = JCALL1(FindClass, jenv, "java/lang/String");
72
73 while ($1[len]) len++;
74 jresult = JCALL3(NewObjectArray, jenv, len, clazz, NULL);
75 /* exception checking omitted */
76
77 for (i=0; i<len; i++) {
78 temp_string = JCALL1(NewStringUTF, jenv, *result++);
79 JCALL3(SetObjectArrayElement, jenv, jresult, i, temp_string);
80 JCALL1(DeleteLocalRef, jenv, temp_string);
81 }
82}
83
84%typemap(javain) char **STRING_ARRAY "$javainput"
85%typemap(javaout) char **STRING_ARRAY {
86 return $jnicall;
87 }
88
89/*
90 * char **STRING_OUT typemaps.
91 * These are typemaps for returning strings when using a C char ** parameter type.
92 * The returned string appears in the 1st element of the passed in Java String array.
93 *
94 * Example usage wrapping:
95 * void foo(char **string_out);
96 *
97 * Java usage:
98 * String stringOutArray[] = { "" };
99 * modulename.foo(stringOutArray);
100 * System.out.println( stringOutArray[0] );
101 */
102%typemap(jni) char **STRING_OUT "jobjectArray"
103%typemap(jtype) char **STRING_OUT "String[]"
104%typemap(jstype) char **STRING_OUT "String[]"
105%typemap(javain) char **STRING_OUT "$javainput"
106
107%typemap(in) char **STRING_OUT($*1_ltype temp) {
108 if (!$input) {
109 SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null");
110 return $null;
111 }
112 if (JCALL1(GetArrayLength, jenv, $input) == 0) {
113 SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element");
114 return $null;
115 }
116 $1 = &temp;
117}
118
119%typemap(argout) char **STRING_OUT {
120 jstring jnewstring = NULL;
121 if($1) {
122 jnewstring = JCALL1(NewStringUTF, jenv, *$1);
123 }
124 JCALL3(SetObjectArrayElement, jenv, $input, 0, jnewstring);
125}
126
127/*
128 * char *BYTE typemaps.
129 * These are input typemaps for mapping a Java byte[] array to a C char array.
130 * Note that as a Java array is used and thus passeed by reference, the C routine
131 * can return data to Java via the parameter.
132 *
133 * Example usage wrapping:
134 * void foo(char *array);
135 *
136 * Java usage:
137 * byte b[] = new byte[20];
138 * modulename.foo(b);
139 */
140%typemap(jni) char *BYTE "jbyteArray"
141%typemap(jtype) char *BYTE "byte[]"
142%typemap(jstype) char *BYTE "byte[]"
143%typemap(in) char *BYTE {
144 $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
145}
146
147%typemap(argout) char *BYTE {
148 JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *) $1, 0);
149}
150
151%typemap(javain) char *BYTE "$javainput"
152
153/* Prevent default freearg typemap from being used */
154%typemap(freearg) char *BYTE ""
155
156#else
157
158#endif
159
160
161/* %include "typemaps.i"
162
163#if defined(SWIGJAVA)
164
165%typemap(in) (char * BYTE, int LENGTH)
166{
167 // Functions from jni.h
168 $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
169 $2 = (int) JCALL1(GetArrayLength, jenv, $input);
170}
171
172%typemap(jni) (char * BYTE, int LENGTH) "jbyteArray"
173%typemap(jtype) (char * BYTE, int LENGTH) "byte[]"
174%typemap(jstype) (char * BYTE, int LENGTH) "byte[]"
175%typemap(javain) (char * BYTE, int LENGTH) "$javainput"
176
177// Specify signature of method to handle
178%apply (char * BYTE, int LENGTH) { (char * byteArray, long len) };
179
180#else
181%apply (char * BYTE, int LENGTH) { (char * byteArray, long len) };
182#endif
183
184*/
0185
=== modified file 'swig/zorba_api.i'
--- swig/zorba_api.i 2012-04-16 20:56:43 +0000
+++ swig/zorba_api.i 2012-04-18 15:53:24 +0000
@@ -97,6 +97,8 @@
97}97}
98#endif98#endif
9999
100/* %include "various.i" required for mapping to Java byte[]*/
101
100//%include "ZorbaStreamProxy.i"102//%include "ZorbaStreamProxy.i"
101%include "SerializationOptions.i"103%include "SerializationOptions.i"
102%include "TypeIdentifier.i"104%include "TypeIdentifier.i"
103105
=== modified file 'test/rbkt/modules/CMakeLists.txt'
--- test/rbkt/modules/CMakeLists.txt 2012-04-16 20:56:43 +0000
+++ test/rbkt/modules/CMakeLists.txt 2012-04-18 15:53:24 +0000
@@ -58,3 +58,5 @@
58# This is as good a place as any to test this feature58# This is as good a place as any to test this feature
59DECLARE_ZORBA_URI_FILE(FILE "random-file.txt"59DECLARE_ZORBA_URI_FILE(FILE "random-file.txt"
60 URI "http://www.zorba-xquery.com/random-file" TEST_ONLY)60 URI "http://www.zorba-xquery.com/random-file" TEST_ONLY)
61
62ADD_SUBDIRECTORY(java)
6163
=== added directory 'test/rbkt/modules/java'
=== added file 'test/rbkt/modules/java/CMakeLists.txt'
--- test/rbkt/modules/java/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ test/rbkt/modules/java/CMakeLists.txt 2012-04-18 15:53:24 +0000
@@ -0,0 +1,40 @@
1# Copyright 2006-2008 The FLWOR Foundation.
2#
3# Licensed under the Apache License, Version 2.0 (the "License")
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# For now we only test building a .jar that we want Zorba to make available
16# on the JVM claspath. This test scenario should be extended to include a
17# Zorba module using the .jar, etc.
18# We make use of the much-improved Java support added in CMake 2.8.6.
19COMPARE_VERSION_STRINGS (${CMAKE_VERSION} "2.8.6" RESULT)
20IF (${RESULT} GREATER -1)
21 FIND_PACKAGE (Java COMPONENTS Development)
22 IF (Java_Development_FOUND)
23 INCLUDE (UseJava)
24
25 # Declare two "different" jars, for testing
26 ADD_JAR (JavaTest Test.java)
27 ADD_JAR (JavaTest2 Test.java)
28
29 # Tell Zorba about the jars
30 GET_PROPERTY (JavaTest_JAR_FILE TARGET JavaTest PROPERTY JAR_FILE)
31 GET_PROPERTY (JavaTest2_JAR_FILE TARGET JavaTest2 PROPERTY JAR_FILE)
32 DECLARE_ZORBA_JAR(FILE ${JavaTest_JAR_FILE} TARGET JavaTest TEST_ONLY)
33 DECLARE_ZORBA_JAR(FILE ${JavaTest2_JAR_FILE} TARGET JavaTest2 TEST_ONLY)
34
35 # Pretend to tell Zorba about some system jars
36 DECLARE_ZORBA_JAR(EXTERNAL FILE
37 "${PROJECT_SOURCE_DIR}/MyJar.jar" "${PROJECT_SOURCE_DIR}/MyJar2.jar")
38
39 ENDIF (Java_Development_FOUND)
40ENDIF (${RESULT} GREATER -1)
041
=== added file 'test/rbkt/modules/java/Test.java'
--- test/rbkt/modules/java/Test.java 1970-01-01 00:00:00 +0000
+++ test/rbkt/modules/java/Test.java 2012-04-18 15:53:24 +0000
@@ -0,0 +1,7 @@
1package org.zorbaxquery;
2
3public class Test {
4 public static void main(String[] args) {
5 System.out.println("Hello, world");
6 }
7}

Subscribers

People subscribed via source and target branches