Re: PHP could become more embeddable

From: Date: Tue, 18 Mar 2014 22:47:57 +0000
Subject: Re: PHP could become more embeddable
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-73277@lists.php.net to get a copy of this message
On Mon, Mar 17, 2014 at 2:05 PM, Kevin Ingwersen <ingwie2000@googlemail.com>wrote: > 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 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > With regard to Windows, you should take a look at Garret Serack's CoApp project. It's pretty impressive, I think. --Kris

« previous php.internals (#73277) next »