Repository: lucy-clownfish
Updated Branches:
refs/heads/master ce5e65bb0 -> a47be68a0
Add option to use system cmark
For the Perl build:
perl Build.PL --with_system_cmark=1
For the C build:
./configure --with-system-cmark
Fixes CLOWNFISH-87.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/a47be68a
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/a47be68a
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/a47be68a
Branch: refs/heads/master
Commit: a47be68a0fdf2d2e9f82fc724e1cc916d1d43121
Parents: ce5e65b
Author: Nick Wellnhofer <[email protected]>
Authored: Sat Aug 6 19:58:24 2016 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Sat Aug 6 20:50:12 2016 +0200
----------------------------------------------------------------------
compiler/c/INSTALL.md | 4 ++++
compiler/common/charmonizer.c | 18 +++++++++++++--
compiler/common/charmonizer.main | 18 +++++++++++++--
compiler/perl/INSTALL.md | 11 +++++++++
compiler/perl/buildlib/Clownfish/CFC/Build.pm | 27 +++++++++++++++++++---
5 files changed, 71 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a47be68a/compiler/c/INSTALL.md
----------------------------------------------------------------------
diff --git a/compiler/c/INSTALL.md b/compiler/c/INSTALL.md
index 838563c..17ba47a 100644
--- a/compiler/c/INSTALL.md
+++ b/compiler/c/INSTALL.md
@@ -42,3 +42,7 @@ Options include
Enable code coverage. Create HTML pages with coverage data using
lcov by running "make coverage".
+ --with-system-cmark
+ The Clownfish compiler is built with a bundled version of libcmark
+ by default. Use this option if you want to link against the system
+ libcmark.
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a47be68a/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index 2d828f7..8bafbca 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -8627,6 +8627,8 @@ int main(int argc, const char **argv) {
CHAZ_CLI_ARG_REQUIRED);
chaz_CLI_register(cli, "disable-threads", "whether to disable threads",
CHAZ_CLI_NO_ARG);
+ chaz_CLI_register(cli, "with-system-cmark", "use system cmark library",
+ CHAZ_CLI_NO_ARG);
chaz_CLI_set_usage(cli, "Usage: charmonizer [OPTIONS] [-- [CFLAGS]]");
{
int result = chaz_Probe_parse_cli_args(argc, argv, cli);
@@ -8712,6 +8714,8 @@ static void
S_write_makefile(struct chaz_CLI *cli) {
SourceFileContext sfc;
+ int with_system_cmark = chaz_CLI_defined(cli, "with-system-cmark");
+
const char *base_dir = "..";
const char *dir_sep = chaz_OS_dir_sep();
const char *host = chaz_CLI_strval(cli, "host");
@@ -8758,7 +8762,9 @@ S_write_makefile(struct chaz_CLI *cli) {
chaz_CFlags_add_include_dir(makefile_cflags, ".");
chaz_CFlags_add_include_dir(makefile_cflags, include_dir);
chaz_CFlags_add_include_dir(makefile_cflags, src_dir);
- chaz_CFlags_add_include_dir(makefile_cflags, cmark_dir);
+ if (!with_system_cmark) {
+ chaz_CFlags_add_include_dir(makefile_cflags, cmark_dir);
+ }
if (chaz_CLI_defined(cli, "enable-coverage")) {
chaz_CFlags_enable_code_coverage(makefile_cflags);
}
@@ -8780,6 +8786,9 @@ S_write_makefile(struct chaz_CLI *cli) {
chaz_MakeBinary_add_prereq(exe, "$(CFC_STATIC_LIB)");
link_flags = chaz_MakeBinary_get_link_flags(exe);
chaz_CFlags_append(link_flags, "$(CFC_STATIC_LIB)");
+ if (with_system_cmark) {
+ chaz_CFlags_add_external_lib(link_flags, "cmark");
+ }
compile_flags = chaz_MakeBinary_get_compile_flags(exe);
chaz_CFlags_append(compile_flags, "$(CFC_CFLAGS)");
@@ -8788,6 +8797,9 @@ S_write_makefile(struct chaz_CLI *cli) {
chaz_MakeBinary_add_prereq(test_exe, "$(CFC_STATIC_LIB)");
link_flags = chaz_MakeBinary_get_link_flags(test_exe);
chaz_CFlags_append(link_flags, "$(CFC_STATIC_LIB)");
+ if (with_system_cmark) {
+ chaz_CFlags_add_external_lib(link_flags, "cmark");
+ }
compile_flags = chaz_MakeBinary_get_compile_flags(test_exe);
chaz_CFlags_append(compile_flags, "$(CFC_CFLAGS)");
}
@@ -8806,7 +8818,9 @@ S_write_makefile(struct chaz_CLI *cli) {
sfc.core_binary = lib;
sfc.test_binary = test_exe;
chaz_Make_list_files(src_dir, "c", S_source_file_callback, &sfc);
- chaz_Make_list_files(cmark_dir, "c", S_source_file_callback, &sfc);
+ if (!with_system_cmark) {
+ chaz_Make_list_files(cmark_dir, "c", S_source_file_callback, &sfc);
+ }
chaz_MakeBinary_add_src_file(lib, src_dir, "CFCParseHeader.c");
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a47be68a/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.main b/compiler/common/charmonizer.main
index ce4ec07..7d24ea6 100644
--- a/compiler/common/charmonizer.main
+++ b/compiler/common/charmonizer.main
@@ -48,6 +48,8 @@ int main(int argc, const char **argv) {
CHAZ_CLI_ARG_REQUIRED);
chaz_CLI_register(cli, "disable-threads", "whether to disable threads",
CHAZ_CLI_NO_ARG);
+ chaz_CLI_register(cli, "with-system-cmark", "use system cmark library",
+ CHAZ_CLI_NO_ARG);
chaz_CLI_set_usage(cli, "Usage: charmonizer [OPTIONS] [-- [CFLAGS]]");
{
int result = chaz_Probe_parse_cli_args(argc, argv, cli);
@@ -133,6 +135,8 @@ static void
S_write_makefile(struct chaz_CLI *cli) {
SourceFileContext sfc;
+ int with_system_cmark = chaz_CLI_defined(cli, "with-system-cmark");
+
const char *base_dir = "..";
const char *dir_sep = chaz_OS_dir_sep();
const char *host = chaz_CLI_strval(cli, "host");
@@ -179,7 +183,9 @@ S_write_makefile(struct chaz_CLI *cli) {
chaz_CFlags_add_include_dir(makefile_cflags, ".");
chaz_CFlags_add_include_dir(makefile_cflags, include_dir);
chaz_CFlags_add_include_dir(makefile_cflags, src_dir);
- chaz_CFlags_add_include_dir(makefile_cflags, cmark_dir);
+ if (!with_system_cmark) {
+ chaz_CFlags_add_include_dir(makefile_cflags, cmark_dir);
+ }
if (chaz_CLI_defined(cli, "enable-coverage")) {
chaz_CFlags_enable_code_coverage(makefile_cflags);
}
@@ -201,6 +207,9 @@ S_write_makefile(struct chaz_CLI *cli) {
chaz_MakeBinary_add_prereq(exe, "$(CFC_STATIC_LIB)");
link_flags = chaz_MakeBinary_get_link_flags(exe);
chaz_CFlags_append(link_flags, "$(CFC_STATIC_LIB)");
+ if (with_system_cmark) {
+ chaz_CFlags_add_external_lib(link_flags, "cmark");
+ }
compile_flags = chaz_MakeBinary_get_compile_flags(exe);
chaz_CFlags_append(compile_flags, "$(CFC_CFLAGS)");
@@ -209,6 +218,9 @@ S_write_makefile(struct chaz_CLI *cli) {
chaz_MakeBinary_add_prereq(test_exe, "$(CFC_STATIC_LIB)");
link_flags = chaz_MakeBinary_get_link_flags(test_exe);
chaz_CFlags_append(link_flags, "$(CFC_STATIC_LIB)");
+ if (with_system_cmark) {
+ chaz_CFlags_add_external_lib(link_flags, "cmark");
+ }
compile_flags = chaz_MakeBinary_get_compile_flags(test_exe);
chaz_CFlags_append(compile_flags, "$(CFC_CFLAGS)");
}
@@ -227,7 +239,9 @@ S_write_makefile(struct chaz_CLI *cli) {
sfc.core_binary = lib;
sfc.test_binary = test_exe;
chaz_Make_list_files(src_dir, "c", S_source_file_callback, &sfc);
- chaz_Make_list_files(cmark_dir, "c", S_source_file_callback, &sfc);
+ if (!with_system_cmark) {
+ chaz_Make_list_files(cmark_dir, "c", S_source_file_callback, &sfc);
+ }
chaz_MakeBinary_add_src_file(lib, src_dir, "CFCParseHeader.c");
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a47be68a/compiler/perl/INSTALL.md
----------------------------------------------------------------------
diff --git a/compiler/perl/INSTALL.md b/compiler/perl/INSTALL.md
index fd08127..2640c53 100644
--- a/compiler/perl/INSTALL.md
+++ b/compiler/perl/INSTALL.md
@@ -9,3 +9,14 @@ following commands:
perl Build test
perl Build install
+The Clownfish compiler is built with a bundled version of libcmark by
+default. If you want to link against the system libcmark, run Build.PL
+with `--with_system_cmark=1`:
+
+ perl Build.PL --with_system_cmark=1
+
+If ExtUtils::PkgConfig is installed, it is used to retrieve information
+about the system cmark library. Otherwise, only `-lcmark` is added to
+the extra linker flags. In this case, you may have to provide additional
+flags with `--extra-compiler-flags` and `--extra-linker-flags`.
+
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a47be68a/compiler/perl/buildlib/Clownfish/CFC/Build.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/buildlib/Clownfish/CFC/Build.pm
b/compiler/perl/buildlib/Clownfish/CFC/Build.pm
index bd649d8..a6bb979 100644
--- a/compiler/perl/buildlib/Clownfish/CFC/Build.pm
+++ b/compiler/perl/buildlib/Clownfish/CFC/Build.pm
@@ -62,24 +62,45 @@ my $CMARK_SOURCE_DIR = catdir( $MODULES_DIR, 'CommonMark',
'src' );
my $LEMON_EXE_PATH = catfile( $LEMON_DIR, "lemon$Config{_exe}" );
my $PPPORT_H_PATH = catfile( $INCLUDE, 'ppport.h' );
+__PACKAGE__->add_property('with_system_cmark');
+
sub new {
my ( $class, %args ) = @_;
- $args{c_source} = [ $CFC_SOURCE_DIR, $CMARK_SOURCE_DIR ];
+ $args{c_source} = [ $CFC_SOURCE_DIR ];
$args{include_dirs} ||= [];
my @aux_include = (
$INCLUDE,
$CFC_SOURCE_DIR,
- $CMARK_SOURCE_DIR,
curdir(), # for charmony.h
);
push @{ $args{include_dirs} }, @aux_include;
- return $class->SUPER::new(
+ my $self = $class->SUPER::new(
%args,
recursive_test_files => 1,
charmonizer_params => {
charmonizer_c => $CHARMONIZER_C,
},
);
+ if ($self->with_system_cmark) {
+ my %pkg_info = eval {
+ require ExtUtils::PkgConfig;
+ ExtUtils::PkgConfig->find('libcmark');
+ };
+ if ($@) {
+ push @{ $self->extra_linker_flags }, '-lcmark';
+ }
+ else {
+ push @{ $self->extra_compiler_flags }, $pkg_info{cflags}
+ if defined $pkg_info{cflags};
+ push @{ $self->extra_linker_flags }, $pkg_info{libs}
+ if defined $pkg_info{libs};
+ }
+ }
+ else {
+ push @{ $self->c_source }, $CMARK_SOURCE_DIR;
+ push @{ $self->include_dirs }, $CMARK_SOURCE_DIR;
+ }
+ return $self;
}
sub _run_make {