put meson.build.pw in php-source directory


Definitions:
pwphpbytecode: complete php source are compiled to bytecode and runned in zend engine
embed: only function calls are runned in zend engine - .php is transpiled to vala
native: without zend engine
both: first native runtime modules, then embed fallback


   native is the best idea for best performance, but if function-calls missing use...
...embed, its calls the functions against the zend-routine, but functions/classes/methods are mapped in vala, but if you use special php language constructs use...
...pwphp, it only compiles to bytecode and run the complete code in zend-vm - for example composer packages







possible lines:


######### Build machinecode files over C

# DEPRECATED: vbin/vlib and the php2vala/VALAPHP path are legacy.
# For new PHP-to-native binaries use PHPEF/phpefc instead, e.g.:
#   ebin = hallowelt.php -> hallowelt
# Keep vbin/vlib only for existing legacy projects until they are migrated.

# Build a native VALAPHP library from PHP source. (use never libphp.so)
# Generates valaphp-libpwexample.so, valaphp-libpwexample.vapi,
# valaphp-libpwexample.h, valaphp-libpwexample.deps and
# /usr/share/valaphp/valaphp-libpwexample/valaphp-libpwexample.stub.php.
vlib-native = example.php -> valaphp-libpwexample (valaphp-runtime-core,valaphp-runtime-std)

# Build an embed VALAPHP library from PHP source. (use libphp.so)
vlib-embed = example.php -> valaphp-libpwexample (valaphp-runtime-core,valaphp-runtime-embed)

# Build an embed VALAPHP library which may call pwphpbytecode classes. (use libphp.so and libphp.so over pwphpbytecode.so)
# valaphp-runtime-embed-pwphpbytecode is added automatically.
vlib-pwphp = example.php -> valaphp-libpwexample (valaphp-runtime-core,valaphp-runtime-embed)

# Build both/native/embed/pwphp binaries from PHP source.
# A dependency named libpwexample is resolved as pkg-config package valaphp-libpwexample.
# A dependency named pwgeneral is resolved as C library pwgeneral-<phpslot>-<abiver>.
# A dependency named std/json/etc is resolved to valaphp-runtime-std/json/etc
# when such a pkg-config package exists.
vbin = example.php -> example
vbin-native = example.php -> example (valaphp-runtime-core,valaphp-runtime-std,libpwexample)
vbin-embed = example.php -> example (valaphp-runtime-core,valaphp-runtime-embed,libpwexample)
vbin-pwphp = example.php -> example (valaphp-runtime-core,valaphp-runtime-embed,libpwexample,pwgeneral)
vbin = example.php -> example [opt=4]
vlib = example.php -> valaphp-libpwexample (std,json) [opt=3]

# vlib/vbin without suffix use php2vala --both-runtimes and add native+embed
# runtime dependencies automatically.
vlib = example.php -> valaphp-libpwexample

VALAPHP-only [] options for vbin/vlib:
# opt=1..4                              php2vala optimizer stage (default: opt=4)
#                                       opt=1 uses --no-optimize-local-vars
#                                       opt=2 uses --optimize-local-vars
#                                       opt=3 uses --optimize-file-func-vars
#                                       opt=4 uses --optimize-cross-file-func-vars
# This is legacy VALAPHP syntax only; PHPEF ebin does not support [opt=...].
pkg-config descriptions are read from the

Example root meson.build:
project('valaphp-libpwexample', ['vala', 'c'], version: '0.01')
project_description = 'Example VALAPHP library from php-source'
php_api_version = '8.3'
abi_implement_version = '3'
run_command(find_program('pw-build-meson'), 'src', php_api_version, abi_implement_version, check: true)
subdir('src')





######### Build PHPEF / PHP ELF binaries through phpefc

# ebin = executable binary through the PHPEF/phpefc pipeline.
# ebin asks phpefc-get-build-pipeline for a machine-readable
# phpefc-build-pipeline-v0 descriptor and renders the visible Meson graph
# from that descriptor. The graph keeps the intermediate artifacts explicit:
# .phpast, .phpir, .valair, .vala, .c, .mapped.c, .raw, final ELF, and
# optional .debug_phpef debug bundle.
#
# Every meson.build.pw file that uses ebin must declare the PHPEF runtime
# policy before the first ebin line. These two lines are required so the
# ebuild RDEPENDs are explicit and match the runtimes pw-build-meson may use:
phpef-runtime-embed = true
phpef-runtime-natives = standard
# Or, when no native runtime may be used, keep the line explicit but empty (in most cases library-optimizer=false is then necessary):
# phpef-runtime-natives =
ebin = hallowelt.php -> hallowelt

# Multi-source PHPEF binaries list every PHP file that belongs to the
# source set. The first source is the executable entry file; additional
# files are compiled as support files and are reached by PHP include/require.
# Both comma-separated and explicit entry + support syntax are supported:
ebin = main.php,lib1.php,lib2.php -> app
ebin = main.php + lib1.php,lib2.php -> app

# Wildcards are expanded by pw-build-meson before Meson sees files(), because
# Meson itself does not expand files('*.php'). Wildcards may be used in both
# list forms and are sorted/deduplicated after expansion:
ebin = main.php,*.php -> app
ebin = main.php + lib/*.php -> app

# In the + form, the left side is always the entry source. In the comma form,
# the first source after wildcard expansion is the entry source; prefer an
# explicit entry file before wildcard support files when entry order matters.

# ebin targets are installed by default. Plain ebin uses Meson's executable
# install default (bindir, usually /usr/bin). ebin(/path) installs to /path.
ebin = hallowelt.php -> hallowelt
ebin(/opt/example/bin) = hallowelt.php -> hallowelt
ebin = hallowelt.php -> hallowelt [roundtrip=true, typing-optimizer=true, library-optimizer=true, fastpath-runtime-optimizer=true, stacktrace=false]

# Preserve PHPEF runtime stacktrace names in stripped binaries by embedding a
# PHPEF-owned .phpef_stacktrace metadata section. The section is readonly but
# not alloc, so normal strip keeps it without LOAD-segment warnings.
ebin = hallowelt.php,*.php -> hallowelt [stacktrace=true]

# Supported options for ebin:
# Debug-section generation is controlled only by Meson's debug option/buildtype.
# roundtrip=true|false                  add the AST -> PHP tokenized roundtrip test (default: true)
# stacktrace=true|false                 embed .phpef_stacktrace metadata for stripped stacktraces (default: false)
# typing-optimizer=true|false           enable/disable typing-zval2static (default: true)
# library-optimizer=true|false          enable/disable library-embed2native (default: true)
# fastpath-runtime-optimizer=true|false enable/disable fastpath-runtime (default: true)
# Install behavior is controlled by the rule key, not by [] options:
#   ebin = ...                         install to Meson's executable bindir (usually /usr/bin)
#   ebin(/path) = ...                  install to /path

# PHPEF ValaIR optimizer pipeline:
# By default, when phpefc's pipeline descriptor provides all optimizer stages,
# ebin builds the active pipeline:
#   phpir -> valair -> valair.afteropt.typing-zval2static -> valair.afteropt.library-embed2native -> valair.afteropt.fastpath-runtime -> vala
# Generated intermediate files:
#   *.valair.afteropt.typing-zval2static
#   *.valair.afteropt.library-embed2native
#   *.valair.afteropt.fastpath-runtime
# Expected optimizer status comments in generated ValaIR files:
#   typing-zval2static result: X/Y zvals left
#   library-embed2native result: X/Y embed libphp.so calls left
#   fastpath-runtime result: X runtime dispatch calls rewritten, Y left
# Disable single stages per rule when needed:
#   ebin = hallowelt.php -> hallowelt [typing-optimizer=false]
#   ebin = hallowelt.php -> hallowelt [library-optimizer=false]
#   ebin = hallowelt.php -> hallowelt [fastpath-runtime-optimizer=false]
#   ebin = hallowelt.php -> hallowelt [typing-optimizer=false, library-optimizer=false, fastpath-runtime-optimizer=false]
# Long-form aliases matching phpefc pass names are also accepted:
#   ebin = hallowelt.php -> hallowelt [valair-optimizer-typing-zval2static=false]     # default: true
#   ebin = hallowelt.php -> hallowelt [valair-optimizer-library-embed2native=false]     # default: true
#   ebin = hallowelt.php -> hallowelt [valair-optimizer-fastpath-runtime=false]         # default: true
# Resulting disabled pipeline when all three optimizers are disabled:
#   phpir -> valair -> vala


######### Build Bytecode files over pwphpbytecode


# Standalone Application without dependencies
bin = show_mem_usage.php -> show_mem_usage

# Application with library binding
bin = show_mem_usage.php -> show_mem_usage (library1:class1,library2:class2)

# Application with JIT-enabled (only for code, not for libraries) library binding
bin-jit = show_mem_usage.php -> show_mem_usage

# Bin File (insert into folder) - File will be executable
bin(/folder) = asd.php -> asd



# Library with dependency from class2 on class1
class = class1.php -> class1 (externlib:classname)
class = class2.php -> class2 (class1)
lib = class1,class2 -> library

# Class with JIT execution
class-jit = class2.php -> class2



################ Create a php opcode file - File will not be executable # NOT USED ANYMORE? CAN BE DELETED?
opcode(/usr/path...) = server.php -> server.phpop




################# Create _raw files for webextension (OBSOLET)

# Create Extension for PHP-FPM (class pw_diffget_server (from same project)
class = diffget_server_src.php -> pw_diffget_server (pwgeneral:pwgeneralcopyright)
lib = pw_diffget_server -> pw_diffget_server_lib
fpmext = pw_diffget_server_lib:pw_diffget_server -> diffget_server






################# Create etc config maintainer
etc(/etc/php/fpm-php*/php.ini)=php_fpm-php_phpini.php->php_fpm-php_phpini (libpwgeneral:pwetc)





################# Create stripped files which must use php-cli as interpreter

# Strip File (insert to /bin/exe) (Plain PHP Execute)
strip = code.php -> exe

# Strip File (insert to /usr/share/php/diffget/diffget_server.php) - File will not be executable!
strip(/usr/share/php/diffget) = diffget_server.php -> diffget_server.php
