<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright 2013 <NAME>
#
# Licensed 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.

from optparse import OptionParser
from build_sys.util.util import print_timing
import build_sys.util.util as util
import os
import sys
import build_sys.gen_build_info as gen_build_info
import build_sys.gen_help as gen_help
import build_sys.gen_nsis as gen_nsis
import build_sys.dependencies as depend
from os.path import abspath

unknown_version_str = "unknown"

def fail(message):
    print("Error: %s" % message)
    exit(1)

def parse_bool(config, group, name):
    value = config.get(group, name)
    if value.lower() in ['1', 'true', 'yes', 'y']:
        return True
    if value.lower() in ['0', 'false', 'no', 'n']:
        return False
    print("Error: %s should be 1 or 0 in build.cfg" % name)
    exit(1)

def parse_command_line():
    optParser = OptionParser()
    optParser.add_option("", "--rebuild",
                         action="store_true",
                         dest="do_rebuild",
                         default=False,
                         help="Rebuild and relink")

    optParser.add_option("", "--version",
                         dest="version",
                         default=unknown_version_str,
                         help="Application version number")

    optParser.add_option("", "--debug",
                         action="store_true",
                         dest="debug",
                         default=False,
                         help="Build with debug symbols")

    optParser.add_option("", "--filthy",
                         action="store_true",
                         dest="filthy",
                         default=False,
                         help="Allow building unclean installer")

    optParser.add_option("", "--timed",
                         action="store_true",
                         dest="timed",
                         default=False,
                         help="Time the build")

    optParser.add_option("", "--stdout",
                         action="store_true",
                         dest="use_stdout",
                         default=False,
                         help="Print compilation output on standard out")

    return optParser.parse_args()


def clean_file_name(f):
    return abspath(f).replace('\\', '/')


def versioned(cmd_opts):
    return cmd_opts.version != unknown_version_str


def versioned_unfilthy(cmd_opts):
    return versioned(cmd_opts) and not cmd_opts.filthy


def check_valid_release(cmd_opts, opts, clean_build):
    if not clean_build:
        if versioned_unfilthy(cmd_opts):
            fail("Build with --version requires empty output folder "
                 "(build/objs)")

    if versioned_unfilthy(cmd_opts):
        # if gen_build_info.working_copy_modified(opts.project_root):
        # fail("Build with --version requires unmodified working copy.")
        return

    if versioned(cmd_opts) and opts.makensis_exe is None:
        fail("Build with --version requires path to nsis in build.cfg")


def prepare_out_dir(obj_root):
    """Recreates the output-dir. Returns true if the folder was recreated
    or empty. (this signifies a clean build)"""
    if not os.path.exists(obj_root):
        os.mkdir(obj_root)
        return True
    elif len(os.listdir(obj_root)) == 0:
        return True
    else:
        return False<commit_msg>Fixme comment for re-adding version info.<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright 2013 <NAME>
#
# Licensed 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.

from optparse import OptionParser
from build_sys.util.util import print_timing
import build_sys.util.util as util
import os
import sys
import build_sys.gen_build_info as gen_build_info
import build_sys.gen_help as gen_help
import build_sys.gen_nsis as gen_nsis
import build_sys.dependencies as depend
from os.path import abspath

unknown_version_str = "unknown"

def fail(message):
    print("Error: %s" % message)
    exit(1)

def parse_bool(config, group, name):
    value = config.get(group, name)
    if value.lower() in ['1', 'true', 'yes', 'y']:
        return True
    if value.lower() in ['0', 'false', 'no', 'n']:
        return False
    print("Error: %s should be 1 or 0 in build.cfg" % name)
    exit(1)

def parse_command_line():
    optParser = OptionParser()
    optParser.add_option("", "--rebuild",
                         action="store_true",
                         dest="do_rebuild",
                         default=False,
                         help="Rebuild and relink")

    optParser.add_option("", "--version",
                         dest="version",
                         default=unknown_version_str,
                         help="Application version number")

    optParser.add_option("", "--debug",
                         action="store_true",
                         dest="debug",
                         default=False,
                         help="Build with debug symbols")

    optParser.add_option("", "--filthy",
                         action="store_true",
                         dest="filthy",
                         default=False,
                         help="Allow building unclean installer")

    optParser.add_option("", "--timed",
                         action="store_true",
                         dest="timed",
                         default=False,
                         help="Time the build")

    optParser.add_option("", "--stdout",
                         action="store_true",
                         dest="use_stdout",
                         default=False,
                         help="Print compilation output on standard out")

    return optParser.parse_args()


def clean_file_name(f):
    return abspath(f).replace('\\', '/')


def versioned(cmd_opts):
    return cmd_opts.version != unknown_version_str


def versioned_unfilthy(cmd_opts):
    return versioned(cmd_opts) and not cmd_opts.filthy


def check_valid_release(cmd_opts, opts, clean_build):
    if not clean_build:
        if versioned_unfilthy(cmd_opts):
            fail("Build with --version requires empty output folder "
                 "(build/objs)")

    if versioned_unfilthy(cmd_opts):
        # Fixme: Re-add the version check with git
        # if gen_build_info.working_copy_modified(opts.project_root):
        # fail("Build with --version requires unmodified working copy.")
        return

    if versioned(cmd_opts) and opts.makensis_exe is None:
        fail("Build with --version requires path to nsis in build.cfg")


def prepare_out_dir(obj_root):
    """Recreates the output-dir. Returns true if the folder was recreated
    or empty. (this signifies a clean build)"""
    if not os.path.exists(obj_root):
        os.mkdir(obj_root)
        return True
    elif len(os.listdir(obj_root)) == 0:
        return True
    else:
        return False
{'fraction_non_alphanumeric': 0.09943001899936668, 'fraction_numerical': 0.004306523115896137, 'mean_word_length': 2.154614462644826, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, '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': '2953716', 'n_tokens_mistral': 2185, 'n_tokens_neox': 2084, 'n_words': 643}