Skip to content

Commit

Permalink
Test against clang in HerculesCI
Browse files Browse the repository at this point in the history
  • Loading branch information
jbboehr committed Jun 28, 2020
1 parent 1160fd6 commit 909f319
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
14 changes: 12 additions & 2 deletions ci.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,35 @@ let
std = let
php = pkgs.${phpAttr};
in pkgs.callPackage ./default.nix {
php = pkgs.${phpAttr};
inherit php;
buildPecl = pkgs.callPackage "${path}/pkgs/build-support/build-pecl.nix" { inherit php; };
astSupport = false;
};
# i686
i686 = let
php = pkgs.pkgsi686Linux.${phpAttr};
in pkgs.pkgsi686Linux.callPackage ./default.nix {
inherit php;
buildPecl = pkgs.pkgsi686Linux.callPackage "${path}/pkgs/build-support/build-pecl.nix" { inherit php; };
astSupport = true;
};
# ast
ast = let
php = pkgs.${phpAttr};
in pkgs.callPackage ./default.nix {
php = pkgs.${phpAttr};
inherit php;
buildPecl = pkgs.callPackage "${path}/pkgs/build-support/build-pecl.nix" { inherit php; };
astSupport = true;
};
# clang
clang = let
php = pkgs.${phpAttr};
stdenv = pkgs.clangStdenv;
in pkgs.callPackage ./default.nix {
inherit stdenv php;
buildPecl = pkgs.callPackage "${path}/pkgs/build-support/build-pecl.nix" { inherit php stdenv; };
astSupport = true;
};
};
in
builtins.mapAttrs (k: _v:
Expand Down
11 changes: 11 additions & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ if test "$PHP_HANDLEBARS" != "no"; then
-Wno-jump-misses-init -Wno-error=jump-misses-init \
-Wno-clobbered -Wno-error=clobbered \
-Wno-shadow -Wno-error=shadow \
-Wno-double-promotion -Wno-error=double-promotion \
-Wno-cast-align -Wno-error=cast-align \
-Wno-missing-braces -Wno-error=missing-braces \
])
CFLAGS="$WARN_CFLAGS $CFLAGS"
LDFLAGS="$WARN_LDFLAGS $LDFLAGS"
Expand Down Expand Up @@ -113,6 +116,14 @@ if test "$PHP_HANDLEBARS" != "no"; then
fi

# extension
AS_IF([test "$CLANG" = "yes"], [
AH_BOTTOM([
#ifdef __clang__
#include "main/php_config.h"
#/**/undef/**/ HAVE_ASM_GOTO
#endif
])
])
PHP_HANDLEBARS_ADD_SOURCES([
src/php_handlebars.c
src/impl.c
Expand Down
20 changes: 12 additions & 8 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# when using nix-shell, run "configurePhase" otherwise you'll have missing headers
# to use a specific version of php, run `nix-shell --arg php '(import <nixpkgs> {}).php73'`

# or clang: nix-shell --arg stdenv '(import <nixpkgs> {}).clangStdenv'
{
pkgs ? import <nixpkgs> {},
stdenv ? pkgs.stdenv,
php ? pkgs.php,
buildPecl ? pkgs.callPackage <nixpkgs/pkgs/build-support/build-pecl.nix> {
inherit php;
inherit php stdenv;
},
gitignoreSource ? (import (pkgs.fetchFromGitHub {
owner = "hercules-ci";
Expand All @@ -28,27 +29,30 @@
url = "https://github.com/jbboehr/handlebars.c/archive/8fe6213e3a15dec63e824d90e124949fffb07b91.tar.gz";
sha256 = "1h3b851b2333kj34wcgn7162iwghisa2jabryq0avl2alkf7ppfv";
})) {
inherit stdenv;
inherit mustache_spec handlebars_spec;
inherit debugSupport devSupport hardeningSupport staticSupport valgrindSupport WerrorSupport;
sharedSupport = !staticSupport;
inherit debugSupport devSupport hardeningSupport ltoSupport valgrindSupport WerrorSupport;
sharedSupport = (!staticSupport && !ltoSupport);
staticSupport = (ltoSupport || staticSupport);
},

php_psr ? pkgs.callPackage (import (fetchTarball {
url = https://github.com/jbboehr/php-psr/archive/v1.0.0.tar.gz;
sha256 = "12237b392rz224r4d8p6pwnldpl2bfrvpcim5947avjd49sn8ss4";
url = https://github.com/jbboehr/php-psr/archive/7d35501d6c39f2ada1a728ccb8c1a299bd682087.tar.gz;
sha256 = "1b5qll9j9x8k8s69wfndpg59di0pi1qvi1h6p5kg3fqasvy5zw28";
})) { inherit buildPecl; },

phpHandlebarsVersion ? "v0.9.1",
phpHandlebarsSha256 ? null,
phpHandlebarsSrc ? pkgs.lib.cleanSourceWith {
filter = (path: type: (builtins.all (x: x != baseNameOf path) [".idea" ".git" "ci.nix" ".travis.sh" ".travis.yml"]));
filter = (path: type: (builtins.all (x: x != baseNameOf path) [".idea" ".git" "ci.nix" ".travis.sh" ".travis.yml" ".ci"]));
src = gitignoreSource ./.;
},

astSupport ? false,
checkSupport ? true,
debugSupport ? false,
devSupport ? false,
ltoSupport ? false,
hardeningSupport ? true,
psrSupport ? true,
WerrorSupport ? (debugSupport || devSupport),
Expand All @@ -57,7 +61,7 @@
}:

pkgs.callPackage ./derivation.nix {
inherit buildPecl handlebarsc php_psr phpHandlebarsVersion phpHandlebarsSrc phpHandlebarsSha256;
inherit stdenv buildPecl handlebarsc php_psr phpHandlebarsVersion phpHandlebarsSrc phpHandlebarsSha256;
inherit handlebars_spec mustache_spec;
inherit astSupport checkSupport debugSupport devSupport hardeningSupport psrSupport valgrindSupport WerrorSupport;
}
4 changes: 4 additions & 0 deletions src/php_handlebars.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ static PHP_MINFO_FUNCTION(handlebars)
if( HANDLEBARS_G(cache) ) {
struct handlebars_cache_stat stat = handlebars_cache_stat(HANDLEBARS_G(cache));

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
#endif

php_info_print_table_start();
php_info_print_table_colspan_header(2, (char *) "Cache");
Expand Down Expand Up @@ -266,7 +268,9 @@ static PHP_MINFO_FUNCTION(handlebars)
snprintf(buf, sizeof(buf), "%zu", stat.collisions);
php_info_print_table_row(2, "Collisions", buf);

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

php_info_print_table_end();
}
Expand Down

0 comments on commit 909f319

Please sign in to comment.