本程序WINDOWS专用,只做抛砖引玉,希望诸位按照各自需求自行修改,主要目的是为了让诸位编译时可以省一些组合指令的时间,只需要修改几个参数即可自动编译。

支持64位编译模式。

改进版本:http://www.cnblogs.com/koangel/p/5673827.html

本程序只是1.0版本,可能不是特别完善,主要是针对我在编译WIN32 BOOST时候的一些需求,已测试过BOOST 1.61。

 # 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"],
["VS110COMNTOOLS","VC110","Visual Studio 2012",False,"Microsoft Visual Studio 11.0"],
["VS120COMNTOOLS","VC120","Visual Studio 2013",False,"Microsoft Visual Studio 12.0"],
["VS140COMNTOOLS","VC140","Visual Studio 2015",False,"Microsoft Visual Studio 14.0"],
["VS150COMNTOOLS","VC150","Visual Studio 2016",False,"Microsoft Visual Studio 15.0"],
] vaild_vs_num = 0 VERSION_KEY = 'VISUALSTUDIOVERSION' # boost编译选项 ,请在此处调整
# 输出目录
build_install_path = "E:/boost/boost_1_61_0"
# 构建32位还是64位
build_is_x64 = False
# 线程模式(不建议修改 ,保持默认)
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():
logtofile("正在构建B2工具集,请耐心等待....")
os.system("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.0 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() temp_old_path = os.path
# 进入BOOST目录
logtofile("跳转进入工作目录...")
os.chdir(boost_work_path); # 检查编译环境
logtofile("检测是否安装VS环境....")
if (check_compiler_env() == False) :
logtofile("未安装VS环境无法继续...")
return 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 = str(os.environ[VERSION_KEY]) # 写出选项
logtofile("检测B2工具集....")
if (os.access("b2.exe",os.F_OK) == False) :
build_b2_tools() # 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
boost_cmd += " --address-model="+cpuMode boost_cmd += ' --prefix="' + build_install_path + '"' if build_is_x64 :
boost_cmd += ' --stagedir=".\bin\x64"' logtofile("生成指令:" + boost_cmd) # 开始编译
os.system(boost_cmd) # 生成完毕
logtofile("生成BOOST完成,请检查是否存在具体错误。") # 开始安装
logtofile("开始安装BOOST...")
os.system(boost_cmd + " install") # ################################################################################
# =========================
# 入口函数
# =========================
if __name__ == '__main__':
main()

[原创]分享本人自己PY写的BOOST编译程序(源码)的更多相关文章

  1. 分享一个与ABP配套使用的代码生成器源码

    点这里进入ABP系列文章总目录 分享一个与ABP配套使用的代码生成器源码 真对不起关注我博客的朋友, 因最近工作很忙, 很久没有更新博客了.以前答应把自用的代码生成器源码共享出来, 也一直没有时间整理 ...

  2. 分享一个难得的YiBo微博客户端应用源码Android版

    今天给大家分享一款,YiBo微博客户端应用源码,这是一款专为Android用户打造的聚合型微博客户端,完美支持新浪微博.腾讯微博.搜狐微博.网易微博和饭否五个微博平台,界面清爽,使用简单轻巧,支持多账 ...

  3. boost.asio源码阅读(2) - task_io_service

    1.0 task_io_service 在boost.asio源码阅读(1)中,代码已经查看到task_io_service中. 具体的操作调用void task_io_service::init_t ...

  4. CENTOS6.6下mysql5.7.11带boost和不带boost的源码安装

    本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn Mysql5.7版本更新后有很多变化,比如json等,连安装都有变化 ...

  5. [转帖]CENTOS6.6下mysql5.7.11带boost和不带boost的源码安装

    CENTOS6.6下mysql5.7.11带boost和不带boost的源码安装 本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuir ...

  6. [原创]Net实现Excel导入导出到数据库(附源码)

    关于数据库导出到Excel和SQLServer数据导出到Excel的例子,在博客园有很多的例子,自己根据网上搜集资料,自己做了亦歌简单的demo,现在分享出来供初学者学习交流使用. 一.数据库导入导出 ...

  7. 分享一个公众号h5裂变吸粉源码工具

    这次我是分享我本人制作的一个恶搞程序,说白了就是一个公众号裂变吸粉工具,市面上有很多引流方法,例如最常见的就是色流,哈哈,今天我跟大家分享的方法是有趣的,好玩的,恶搞的.这个程序上线一天已经收获了61 ...

  8. Java写的斗地主游戏源码

    源码下载在最后 我们的前年的课设要求做一个斗地主程序,当时正在愁如何做界面,当时刚好在学习C#,于是就用C#完成了这个程序.一方面,当时我C#功底还很差(其实现在也不怎么样),很多地方用了“笨办法”, ...

  9. boost.asio源码剖析(一) ---- 前 言

    * 前言 源码之前,了无秘密.                                                       ——侯捷 Boost库是一个可移植.提供源代码的C++库,作 ...

随机推荐

  1. vm虚拟机怎么访问本地硬盘

    第一步:点击VMware菜单“虚拟→设置”,在配置窗口的“选项”标签页内点击“共享文件夹”,在右侧点击“添加”按钮添加要共享的文件夹. 先确认虚拟机是关闭状态(susppend时无法修改属性)再修改虚 ...

  2. [LeetCode系列] 跳跃问题II

    给定一系列非负整数, 每个值代表从此下标可以向前跳跃的最远距离, 试求出跳跃到数组尾端需要的最少步骤. 如给定 [2,3,1,1,4], 返回2. (从下标0跳到1, 从1跳到下标4). 算法描述: ...

  3. jdk版本对应数字

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springfr ...

  4. 【monkeyrunner】monkeyrunner 的的方法介绍

    1.用法:MonkeyRunner.alert(message,title,okTitle) 执行当前脚本弹出一个警示对话框,用户关闭对话框后脚本才结束. message:会话弹出的内容title:会 ...

  5. 安全关闭MySQL

    想要安全关闭 mysqld 服务进程,建议按照下面的步骤来进行: 0.用具有SUPER.ALL等最高权限的账号连接MySQL,最好是用 unix socket 方式连接: 1.在5.0及以上版本,设置 ...

  6. linux Posix 信号量 二

    一.Posix信号量 1.Posix信号量分为两种: 1.   有名信号量:使用Posix IPC名字标识(有名信号量总是既可用于线程间的同步,又可以用于进程间的同步) 2.   内存信号量:存放在共 ...

  7. 关于hashmap的排序

    刚学java不久 之前在学习hashmap的时候 无意间发现,诶?怎么结果是排序的,然后重新输入了好多次,握草,原来java 1.8都实现了hashmap的排序 天真的我没有去网上查,没有去想java ...

  8. 汇编_指令_INC

    加1指令 INC指令功能:目标操作数+1 INC指令只有1个操作数,它将指定的操作数的内容加1,再将结果送回到该操作数.INC指令将影响SF,AF,ZF,PF,OF标志位,但是不影响CF标志位. IN ...

  9. LeetCode 177. Nth Highest Salary

    https://leetcode.com/problems/nth-highest-salary/description/ Write a SQL query to get the nth highe ...

  10. 031:Cetus sharding

    目录 一.主机环境 二.搭建环境 1.准备环境 三.Cetus安装 1.下载包和安装依赖包 2.Cetus安装 1.安装说明 2.安装实施 四.Cetus配置 1.创建和修改配置文件 2.启动cetu ...