Python写的Boost自动编译程序 1.1

改进:

根据自己的环境筛选出已安装环境,并列出 环境提供选择。

支持X64位的自动参数编译。

可以选择编译的参数,其他版本持续改进中

自动编译自动安装到指定目录(需要自己改PY代码)

有需要改进的请继续,自行修改,修改请保留作者版权。

已测试过 WIN10下自动编译B2和编译VS2010版BOOST 1.61

目前仅支持VS2010以及未来版本,仅支持BOOST 1.53以上版本

源码:

# Code by koangel
# EMail: jackliu100@gmail.com
# version : 1.1 beta
# boost 全自动编译工具,仅用于WIN32编译 #
import os
import sys
import string
import signal
import platform
import time reload(sys) # 全局变量设置 #
# boost的源码路径
boost_work_path = "E:/boost/boost_1_61_0" # build log文件名
build_log_file_name = "build_log.txt" # 启动环境变量输出
is_write_evn_log = False # 原始目录
temp_old_path = "" ISOTIMEFORMAT='%Y-%m-%d %X'
# vc环境
g_vs_env_data = [
# env , vc ver
["VS100COMNTOOLS","VC100","Visual Studio 2010",False,"Microsoft Visual Studio 10.0","10.0"],
["VS110COMNTOOLS","VC110","Visual Studio 2012",False,"Microsoft Visual Studio 11.0","11.0"],
["VS120COMNTOOLS","VC120","Visual Studio 2013",False,"Microsoft Visual Studio 12.0","12.0"],
["VS140COMNTOOLS","VC140","Visual Studio 2015",False,"Microsoft Visual Studio 14.0","14.0"],
["VS150COMNTOOLS","VC150","Visual Studio 2016",False,"Microsoft Visual Studio 15.0","15.0"],
] vaild_vs_num = 0 VERSION_KEY = 'VISUALSTUDIOVERSION' # boost编译选项 ,请在此处调整
# 输出目录
build_install_path = "E:/boost/boost_1_61_0"
# 构建32位还是64位
build_is_x64 = True
# 线程模式(不建议修改 ,保持默认)
build_threading_link = "multi"
# 链接模式
build_is_shared_link = False
# 运行库链接模式
build_is_shared_runtime = False
# 编译模式(不建议调试)
build_variant = "debug,release"
# 某些特殊编译模式
build_is_with_python = False
build_is_with_MPI = False def getLogPath():
return boost_work_path + "/" + build_log_file_name # 写出函数
def logtofile(str):
type = sys.getfilesystemencoding()
timeStr = time.strftime(ISOTIMEFORMAT,time.localtime(time.time()))
print("["+ timeStr + "] " +str.decode('utf-8').encode(type))
os.system("echo " + "["+ timeStr + "] " + str.decode('utf-8').encode(type) + " >> " + getLogPath()) def build_b2_tools( toPath ):
logtofile("正在构建B2工具集,请耐心等待....")
os.system(toPath + " & bootstrap.bat >> " + getLogPath() )
logtofile("构建B2工具集完成...") def check_compiler_env() :
logtofile("开始检测VS环境是否有效...")
isFindVC = False
vaild_vs_num = 0
for vi in g_vs_env_data:
if os.environ.has_key(vi[0]) :
logtofile(" 环境:" + vi[2] + " 有效...")
vi[3] = True
vaild_vs_num = vaild_vs_num+1
else:
logtofile(" 环境:" +vi[2] + " 无效...")
isFindVC = True return isFindVC def write_env_data():
if is_write_evn_log :
logtofile("输出全部环境变量:")
for ev in os.environ.data:
logtofile("环境变量:" + str(ev) + " data:" + os.environ[ev]) def main():
print("===========================================================================")
print(" Boost Auto Build Tools for Windows Version 1.1 beta")
print(" Code by Koangel , Using Python 2.7 ")
print(" weibo: http:\\www.weibo.com/koangel")
print(" Visual Studio for vs2010 or newer ")
print(" Boost for boost 1.53 or newer ")
print("===========================================================================") sys.setdefaultencoding('gbk')
#os.remove(getLogPath())
logtofile("检测是否为WINDOWS...")
if (os.name != 'nt'):
logtofile("非WINDOWS环境,无法运行...")
return write_env_data() # 检查编译环境
logtofile("检测是否安装VS环境....")
if (check_compiler_env() == False) :
logtofile("未安装VS环境无法继续...")
return logtofile("请选择X86 or X64:( 1、x86 2、x64 )...")
addrMode = int(raw_input("Select:"))
if addrMode == '' or addrMode == 1:
build_is_x64 = False
elif addrMode == '' or addrMode == 2:
build_is_x64 = True
else:
logtofile("选择错误,请重新运行...")
return logtofile("请选择Runtime模式:( 1、Shared Runtime 2、Static Runtime )...")
smode = int(raw_input("Select:"))
if smode == 1:
build_is_shared_runtime = True
else:
build_is_shared_runtime = False logtofile("请选择Link模式:( 1、Shared 2、Static )...")
smode = int(raw_input("Select:"))
if smode == 1:
build_is_shared_link = True
else:
build_is_shared_link = False nVSIDX = 1
logtofile("请选择一个您需要的编译器版本:") gvslist = []
for vevi in g_vs_env_data:
if vevi[3] :
logtofile(" " + str(nVSIDX) + "、" + vevi[4] + "。")
gvslist.append(vevi)
nVSIDX += 1 vsSel = int(raw_input("Select:"))
if vsSel < 0 or vsSel > len(gvslist):
logtofile("无效的选项,超出选项索引...")
return # 运行关键内容
targetVSEnv = gvslist[vsSel-1]
logtofile("选择编译环境:" + targetVSEnv[4]) toPath = 'call \"'+os.environ[targetVSEnv[0]] + '..\\..\\VC\\vcvarsall.bat\"' if build_is_x64:
toPath += " x86_amd64"
else:
toPath += " x86" #os.system(toPath) temp_old_path = os.path
# 进入BOOST目录
logtofile("跳转进入工作目录...")
os.chdir(boost_work_path); #if (os.environ.has_key(VERSION_KEY) == False) :
# logtofile("未检测到VS环境,自动输出使用方法:")
# logtofile(" 首先使用指定版本的VC工具性运行命令行,具体方法为打开,请尽量使用x86_x64兼容命令行。")
# logtofile(" 以VS2010为例:从vs2010的工具菜单进入命令提示窗口(单击“开始”按钮,指向“所有程序”,指向“Microsoft Visual Studio 2010”,指向“Visual Studio tools(工具)”,然后单击“Visual Studio 2010 command prompt(命令提示)”")
# logtofile(" 之后运行本Python程序即可,Coding by koangel。")
# return toVersion = targetVSEnv[5] #str(os.environ[VERSION_KEY]) # 写出选项
logtofile("检测B2工具集....")
if (os.access("b2.exe",os.F_OK) == False) :
build_b2_tools(toPath) # X86 还是 X64选项
cpuMode = ""
if build_is_x64:
cpuMode = "" logtofile("检测并构建编译命令...")
boost_cmd = "b2 --toolset=msvc-" + toVersion.strip()
if (build_is_with_python == False ):
boost_cmd += " --without-python" if (build_is_with_MPI == False ):
boost_cmd += " --without-mpi" boost_cmd += " threading=" + build_threading_link
boost_cmd += " link="
if build_is_shared_link:
boost_cmd += "shared"
else:
boost_cmd += "static" boost_cmd += " runtime-link="
if build_is_shared_runtime:
boost_cmd += "shared"
else:
boost_cmd += "static" boost_cmd += " variant=" + build_variant if build_is_x64:
boost_cmd += " address-model="+cpuMode boost_cmd += ' --prefix="' + build_install_path + '"' if build_is_x64 :
boost_cmd += ' --stagedir=".\\bin\\x64"' logtofile("生成指令:" + boost_cmd) # 开始编译
#logtofile( toPath + ' & ' + boost_cmd )
os.system( toPath + ' & ' + boost_cmd ) # 生成完毕
logtofile("生成BOOST完成,请检查是否存在具体错误。") # 开始安装
logtofile("开始安装BOOST...")
if build_is_x64 == False:
os.system(boost_cmd + " install") # ################################################################################
# =========================
# 入口函数
# =========================
if __name__ == '__main__':
main()

[分享]PY的Boost自动编译程序 1.1 根据环境自动编译的更多相关文章

  1. windows下用vs2008和boost结合编译程序

      原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://co63oc.blog.51cto.com/904636/504469 win ...

  2. Web自动化框架之五一套完整demo的点点滴滴(excel功能案例参数化+业务功能分层设计+mysql数据存储封装+截图+日志+测试报告+对接缺陷管理系统+自动编译部署环境+自动验证false、error案例)

    标题很大,想说的很多,不知道从那开始~~直接步入正题吧 个人也是由于公司的人员的现状和项目的特殊情况,今年年中后开始折腾web自动化这块:整这个原因很简单,就是想能让自己偷点懒.也让减轻一点同事的苦力 ...

  3. Maven 整合 spring profile实现多环境自动切换

    Maven 整合 spring profile实现多环境自动切换 时间:2014-03-19 15:32来源:Internet 作者:Internet 点击:525次 profile主要用在项目多环境 ...

  4. 简进祥-SVN版本控制方案:多分支并行开发,多环境自动部署

    两地同时开发一个产品,目前线上有3个环境:测试环境.预发布环境.生产环境.目前系统部署采用jenkins自动化部署工具 用jenkins部署的方案 jenkins 测试环境:配置了各个分支的svn 地 ...

  5. svn版本控制方案:多分支并行开发,多环境自动部署

    背景 keywords:svn,trunk,branch,jenkins,maven,merge 两地同时开发一个产品,目前线上有3个环境:测试环境.预发布环境.生产环境.目前系统部署采用jenkin ...

  6. win10彻底禁用自动更新,win10怎样彻底关闭自动更新,永久关闭win10自动更新,win10更新助手

    首先,请广大win10受害者原谅小菜用一个如此长的标题来吸引你们,为了尽最大努力帮助那些饱受win10自动更新折磨的朋友们,小菜不得已出此下策,望见谅! windows 10是一个神奇的操作系统,当你 ...

  7. EF的CodeFirst模式自动迁移(适用于开发环境)

    EF的CodeFirst模式自动迁移(适用于开发环境) 1.开启EF数据迁移功能 NuGet包管理器------>程序包管理控制台---------->Enable-Migrations ...

  8. JPA中自动使用@Table(name = "userTab")后自动将表名、列名添加了下划线的问题

    一.问题 JPA中自动使用@Table(name = "userTab")后自动将表名.列名添加了下划线的问题,如下图: 二.解决 在application.properties文 ...

  9. mybatis generator配置,Mybatis自动生成文件配置,Mybatis自动生成实体Bean配置

    mybatis generator配置,Mybatis自动生成文件配置,Mybatis自动生成实体Bean配置 ============================== 蕃薯耀 2018年3月14 ...

随机推荐

  1. flask第二十四篇——模板【6】自定义过滤器

    请关注孟船长的公众号:自动化测试实战 大家想了解其他过滤器可以参考这里: http://jinja.pocoo.org/docs/dev/templates/#builtin-filters ---- ...

  2. python urllib2 error handling

    python 2 里面的下载实现. https://stackoverflow.com/questions/666022/what-errors-exceptions-do-i-need-to-han ...

  3. 泰克 Tektronix THS720A 示波器 显示屏维修记录

    THS720A 示波器 显示屏维护记录 打开后看到显示屏是 LM32P10 的型号,在网上找了一圈都要 1000 块左右. 看了一个规格书 Sharp 的,已经停产. 下一步看看有没有替代的.

  4. C#:进程、线程、应用程序域(AppDomain)与上下文分析

    进程     进程是操作系统用于隔离众多正在运行的应用程序的机制.在.Net之前,每一个应用程序被加载到单独的进程中,并为该进程指定私有的虚拟内存.进程不能直接访问物理内存,操作系统通过其它的处理把这 ...

  5. GNU Radio: Overview of the GNU Radio Scheduler

    Scetion 1: The Flowgraph The flowgraph moves data from sources into sinks. 一个流图由多个模块组成,其中一般包括信源(Sour ...

  6. Python自然语言处理(1):初识NLP

    由于我们从美国回来就是想把医学数据和医学人工智能的事认真做起来,所以我们选择了比较扎实的解决方法,想快速出成果的请绕道.我们的一些解决方法是:1.整合公开的所有医学词典,尽可能包含更多的标准医学词汇: ...

  7. LCD RGB 控制技术讲解 — 时钟篇(上)

    时序图 下面是LCD RGB 控制的典型时序图  天啊,一下就上这玩意,怎么看??? 其实要解释上面的时序图,我们还需要了解一些LCD的显示过程.所以现在只是有个印象,稍后我们详细讲解. LCD显示流 ...

  8. HDU 4586 Play the Dice(数学期望)

    Play the Dice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tot ...

  9. Bootstrap-CL:徽章

    ylbtech-Bootstrap-CL:徽章 1.返回顶部 1. Bootstrap 徽章(Badges) 本章将讲解 Bootstrap 徽章(Badges).徽章与标签相似,主要的区别在于徽章的 ...

  10. Java之dom4j的简单解析和生成xml的应用

    一.dom4j是一个Java的XML API,是jdom的升级品,用来读写XML文件的.dom4j是一个十分优秀的JavaXML API,具有性能优异.功能强大和极其易使用的特点,它的性能超过sun公 ...