[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[platform-dev] Taming native build scripts under Linux
|
Hello,
At first, I must say I've installed Eclipse for the first time
and I'm thoroughly impressed. It's the IDE of my dreams coming
true. Excellent job, folks :)
I set out to roll it into an RPM package for the Linux distribution
I use. This meant I had to resort to ant build. I had also set
a goal to rebuild the native modules using the infrastructure
at hand. Here's what I learnt in process.
1. The native sources are islands in the build waterfall: if you
remove the native binaries and build the whole tree, the binaries
don't get rebuilt and will be missing in the distribution zips
with no warning.
2. For building the native modules, there are hairy shell scripts
and makefiles. From the first glance, ant could do everything
these files do and more.
3. Furthermore, the build scripts don't work if something
in your system differs from the one where they probably used to.
For example, output from `pkg-config --libs gthread-2.0` is not
always safe for ye olde ld, as it contains flags intended
for gcc.
I developed a number of patches that amend point 3 from above.
These patches are attached to this message. The first is applied
to the Eclipse source tree root. The two others have to be
applied to 'plugins/org.eclipse.swt/Eclipse SWT PI'.
Whoever left spaces in directory names should be taken out
of the project and shot :)
Below is an excerpt from my RPM spec file, depicting
what I had to do to build the whole thing after applying
the patches.
find plugins -name '*.so' | xargs rm -f
%define buildflags -os %_target_os -ws gtk
%define eclipse_features jdt pde platform platform.%_target_os.gtk sdk.%_target_os.gtk team.extras
%build
./build %buildflags -target compile
# Build the native stuff
cd 'plugins/org.eclipse.swt/Eclipse SWT PI/gtk/library'
ln -sf '../../../Eclipse SWT/common/library/make_common.mak' make_common.mak
ln -sf '../../../Eclipse SWT/common/library/callback.c' callback.c
ln -sf '../../../Eclipse SWT/common/library/callback.h' callback.h
ln -sf '../../../Eclipse SWT/common/library/swt.h' swt.h
ant -f make_gtk.xml -Dcc.optflags="$RPM_OPT_FLAGS"
cd -
cd plugins/org.eclipse.core.resources.linux/src
make CFLAGS="$RPM_OPT_FLAGS" JDK_INCLUDE=%_libdir/j2se/include
mv libcore*.so ../os/%_target_os/%earch
cd -
cd plugins/org.eclipse.update.core.linux/src
ant -Djdk-path=%_libdir/j2se -Dcc.optflags="$RPM_OPT_FLAGS"
cd -
cd plugins/platform-launcher/library/gtk
make -f make_gtk.mak \
PROGRAM_OUTPUT=eclipse \
PROGRAM_NAME=Eclipse \
DEFAULT_OS=%_target_os \
DEFAULT_OS_ARCH=%earch \
DEFAULT_WS=gtk \
OPTFLAGS="$RPM_OPT_FLAGS" \
all
mv -f eclipse ../../bin/%_target_os/gtk/eclipse
cd -
./build %buildflags -target buildDoc
./build %buildflags -target install
for feature in %eclipse_features; do
cd features/org.eclipse.$feature-feature
ant zip.distribution
unzip -Z -1 org.eclipse.$feature*.bin.dist.zip |\
sed -n -e '\#^\(features\|plugins\)/$#! s#\(.*\)/$#%%dir %eclipse_home/\1#p' >../../$feature.list
unzip -Z -1 org.eclipse.$feature*.bin.dist.zip |\
sed -n -e 's#\(.*[^/]\)$#%eclipse_home/\1#p' >>../../$feature.list
cd -
done
FYI, the package I built is available in the no-source form at
http://people.altlinux.ru/~mhz/software/SRPMS/eclipse-2.1-alt1.nosrc.rpm
It's built for ALT Linux distribution, but it must be easy
to port it to Mandrake or RedHat.
--
Stay tuned,
MhZ JID: mhz@xxxxxxxxxxxx
___________
"I only touch base with reality on an as-needed basis!"
-- Royal Floyd Mengot (Klaus)
--- plugins/org.eclipse.core.resources.linux/src/Makefile.patch-make 2003-03-28 05:53:22 +0300
+++ plugins/org.eclipse.core.resources.linux/src/Makefile 2003-04-05 23:01:43 +0400
@@ -1,13 +1,21 @@
# makefile for libcore.so
-CORE.C = core.c
-CORE.O = core.o
+JDK_INCLUDE = /usr/lib/jdk/include
+JDK_PLATFORM = linux
+
+CC = gcc
+
+CFLAGS = -g
+LIBS =
+
LIB_NAME = libcore.so
LIB_NAME_FULL = libcore_2_1_0a.so
-core :
- gcc -fPIC -g -c -I$(JDK_INCLUDE) $(CORE.C) -o $(CORE.O)
- gcc -g -shared -Wl,-soname,$(LIB_NAME) -o $(LIB_NAME_FULL) $(CORE.O) -lc
+all : $(LIB_NAME_FULL)
+
+$(LIB_NAME_FULL) : core.c core.h
+ $(CC) -fPIC $(CFLAGS) -c -I$(JDK_INCLUDE) -I$(JDK_INCLUDE)/$(JDK_PLATFORM) core.c -o core.o
+ $(CC) $(CFLAGS) -shared -Wl,-soname,$(LIB_NAME) -o $(LIB_NAME_FULL) core.o $(LIBS)
clean :
rm *.o
--- plugins/platform-launcher/library/gtk/make_gtk.mak.patch-make 2003-03-28 05:54:41 +0300
+++ plugins/platform-launcher/library/gtk/make_gtk.mak 2003-04-05 23:01:43 +0400
@@ -28,7 +28,9 @@
EXEC = $(PROGRAM_OUTPUT)
LIBS = `pkg-config --libs gtk+-2.0`
-CFLAGS = -O -s \
+OPTFLAGS = -O2 -s
+
+CFLAGS = $(OPTFLAGS) \
-DPROGRAM_NAME="\"$(PROGRAM_NAME)\"" \
-DDEFAULT_OS="\"$(DEFAULT_OS)\"" \
-DDEFAULT_OS_ARCH="\"$(DEFAULT_OS_ARCH)\"" \
--- plugins/org.eclipse.update.core.linux/src/build.xml.patch-make 2003-03-28 05:54:05 +0300
+++ plugins/org.eclipse.update.core.linux/src/build.xml 2003-04-06 02:20:17 +0400
@@ -1,19 +1,21 @@
-<?xml version="1.0"?>
-<project name="buildlibrary" default="run" basedir=".">
+<?xml version="1.0" encoding="UTF-8"?>
+<project default="run" basedir="." name="buildlibrary">
<!-- The properties ${eclipse-home} ${jdk-path} should be passed into this script -->
<!-- Set a meaningful default value for when it is not. -->
<property name="eclipse-home" value="${basedir}/../.."/>
<property name="jdk-path" value="${java.home}"/>
<property name="destination" value="${eclipse-home}/org.eclipse.update.core.linux/os/linux/x86/"/>
- <property name="obj-path" value="${eclipse-home}/org.eclipse.update.core/src/"/>
- <property name="src-path" value="${eclipse-home}/org.eclipse.update.core/src/"/>
-
+ <property name="obj-path" value="${basedir}"/>
+ <property name="src-path" value="${basedir}"/>
+
<!-- sets the properties -->
<property name="library-name" value="libupdate"/>
<property name="library-platform" value="so"/>
<property name="library-file" value="${library-name}.${library-platform}"/>
-
+ <property name="cc" value="gcc"/>
+ <property name="cc.optflags" value="-O2"/>
+
<!-- This target holds all initialization code that needs to be done for -->
<!-- all tests that are to be run. Initialization for individual tests -->
<!-- should be done within the body of the suite target. -->
@@ -45,20 +47,18 @@
<echo message="Building ${library-file}"/>
<property name="header-path" value="${jdk-path}/include"/>
- <property name="header-linux-path" value="${header-path}/linux" />
+ <property name="header-linux-path" value="${header-path}/linux"/>
- <echo message="gcc -o ${library-file} -shared -I${src-path} -I${header-linux-path} ${library-file} -static -lc"/>
+ <echo message="${cc} -o ${library-file} ${cc.optflags} -shared -I${src-path} -I${header-path} -I${header-linux-path} ${src-path}/*.cpp"/>
- <apply executable="gcc" dest="${eclipse-home}/" parallel="false">
+ <apply executable="${cc}" dest="${eclipse-home}/" parallel="false">
<arg value="-o"/>
<arg value="${library-file}"/>
+ <arg line="${cc.optflags}"/>
<arg value="-shared"/>
<arg value="-I${src-path}"/>
<arg value="-I${header-path}"/>
<arg value="-I${header-linux-path}"/>
- <srcfile/>
- <arg value="-static"/>
- <arg value="-lc"/>
<fileset dir="${src-path}" includes="*.cpp"/>
<mapper type="glob" from="*.cpp" to="*.o"/>
</apply>
--- gtk/library/make_gtk.xml.patch-make1 2003-03-28 05:50:02 +0300
+++ gtk/library/make_gtk.xml 2003-04-06 02:22:40 +0400
@@ -1,14 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project default="build_gtk_linux_lib" basedir="../../..">
+<project default="build_gtk_linux_lib" basedir=".">
<target name="init">
<tstamp/>
- <property name="fragment_dir" value="${basedir}/../org.eclipse.swt.gtk" />
+ <property name="fragment_dir" value="${basedir}/../../../../org.eclipse.swt.gtk" />
<property name="jar_destdir" value="${fragment_dir}/ws/linux" />
<property name="lib_destdir" value="${fragment_dir}/os/linux/x86" />
- <property name="log_dir" value="${basedir}"/>
-
+ <property name="log_dir" value="${basedir}/../../.."/>
+
+ <property name="cc.optflags" value="-O2"/>
+
<mkdir dir="${jar_destdir}" />
<mkdir dir="${lib_destdir}" />
</target>
@@ -17,19 +19,23 @@
<!-- Output .so for this platform into the org.eclipse.swt.gtk/os directory -->
<!-- .log files from the compilers in the org.eclipse.swt/ directory -->
<target name="build_gtk_linux_lib" depends="init">
- <exec dir="./bin/library" executable="sh" output="${log_dir}/build_log.txt">
- <arg line="${basedir}/bin/library/build.sh"/>
+ <exec dir="${basedir}" executable="sh" output="${log_dir}/build_log.txt">
+ <arg file="${basedir}/build.sh"/>
+ <arg value="OPTFLAGS=${cc.optflags}"/>
</exec>
- <copy todir="${lib_destdir}">
- <fileset dir="${basedir}/bin/library/" includes="*.so"/>
- </copy>
+ <move todir="${lib_destdir}">
+ <fileset dir="${basedir}" includes="*.so"/>
+ </move>
+ <chmod perm="ugo+x">
+ <fileset dir="${lib_destdir}" includes="*.so"/>
+ </chmod>
</target>
<target name="clean" depends="init">
<tstamp/>
- <exec dir="./bin/library" executable="sh" output="${log_dir}/build_log.txt">
- <arg line="${basedir}/bin/library/build.sh"/>
- <arg line="clean"/>
+ <exec dir="${basedir}" executable="sh" output="${log_dir}/build_log.txt">
+ <arg file="${basedir}/build.sh"/>
+ <arg value="clean"/>
</exec>
</target>
--- gtk/library/make_gtk.mak.patch-make1 2003-03-28 05:52:11 +0300
+++ gtk/library/make_gtk.mak 2003-04-06 04:42:29 +0400
@@ -18,15 +18,8 @@
# Define the installation directories for various products.
# Your system may have these in a different place.
-# Define the installation directories for various products.
-# Your system may have these in a different place.
-# IVE_HOME - IBM's version of Java (J9)
-IVE_HOME = /bluebird/teamswt/swt-builddir/ive
-#IVE_HOME = /opt/IBMvame1.4/ive
-
-JAVA_JNI=$(IVE_HOME)/bin/include
-JAVAH=$(IVE_HOME)/bin/javah
-LD_LIBRARY_PATH=$(IVE_HOME)/bin
+JAVA_JNI=/usr/lib/j2se/include
+JAVA_PLATFORM=linux
# Whether we want GTK over X or FB
GTKTARGET = gtk+-2.0
@@ -35,6 +28,8 @@
CC = gcc
LD = ld
+OPTFLAGS = -O2 -s
+
# Define the various DLL (shared) libraries to be made.
SWT_PREFIX = swt
@@ -45,22 +40,13 @@
GNOME_DLL = lib$(GNOME_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).so
GNOME_OBJ = gnome.o
-GNOME_CFLAGS = `pkg-config --cflags gnome-vfs-2.0`
-GNOME_LIB = -x -shared `pkg-config --libs gnome-vfs-2.0`
+GNOME_CFLAGS = `pkg-config --cflags gnome-vfs-module-2.0`
+GNOME_LIB = `pkg-config --libs gnome-vfs-module-2.0`
# Compile and link options from pkg-config
-GTKCFLAGS = `pkg-config --cflags $(GTKTARGET)` `pkg-config --cflags pango`
-
-# TEMPORARY CODE
-#
-# Note: pkg-config is not being used because it generates flags that are dependent
-# on the machine setup. Some machines do not have free type fonts support. The line
-# below was obtained by running pkg-config and removing "-lpangoxft-1.0" from
-# the result.
-#
-GTKLIBS = `pkg-config --libs gthread-2.0` -L/usr/local/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
-#GTKLIBS = `pkg-config --libs $(GTKTARGET)`
+GTKCFLAGS = `pkg-config --cflags $(GTKTARGET)`
+GTKLIBS = `pkg-config --libs $(GTKTARGET)`
#
@@ -74,7 +60,7 @@
make_gnome: $(GNOME_DLL)
$(GNOME_DLL): gnome.o
- ld -o $@ $(GNOME_OBJ) $(GNOME_LIB)
+ $(CC) -shared -Wl,-x -o $@ $(GNOME_OBJ) $(GNOME_LIB)
$(GNOME_OBJ): gnome.c
$(CC) $(CFLAGS) $(GNOME_CFLAGS) -c -o gnome.o gnome.c
@@ -84,11 +70,11 @@
PI_OBJECTS = swt.o structs.o
$(SWT_DLL): callback.o
- $(LD) -x -shared \
+ $(CC) -shared -Wl,-x \
-o $(SWT_DLL) callback.o
-
+
$(SWTPI_DLL): $(PI_OBJECTS) structs.o
- $(LD) -x -shared \
+ $(CC) -shared -Wl,-x \
$(GTKLIBS) \
-o $(SWTPI_DLL) $(PI_OBJECTS)
@@ -99,15 +85,16 @@
# All about Compiling
SWT_WARNINGS = #-Wimplicit-function-declaration
-CFLAGS = -c -O -s \
+CFLAGS = -c $(OPTFLAGS) \
-DSWT_VERSION=$(SWT_VERSION) \
-DLINUX -DGTK \
$(SWT_WARNINGS) \
-fpic -fPIC \
$(GTKCFLAGS) \
- -I$(JAVA_JNI)
+ -I$(JAVA_JNI) \
+ -I$(JAVA_JNI)/$(JAVA_PLATFORM)
-callback.o: callback.c
+callback.o: callback.c callback.h swt.h
$(CC) $(CFLAGS) callback.c
swt.o: swt.c swt.h
--- gtk/library/build.sh.patch-make1 2003-03-28 05:51:12 +0300
+++ gtk/library/build.sh 2003-04-06 02:22:40 +0400
@@ -29,4 +29,4 @@
# Determine the operating system being built
-make -f make_gtk.mak ${1+"$@"}
+make -f make_gtk.mak "$@"
--- gtk/library/gnome.c.patch-warnings 2003-04-06 02:24:34 +0400
+++ gtk/library/gnome.c 2003-04-06 04:46:49 +0400
@@ -21,9 +21,11 @@
#include "structs.h"
#include <stdio.h>
+#include <string.h>
#include <assert.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <libgnomevfs/gnome-vfs-mime-info.h>
#ifndef NO_GnomeVFSMimeApplication
typedef struct GnomeVFSMimeApplication_FID_CACHE {
@@ -110,7 +112,7 @@
{
DEBUG_CALL("gnome_1vfs_1mime_1extensions_1list_1free\n")
- gnome_vfs_mime_extensions_list_free(arg0);
+ gnome_vfs_mime_extensions_list_free((GList *)arg0);
}
#endif
@@ -120,7 +122,7 @@
{
DEBUG_CALL("gnome_1vfs_1mime_1registered_1mime_1type_1list_1free\n")
- gnome_vfs_mime_registered_mime_type_list_free(arg0);
+ gnome_vfs_mime_registered_mime_type_list_free((GList *)arg0);
}
#endif
--- gtk/library/swt.c.patch-warnings 2003-04-06 02:24:34 +0400
+++ gtk/library/swt.c 2003-04-06 12:06:48 +0400
@@ -15,7 +15,7 @@
#define G_DISABLE_DEPRECATED
-#define GTK_DISABLE_DEPRECATED
+/* #define GTK_DISABLE_DEPRECATED */
#include "swt.h"
#include "structs.h"