1
0
mirror of https://github.com/halaxa/json-machine.git synced 2025-01-17 04:58:16 +01:00

make ext-build, make ext-build-debug

This commit is contained in:
Filip Halaxa 2023-05-06 19:36:58 +02:00
parent f3bc5ecb10
commit b479a39975
4 changed files with 19 additions and 40 deletions

View File

@ -108,14 +108,18 @@ release: .env build
docker-run: ## Run a command in a latest JSON Machine PHP docker container. Ex.: make docker-run CMD="php -v"
@$(call DOCKER_RUN,$(LATEST_PHP),$(CMD))
ext-build: ## Build JSON Machine's PHP extension
docker build --tag json-machine-ext ext/build
EXT_BUILD_POST_CMD=composer performance-tests
ext-build: ## Build JSON Machine's PHP extension for production and run performance tests
docker build --tag json-machine-ext --build-arg debug=$(DEBUG) ext/build
docker rm json-machine-ext || true
docker run --volume "$$PWD:/json-machine" -it json-machine-ext /bin/bash -c \
"cd /json-machine/ext/jsonmachine; phpize && ./configure && make clean && make && make install && cd /json-machine && php -d xdebug.mode=off -d opcache.enable_cli=1 -d opcache.jit_buffer_size=100M test/performance/testPerformance.php"
"cd /json-machine/ext/jsonmachine; phpize && ./configure && make clean && make && make install && cd /json-machine && $(EXT_BUILD_POST_CMD)"
zephir: ## Build JSON Machine's PHP extension
ext-build-debug: DEBUG=--enable-debug
ext-build-debug: EXT_BUILD_POST_CMD=composer tests -- --colors=always
ext-build-debug: ext-build ## Build JSON Machine's PHP extension for development and run tests
zephir:
docker build --tag json-machine-zephir ext/jsonmachine
docker rm json-machine-zephir || true
docker run --volume "$$PWD:/json-machine" -it json-machine-zephir /bin/bash -c \

View File

@ -22,11 +22,16 @@ RUN apt update && apt-get install -y \
valgrind \
git \
libxml2-dev \
libsqlite3-dev
libsqlite3-dev \
wget \
libssl-dev
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN wget https://getcomposer.org/download/2.2.18/composer.phar -O /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer
RUN useradd --create-home --shell /bin/bash user
USER user
WORKDIR /home/user
@ -34,10 +39,11 @@ WORKDIR /home/user
# https://www.zend.com/setting-up-your-php-build-environment
RUN git clone https://github.com/php/php-src.git
ARG debug
RUN cd php-src \
&& git checkout php-8.0.9 \
&& ./buildconf --force \
&& ./configure --enable-mbstring --disable-mbregex \
&& ./configure $debug --enable-mbstring --disable-mbregex --with-openssl --enable-openssl \
--prefix=$HOME/php-bin \
--with-config-file-path=$HOME/php-bin/etc \
&& make -j`nproc` \

View File

@ -1,33 +0,0 @@
<?php
namespace JsonMachineTest;
use PHPUnit\Framework\TestCase;
class ExtJsonmachineTest extends TestCase
{
public function testExtensionLoaded()
{
$this->assertTrue(function_exists('jsonmachine_next_token'));
$lastIndex = 0;
$inString = false;
$escaping = false;
$tokenBuffer = "";
foreach (["[{\"one\": 1}, {\"two\": false}, {\"thr\\", "\"ee\": \"string\"}]"] as $chunk) {
while($token = jsonmachine_next_token($chunk, $tokenBuffer, $escaping, $inString, $lastIndex)) {
// var_dump($token, $tokenBuffer, $escaping, $inString, $lastIndex);
var_dump($token);
flush();
ob_flush();
}
// var_dump($token, $tokenBuffer, $escaping, $inString, $lastIndex);
var_dump($token);
flush();
ob_flush();
}
}
}

View File

@ -9,6 +9,8 @@ use JsonMachine\Parser;
require_once __DIR__.'/../../vendor/autoload.php';
passthru('php -v');
echo "Ext jsonmachine version: ". phpversion('jsonmachine') . PHP_EOL;
if ( ! ini_get('xdebug.mode')) {
echo "Xdebug disabled\n";
} else {