Skip to content

Commit ea303b6

Browse files
committed
initial release ready
1 parent 5ca65db commit ea303b6

File tree

9 files changed

+103
-91
lines changed

9 files changed

+103
-91
lines changed

MANIFEST

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
MANIFEST
2-
README.md
3-
LICENSE
4-
Todo
1+
jq/scripts/gen_builtin_inc.pl
2+
jq/src/setenv.h
3+
jq/src/setenv.c
4+
jq/builtin.c.patch
5+
jq/CMakeLists.txt
6+
jq/Config.cmake.in
7+
jq/dist.info
8+
jq/jq.pc.cmake.in
9+
lib/Alien/LibJQ.pm
10+
t/001_load.t
11+
alienfile
512
Changes
13+
LICENSE
614
Makefile.PL
7-
lib/Alien/LibJQ.pm
8-
t/001_load.t
15+
MANIFEST
16+
README.md

Makefile.PL

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ use File::Spec;
66
use Alien::Build;
77
use Alien::Build::MM;
88

9-
build_libonig();
10-
exit 0;
11-
129
my $alien_build_version = '2.37';
1310
my $ext_makemaker_version = '7.46';
1411

@@ -60,18 +57,4 @@ WriteMakefile($abmm->mm_args(%WriteMakefileArgs));
6057

6158
sub MY::postamble {
6259
$abmm->mm_postamble;
63-
}
64-
65-
sub build_libonig {
66-
my $build = Alien::Build->load('libonig.alienfile');
67-
my $prefix = File::Spec->catdir($build->root, 'install');
68-
return if -f File::Spec->catfile($prefix, 'lib', 'libonig.a');
69-
$build->load_requires('configure');
70-
$build->set_prefix($build);
71-
$build->set_stage($prefix);
72-
# for some reason, set_prefix doesn't work, set manually
73-
$build->install_prop->{prefix} = $prefix;
74-
$build->load_requires($build->install_type);
75-
$build->download;
76-
$build->build;
77-
}
60+
}

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ Install as usual:
1919

2020
## How This Module Performs the Build
2121

22-
1. Download oniguruma package and build static library using cmake.
23-
2. Download and extract jq package.
24-
3. Copy required script/cmake/source files into extracted jq package directory.
25-
4. Build jq executable and static library using cmake.
26-
5. Install both oniguruma and jq artifacts.
22+
1. Download and extract jq package.
23+
2. Copy required script/cmake/source files into extracted jq package directory.
24+
3. Build jq executable and jq/oniguruma static libraries using cmake.
25+
4. Install both jq and oniguruma artifacts.
2726

2827
## Cmake Advantage
2928

Todo

Lines changed: 0 additions & 5 deletions
This file was deleted.

alienfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use alienfile;
2+
3+
use File::Spec::Functions qw/catfile/;
4+
5+
# download utility available
6+
plugin 'Probe::CommandLine' => (
7+
command => 'curl',
8+
);
9+
plugin 'Probe::CommandLine' => (
10+
command => 'wget',
11+
secondary => 1,
12+
);
13+
14+
share {
15+
#start_url 'https://github.com/stedolan/jq/releases/';
16+
# china mirror
17+
start_url 'https://hub.fastgit.org/stedolan/jq/releases/';
18+
plugin Download => (
19+
version => qr/^jq-([0-9\.]+)\.tar\.gz$/o,
20+
);
21+
plugin Extract => 'tar.gz';
22+
plugin 'Build::CMake';
23+
# require Strawberry perl gmake.exe on windows
24+
plugin 'Build::Make' => ( $^O eq 'MSWin32' ? 'gmake' : 'make' );
25+
build [
26+
# pitch in required cmake stuff
27+
'echo %cd%',
28+
[ '%{cp}', catfile('..', '..', '..', 'jq', 'scripts', 'gen_builtin_inc.pl'), 'scripts' ],
29+
[ '%{cp}', catfile('..', '..', '..', 'jq', 'src', 'setenv.h'), 'src' ],
30+
[ '%{cp}', catfile('..', '..', '..', 'jq', 'src', 'setenv.c'), 'src' ],
31+
[ '%{cp}', catfile('..', '..', '..', 'jq', 'builtin.c.patch'), '.' ],
32+
[ '%{cp}', catfile('..', '..', '..', 'jq', 'CMakeLists.txt'), '.' ],
33+
[ '%{cp}', catfile('..', '..', '..', 'jq', 'Config.cmake.in'), '.' ],
34+
[ '%{cp}', catfile('..', '..', '..', 'jq', 'dist.info'), '.' ],
35+
[ '%{cp}', catfile('..', '..', '..', 'jq', 'jq.pc.cmake.in'), '.' ],
36+
# execute cmake build
37+
[ '%{cmake}', -G => '%{cmake_generator}', ( $^O eq 'MSWin32' ? '-DCMAKE_MAKE_PROGRAM=%{make}' : () ),
38+
'-DBUILD_SHARED_LIBS=OFF', '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
39+
'-DENABLE_MAINTAINER_MODE=OFF', '-DWITH_ONIGURUMA=builtin',
40+
'-DCMAKE_INSTALL_PREFIX=%{.install.prefix}',
41+
'.'
42+
],
43+
'%{make}',
44+
'%{make} install',
45+
];
46+
plugin 'Gather::IsolateDynamic';
47+
};

jq/CMakeLists.txt

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ endif()
7474
set(VERSION ${PACKAGE_VERSION})
7575
target_compile_definitions(jq_compiler_flags INTERFACE PACKAGE=${PACKAGE} VERSION=${VERSION})
7676

77+
include(modules/oniguruma/cmake/dist.cmake)
7778
include(CheckCSourceCompiles)
7879
include(CheckIncludeFiles)
7980
include(CheckFunctionExists)
@@ -231,6 +232,7 @@ check_symbol_exists(trunc "math.h" HAVE_TRUNC)
231232
check_symbol_exists(y0 "math.h" HAVE_Y0)
232233
check_symbol_exists(y1 "math.h" HAVE_Y1)
233234
check_symbol_exists(yn "math.h" HAVE_YN)
235+
unset(CMAKE_REQUIRED_LIBRARIES)
234236
target_compile_definitions_if_true(
235237
HAVE_ACOSH
236238
HAVE_ACOS
@@ -399,6 +401,10 @@ set_source_files_properties(src/builtin.c PROPERTIES OBJECT_DEPENDS src/builtin.
399401

400402
if(${WITH_ONIGURUMA} STREQUAL "builtin")
401403
target_link_libraries(jq PUBLIC onig)
404+
target_include_directories(jq PUBLIC
405+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/modules/oniguruma/src>
406+
$<INSTALL_INTERFACE:include>
407+
)
402408
elseif(HAVE_LIBONIG)
403409
target_link_libraries(jq PUBLIC oniguruma::onig)
404410
endif()
@@ -432,28 +438,11 @@ endif()
432438
if(ENABLE_DOCS)
433439
endif()
434440

435-
# TODO: support packaging using CPack
436-
install(TARGETS jq_bin DESTINATION bin)
437-
install(TARGETS jq DESTINATION lib EXPORT jqTargets)
438-
install(FILES src/jv.h src/jq.h DESTINATION include)
439-
install(EXPORT jqTargets FILE jqTargets.cmake DESTINATION lib/cmake/jq)
440-
441-
include(CMakePackageConfigHelpers)
442-
configure_package_config_file(
443-
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
444-
${CMAKE_CURRENT_BINARY_DIR}/jqConfig.cmake
445-
INSTALL_DESTINATION lib/cmake/jq
446-
NO_SET_AND_CHECK_MACRO
447-
NO_CHECK_REQUIRED_COMPONENTS_MACRO
448-
)
449-
write_basic_package_version_file(
450-
${CMAKE_CURRENT_BINARY_DIR}/jqConfigVersion.cmake
451-
VERSION ${PACKAGE_VERSION}
452-
COMPATIBILITY AnyNewerVersion
453-
)
454-
install(FILES
455-
${CMAKE_CURRENT_BINARY_DIR}/jqConfig.cmake
456-
${CMAKE_CURRENT_BINARY_DIR}/jqConfigVersion.cmake
457-
DESTINATION lib/cmake/jq
458-
)
459-
#export(EXPORT jqTargets FILE ${CMAKE_CURRENT_BINARY_DIR}/jqTargets.cmake)
441+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jq.pc.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/jq.pc @ONLY)
442+
443+
# TODO: support full packaging
444+
install_library(jq)
445+
install_executable(jq_bin)
446+
install_header(src/jv.h src/jq.h)
447+
install_data(AUTHORS COPYING NEWS README)
448+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jq.pc DESTINATION lib/pkgconfig)

jq/dist.info

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- This file is part of LuaDist project
2+
3+
name = "jq"
4+
version = "1.6"
5+
6+
desc = "jq is a lightweight and flexible command-line JSON processor."
7+
author = "https://github.com/stedolan/jq/graphs/contributors"
8+
license = "https://github.com/stedolan/jq/blob/master/COPYING"
9+
url = "https://stedolan.github.io/jq/"
10+
maintainer = "https://github.com/stedolan/jq/graphs/contributors"

jq/jq.pc.cmake.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
exec_prefix=${prefix}
3+
libdir=${exec_prefix}/lib
4+
includedir=${prefix}/include
5+
datarootdir=${prefix}/share
6+
datadir=${prefix}/share
7+
8+
Name: jq
9+
Description: lightweight and flexible command-line JSON processor
10+
Version: @PACKAGE_VERSION@
11+
Requires:
12+
Libs: -L${libdir} -ljq -lonig
13+
Cflags: -I${includedir}

libonig.alienfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)