Dear John,
Thank you very much for your help so far, please no need to
apologise for detailing anything about the inner workings of Jam.
I'm still very much a novice with this tool but getting very close
to the perfect build setup for my (soon to be) open source project.
This setup would complete item 2 in the
Joel
Test
.
I setup
homebrew on
my brother's Apple Mac OS X and used it to install the necessary
LLVM, D Compiler and Jam tools to test the build environment. The
Jam build tool in the homebrew repository sets up the Perforce
version of Jam. I added the additional rules for building D files to
my Jamfile and all is working perfectly. The build script so far is:
# auxiliary rules to support building D
code with perforce Jam
rule UserObject {
switch $(>:S) {
case .d : Dc $(<) : $(>) ;
case * :
Exit "Unknown suffix on " $(>) " - see UserObject rule in
Jambase." ;
}
}
rule Dc {
Depends $(<) : $(>) ;
DCFLAGS on $(<) += $(DCFLAGS) $(SUBDIRDCFLAGS) ;
}
actions Dc {
$(DC) -c -of$(<) $(DCFLAGS) $(DOPTIM) $(>)
}
# override the Link action to correct for the dmd compiler -o flag
actions Link bind NEEDLIBS {
$(LINK) $(LINKFLAGS) -of$(<) $(UNDEFS) $(>) $(NEEDLIBS)
$(LINKLIBS)
}
DC = dmd ;
DCFLAGS = -fPIC -O -inline -release -w -wi -I./imports/llvm-2.9
-I./src/ ;
C++FLAGS =
-I/usr/include
-DNDEBUG
-D_GNU_SOURCE
-D__STDC_LIMIT_MACROS
-D__STDC_CONSTANT_MACROS
-O3
-fomit-frame-pointer
-fno-exceptions
-fPIC
-Woverloaded-virtual
-Wcast-qual ; # should be generated from `llvm-config
--cxxflags`
LINK = $(DC) ;
DFILES = [ GLOB src/ob2c : *.d ] ;
MainFromObjects ob2c : $(DFILES:S=.o) ;
Objects $(DFILES) ;
LinkLibraries ob2c : llvm-c-ext ;
Library llvm-c-ext :
imports/llvm-2.9/llvm/Ext.cpp
imports/llvm-2.9/llvm/Target.cpp ;
The only remaining addition I'd like to make is to force all build
output to a dedicated build folder as you've been helping me with. I
don't understand where to apply the SubDir rule and the
ALL_LOCATE_TARGET variable. My project directory structure is as
follows:
code/
|-- src/
|-- imports/
|-- build/ <-- folder for all build output
|-- Jamfile
Cheers,
Chris
On 01/06/11 22:11, John Waugh wrote:
On Tue, May 31, 2011 at 5:02 AM, Chris Molozian <chris <at> cmoz.me> wrote:
As suggested I've tried:
MkDir build ;
ALL_LOCATE_TARGET = build ;
to relocate all build output to a dedicated build folder but it appears to do nothing. The object files are still built alongside source files and the libraries and executable build in the same directory as the Jamfile. I'm not sure what I'm doing wrong.
I forgot to mention: you can always set LOCATE on targets yourself, of course.
In fact, if you look in Jambase at how ALL_LOCATE_TARGET is used (it's
just 2 lines), it just sets the default LOCATE path.
LOCATE itself is a jam 'special' variable, which is used to bind a
target to a physical path on the file system.
c.f. http://public.perforce.com/public/jam/src/Jam.html#search
(apologies if you already knew this)
-John