<commit_before># -*- python -*-

# stdlib imports ---
import os
import os.path as osp

# waf imports ---
import waflib.Utils
import waflib.Logs as msg
from waflib.Configure import conf

#
_heptooldir = osp.dirname(osp.abspath(__file__))

def options(opt):
    opt.load('hep-waftools-base', tooldir=_heptooldir)
    opt.add_option(
        '--with-libxml2',
        default=None,
        help="Look for LibXML2 at the given path")
    return

def configure(conf):
    conf.load('hep-waftools-base', tooldir=_heptooldir)
    return

@conf
def find_libxml2(ctx, **kwargs):
    
    if not ctx.env.CXX:
        msg.fatal('load a C++ compiler first')
        pass


    # find LibXML2
    xml_cfg = "xml2-config"
    path_list = []
    if ctx.options.with_libxml2:
        path_list.append(
            osp.abspath(
                osp.join(ctx.options.with_libxml2, "bin")
                )
            )
        pass

    
    ctx.find_program(
        xml_cfg,
        var='LIBXML2-CONFIG',
        path_list=path_list,
        **kwargs)
    #xml_cfg = ctx.env['LIBXML2-CONFIG']
    
    ctx.check_with(
        ctx.check_cfg,
        "xml2",
        path=xml_cfg,
        package="",
        uselib_store="libxml2",
        args='--cflags --libs',
        **kwargs)

    version = ctx.check_cxx(
        msg="Checking xml2 version",
        okmsg="ok",
        fragment='''\
        #include "libxml/xmlversion.h"
        #include <iostream>

        int main(int argc, char* argv[]) {
          std::cout << LIBXML_DOTTED_VERSION;
          return 0;
        }
        ''',
        use="libxml2",
        define_name = "HEPWAF_LIBXML2_VERSION",
        define_ret = True,
        execute  = True,
        mandatory=True,
        )
    ctx.start_msg("libxml2 version")
    ctx.end_msg(version)

    ctx.env.LIBXML2_VERSION = version
    ctx.env.HEPWAF_FOUND_LIBXML2 = 1
    return

## EOF ##
<commit_msg>libxml2: do not rely on 'options.with_libxml2'<commit_after># -*- python -*-

# stdlib imports ---
import os
import os.path as osp

# waf imports ---
import waflib.Utils
import waflib.Logs as msg
from waflib.Configure import conf

#
_heptooldir = osp.dirname(osp.abspath(__file__))

def options(opt):
    opt.load('hep-waftools-base', tooldir=_heptooldir)
    opt.add_option(
        '--with-libxml2',
        default=None,
        help="Look for LibXML2 at the given path")
    return

def configure(conf):
    conf.load('hep-waftools-base', tooldir=_heptooldir)
    return

@conf
def find_libxml2(ctx, **kwargs):
    
    if not ctx.env.CXX:
        msg.fatal('load a C++ compiler first')
        pass


    # find LibXML2
    xml_cfg = "xml2-config"
    path_list = []
    if getattr(ctx.options, 'with_libxml2', None):
        path_list.append(
            osp.abspath(
                osp.join(ctx.options.with_libxml2, "bin")
                )
            )
        pass

    
    ctx.find_program(
        xml_cfg,
        var='LIBXML2-CONFIG',
        path_list=path_list,
        **kwargs)
    #xml_cfg = ctx.env['LIBXML2-CONFIG']
    
    ctx.check_with(
        ctx.check_cfg,
        "xml2",
        path=xml_cfg,
        package="",
        uselib_store="libxml2",
        args='--cflags --libs',
        **kwargs)

    version = ctx.check_cxx(
        msg="Checking xml2 version",
        okmsg="ok",
        fragment='''\
        #include "libxml/xmlversion.h"
        #include <iostream>

        int main(int argc, char* argv[]) {
          std::cout << LIBXML_DOTTED_VERSION;
          return 0;
        }
        ''',
        use="libxml2",
        define_name = "HEPWAF_LIBXML2_VERSION",
        define_ret = True,
        execute  = True,
        mandatory=True,
        )
    ctx.start_msg("libxml2 version")
    ctx.end_msg(version)

    ctx.env.LIBXML2_VERSION = version
    ctx.env.HEPWAF_FOUND_LIBXML2 = 1
    return

## EOF ##

{'fraction_non_alphanumeric': 0.1236712470832253, 'fraction_numerical': 0.010370754472387866, 'mean_word_length': 1.9768518518518519, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 34}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '569468', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1328, 'n_words': 251}