Alien-Xmake
view release on metacpan or search on metacpan
eg/nuklear/nuklear.pl view on Meta::CPAN
my $src_dir = $RealBin;
my $dest_dir = $RealBin; # install the .dll/.so next to this script
my $ext = $^O eq 'MSWin32' ? '.dll' : $^O eq 'darwin' ? '.dylib' : '.so';
my $artifact = File::Spec->catfile( $dest_dir, "nk_win$ext" );
my $tool = Alien::Xmake->new( verbose => 0, yes => 1 );
die 'no xmake available via Alien::Xmake' unless $tool->exe;
# Run `xmake <action>` in $dir (a temp copy of the project), feeding repeated "y" answers on stdin.
# xmake's first-run package install reads io.read() and ignores the global --yes/-y flag, so a
# piped/redirected "y" is the only way to answer it without a TTY. We redirect stdin from a temp
# file of "y"s via the shell; stdout/stderr are inherited so the user sees xmake's progress.
sub run_xmake ( $dir, @args ) {
local $ENV{XMAKE_THEME} = 'plain';
my ( $fh, $yfile ) = tempfile( SUFFIX => '.in', UNLINK => 0 );
print {$fh} ("y\n") x 16;
close $fh or die "close $yfile: $!";
chdir $dir or die "chdir $dir: $!";
my $cmd = join ' ', map { /\s/ ? '"' . $_ . '"' : $_ } ( $tool->exe, @args );
return system("$cmd < $yfile") == 0;
}
eg/nuklear/nuklear_xlib.h view on Meta::CPAN
free(surf);
}
NK_API XFont*
nk_xfont_create(Display *dpy, const char *name)
{
#ifdef NK_XLIB_USE_XFT
XFont *font = (XFont*)calloc(1, sizeof(XFont));
font->ft = XftFontOpenName(dpy, XDefaultScreen(dpy), name);
if (!font->ft) {
fprintf(stderr, "missing font: %s\n", name);
return font;
}
font->ascent = font->ft->ascent;
font->descent = font->ft->descent;
font->height = font->ft->height;
#else
int n;
char *def, **missing;
XFont *font = (XFont*)calloc(1, sizeof(XFont));
font->set = XCreateFontSet(dpy, name, &missing, &n, &def);
if(missing) {
while(n--)
fprintf(stderr, "missing fontset: %s\n", missing[n]);
XFreeStringList(missing);
}
if(font->set) {
XFontStruct **xfonts;
char **font_names;
XExtentsOfFontSet(font->set);
n = XFontsOfFontSet(font->set, &xfonts, &font_names);
while(n--) {
font->ascent = NK_MAX(font->ascent, (*xfonts)->ascent);
font->descent = NK_MAX(font->descent,(*xfonts)->descent);
t/000_compile.t view on Meta::CPAN
my $xmake = Alien::Xmake->new;
diag 'Install type: ' . $xmake->install_type;
diag 'Xmake version: ' . $xmake->version;
use Capture::Tiny qw[capture];
my $exe = $xmake->exe;
diag 'Path to exe: ' . $exe;
qx["$exe" g --theme=plain];
#
subtest xmake => sub {
diag 'Path to exe: ' . $exe;
my ( $stdout, $stderr, $exit ) = capture { system $exe, '--version' };
is $exit, 0, $exe . ' --version';
diag $stdout if length $stdout;
diag $stderr if length $stderr;
};
#
subtest xrepo => sub {
my ( $stdout, $stderr, $exit ) = capture { system $exe, 'lua', 'private.xrepo', '--version' };
is $exit, 0, $exe . ' --version';
diag $stdout if length $stdout;
diag $stderr if length $stderr;
};
#
done_testing;
t/002_build_cpp.t view on Meta::CPAN
use Capture::Tiny qw[capture];
my $dir = tempdir();
#
use Alien::Xmake;
#
my $xmake = Alien::Xmake->new;
{
my $exe = $xmake->exe;
qx["$exe" g --theme=plain];
chdir $dir;
my ( $stdout, $stderr, $exit ) = capture { system $exe, qw[create --quiet --project=test_cpp --language=c++ --template=console] };
ok( ( -d 'test_cpp' ), 'project created' );
#~ ok !$exit, 'project created';
diag $stdout if $exit && length $stdout;
diag $stderr if $exit && length $stderr;
chdir 'test_cpp';
subtest compile => sub {
my $todo = todo 'Require a working compiler'; # outside the scope of Alien::Xmake
diag 'Building project..';
( $stdout, $stderr, $exit ) = capture { system $exe, '--quiet' };
ok !$exit, 'project built';
diag $stdout if $exit && length $stdout;
diag $stderr if $exit && length $stderr;
( $stdout, $stderr, $exit ) = capture { system $exe, 'run' };
ok $stdout =~ /hello world!/, 'project says hello';
diag $stdout if $exit && length $stdout;
diag $stderr if $exit && length $stderr;
}
}
#
done_testing;
( run in 0.827 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )