<commit_before>package org.apache.maven.plugin.nar;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.LinkedList;

import net.sf.antcontrib.cpptasks.CUtil;
import net.sf.antcontrib.cpptasks.LinkerDef;
import net.sf.antcontrib.cpptasks.LinkerEnum;
import net.sf.antcontrib.cpptasks.types.LibrarySet;
import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
import net.sf.antcontrib.cpptasks.types.LinkerArgument;
import net.sf.antcontrib.cpptasks.types.SystemLibrarySet;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.tools.ant.Project;
import org.codehaus.plexus.util.FileUtils;

/**
 * Linker tag
 * 
 * @author <NAME>
 */
public class Linker
{

    /**
     * The Linker Some choices are: "msvc", "g++", "CC", "icpc", ... Default is Architecture-OS-Linker specific: FIXME:
     * table missing
     * 
     * @parameter expression=""
     */
    private String name;

    /**
     * Enables or disables incremental linking.
     * 
     * @parameter expression="" default-value="false"
     * @required
     */
    private boolean incremental = false;

    /**
     * Enables or disables the production of a map file.
     * 
     * @parameter expression="" default-value="false"
     * @required
     */
    private boolean map = false;

    /**
     * Options for the linker Defaults to Architecture-OS-Linker specific values. FIXME table missing
     * 
     * @parameter expression=""
     */
    private List options;

    /**
     * Options for the linker as a whitespace separated list. Defaults to Architecture-OS-Linker specific values. Will
     * work in combination with &lt;options&gt;.
     * 
     * @parameter expression=""
     */
    private String optionSet;

    /**
     * Clears default options
     * 
     * @parameter expression="" default-value="false"
     * @required
     */
    private boolean clearDefaultOptions;

    /**
     * Adds libraries to the linker.
     * 
     * @parameter expression=""
     */
    private List/* <Lib> */libs;

    /**
     * Adds libraries to the linker. Will work in combination with &lt;libs&gt;. The format is comma separated,
     * colon-delimited values (name:type:dir), like "myLib:shared:/home/me/libs/, otherLib:static:/some/path".
     * 
     * @parameter expression=""
     */
    private String libSet;

    /**
     * Adds system libraries to the linker.
     * 
     * @parameter expression=""
     */
    private List/* <SysLib> */sysLibs;

    /**
     * Adds system libraries to the linker. Will work in combination with &lt;sysLibs&gt;. The format is comma
     * separated, colon-delimited values (name:type), like "dl:shared, pthread:shared".
     * 
     * @parameter expression=""
     */
    private String sysLibSet;

    /**
     * <p>
     * Specifies the link ordering of libraries that come from nar dependencies. The format is a comma separated list of
     * dependency names, given as groupId:artifactId.
     * </p>
     * <p>
     * Example: &lt;narDependencyLibOrder&gt;someGroup:myProduct, other.group:productB&lt;narDependencyLibOrder&gt;
     * </p>
     * 
     * @parameter expression=""
     */
    private String narDependencyLibOrder;

    public Linker()
    {
        // default constructor for use as TAG
    }

    /**
     * For use with specific named linker.
     * 
     * @param name
     */
    public Linker( String name )
    {
        this.name = name;
    }

    public String getName( Properties defaults, String prefix )
        throws MojoFailureException
    {
        if ( ( name == null ) && ( defaults != null ) && ( prefix != null ) )
        {
            name = defaults.getProperty( prefix + "linker" );
        }
        if ( name == null )
        {
            throw new MojoFailureException( "One of two things may be wrong here:\n"+
                                            "1. <Name> tag is missing inside the <Linker> tag of your NAR configuration\n"+
                                            "2. no linker is defined in the aol.properties file for '"+prefix+"'");
        }
        return name;
    }

    public LinkerDef getLinker( AbstractCompileMojo mojo, Project antProject, String os, String prefix, String type )
        throws MojoFailureException, MojoExecutionException
    {
        if ( name == null )
        {
            throw new MojoFailureException( "NAR: Please specify a <Name> as part of <Linker>" );
        }

        LinkerDef linker = new LinkerDef();
        linker.setProject( antProject );
        LinkerEnum linkerEnum = new LinkerEnum();
        linkerEnum.setValue( name );
        linker.setName( linkerEnum );

        // incremental, map
        linker.setIncremental( incremental );
        linker.setMap( map );

        // Add definitions (Window only)<commit_msg>Fixed NAR-55<commit_after>package org.apache.maven.plugin.nar;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.LinkedList;

import net.sf.antcontrib.cpptasks.CUtil;
import net.sf.antcontrib.cpptasks.LinkerDef;
import net.sf.antcontrib.cpptasks.LinkerEnum;
import net.sf.antcontrib.cpptasks.types.LibrarySet;
import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
import net.sf.antcontrib.cpptasks.types.LinkerArgument;
import net.sf.antcontrib.cpptasks.types.SystemLibrarySet;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.tools.ant.Project;
import org.codehaus.plexus.util.FileUtils;

/**
 * Linker tag
 * 
 * @author <NAME>
 */
public class Linker
{

    /**
     * The Linker Some choices are: "msvc", "g++", "CC", "icpc", ... Default is Architecture-OS-Linker specific: FIXME:
     * table missing
     * 
     * @parameter expression=""
     */
    private String name;

    /**
     * Enables or disables incremental linking.
     * 
     * @parameter expression="" default-value="false"
     * @required
     */
    private boolean incremental = false;

    /**
     * Enables or disables the production of a map file.
     * 
     * @parameter expression="" default-value="false"
     * @required
     */
    private boolean map = false;

    /**
     * Options for the linker Defaults to Architecture-OS-Linker specific values. FIXME table missing
     * 
     * @parameter expression=""
     */
    private List options;

    /**
     * Options for the linker as a whitespace separated list. Defaults to Architecture-OS-Linker specific values. Will
     * work in combination with &lt;options&gt;.
     * 
     * @parameter expression=""
     */
    private String optionSet;

    /**
     * Clears default options
     * 
     * @parameter expression="" default-value="false"
     * @required
     */
    private boolean clearDefaultOptions;

    /**
     * Adds libraries to the linker.
     * 
     * @parameter expression=""
     */
    private List/* <Lib> */libs;

    /**
     * Adds libraries to the linker. Will work in combination with &lt;libs&gt;. The format is comma separated,
     * colon-delimited values (name:type:dir), like "myLib:shared:/home/me/libs/, otherLib:static:/some/path".
     * 
     * @parameter expression=""
     */
    private String libSet;

    /**
     * Adds system libraries to the linker.
     * 
     * @parameter expression=""
     */
    private List/* <SysLib> */sysLibs;

    /**
     * Adds system libraries to the linker. Will work in combination with &lt;sysLibs&gt;. The format is comma
     * separated, colon-delimited values (name:type), like "dl:shared, pthread:shared".
     * 
     * @parameter expression=""
     */
    private String sysLibSet;

    /**
     * <p>
     * Specifies the link ordering of libraries that come from nar dependencies. The format is a comma separated list of
     * dependency names, given as groupId:artifactId.
     * </p>
     * <p>
     * Example: &lt;narDependencyLibOrder&gt;someGroup:myProduct, other.group:productB&lt;narDependencyLibOrder&gt;
     * </p>
     * 
     * @parameter expression=""
     */
    private String narDependencyLibOrder;

    public Linker()
    {
        // default constructor for use as TAG
    }

    /**
     * For use with specific named linker.
     * 
     * @param name
     */
    public Linker( String name )
    {
        this.name = name;
    }

    public String getName( Properties defaults, String prefix )
        throws MojoFailureException
    {
        if ( ( name == null ) && ( defaults != null ) && ( prefix != null ) )
        {
            name = defaults.getProperty( prefix + "linker" );
        }
        if ( name == null )
        {
            throw new MojoFailureException( "NAR: One of two things may be wrong here:\n\n"+
                                            "1. <Name> tag is missing inside the <Linker> tag of your NAR configuration\n\n"+
                                            "2. no linker is defined in the aol.properties file for '"+prefix+"linker'\n");
        }
        return name;
    }

    public LinkerDef getLinker( AbstractCompileMojo mojo, Project antProject, String os, String prefix, String type )
        throws MojoFailureException, MojoExecutionException
    {
        if ( name == null )
        {
            throw new MojoFailureException( "NAR: Please specify a <Name> as part of <Linker>" );
        }

        LinkerDef linker = new LinkerDef();
        linker.setProject( antProject );
        LinkerEnum linkerEnum = new LinkerEnum();
        linkerEnum.setValue( name );
        linker.setName( linkerEnum );

        // incremental, map
        linker.setIncremental( incremental );
        linker.setMap( map );

        // Add definitions (Window only)
{'fraction_non_alphanumeric': 0.10323082239115411, 'fraction_numerical': 0.0012093987560469939, 'mean_word_length': 2.511373976342129, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6982804', 'n_tokens_mistral': 3308, 'n_tokens_neox': 3147, 'n_words': 1027}