From b479a3997569d51c3c52581838e878e38aeb6db2 Mon Sep 17 00:00:00 2001 From: Filip Halaxa Date: Sat, 6 May 2023 19:36:58 +0200 Subject: [PATCH] make ext-build, make ext-build-debug --- Makefile | 14 +++++---- ext/build/Dockerfile | 10 +++++-- test/JsonMachineTest/ExtJsonmachineTest.php | 33 --------------------- test/performance/testPerformance.php | 2 ++ 4 files changed, 19 insertions(+), 40 deletions(-) delete mode 100644 test/JsonMachineTest/ExtJsonmachineTest.php diff --git a/Makefile b/Makefile index fc06df1..e8f5082 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/ext/build/Dockerfile b/ext/build/Dockerfile index c33dc29..840c869 100644 --- a/ext/build/Dockerfile +++ b/ext/build/Dockerfile @@ -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` \ diff --git a/test/JsonMachineTest/ExtJsonmachineTest.php b/test/JsonMachineTest/ExtJsonmachineTest.php deleted file mode 100644 index b6ca5c5..0000000 --- a/test/JsonMachineTest/ExtJsonmachineTest.php +++ /dev/null @@ -1,33 +0,0 @@ -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(); - } - } -} diff --git a/test/performance/testPerformance.php b/test/performance/testPerformance.php index 042ea51..097f3bb 100644 --- a/test/performance/testPerformance.php +++ b/test/performance/testPerformance.php @@ -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 {