Can't build external xpcom components from headers in build tree

RESOLVED FIXED

Status

SeaMonkey
Build Config
RESOLVED FIXED
16 years ago
14 years ago

People

(Reporter: Akkana Peck, Assigned: dougt)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

16 years ago
I'm trying to take a build tree and generate headers (or a suitable set of -I
directives I can put in a Makefile) to be able to build xpcom components outside
the build tree.  (I don't want to install an RPM or deb package, because I'm
using moz builds from m.o.)

If I point to various directories under dist/include, I can't build because nspr
headers aren't there.  If I point to directories under dist/sdk, I can't build
because of this:

In file included from
/u/builds/vanilla/mozilla/dist/sdk/xpcom/include/nsISupportsUtils.h:61,
                 from
/u/builds/vanilla/mozilla/dist/sdk/xpcom/include/nsISupports.h:118,
/u/builds/vanilla/mozilla/dist/sdk/xpcom/include/nsISupportsImpl.h:62:
nsTraceRefcnt.h: No such file or directory

Eventually I came up with this:
MOZINCDIR = $(MOZTREE)/dist/include
MOZSDKDIR = $(MOZTREE)/dist/sdk
MOZINCS = -I$(MOZINCDIR) -I$(MOZINCDIR)/xpcom -I$(MOZSDKDIR)/nspr/include
IDLINCS = -I$(MOZSDKDIR)/xpcom/idl

This seems to work, but it's messy and there should be a cleaner way.  Ideally
even a "make installhdrs" target that installs the dev headers in some standard
system location (which developers of xpcom packages could then use as their
configure/makefile defaults), but in the short term it would be fine if the
stuff in dist/sdk was usable.
(Assignee)

Comment 1

16 years ago
wow - incredible timing.  working on a Makefile to just this.  stay tuned.
(Assignee)

Comment 2

16 years ago
i am writing a book about how to do this actually :-)

Here is a makefile which should get you started.  Thanks to cls for the corrections:


CXX   = c++

CPPFLAGS +=     -fno-rtti              \
                -fno-exceptions        \
                -shared

# Change this to point at your Gecko SDK directory.
GECKO_SDK_PATH = /home/dougt/gecko-sdk

# GCC only define which allows us to not have to #include mozilla-config
# in every .cpp file.  If your not using GCC remove this line and add
# #include "mozilla-config.h" to each of your .cpp files.
GECKO_CONFIG_INCLUDE = -include mozilla-config.h

GECKO_DEFINES  = -DXPCOM_GLUE -DMOZILLA_STRICT_API

GECKO_INCLUDES = -I $(GECKO_SDK_PATH)                    \
                 -I $(GECKO_SDK_PATH)/xpcom/include      \
                 -I $(GECKO_SDK_PATH)/nspr/include       \
                 -I $(GECKO_SDK_PATH)/string/include     \
                 -I $(GECKO_SDK_PATH)/embedstring/include

GECKO_LDFLAGS =  -L $(GECKO_SDK_PATH)/xpcom/bin -lxpcomglue \
                 -L $(GECKO_SDK_PATH)/nspr/bin -lnspr4      \
                 -L $(GECKO_SDK_PATH)/nspr/bin -lplds4      \
                 -L $(GECKO_SDK_PATH)/embedstring/bin/ -lembedstring

build:
        $(CXX) -o MozShim.so $(GECKO_CONFIG_INCLUDE) $(GECKO_DEFINES)
$(GECKO_INCLUDES) $(GECK\
O_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) MozShim.cpp
        chmod +x MozShim.so

clean:
        rm MozShim.so



I am marking fixed as I am able to build a component against the gecko SDK.  

Status: NEW → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → FIXED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.