How do I run jam from a directory other than the directory containing Jamfile.jam?

Added by Ben Hymers over 8 years ago

If I specify my jamfile with the -f option, jam complains that all the rules I've used are unknown. It's as if -f overrides the jambase. I want to be able to do this so I can make a vs2010 makefile project in a different directory to the jamfile (I had far too much hassle getting the workspace generator working unfortunately!).

So, can this be done?


Replies (5)

RE: How do I run jam from a directory other than the directory containing Jamfile.jam? - Added by Joshua Jensen over 8 years ago

Can you use "jam -C path/to/working/directory"?

If you wouldn't mind, can you explain the issues with the workspace generator? I've not heard of anyone else having issues, but I would like to make sure anything you ran into was taken care of.

Thanks.

Josh

RE: How do I run jam from a directory other than the directory containing Jamfile.jam? - Added by Ben Hymers over 8 years ago

Aha, -C worked fine. I didn't spot that in the documentation. Thanks!

I can't remember exactly what the problems were I'm afraid... Some things I remember having to do though:
  • Move the lua scripts and batch files into the jam bin directory - on Linux these are put there as part of the build but not on Windows
  • Install Lua. Sounds stupid but the docs don't mention it :)
  • Install a bunch of other packages for Lua. After installing it and trying to run the scripts I was getting lots of errors about packages not being found. There's some bundled up installer for Lua and a load of packages I found somewhere, can't remember the name...
  • Remove the funny characters from the batch file. I don't know what "%~dp0" is meant to do but it was resulting in the script telling me paths didn't exist.
  • Run the command in a specific directory... This is where my memory gets fuzzy, it was quite late! To be fair this is probably because I removed those characters from the batch file

After I'd done all that it still didn't work, I can't remember why, either it just exited without any message or it told me some path didn't exist. Sorry, I wish I could be more specific! If you like I can run through the process again to see exactly what the problems were but I'm tempted to just make my own project files now that I know about the -C option :)

RE: How do I run jam from a directory other than the directory containing Jamfile.jam? - Added by Ben Hymers over 8 years ago

Oh alright, I felt bad about not being very helpful so I went back and had another go to see if I could provide some more information. I must not have been firing on all cylinders the other day though since it didn't take much mental work to figure it all out.

First, that "%~dp0" stuff is clearly something to do with the working directory, and restoring it made it work without having to be in a specific directory. The first one (for the path to Lua) caused some problems because Lua was installed elsewhere, but of course that's just a hint that it's supposed to be installed there rather than a mistake :) So I went looking through the JamPlus docs and found that I needed a particular variant of Lua, LuaPlus, which I got, built, and put in the bin directory, and then magically everything worked fine. I've now got generated project files, which still have some problems (something to do with missing manifests, I'll investigate in a minute), but I'm happy :)

For reference, this is what happens when run with Lua For Windows (the distribution I found):

$ jam.exe --workspace
lua: ..\scripts\JamToWorkspace.lua:17: module 'uuid' not found:
no field package.preload['uuid']
no file '.\uuid.lua'
no file 'e:\Lua\5.1\lua\uuid.lua'
no file 'e:\Lua\5.1\lua\uuid\init.lua'
no file 'e:\Lua\5.1\uuid.lua'
no file 'e:\Lua\5.1\uuid\init.lua'
no file 'E:\Lua\5.1\lua\uuid.luac'
no file '.\uuid.dll'
no file '.\uuid51.dll'
no file 'e:\Lua\5.1\uuid.dll'
no file 'e:\Lua\5.1\uuid51.dll'
no file 'e:\Lua\5.1\clibs\uuid.dll'
no file 'e:\Lua\5.1\clibs\uuid51.dll'
no file 'e:\Lua\5.1\loadall.dll'
no file 'e:\Lua\5.1\clibs\loadall.dll'
stack traceback:
[C]: in function 'require'
..\scripts\JamToWorkspace.lua:17: in main chunk
[C]: ?

I googled for 'lua uuid module' but that didn't seem to turn up much, presumably because it's very specific to LuaPlus. Maybe it would be a good idea to add some comment about needing LuaPlus in the workspace generator docs? Maybe it's obvious, but I consider myself not too bad at this kind of thing and clearly I didn't find it obvious.

RE: How do I run jam from a directory other than the directory containing Jamfile.jam? - Added by Joshua Jensen over 8 years ago

Ben Hymers wrote:

Oh alright, I felt bad about not being very helpful so I went back and had another go to see if I could provide some more information. I must not have been firing on all cylinders the other day though since it didn't take much mental work to figure it all out.

Thanks for the help!

Move the lua scripts and batch files into the jam bin directory - on Linux these are put there as part of the build but not on Windows.

These only get copied during the build process if the LUA_BIN environment variable is set. See http://jamplus.org/git/jamplus/docs/html/building.html.

Install Lua. Sounds stupid but the docs don't mention it :)

I was confused when I read this. I checked my local documentation, and I was surprised it wasn't up to date. I then realized I got a new computer a while back, and my automated documentation generation process was failing, because Doxygen wasn't installed.

I have checked in the latest docs.

First, that "%~dp0" stuff is clearly something to do with the working directory, and restoring it made it work without having to be in a specific directory.

See http://weblogs.asp.net/jgalloway/archive/2006/11/20/top-10-dos-batch-tips-yes-dos-batch.aspx.

%~dp0 means the directory the batch file resides in.

So I went looking through the JamPlus docs and found that I needed a particular variant of Lua, LuaPlus, which I got, built, and put in the bin directory, and then magically everything worked fine.

FWIW, the needed LuaPlus binaries are in the binary distribution of JamPlus for all platform zips.

I've now got generated project files, which still have some problems (something to do with missing manifests, I'll investigate in a minute), but I'm happy :)

Missing manifests should have nothing to do with the generated workspace, so I suspect you've run across a bug we need to fix.

For reference, this is what happens when run with Lua For Windows (the distribution I found):

Thanks for the info. If I have time, I'll look into it, but I suspect they don't include all the right modules to make this thing go.

Thanks for being patient.

Josh

RE: How do I run jam from a directory other than the directory containing Jamfile.jam? - Added by Ben Hymers over 8 years ago

Joshua Jensen wrote:

Thanks for the help!

No worries, it's not so much helping you as helping myself though really :) I'm sure you can do without people dumping their problems on you!

These only get copied during the build process if the LUA_BIN environment variable is set. See http://jamplus.org/git/jamplus/docs/html/building.html.

Ah, I don't even think I read that document, I just headed straight for the .sln files! I'll try that.

Missing manifests should have nothing to do with the generated workspace, so I suspect you've run across a bug we need to fix.

Turns out that was my fault, I was fiddling around with a dependent library at the same time and that went a bit wrong. It's working without error now.

I did notice that the workspace generator spits out some warnings about the test results files (and opens them in my text editor) though, that might be worth checking out. Try generating a workspace from a jamfile that does that testing stuff I was asking about in another thread (after generating the results files) and you'll see what I mean, hopefully.

Thanks for the info. If I have time, I'll look into it, but I suspect they don't include all the right modules to make this thing go.

I honestly wouldn't bother with it, I think the docs are fairly self explanatory (once you read them...), it's perfectly acceptable to depend on a particular variant.

I've got a couple of other questions but they're getting away from the original topic so I'll start another thread. Thanks for your help!

(1-5/5)