Good evening, internals!
I have posted about this just a while ago - I am slightly concerned about the current build system.
Nothing against autotools and the current „phpize“ system - t runs, is stable, and well concepted. But currently, PHP is a program on its own, and to me, it is hard to imagine being able to embed it on a system - like Windows, where you have nothing like apt, yum, zypper, or whatever. I am writing a package manager for that reason…but it might want to integrate PHP for a varity of reasons. But at the current state, its hard to implement PHP into anything, without getting a hang on itself first.
Setting up the deps folder with the required headers and dll’s, or compiling other stuff on UNIX is okay. But to embed PHP, one needs to be able to run a proper shell - bash - have make and some headers/libs installed, making it rather hard to implement.
I for myself only want to implement parts of PHP. Like the core engine, the pthreads PECL extension and using PHP-CPP, I will be making my libd0p and others available to PHP too. But if I want to build on Windows, I am quite lost.
The build system I deem to use is a script-like system, and it is by nature windows compatible. It might not be as direct as make, or not even Ninja, but things like the following work quite nicely.
—
Builting some librarys and making it into a binary.
target static_lib("d0p") {
// I could have said "target libd0p.a" - but using a function, I can make this cross platform.
// So it is either .a or .lib, depending on the os.
rule "static_lib";
input [files("libd0p/.cpp")];
requires [targets("d0p")]; // We can assign tags for easer finding
}
target static_lib("canister") {
rule "static_lib";
tag "d0p";
input [files("libcanister/src/.cpp")];
CPPFLAGS = CPPFLAGS.define("foo=bar"); # Will automaticaly set -D or /D and add to the flags
}
target static_lib("bu") {
rule "static_lib";
tag "d0p";
input [
files("libbu/src/stable/.cpp"),
files("libbu/src/experimental/.cpp"),
files("libbu/src/unstable/*.cpp")
];
CPPFLAGS = CPPFLAGS.include("libbu/");
}
target "d0p-tool" {
rule "exe";
requires [targets("d0p")];
input "d0p.cpp";
CPPFLAGS = CPPFLAGS.include("libbu/").include("libcanister/src");
}
action "default" {
build: "d0p";
}
—
This build system is currently learning configuration (checking for headers, functions, libraries, tools), generating and downloading of files. After this is done, I hope to replicate PHP’s main build system int hat way - so I can then include the file from a main file. But in order to do this, I need to learn as much as I can about the very basic PHP building.
But this isnt just useful for me. For anyone who wishes to integrate a basic PHP engine, this would be some useful knowledge. What to check for, what to generate - and then, what to build - to just get a basic thing up and running.
As much as I have searched for now, PHP generates a tiny bit of files:
./ext/date/lib/timelib_config.h
./main/build-defs.h
./main/internal_functions.c
./main/internal_functions_cli.c
./main/php_config.h
./TSRM/tsrm_config.h
./Zend/zend_config.h
But, can’t this process be simplified? For example:
$ cat TSRM/tsrm_config.h
#include <../main/php_config.h>
Why do we even need this file, if it is more or less pointless, as it just includes a file at another location?
My goal is to achieve a way to make embedding PHP for others simpler - that will incldue adding PHP-CPP. Because its structured so simple, that it only comes with a makefile - and you basically could:
g++ -c src/*.cpp -I. -Iinclude
ar rcs libphpcpp.a *.o
Voila, built.
So, to sumarize my points that I somehow tried to explain, but I am not very good with wording myself in english - my main language is german.
- Autotools is not capable of properly including other projects, without forcing more configure calls, which check things over and over again.
- Someone may sumarize how to compile the basic PHP by hand - like, what files to compile with gcc and which .o’s to put together for a basic libphp5.a?
- Can the build of PHP be made easier, for embedding purpose - by refactoring some generations and checks?
I will keep investigating into this topic, as I really want to use PHP - now even more avter finding out about PHP-CPP, which is like, the best „addon“ to PHP that I have ever, ever seen…thanks again to the person who posted about that, its an amazing finding!
Kind regards, Ingwie
The build system I deem to use is a script-like system, and it is by nature windows compatible. It might not be as direct as make, or not even Ninja, but things like the following work quite nicely.
Why not cmake or the like?
--
Andrea Faulds
http://ajf.me/
I would port to cmake too, but i have to learn more of it first. :)
Am 17.03.2014 um 22:12 schrieb Andrea Faulds ajf@ajf.me:
The build system I deem to use is a script-like system, and it is by nature windows compatible. It might not be as direct as make, or not even Ninja, but things like the following work quite nicely.
Why not cmake or the like?
--
Andrea Faulds
http://ajf.me/
On Mon, Mar 17, 2014 at 10:17 PM, Kevin Ingwersen
ingwie2000@googlemail.com wrote:
I would port to cmake too, but i have to learn more of it first. :)
we have a branch with cmake support, except phpize almost everything
was working, if you are interested.
--
Pierre
@pierrejoye | http://www.libgd.org
I saw that branch, but it looked ultra-outdated, like it was for php4 - not 5. But it is a good start. I have that whole stuff cloned…did a full svn check out once.
Am 17.03.2014 um 22:27 schrieb Pierre Joye pierre.php@gmail.com:
On Mon, Mar 17, 2014 at 10:17 PM, Kevin Ingwersen
ingwie2000@googlemail.com wrote:I would port to cmake too, but i have to learn more of it first. :)
we have a branch with cmake support, except phpize almost everything
was working, if you are interested.
This build system is currently learning configuration (checking for
headers, functions, libraries, tools), generating and downloading of
files. After this is done, I hope to replicate PHP’s main build system
int hat way - so I can then include the file from a main file. But in
order to do this, I need to learn as much as I can about the very
basic PHP building.But this isnt just useful for me. For anyone who wishes to integrate a
basic PHP engine, this would be some useful knowledge. What to check
for, what to generate - and then, what to build - to just get a basic
thing up and running.
The autotools based build system works and takes care of all the
difference in unix systems. And giving users a system which works in a
common way with other software making it easy for unix administrators to
get started. It is also easily extensible for new extensions and the
make process is fast (quick cycle for "vim somefile.c && make" is
important for efficient work, many other build systems spend way more
time finding changes and are recompiling more things maing that process
slow, currently the speed is mostly limited by SAPI linkage)
Unless those things are there it needs really good other benefits to
switch to a different build system.
As much as I have searched for now, PHP generates a tiny bit of files:
./ext/date/lib/timelib_config.h
./main/build-defs.h
./main/internal_functions.c
./main/internal_functions_cli.c
./main/php_config.h
./TSRM/tsrm_config.h
./Zend/zend_config.hBut, can’t this process be simplified? For example:
$ cat TSRM/tsrm_config.h
#include <../main/php_config.h>Why do we even need this file, if it is more or less pointless, as it
just includes a file at another location?
Since TSRM is a stand-alone library. You can build TSRM without anything
from PHP for usage in other software:
$ mv phpsrc/TSRM TSRM
$ cd TSRM
$ ./buildconf && ./configure && make
$ ls -l .libs/libtsrm.a
-rw-r--r-- 1 johannes staff 4910 2014-03-18 11:50 .libs/libtsrm.a
I'm not aware of anybody doing this (which doesn't mean anything) but I
know of historic cases where this has been done. This also ensures clear
encapsulation of concerns which makes good design for a larger software
project. Also TSRM is using different license and copyrights.
Similar for date's timelib or even the Zend Engine.
The builtin_functions files have to be generated as we need a way to
register all enabled extensions in specific order (some have
dependencies)
The config files have all the other built time relevant information on
the (mis-)ehaviour of the system which we can't know while writing code
without limiting our supported platforms. (which essentially are:
everything more or less posix-like with a more or less standard c
library and compiler and Windows)
My goal is to achieve a way to make embedding PHP for others simpler -
that will incldue adding PHP-CPP. Because its structured so simple,
that it only comes with a makefile - and you basically could:g++ -c src/*.cpp -I. -Iinclude
ar rcs libphpcpp.a *.oVoila, built.
Unfortunately different systems are different, system libraries work
differently, compilers work differently, ... and PHP is using a lot of
those.
So, to sumarize my points that I somehow tried to explain, but I am
not very good with wording myself in english - my main language is
german.- Autotools is not capable of properly including other projects,
without forcing more configure calls, which check things over and over
again.
Yes, the pain for flexibility and compatibility to all sorts of systems.
- Someone may sumarize how to compile the basic PHP by hand - like,
what files to compile with gcc and which .o’s to put together for a
basic libphp5.a?
As said, at least in two mails before already: Nobody does, as nobody
cares. If you care ask make. (i.e. make -n or read the Makefile) and as
said nothing of that is a committed interface: file structures, build
system created defines, ... might change on every release.
- Can the build of PHP be made easier, for embedding purpose - by
refactoring some generations and checks?
It is software, everything is possible, I listed some high level
requirements above a build system for PHP has to deliver. And as said in
a previous mail the suggested path is to use PHP's build system to build
the embed SAPI and use that from some other project (or creating a SAPI)
Yes, this adds a step and a dependency, but PHP is not a simple piece of
self-contained software but a glue on tons ob libraries and system
functions, trying to overcome many system specific anomalies.
Creating a good build system is extremely hard. That's why none exists.
About your system: Your examples are the trivial part. In the examples
you don't seem to have external dependencies. How do you check whether a
library exists or the behavior of a library call? (i.e. "does dlsym on
this platform require a _ before the symbol name ornot?") How check
endianess for encoding routines? How do you check for external tools and
run them (i.e. parser generator)? Oh and compiler features ... does it
know how different compilers use different options?
And as cmake was mentioned in this thread: cmake is a great tool, but it
reduces UNIX-specific freedoms (autocrap allows me to call out to any
program I want at basically any stage) in order to be compatible to
non-UNIX(like) platforms. In the implementations it saw it also often
produced way less efficient Makefiles (which really hurts for a change,
build, test cycle) and is harder to debug (this might be subjective due
to experience but in cmake systems I have to search through tons of
files to find an issue, in out autotools implementation it seems to be
quite more centralized)
johannes
On Mon, Mar 17, 2014 at 2:05 PM, Kevin Ingwersen
ingwie2000@googlemail.comwrote:
Good evening, internals!
I have posted about this just a while ago - I am slightly concerned about
the current build system.Nothing against autotools and the current "phpize" system - t runs, is
stable, and well concepted. But currently, PHP is a program on its own, and
to me, it is hard to imagine being able to embed it on a system - like
Windows, where you have nothing like apt, yum, zypper, or whatever. I am
writing a package manager for that reason...but it might want to integrate
PHP for a varity of reasons. But at the current state, its hard to
implement PHP into anything, without getting a hang on itself first.Setting up the deps folder with the required headers and dll's, or
compiling other stuff on UNIX is okay. But to embed PHP, one needs to be
able to run a proper shell - bash - have make and some headers/libs
installed, making it rather hard to implement.I for myself only want to implement parts of PHP. Like the core engine,
the pthreads PECL extension and using PHP-CPP, I will be making my libd0p
and others available to PHP too. But if I want to build on Windows, I am
quite lost.The build system I deem to use is a script-like system, and it is by
nature windows compatible. It might not be as direct as make, or not even
Ninja, but things like the following work quite nicely.--
Builting some librarys and making it into a binary.
target static_lib("d0p") {
// I could have said "target libd0p.a" - but using a function, I
can make this cross platform.
// So it is either .a or .lib, depending on the os.
rule "static_lib";
input [files("libd0p/.cpp")];
requires [targets("d0p")]; // We can assign tags for easer finding
}
target static_lib("canister") {
rule "static_lib";
tag "d0p";
input [files("libcanister/src/.cpp")];
CPPFLAGS = CPPFLAGS.define("foo=bar"); # Will automaticaly set -D
or /D and add to the flags
}
target static_lib("bu") {
rule "static_lib";
tag "d0p";
input [
files("libbu/src/stable/.cpp"),
files("libbu/src/experimental/.cpp"),
files("libbu/src/unstable/*.cpp")
];
CPPFLAGS = CPPFLAGS.include("libbu/");
}target "d0p-tool" {
rule "exe";
requires [targets("d0p")];
input "d0p.cpp";
CPPFLAGS = CPPFLAGS.include("libbu/").include("libcanister/src");
}action "default" {
build: "d0p";
}This build system is currently learning configuration (checking for
headers, functions, libraries, tools), generating and downloading of files.
After this is done, I hope to replicate PHP's main build system int hat way
- so I can then include the file from a main file. But in order to do this,
I need to learn as much as I can about the very basic PHP building.But this isnt just useful for me. For anyone who wishes to integrate a
basic PHP engine, this would be some useful knowledge. What to check for,
what to generate - and then, what to build - to just get a basic thing up
and running.As much as I have searched for now, PHP generates a tiny bit of files:
./ext/date/lib/timelib_config.h
./main/build-defs.h
./main/internal_functions.c
./main/internal_functions_cli.c
./main/php_config.h
./TSRM/tsrm_config.h
./Zend/zend_config.hBut, can't this process be simplified? For example:
$ cat TSRM/tsrm_config.h
#include <../main/php_config.h>Why do we even need this file, if it is more or less pointless, as it just
includes a file at another location?My goal is to achieve a way to make embedding PHP for others simpler -
that will incldue adding PHP-CPP. Because its structured so simple, that it
only comes with a makefile - and you basically could:g++ -c src/*.cpp -I. -Iinclude
ar rcs libphpcpp.a *.oVoila, built.
So, to sumarize my points that I somehow tried to explain, but I am not
very good with wording myself in english - my main language is german.- Autotools is not capable of properly including other projects,
without forcing more configure calls, which check things over and over
again.
- Someone may sumarize how to compile the basic PHP by hand -
like, what files to compile with gcc and which .o's to put together for a
basic libphp5.a?
- Can the build of PHP be made easier, for embedding purpose - by
refactoring some generations and checks?I will keep investigating into this topic, as I really want to use PHP -
now even more avter finding out about PHP-CPP, which is like, the best
"addon" to PHP that I have ever, ever seen...thanks again to the person who
posted about that, its an amazing finding!Kind regards, Ingwie
With regard to Windows, you should take a look at Garret Serack's CoApp
project. It's pretty impressive, I think.
--Kris