Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
r2323@opsdev009 (orig r101953): dave | 2008-06-02 08:54:13 -0700
Browse files Browse the repository at this point in the history
 Facebook Open Platform: New trees for libfbml-1.2.0 and fbopen PHP source bases.
 
 reviewed by: mvernal
 
 Test Plan: 
 http://www.dave4.devrs002.facebook.com/fbopentest/testall.php
 
 Revert Plan: no prob
  • Loading branch information
(no author) committed Jun 2, 2008
1 parent 9dc4a49 commit 9a631ca
Show file tree
Hide file tree
Showing 1,895 changed files with 532,317 additions and 0 deletions.
110 changes: 110 additions & 0 deletions fbopen-libfbml/LICENSE

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions fbopen-libfbml/Makefile
@@ -0,0 +1,74 @@
# /******BEGIN LICENSE BLOCK*******
# *
# * Common Public Attribution License Version 1.0.
# *
# * The contents of this file are subject to the Common Public Attribution
# * License Version 1.0 (the "License") you may not use this file except in
# * compliance with the License. You may obtain a copy of the License at
# * http://developers.facebook.com/fbopen/cpal.html. The License is based
# * on the Mozilla Public License Version 1.1 but Sections 14 and 15 have
# * been added to cover use of software over a computer network and provide
# * for limited attribution for the Original Developer. In addition, Exhibit A
# * has been modified to be consistent with Exhibit B.
# * Software distributed under the License is distributed on an "AS IS" basis,
# * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# * for the specific language governing rights and limitations under the License.
# * The Original Code is Facebook Open Platform.
# * The Original Developer is the Initial Developer.
# * The Initial Developer of the Original Code is Facebook, Inc. All portions
# * of the code written by Facebook, Inc are
# * Copyright 2006-2008 Facebook, Inc. All Rights Reserved.
# *
# *
# ********END LICENSE BLOCK*********/
#

VERSION = 1.2.0
PROJECT_ROOT = .
PROJECT_NAME = fbml

AUTO_SOURCES = 1
SOURCE_SUBDIRS = ext

# we really just use this as what LIB_TARGETS depends on
CODEGEN_TARGETS = libatom.a

LIB_TARGETS = \
src \

PROGRAMS = \
test \

CPPFLAGS = -Isrc

LIBS = \
$(LIB_DIR)/libfbml.a \
src/lib/libmozutil_s.a \
src/lib/libexpat_s.a \
src/lib/libsaxp.a \
src/lib/libunicharutil_s.a \
src/lib/libxpcomcomponents_s.a \
src/lib/libxpcomproxy_s.a \
src/lib/libxpcomio_s.a \
src/lib/libxpcomds_s.a \
src/lib/libxpcomglue.a \
src/lib/libxpcombase_s.a \
src/lib/libxpcomthreads_s.a \
src/lib/libxptcmd.a \
src/lib/libxptcall.a \
src/lib/libxptinfo.a \
src/lib/libxpt.a \
src/lib/libstring_s.a \
src/lib/libplc4.a \
src/lib/libplds4.a \
src/lib/libnspr4.a \
libatom.a \
-lstdc++ -lpthread

include $(PROJECT_ROOT)/rules.mk
TARGETS = $(PROGRAMS)

all: $(TARGETS)

libatom.a: src/lib/os_Linux_x86.o
$(AR) $@ $^
114 changes: 114 additions & 0 deletions fbopen-libfbml/README
@@ -0,0 +1,114 @@
libfbml for Apache 2.x

Common Public Attribution License Version 1.0.

The contents of this file are subject to the Common Public Attribution
License Version 1.0 (the "License") you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://developers.facebook.com/fbopen/cpal.html. The License is based
on the Mozilla Public License Version 1.1 but Sections 14 and 15 have
been added to cover use of software over a computer network and provide
for limited attribution for the Original Developer. In addition, Exhibit A
has been modified to be consistent with Exhibit B.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Original Code is Facebook Open Platform.
The Original Developer is the Initial Developer.
The Initial Developer of the Original Code is Facebook, Inc. All portions
of the code written by Facebook, Inc are
Copyright 2006-2008 Facebook, Inc. All Rights Reserved.

Overview:

libfbml is a package that provides the basic functionality needed
to parse and render FBML. libfbml builds both a general C++ library and
a PHP extension that layers on top of the C++ module. The PHP extension
can then be installed behind Apache so that a collection of PHP functions
are available to your PHP pages. The build script we provide should
compile, link, and install everything needed for both the C++ and PHP modules.

Downloading Mozilla Dependencies:

The libfbml package depends on firefox-2.0.0.4, which itself requires that
several open source packages be installed. firefox-2.0.0.4-source.tar.bz2 is
included with this release and resides in the dependencies subdirectory.
Please note that firefox-2.0.0.4 relies on the below products (note that
the URLs are provided purely as a convenience):

glib-2.14.6.tar.gz (http://ftp.acc.umu.se/pub/GNOME/sources/glib/2.14/glib-2.14.6.tar.gz)
pkg-config-0.20.tar.gz (ftp://ftp.gtk.org/pub/gtk/v2.10/dependencies/pkg-config-0.20.tar.gz)
atk-1.9.1.tar.bz2 (ftp://ftp.gtk.org/pub/gtk/v2.10/dependencies/atk-1.9.1.tar.bz2)
freetype-2.3.4.tar.gz (http://download.savannah.gnu.org/releases/freetype/freetype-2.3.4.tar.gz)
fontconfig-2.3.97.tar.gz (http://fontconfig.org/release/fontconfig-2.3.97.tar.gz)
libpng-1.2.25.tar.gz (http://internap.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.25.tar.gz)
cairo-1.2.6.tar.gz (ftp://ftp.gtk.org/pub/gtk/v2.10/dependencies/cairo-1.2.6.tar.gz)
tiff-3.7.4.tar.gz (ftp://ftp.gtk.org/pub/gtk/v2.10/dependencies/tiff-3.7.4.tar.gz)
pango-1.18.4.tar.bz2 (http://ftp.gnome.org/pub/gnome/sources/pango/1.18/pango-1.18.4.tar.bz2)
gtk+-2.10.13.tar.bz2 (ftp://ftp.gtk.org/pub/gtk/v2.10/gtk+-2.10.13.tar.bz2)
libIDL-0.8.8.tar.gz (http://ftp.gnome.org/pub/gnome/sources/libIDL/0.8/libIDL-0.8.8.tar.gz)
libXft-2.1.12.tar.gz (http://xorg.freedesktop.org/releases/individual/lib/libXft-2.1.12.tar.gz)
xproto-7.0.7.tar.gz (http://xorg.freedesktop.org/releases/individual/proto/xproto-7.0.7.tar.gz)
xrender-0.8.3.tar.bz2 (http://freeware.sgi.com/source/xrender/xrender-0.8.3.tar.bz2)


Note that if you place these compressed tarballs (don't expand them) in
the dependencies subdirectory alongside firefox-2.0.0.4-source.tar.bz2,
you can use the build.all.py script in the Installation instructions
below to install all of the packages in the correct order.

Installation:

The installation can be managed entirely by the build-all.py script, which sits
at the root of the unzipped, untarred directory. From the command line, type:

> ./build-all.py

The collection of open source packages will be configured, made, and make
installed automatically.

The libfbml PHP module depends on compilation products generated by Mozilla,
which itself depends on a collection of other open source products. The build-all.py
script expands and installs all open source components (except firefox, which comes
later) in the order outlined above.

If you have all of the above files in the dependencies folder, then the
build-all.py script will unzip, untar, configure, make, and make install
each and every one of them.

The script then proceeds to build the 2.0.0.4 version of firefox. Our libfbml
module depends on a collection of modules generated by the compilation of the
firefox.2.0.0.4 source code. The build-all.py script unzips, untars, configured,
and makes the firefox source, but it stops short of installing it, since it
isn't required in order to build libfbml.

Once firefox has been made, we plant soft links to a subset of .o and .a files
that are relevant to the libfbml make system. An overwhelming majority
of the header and source files that come with the firefox project are already
included within the src subdirectory. The current version of libfbml relies
on the Mozilla HTML parser, which was modified to recognize FBML tags and
construct FBML parse trees.

Once the requisite set of archive files have been generated and the soft links
to those files have been laid down, build-all.py compiles, builds, and installs
libfbml as a PHP extension to Apache. The script should print:

Build complete. You'll need to restart Apache before the new PHP extension can be used.

just before it exits.

Changing the Source:

The build-all.py scripts need only be executed once, as its primary purpose
is to build the mozilla parser and to lay down soft links to mozilla libraries
within the libfbml-specified source tree. As you change the libfbml source,
you only need to interact with the Makefile at the root of the entire project
tree, and phpize/configure/make/install within the ext directory.

Note:

On some systems, we've noticed that the installation of pango-1.18.4 fails to copy
in a specific file in spite of the fact that it should be. If the build fails
because of complaints that pango wasn't configured to use cairo, then the quick
fix is to copy pangocairo.pc (which resides in the pango-1.18.4 directory) to
/usr/local/lib/pkgconfig.
166 changes: 166 additions & 0 deletions fbopen-libfbml/build-all.py
@@ -0,0 +1,166 @@
#!/usr/bin/env python

# /******BEGIN LICENSE BLOCK*******
# *
# * Common Public Attribution License Version 1.0.
# *
# * The contents of this file are subject to the Common Public Attribution
# * License Version 1.0 (the "License") you may not use this file except in
# * compliance with the License. You may obtain a copy of the License at
# * http://developers.facebook.com/fbopen/cpal.html. The License is based
# * on the Mozilla Public License Version 1.1 but Sections 14 and 15 have
# * been added to cover use of software over a computer network and provide
# * for limited attribution for the Original Developer. In addition, Exhibit A
# * has been modified to be consistent with Exhibit B.
# * Software distributed under the License is distributed on an "AS IS" basis,
# * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# * for the specific language governing rights and limitations under the License.
# * The Original Code is Facebook Open Platform.
# * The Original Developer is the Initial Developer.
# * The Initial Developer of the Original Code is Facebook, Inc. All portions
# * of the code written by Facebook, Inc are
# * Copyright 2006-2008 Facebook, Inc. All Rights Reserved.
# *
# *
# ********END LICENSE BLOCK*********/

# Simple script in place to configure, make, and sudo make install
# all of the open source tools used by libfbml. It then goes on
# to actually install libfbml as well.

from os import *
from os.path import *
import sys;

# Helper function designed to expand a zipped tar file, where the zip executable was either gunzip
# or bunzip2. We untar the zipped, tarred file in one of two ways, relying (not surprisingly) on
# the file extension to determine which flags should be passed to the tar executable. Only
# .gz and .bz2 extensions are supported.

def expandPackage(package):
if package.endswith(".tar.gz"):
result = system("tar zxfv " + package);
elif package.endswith(".tar.bz2"):
result = system("tar jxfv " + package);
else:
raise ValueError, "Only \"tar.gz\" and \"tar.bz2\" are expected. Please update the implementation to handle other extensions."
if result != 0:
print "Attempt to decompress \"%s\" failed. Aborting..." % package

# Takes a string of the form "<base-name>.tar.gz" or "<base-name>.tar.bz2" and returns
# just the "<base-name>" part. The implementation is completely brute force but self explanatory.

def stripCompressionExtensions(package):
if package.endswith(".tar.gz"):
return package[0:-len(".tar.gz")]
if package.endswith(".tar.bz2"):
return package[0:-len(".tar.bz2")]
raise ValueError, "Only \"tar.gz\" and \"tar.bz2\" are expected. Please update the implementation to handle other extensions."

# Routine that creates a soft link to the specified file within the specified sourcedir.
# The soft link is laid down, using the same filename, in the specified destdir.

def createSoftLink(sourcedir, filename, destdir, commonparentdir):
command = "find " + sourcedir + " -name " + filename + " -print"
output = popen(command)
allmatches = output.readlines()
for match in allmatches:
match = match.strip();
if not islink(match):
print "Soft linking to " + match
command = "ln -s " + commonparentdir + sep + match + " " + destdir + sep + filename
system(command)
return
print "Uh oh! Couldn't find " + filename + " anywhere. Aborting...."
sys.exit(1)

# subdirectories is the ordered list of directories into which we should
# descend, ./configure, make, sudo make install, and ascend out of. The
# order is important, since in some cases, tools than come later in the
# list depend on tools that come before it.

packages = ('pkg-config-0.20.tar.gz', 'glib-2.14.6.tar.gz', 'atk-1.9.1.tar.bz2', 'freetype-2.3.4.tar.gz',
'fontconfig-2.3.97.tar.gz', 'libpng-1.2.25.tar.gz', 'cairo-1.2.6.tar.gz', 'tiff-3.7.4.tar.gz', 'pango-1.18.4.tar.bz2',
'gtk+-2.10.13.tar.bz2', 'libIDL-0.8.8.tar.gz', 'libXft-2.1.12.tar.gz', 'xproto-7.0.7.tar.gz',
'xrender-0.8.3.tar.bz2')

# commands maps each of the above packages to the sequence of command line instructions
# that need to be executed in order to install that component. All of these commands
# are executed within the subdirectory created by unzipping and untarring the package.

commands = { 'pkg-config-0.20.tar.gz': ("./configure", "make", "sudo make install"),
'glib-2.14.6.tar.gz': ("./configure", "make", "sudo make install"),
'atk-1.9.1.tar.bz2': ("./configure", "make", "sudo make install"),
'freetype-2.3.4.tar.gz': ("./configure", "make", "sudo make install"),
'fontconfig-2.3.97.tar.gz': ("./configure", "make", "sudo make install"),
'libpng-1.2.25.tar.gz' : ("./configure", "make", "sudo make install"),
'cairo-1.2.6.tar.gz': ("./configure", "make", "sudo make install"),
'tiff-3.7.4.tar.gz': ("./configure", "make", "sudo make install"),
'pango-1.18.4.tar.bz2': ("./configure", "make", "sudo make install", "sudo cp pangocairo.pc /usr/local/lib/pkgconfig"),
'gtk+-2.10.13.tar.bz2': ("./configure", "make", "sudo make install"),
'libIDL-0.8.8.tar.gz': ("./configure", "make", "sudo make install"),
'libXft-2.1.12.tar.gz': ("./configure", "make", "sudo make install"),
'xproto-7.0.7.tar.gz': ("./configure", "make", "sudo make install"),
'xrender-0.8.3.tar.bz2': ("./configure", "make", "sudo make install") }

dependenciesdir = "dependencies"
chdir(dependenciesdir)
for package in packages:
# descend into the directory, configure, make, sudo make install, and ascend
expandPackage(package)
subdirectory = stripCompressionExtensions(package)
chdir(subdirectory);
for command in commands[package]: # loop through all the commands relevant to installation of the package being installed
result = system(command)
if result != 0:
print "Running \"%s\" within the \"%s\" subdirectory failed with error code %d. Aborting script..." % (command, subdirectory, result)
sys.exit(result)
chdir("..")

# got this far, you're good to actually configure and make firefox. No need to install it, because
# we're interested only in the source files and the archive files, which the make system for libfbml references.

package = "firefox-2.0.0.4-source.tar.bz2"
result = system("tar jxfv " + package)
mozilla = "mozilla"
chdir(mozilla)
for command in ("./configure --enable-application=browser --enable-system-cairo", "make"):
result = system(command)
if result != 0:
print "Running \"%s\" within the \"%s\" subdirectory failed with error code %d. Aborting script..." % (command, mozilla, result)
sys.exit()

# rise out of mozilla folder, and rise even further to top-level directory
chdir("..")
chdir("..")

# set up soft links to a distinguished set of .a files (and one .o file). The build system supporting
# libfbml needs to pretend that these .o/.a files exist in ./src/lib/ so that libatom.a and libfbml.a can
# can be built. All of the relative paths are hard-coded.

print "Searching for all of the Mozilla object files and archives that libfbml depends on"
archivefiles = ("os_Linux_x86.o", "libxptinfo.a", "libxptcmd.a", "libxptcall.a", "libxpt.a", "libxpcomthreads_s.a",
"libxpcomproxy_s.a", "libxpcomio_s.a", "libxpcomglue_s.a", "libxpcomglue.a", "libxpcomds_s.a",
"libxpcomcomponents_s.a", "libxpcombase_s.a", "libunicharutil_s.a", "libstrres_s.a",
"libstring_s.a", "libsaxp.a", "libplds4.a", "libplc4.a", "libnspr4.a", "libmozutil_s.a",
"libexpat_s.a")

for filename in archivefiles:
system("rm -f src/lib/" + filename) # force the removal of previously set up soft links
createSoftLink(dependenciesdir + sep + mozilla, filename, "src" + sep + "lib", ".." + sep + "..")

result = system("make")
if result != 0:
print "Failed to make libfbml.... Aborting"
sys.exit(result)

# finally, descend into PHP extension directory and push new PHP extension back behind apache
subdirectory = "ext"
chdir(subdirectory)
for command in ("phpize", "./configure", "make", "sudo make install"):
result = system(command)
if result != 0:
print "Running \"%s\" within the \"%s\" subdirectory failed with error code %d. Aborting script..." % (command, subdirectory, result)
sys.exit(result)

print "Build complete. You'll need to restart Apache before the new PHP extension can be used."

0 comments on commit 9a631ca

Please sign in to comment.