How to use the cmake.make_versioncpp.Generator function in cmake

To help you get started, we’ve selected a few cmake examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github freeorion / freeorion / cmake / make_versioncpp.py View on Github external
print "ERROR: invalid parameters."
    print "make_versioncpp.py  "
    quit()

os.chdir(sys.argv[1])
build_sys = sys.argv[2]

# A list of tuples containing generators
generators = [
    Generator('util/Version.cpp.in', 'util/Version.cpp')
]
if system() == 'Windows':
    generators.append(NsisInstScriptGenerator('Installer/FreeOrion_Install_Script.nsi.in',
                                              'Installer/FreeOrion_Install_Script.nsi'))
if system() == 'Darwin':
    generators.append(Generator('Xcode/Info.plist.in', 'Xcode/Info.plist'))

version = "0.4.9+"
branch = ""
build_no = INVALID_BUILD_NO

try:
    branch = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
    if (branch == "master") or (branch[:7] == "release"):
        branch = ""
    else:
        branch += " "
    commit = check_output(["git", "show", "-s", "--format=%h", "--abbrev=7", "HEAD"]).strip()
    timestamp = float(check_output(["git", "show", "-s", "--format=%ct", "HEAD"]).strip())
    build_no = ".".join([datetime.utcfromtimestamp(timestamp).strftime("%Y-%m-%d"), commit])
except:
    print "WARNING: git not installed or not setup correctly"
github freeorion / freeorion / cmake / make_versioncpp.py View on Github external
FreeOrion_BUILDSYS=build_sys,
                FreeOrion_DLL_LIST_INSTALL="",
                FreeOrion_DLL_LIST_UNINSTALL="")


if 3 != len(sys.argv):
    print "ERROR: invalid parameters."
    print "make_versioncpp.py  "
    quit()

os.chdir(sys.argv[1])
build_sys = sys.argv[2]

# A list of tuples containing generators
generators = [
    Generator('util/Version.cpp.in', 'util/Version.cpp')
]
if system() == 'Windows':
    generators.append(NsisInstScriptGenerator('Installer/FreeOrion_Install_Script.nsi.in',
                                              'Installer/FreeOrion_Install_Script.nsi'))
if system() == 'Darwin':
    generators.append(Generator('Xcode/Info.plist.in', 'Xcode/Info.plist'))

version = "0.4.9+"
branch = ""
build_no = INVALID_BUILD_NO

try:
    branch = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
    if (branch == "master") or (branch[:7] == "release"):
        branch = ""
    else:
github freeorion / freeorion / cmake / make_versioncpp.py View on Github external
print "Build number matches build number in existing Version.cpp, skip regenerating it"
                    return

        try:
            with open(self.infile) as template_file:
                template = Template(template_file.read())
        except:
            print "WARNING: Can't access %s, %s not updated!" % (self.infile, self.outfile)
            return

        print "Writing file: %s" % self.outfile
        with open(self.outfile, "w") as generated_file:
            generated_file.write(self.compile_output(template, version, branch, build_no, build_sys))


class NsisInstScriptGenerator(Generator):
    def compile_dll_list(self):
        all_dll_files = glob("*.dll")
        accepted_dll_files = set(["GiGi.dll", "GiGiSDL.dll"])
        for dll_file in all_dll_files:
            if dll_file.startswith("boost_"):
                if dll_file.partition(".")[0] in required_boost_libraries:
                    accepted_dll_files.add(dll_file)
            else:
                accepted_dll_files.add(dll_file)
        return sorted(accepted_dll_files)

    def compile_output(self, template, version, branch, build_no, build_sys):
        dll_files = self.compile_dll_list()
        if dll_files:
            return template.substitute(
                FreeOrion_VERSION=version,