Commit dcf05e6d authored by Victor Yacovlev's avatar Victor Yacovlev

Fixed #kumir2-1910

parent 31d1f2c3
......@@ -6,19 +6,12 @@ if(NOT DEFINED USE_QT)
set(USE_QT 4)
endif(NOT DEFINED USE_QT)
#if(APPLE)
set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
#endif(APPLE)
#set(QT_USE_QTMAIN 1)
#find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtScript QtNetwork QtXml QtSvg QtWebKit QtDeclarative REQUIRED)
#include (${QT_USE_FILE})
include_directories(${CMAKE_SOURCE_DIR}/src/shared)
include_directories(${CMAKE_SOURCE_DIR}/src)
#if(WIN32)
# include_directories(${CMAKE_SOURCE_DIR}/boost_include)
#endif()
......
find_package(PythonInterp 2.7.0 REQUIRED)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/scripts/read_disabled_modules.py"
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/scripts/query_version_info.py" "--mode=cmake_disabled_modules"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE DISABLED_SUBDIRS
)
......
import re
import subprocess
import os
import os.path
import sys
import time
if 3 == sys.version_info.major:
from urllib.parse import unquote
def to_str(x):
return x.decode("utf-8")
else:
from urllib import unquote
def to_str(x):
return unicode(x)
OUT_FILE = sys.stdout
def get_version_information(top_level_dir):
assert isinstance(top_level_dir, str) or isinstance(top_level_dir, unicode)
if os.path.exists(top_level_dir + os.path.sep + ".git"):
try:
version_info = subprocess.check_output(
"git describe --abbrev=0 --tags --exact-match",
shell=True,
stderr=subprocess.PIPE
).strip()
except subprocess.CalledProcessError:
version_info = subprocess.check_output(
"git rev-parse --abbrev-ref HEAD",
shell=True
).strip()
else:
dir_name = os.path.basename(top_level_dir)
match = re.match(r"kumir2-(.+)", dir_name)
version_info = match.group(1)
return to_str(version_info)
def get_timestamp(top_level_dir):
assert isinstance(top_level_dir, str) or isinstance(top_level_dir, unicode)
if os.path.exists(top_level_dir + os.path.sep + ".git"):
return to_str(subprocess.check_output(
"git --no-pager log -1 --pretty=format:%ct",
shell=True,
stderr=subprocess.PIPE
)).strip()
else:
return "{}".format(int(time.time()))
def is_tag(version):
return version.startswith("2")
def find_suitable_list_file_name(version_name):
base = os.getcwd() + os.path.sep + "subdirs-disabled-{}.txt"
name = base.format(version_name)
if os.path.exists(name):
return name
match = re.match(r"(.+)-(alpha|beta|rc|pt|test)[0-9]+", version_name)
if match:
version_base = match.group(1)
name = base.format(version_base)
if os.path.exists(name):
return name
def cmake_disabled_modules():
version_name = get_version_information(os.getcwd())
disabled_list_file_name = find_suitable_list_file_name(version_name)
disabled_list = []
if disabled_list_file_name:
with open(disabled_list_file_name) as source:
lines = source.read().split('\n')
for line in lines:
line = line.strip()
if line and not line.startswith("#"):
disabled_list += ["[" + line + "]"]
if disabled_list:
OUT_FILE.write(" ".join(disabled_list))
def cmake_version_info():
version_name = get_version_information(os.getcwd())
timestamp = get_timestamp(os.getcwd())
if is_tag(version_name):
OUT_FILE.write("-DGIT_TAG=\"{}\";".format(version_name))
OUT_FILE.write("-DGIT_BRANCH=\"unknown\";")
OUT_FILE.write("-DGIT_HASH=\"unknown\";")
else:
OUT_FILE.write("-DGIT_TAG=\"unknown\";")
branch, ghash = version_name.split("-")
OUT_FILE.write("-DGIT_BRANCH=\"{}\";".format(branch))
OUT_FILE.write("-DGIT_HASH=\"{}\";".format(ghash))
OUT_FILE.write("-DGIT_TIMESTAMP=\"{}\";".format(timestamp))
def package_bundle_name():
version_name = get_version_information(os.getcwd())
prefix = ""
suffix = ""
nl = ""
for arg in sys.argv:
if arg.startswith("--prefix="):
prefix = unquote(arg[9:].replace('@', '%'))
elif arg.startswith("--suffix="):
suffix = unquote(arg[9:].replace('@', '%'))
elif "--nl" == arg:
if os.name.startswith("nt"):
nl = "\r\n"
else:
nl = "\n"
output = prefix + version_name + suffix + nl
OUT_FILE.write(output)
def main():
global OUT_FILE
mode = "package_bundle_name"
for arg in sys.argv:
if arg.startswith("--mode="):
mode = arg[7:]
elif arg.startswith("--out="):
OUT_FILE = open(arg[6:], 'w')
if mode in globals():
globals()[mode]()
OUT_FILE.close()
if __name__ == "__main__":
main()
......@@ -32,7 +32,7 @@ def find_suitable_list_file_name(version_name):
name = base.format(version_name)
if os.path.exists(name):
return name
match = re.match(r"(.+)-(alpha|beta|rc)[0-9]+", version_name)
match = re.match(r"(.+)-(alpha|beta|rc|pt|test)[0-9]+", version_name)
if match:
version_base = match.group(1)
name = base.format(version_base)
......
......@@ -21,51 +21,59 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/version_info.cmake")
add_definitions(-DGIT_TAG=\"${GIT_TAG}\")
add_definitions(-DGIT_BRANCH=\"${GIT_BRANCH}\")
else()
set(GIT_HASH unknown)
set(GIT_TIMESTAMP 0)
set(GIT_BRANCH unknown)
set(GIT_TAG unknown)
find_program(GIT git)
if(GIT)
execute_process(
COMMAND ${GIT} --no-pager log -1 --pretty=format:%H
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_HASH
)
execute_process(
COMMAND ${GIT} describe --abbrev=0 --tags --exact-match
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG
RESULT_VARIABLE GIT_TAG_ERROR
ERROR_VARIABLE NULL
)
if(NOT "${GIT_TAG_ERROR}" EQUAL "0")
set(GIT_TAG unknown)
endif()
execute_process(
COMMAND ${GIT} --no-pager log -1 --pretty=format:%ct
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TIMESTAMP
)
execute_process(
COMMAND ${GIT} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
string(STRIP "${GIT_HASH}" GIT_HASH)
set(GIT_TAG "unknown") # string(STRIP "${GIT_TAG}" GIT_TAG)
string(STRIP "${GIT_TIMESTAMP}" GIT_TIMESTAMP)
else()
message(WARNING "git not found and no version info provided")
endif()
find_package(PythonInterp 2.7.0 REQUIRED)
add_definitions(-DGIT_HASH=\"${GIT_HASH}\")
add_definitions(-DGIT_TIMESTAMP=\"${GIT_TIMESTAMP}\")
add_definitions(-DGIT_TAG=\"${GIT_TAG}\")
add_definitions(-DGIT_BRANCH=\"${GIT_BRANCH}\")
execute_process(
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/scripts/query_version_info.py" "--mode=cmake_version_info"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_DEFINITIONS
)
add_definitions(${VERSION_DEFINITIONS})
# set(GIT_HASH unknown)
# set(GIT_TIMESTAMP 0)
# set(GIT_BRANCH unknown)
# set(GIT_TAG unknown)
# find_program(GIT git)
# if(GIT)
# execute_process(
# COMMAND ${GIT} --no-pager log -1 --pretty=format:%H
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# OUTPUT_VARIABLE GIT_HASH
# )
# execute_process(
# COMMAND ${GIT} describe --abbrev=0 --tags --exact-match
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# OUTPUT_VARIABLE GIT_TAG
# RESULT_VARIABLE GIT_TAG_ERROR
# ERROR_VARIABLE NULL
# )
# if(NOT "${GIT_TAG_ERROR}" EQUAL "0")
# set(GIT_TAG unknown)
# endif()
# execute_process(
# COMMAND ${GIT} --no-pager log -1 --pretty=format:%ct
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# OUTPUT_VARIABLE GIT_TIMESTAMP
# )
# execute_process(
# COMMAND ${GIT} rev-parse --abbrev-ref HEAD
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# OUTPUT_VARIABLE GIT_BRANCH
# )
# string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
# string(STRIP "${GIT_HASH}" GIT_HASH)
# set(GIT_TAG "unknown") # string(STRIP "${GIT_TAG}" GIT_TAG)
# string(STRIP "${GIT_TIMESTAMP}" GIT_TIMESTAMP)
# else()
# message(WARNING "git not found and no version info provided")
# endif()
# add_definitions(-DGIT_HASH=\"${GIT_HASH}\")
# add_definitions(-DGIT_TIMESTAMP=\"${GIT_TIMESTAMP}\")
# add_definitions(-DGIT_TAG=\"${GIT_TAG}\")
# add_definitions(-DGIT_BRANCH=\"${GIT_BRANCH}\")
endif()
if(MSVC_IDE)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment