Alien-LibJQ
view release on metacpan or search on metacpan
jq/scripts/gen_builtin_inc.pl
jq/src/setenv.h
jq/src/setenv.c
jq/builtin.c.patch
jq/CMakeLists.txt
jq/Config.cmake.in
jq/dist.info
jq/jq.pc.cmake.in
lib/Alien/LibJQ.pm
t/001_load.t
alienfile
Changes
LICENSE
## How This Module Performs the Build
1. Download and extract jq package.
2. Copy required script/cmake/source files into extracted jq package directory.
3. Build jq executable and jq/oniguruma static libraries using cmake.
4. Install both jq and oniguruma artifacts.
## Cmake Advantage
1. Enhanced compile and link toolchain.
2. Fix a jq code portability issue (calling POSIX setenv) on windows mingw.
## Windows Build Note
1. Only strawberry perl is tested.
2. Alien::cmake3 is required to build using cmake.
3. It is possible to build this package using autoconf approach on windows:
1. strawberry is required to provide a working gcc toolchain from mingw.
2. git windows package is required to offer bash executable on windows, installation path must NOT contain space (thus C:\Program Files not recommended).
3. run configure using sh/bash executable.
4. replace all MAKE variable value in generated Makefile by 'gmake' (from strawberry).
plugin Download => (
filter => qr/^jq-.+?\.tar\.gz$/,
version => qr/[0-9\.]+/,
);
plugin Extract => 'tar.gz';
plugin 'Build::CMake';
build [
# pitch in required cmake stuff
'echo %cd%',
[ '%{cp}', catfile('..', '..', '..', 'jq', 'scripts', 'gen_builtin_inc.pl'), 'scripts' ],
[ '%{cp}', catfile('..', '..', '..', 'jq', 'src', 'setenv.h'), 'src' ],
[ '%{cp}', catfile('..', '..', '..', 'jq', 'src', 'setenv.c'), 'src' ],
[ '%{cp}', catfile('..', '..', '..', 'jq', 'builtin.c.patch'), '.' ],
[ '%{cp}', catfile('..', '..', '..', 'jq', 'CMakeLists.txt'), '.' ],
[ '%{cp}', catfile('..', '..', '..', 'jq', 'Config.cmake.in'), '.' ],
[ '%{cp}', catfile('..', '..', '..', 'jq', 'dist.info'), '.' ],
[ '%{cp}', catfile('..', '..', '..', 'jq', 'jq.pc.cmake.in'), '.' ],
# execute cmake build
[ '%{cmake}', -G => '%{cmake_generator}', ( $^O eq 'MSWin32' ? '-DCMAKE_MAKE_PROGRAM=%{make}' : () ),
'-DBUILD_SHARED_LIBS=OFF', '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
'-DENABLE_MAINTAINER_MODE=OFF', '-DWITH_ONIGURUMA=builtin',
'-DCMAKE_INSTALL_PREFIX=%{.install.prefix}',
jq/CMakeLists.txt view on Meta::CPAN
if(${WITH_ONIGURUMA} STREQUAL "builtin")
target_link_libraries(jq PUBLIC onig)
target_include_directories(jq PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/modules/oniguruma/src>
$<INSTALL_INTERFACE:include>
)
elseif(HAVE_LIBONIG)
target_link_libraries(jq PUBLIC oniguruma::onig)
endif()
# src/builtin.c calls setenv, which is not portable on windows
# below check will add a local implementation and compile
if(WIN32 AND MINGW)
check_symbol_exists(setenv "stdlib.h" HAVE_SETENV)
target_compile_definitions_if_true(HAVE_SETENV)
if(NOT HAVE_SETENV)
target_sources(jq PRIVATE
src/setenv.h src/setenv.c
)
message(STATUS "patching src/builtin.c")
execute_process(
COMMAND patch -p0 -N --binary -i builtin.c.patch
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
endif()
add_executable(jq_bin src/main.c src/version.h)
jq/builtin.c.patch view on Meta::CPAN
--- src/builtin.c.orig 2021-02-20 21:23:48.927878700 +0800
+++ src/builtin.c 2021-02-20 21:27:36.698376700 +0800
@@ -42,6 +42,9 @@
#include "locfile.h"
#include "jv_unicode.h"
#include "jv_alloc.h"
+#ifndef HAVE_SETENV
+#include "setenv.h"
+#endif
static jv type_error(jv bad, const char* msg) {
jq/src/setenv.c view on Meta::CPAN
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "setenv.h"
/*-------------------------------------------------------------------------
*
* setenv.c
* setenv() emulation for machines without it
*
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* src/port/setenv.c
*
*-------------------------------------------------------------------------
*/
int
setenv(const char *name, const char *value, int overwrite) {
char *envstr;
/* Error conditions, per POSIX */
if (name == NULL || name[0] == '\0' || strchr(name, '=') != NULL || value == NULL) {
errno = EINVAL;
return -1;
}
/* No work if variable exists and we're not to replace it */
if (overwrite == 0 && getenv(name) != NULL)
jq/src/setenv.h view on Meta::CPAN
#ifndef SETENV_H
#define SETENV_H
int setenv(const char *name, const char *value, int overwrite);
#endif
( run in 0.429 second using v1.01-cache-2.11-cpan-3989ada0592 )