build on MacOS 10.15.

dev
Apex Liu 2020-08-12 23:48:12 +08:00
parent 8fef2fc2cd
commit e4ecbe6543
9 changed files with 125 additions and 91 deletions

5
.gitignore vendored
View File

@ -15,8 +15,8 @@
# for CMake
CMakeFiles
cmake_install.cmake
cmake-build
cmake-build-debug
cmake-build-*
# cmake-build-debug
client/tp_assist_macos/build
**/xcode_build
**/DerivedData
@ -109,3 +109,4 @@ profile
/external/zlib
/client/tools/qt-redist
/config.json
/config.*.json

View File

@ -45,11 +45,18 @@ function dlfile()
echo ""
# curl --insecure https://www.python.org/ftp/python/3.7.0/${VER_PYTHON}.tgz -o "${PATH_PYTHON}/${VER_PYTHON}.tgz"
echo wget $2$3 -O "$4/$3"
wget --no-check-certificate $2$3 -O "$4/$3"
if [ ! -f "$4/$3" ]; then
if [ -f "$4/$3._tmp_" ]; then
rm -rf "$4/$3._tmp_"
fi
wget --no-check-certificate $2$3 -O "$4/$3._tmp_"
if [ ! -f "$4/$3._tmp_" ]; then
on_error "Can not download $1: $3"
fi
mv "$4/$3._tmp_" "$4/$3"
else
echo " already exists, skip."
fi

View File

@ -229,12 +229,12 @@ def add_split(title=None):
def make_options():
if ctx.host_os in ['windows']:
add_split('prepare for client [build once]')
add_split('prepare external [build once]')
# add_option('x86', 'external', '[OBSOLETE] Build external dependency')
add_option('x86', 'ext-client', 'Build external libraries for client')
add_split('prepare for server [build once]')
add_option('x86', 'pysrt', 'Make Python-Runtime for python%s-x86' % env.py_ver_str)
add_option('x86', 'ext-server', 'Build external libraries for server')
add_option('x86', 'ext-client', '[client] Build external libraries for client')
# add_split('prepare for server [build once]')
add_option('x86', 'pysrt', '[server] Make Python-Runtime for python%s-x86' % env.py_ver_str)
add_option('x86', 'ext-server', '[server] Build external libraries for server')
add_split('version [build every release]')
add_option('x86', 'ver', 'Update version setting')
add_split('client side')
@ -253,30 +253,30 @@ def make_options():
add_option('x86', 'clear-ext-client', 'Clear external libraries for client')
add_option('x86', 'clear-ext-server', 'Clear external libraries for server')
elif ctx.host_os == 'macos':
add_split('prepare for client [build once]')
add_option('x64', 'ext-client', 'Build external libraries for client')
add_split('version [build every release]')
add_option('x64', 'ver', 'Update version setting')
add_split('client side')
add_option('x64', 'client', 'Assist Execute [%s]' % ctx.target_path)
add_option('x64', 'client-installer', 'Assist Installer')
add_option('x64', 'ext-client', 'build external libraries for client')
add_option('x64', 'client', 'build client applications [%s]' % ctx.target_path)
add_option('x64', 'client-installer', 'make client installer')
add_split('server side')
add_option('x64', 'ext-server', 'build external libraries for server')
add_option('x64', 'server', '(DEV-ONLY) build server applications [%s]' % ctx.target_path)
add_split('clear')
add_option('x86', 'clear-ext-client', 'Clear external libraries for client')
add_option('x64', 'clear-ext-client', 'clear external libraries for client')
add_option('x64', 'clear-ext-server', 'clear external libraries for server')
add_split('misc')
add_option('x64', 'ver', 'update version setting')
else:
add_split('prepare for server [build once]')
add_option('x64', 'pysrt', 'Make Python-Runtime for python%s-x64' % env.py_ver_str)
# add_option('x64', 'external', '[OBSOLETE] Build external dependency')
# add_option('x86', 'ext-client', 'Build external libraries for client')
add_option('x64', 'ext-server', 'Build external libraries for server')
add_split('version [build every release]')
add_option('x64', 'ver', 'Update version setting')
add_split('server side')
add_option('x64', 'server', 'Build server applications [%s]' % ctx.target_path)
# add_option('x64', 'installer', '[OBSOLETE] Make server installer for %s' % ctx.host_os)
add_option('x64', 'server-installer', 'Make server installer for %s' % ctx.host_os)
add_option('x64', 'ext-server', 'build external libraries for server')
add_option('x64', 'server', 'build server applications [%s]' % ctx.target_path)
add_option('x64', 'server-installer', 'make server installer for %s' % ctx.host_os)
add_split('clear')
# add_option('x64', 'clear-ext-client', 'Clear external libraries for client')
add_option('x64', 'clear-ext-server', 'Clear external libraries for server')
add_option('x64', 'clear-ext-server', 'clear external libraries for server')
add_split('misc')
add_option('x64', 'ver', 'update version setting')
def get_input(msg, log_func=cc.w):

View File

@ -49,7 +49,7 @@ class PYSBase:
pypi_modules = ['cffi', 'cryptography', 'ldap3', 'mako', 'Pillow', 'psutil', 'pyasn1', 'pymysql', 'qrcode', 'tornado', 'wheezy.captcha']
for p in pypi_modules:
cc.n('install {} ...'.format(p))
utils.sys_exec('{} install -i https://pypi.tuna.tsinghua.edu.cn/simple {}'.format(pip, p), direct_output=True)
utils.sys_exec('{} install -i https://pypi.tuna.tsinghua.edu.cn/simple {}'.format(pip, p))
self._make_base()
self._make_python_zip()

View File

@ -91,17 +91,17 @@ class BuilderLinux(BuilderBase):
utils.makedirs(out_path)
build_path = os.path.join(env.root_path, 'cmake-build')
build_path = os.path.join(env.root_path, 'cmake-build-linux')
if not os.path.exists(build_path):
utils.makedirs(build_path)
old_p = os.getcwd()
os.chdir(build_path)
utils.cmake(build_path, ctx.target_path, False)
os.chdir(build_path)
utils.sys_exec('make')
# utils.strip(out_file)
os.chdir(old_p)
# old_p = os.getcwd()
# os.chdir(build_path)
# utils.cmake(build_path, ctx.target_path, False)
# os.chdir(build_path)
# utils.sys_exec('make')
# # utils.strip(out_file)
# os.chdir(old_p)
for f in out_files:
if os.path.exists(f):
@ -130,7 +130,7 @@ class BuilderMacOS(BuilderBase):
utils.makedirs(out_path)
utils.cmake(os.path.join(env.root_path, 'cmake-build'), ctx.target_path, False)
utils.cmake(os.path.join(env.root_path, 'cmake-build-macos'), ctx.target_path, False)
# utils.strip(out_file)
for f in out_files:

View File

@ -75,11 +75,12 @@ class Env(object):
return True
def _load_config(self, warn_miss_tool):
_cfg_file = 'config.{}.json'.format(self.plat)
# _cfg_file = os.path.join(self.root_path, 'config.ini')
_cfg_file = os.path.join(self.root_path, 'config.json')
_cfg_file = os.path.join(self.root_path, _cfg_file)
if not os.path.exists(_cfg_file):
# cc.e('can not load configuration.\n\nplease copy `config.ini.in` to `config.ini` and modify it to fit your condition and try again.')
cc.e('can not load configuration.\n\nplease copy `config.json.in` to `config.json` and modify it to fit your condition and try again.')
cc.e('can not load configuration.\n\nplease copy `config.json.in` to `config.{}.json` and modify it to fit your condition and try again.'.format(self.plat))
return False
try:
@ -196,6 +197,15 @@ class Env(object):
if warn_miss_tool:
cc.w(' - can not locate `qt`, so I can not build tp-player.')
if 'cmake' in _tmp:
self.cmake = _tmp['cmake']
else:
self.cmake = '/usr/local/bin/cmake'
if not os.path.exists(self.cmake):
if warn_miss_tool:
cc.e(' - can not locate `cmake`, so I can not build binary from source.')
return True
def _load_version(self):

View File

@ -268,8 +268,8 @@ def ensure_file_exists(filename):
raise RuntimeError('path exists but not a file: {}'.format(filename))
def sys_exec(cmd, direct_output=False, output_codec=None):
print(cmd)
def sys_exec(cmd, direct_output=True, output_codec=None):
cc.o(cmd)
if output_codec is None:
if env.is_win:
output_codec = 'gb2312'
@ -280,9 +280,11 @@ def sys_exec(cmd, direct_output=False, output_codec=None):
if env.is_win:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True)
# elif env.is_macos:
# p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True)
else:
p = subprocess.Popen(cmd, close_fds=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
universal_newlines=True, shell=True)
p = subprocess.Popen(cmd, close_fds=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True)
output = list()
f = p.stdout
@ -310,12 +312,12 @@ def msvc_build(sln_file, proj_name, target, platform, force_rebuild):
if force_rebuild:
cmd = '"{}" "{}" "/target:clean" "/property:Configuration={};Platform={}"'.format(env.msbuild, sln_file, target,
platform)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
cc.v('ret:', ret)
cmd = '"{}" "{}" "/target:{}" "/property:Configuration={};Platform={}"'.format(env.msbuild, sln_file, proj_name,
target, platform)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
if ret != 0:
raise RuntimeError('build MSVC project `{}` failed.'.format(proj_name))
@ -329,7 +331,7 @@ def qt_build(prj_path, prj_name, bit_path, target_path):
tmp_path = os.path.join(env.root_path, 'out', '_tmp_', prj_name, bit_path)
# C:\Windows\System32\cmd.exe /A /Q /K C:\Qt\Qt5.12.0\5.12.0\msvc2017\bin\qtenv2.bat
cmd = 'C:\\Windows\\System32\\cmd.exe /A /Q /C ""{}\\qt-helper.bat" "{}\\bin\\qtenv2.bat" "{}VC\\Auxiliary\\Build\\vcvarsall.bat" {} "{}" "{}" {}"'.format(env.build_path, env.qt, env.visual_studio_path, bit_path, tmp_path, prj_path, target_path)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
if ret != 0:
raise RuntimeError('build XCode project `{}` failed.'.format(prj_name))
elif env.is_macos:
@ -340,7 +342,7 @@ def qt_build(prj_path, prj_name, bit_path, target_path):
os.chdir(prj_path)
cmd = '"{}" "{}"; make'.format(qmake, pro_file)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
if ret != 0:
raise RuntimeError('make Makefile for build `{}` failed.'.format(prj_name))
@ -354,7 +356,7 @@ def qt_deploy(app):
if env.is_macos:
qmake = os.path.join(env.qt, 'macdeployqt')
cmd = '"{}" "{}"'.format(qmake, app)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
if ret != 0:
raise RuntimeError('make deploy for QT failed.')
@ -362,11 +364,11 @@ def qt_deploy(app):
def xcode_build(proj_file, proj_name, target, force_rebuild):
if force_rebuild:
cmd = 'xcodebuild -project "{}" -target {} -configuration {} clean'.format(proj_file, proj_name, target)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
cc.v('ret:', ret)
cmd = 'xcodebuild -project "{}" -target {} -configuration {}'.format(proj_file, proj_name, target)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
if ret != 0:
raise RuntimeError('build XCode project `{}` failed.'.format(proj_name))
@ -379,7 +381,7 @@ def make_dmg(json_file, dmg_file):
makedirs(out_path)
cmd = 'appdmg "{}" "{}"'.format(json_file, dmg_file)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
if ret != 0:
raise RuntimeError('make dmg failed.')
@ -389,7 +391,7 @@ def nsis_build(nsi_file, _define=''):
raise RuntimeError('where is `nsis`?')
cmd = '"{}" /V2 {} /X"SetCompressor /SOLID /FINAL lzma" "{}"'.format(env.nsis, _define, nsi_file)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
if ret != 0:
raise RuntimeError('make installer with nsis failed. [{}]'.format(nsi_file))
@ -414,14 +416,14 @@ def cmake(work_path, target, force_rebuild, cmake_define='', cmake_pre_define=''
else:
target = 'Release'
cmd = '{} "{}" -DCMAKE_BUILD_TYPE={} {} ..'.format(cmake_pre_define, env.cmake, target, cmake_define)
cc.o(cmd)
ret, _ = sys_exec(cmd, direct_output=True)
# if ret != 0:
# raise RuntimeError('build with cmake failed, ret={}. [{}]'.format(ret, target))
# cmd = 'make'
# cc.o(cmd)
# ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
if ret != 0:
raise RuntimeError('build with cmake failed, ret={}. [{}]'.format(ret, target))
cmd = 'make'
# cc.o(cmd)
ret, _ = sys_exec(cmd)
os.chdir(old_p)
if ret != 0:
@ -433,7 +435,7 @@ def strip(filename):
if not os.path.exists(filename):
return False
cmd = 'strip {}'.format(filename)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
if ret != 0:
raise RuntimeError('failed to strip binary file [{}], ret={}.'.format(filename, ret))
return True
@ -444,7 +446,7 @@ def fix_new_line_flag(filename):
if not os.path.exists(filename):
return False
cmd = 'dos2unix {}'.format(filename)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
if ret != 0:
raise RuntimeError('failed to dos2unix file [{}], ret={}.'.format(filename, ret))
return True
@ -499,7 +501,7 @@ def make_targz(work_path, folder, to_file):
os.chdir(work_path)
cmd = 'tar zcf "{}" "{}"'.format(to_file, folder)
ret, _ = sys_exec(cmd, direct_output=True)
ret, _ = sys_exec(cmd)
ensure_file_exists(to_file)
os.chdir(old_p)

View File

@ -1,14 +1,14 @@
#ifndef __EX_INI_H__
#ifndef __EX_INI_H__
#define __EX_INI_H__
/*
<EFBFBD>ر<EFBFBD>ע<EFBFBD>
1. <EFBFBD><EFBFBD> <EFBFBD>ֺ<EFBFBD>';' <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>'#' <EFBFBD><EFBFBD>Ϊע<EFBFBD><EFBFBD><EFBFBD>еĵ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
2. <EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>
3. ֵ<EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>Ⱥŷָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>пո<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԣ<EFBFBD>֮<EFBFBD><EFBFBD>Ŀո<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD>ո<EFBFBD>
4. <EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD>С<EFBFBD>ڵ<EFBFBD>ֵ<EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>GetDumySection()<EFBFBD><EFBFBD>ȡ
DumySection<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ򵥵<EFBFBD>Python<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
1. ';' '#'
2.
3.
4. 使GetDumySection()
DumySectionPython
*/
#include "ex_str.h"

62
make.sh
View File

@ -1,10 +1,22 @@
#!/bin/bash
PATH_ROOT=$(cd "$(dirname "$0")"; pwd)
CFG_FILE=config.json
#CFG_FILE=config.json
function check_cfg_file
{
if [ ! -f "./${CFG_FILE}" ] ; then
on_error_begin "\`${CFG_FILE}\` does not exists."
echo "please copy \`config.json.in\` into \`${CFG_FILE}\`"
echo "and modify it to fit your condition, then try again."
on_error_end
fi
}
function build_win
{
check_cfg_file
# find pyexec from json file
pyexec=$(grep -P '"pyexec":' ./${CFG_FILE} | grep -Po '(?<="pyexec":)([[:space:]]*)"(.*)"')
# remove left "
@ -41,6 +53,8 @@ function build_win
function build_linux
{
check_cfg_file
if [ `id -u` -eq 0 ]; then
on_error "Do not build as root."
fi
@ -49,20 +63,21 @@ function build_linux
on_error "Sorry, build script works on CentOS 7 only."
fi
X=$(yum list installed | grep "libffi-devel")
if [ "$X-x" = "-x" ] ; then
on_error "Need libffi-devel to build Python, try:\r\n sudo yum install libffi-devel"
fi
X=$(yum list installed | grep "zlib-devel")
if [ "$X-x" = "-x" ] ; then
on_error "Need zlib-devel to build Python, try:\r\n sudo yum install zlib-devel"
fi
PYEXEC=${PATH_ROOT}/external/linux/release/bin/python3.7
PYSTATIC=${PATH_ROOT}/external/linux/release/lib/libpython3.7m.a
if [ ! -f "${PYSTATIC}" ] ; then
X=$(yum list installed | grep "libffi-devel")
if [ "$X-x" = "-x" ] ; then
on_error "Need libffi-devel to build Python, try:\r\n sudo yum install libffi-devel"
fi
X=$(yum list installed | grep "zlib-devel")
if [ "$X-x" = "-x" ] ; then
on_error "Need zlib-devel to build Python, try:\r\n sudo yum install zlib-devel"
fi
echo "python static not found, now build it..."
"${PATH_ROOT}/build/build-py-static.sh"
@ -77,6 +92,8 @@ function build_linux
function build_macos
{
check_cfg_file
python3 -B "${PATH_ROOT}/build/build.py" $@
}
@ -108,24 +125,21 @@ function on_error_end()
# main
##############################################
if [ ! -f "./${CFG_FILE}" ] ; then
on_error_begin "\`${CFG_FILE}\` does not exists."
echo "please copy \`${CFG_FILE}.in\` into \`${CFG_FILE}\`"
echo "and modify it to fit your condition, then try again."
on_error_end
fi
export TP_BUILD_SYSTEM="start"
SYSTEM=`uname -s`
SYSTEM=${SYSTEM:0:4} # cut first 4 char.
echo $SYSTEM
SYS_NAME=`uname -s`
SYS_NAME=${SYS_NAME:0:4} # cut first 4 char.
# echo ${SYS_NAME}
# SYSTEM=${SYSTEM^^} # upper case
if [ $SYSTEM = "Linu" ] ; then
if [ ${SYS_NAME} = "Linu" ] ; then
export CFG_FILE=config.linux.json
build_linux $@
elif [ $SYSTEM = "Darw" ] ; then
elif [ ${SYS_NAME} = "Darw" ] ; then
export CFG_FILE=config.macos.json
build_macos $@
elif [ $SYSTEM == "MSYS" ] ; then
elif [ ${SYS_NAME} == "MSYS" ] ; then
export CFG_FILE=config.win.json
build_win $@
else
on_error_begin "Unsupported platform."