本程序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. Archiva与maven配置使用

    在之前的博文里头已经介绍了Archiva私服的使用,本文主要介绍,如何与maven进行配置,在进行maven使用的时候可以自动上传至Archiva上 1.设置maven的用户配置,到maven的安装目 ...

  2. column count of mysql.proc is wrong. expected 20,found 16. the table is probably corruptd.

    1558 1547 column count of mysql.proc is wrong. expected 20,found 16. the table is probably corruptd. ...

  3. 【monkeyrunner】monkeyrunner 实例

    import time import os import re from com.android.monkeyrunner import MonkeyRunner as mr from com.and ...

  4. GCC 三

    前记: 经常浏览博客园的同学应该会觉得本文有标题党之嫌,这个标题的句式来自于MiloYip大牛的大作<C++强大背后>,在此,向Milo兄致意. GCC,全称GNU Compiler Co ...

  5. .net 提取注释生成API文档 帮助文档

    提取注释生成API文档   一.前言 在多人协作的项目中,除了良好的代码规范外,完整的API文档也相当重要.通过文档我们快速了解系统各模块的实际接口,及其使用场景.使用示例,一定程度上降低沟通成本,和 ...

  6. 峰Spring4学习(6)spring AOP的应用例子

    一.AOP简介: 二.AOP实例: 三.使用的例子 需求:在student添加的前后,打印日志信息: 0)spring AOP需要引用的jar包: 1)StudentService.java接口: p ...

  7. 马士兵Spring-AOP-XML配置(2)

    一. UserDAO.java: package com.cy.dao; import com.cy.model.User; public interface UserDAO { public voi ...

  8. C#计数器

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  9. C# 二元一次方程参数求解

    本文记录了关于求直线斜率及纵截距值的简单方法,只是简单的记录下求解思路,最终还需根据具体项目进行优化. 设直线方程式为:y=kx+b 编程思想: 1.代入y1与x1的值,得到:y1=kx1+b 2.代 ...

  10. RAD C++Builder xe7 std::map xtree BUG

    c++Builder 6 下的std::map还能用,有代码提示. 换到xe7,代码提示出来就一个tt.operator [](),代码没法往下写了. 最后把Target Platforms切换到64 ...