Example #1
0
def vcbuild(context, filepath, config, platform=None, use_env=False, extra=None, ignore_errors=False):
    """Build a Visual C++ project file or solution
    
    Uses vcbuild for vc9 and older, msbuild otherwise 
    
    Arguments:
    context -- BuildContext instance
    filepath -- path to project or solution
    config -- the solution configuration to use
    extras -- extra command line options to pass to vcbuild or msbuild
    ignore_errors -- ignore CalledProcessError or not
    """
    if platform is None:
        if context.arch == "x64":
            platform = "x64"
        else:
            platform = "Win32"
    if extra is None:
        extra = []
    
    use_env_opt = ""
    
    if int(vc_version(context.toolchain)) > 9:
        if use_env:
            use_env_opt = "/p:UseEnv=true"  
        system.run_cmd("msbuild", [filepath, "/m", "/nologo", "/verbosity:minimal",
                                   "/p:Configuration=" + config,
                                   "/p:Platform=" + platform, use_env_opt] + extra, 
                                   ignore_errors=ignore_errors)
    else: 
        if use_env:
            use_env_opt = "/useenv"        
        system.run_cmd("vcbuild", [filepath, "{0}|{1}".format(config, platform), use_env_opt] + extra, 
                       ignore_errors=ignore_errors)
Example #2
0
def cmake(context, options={}, build_dir=""):
    """Configure a CMake based project

    The current directory is assumed to be the top level source directory
    CMAKE_INSTALL_PREFIX will be set to context.install_dir
    
    Arguments:
    context -- BuildContext instance
    options -- dictionary of CMake cache variables
    build_dir -- the directory used for the build (defaults to ./cmake_build)
    """
    if not build_dir:
        build_dir = "cmake_build"
    
    if not os.path.exists(build_dir):
        os.mkdir(build_dir)
        
    os.chdir(build_dir)
    
    args = ["-D", "CMAKE_INSTALL_PREFIX=" + context.install_dir]
    for i in options.iteritems():
        args.extend(["-D", "=".join(i)])
    args.extend(["-G", cmake_generator(context.toolchain, context.arch)])
    args.append(os.path.relpath(".", build_dir))
    
    system.run_cmd("cmake", args)
    
    os.chdir("..")
Example #3
0
def vcproj_upgrade(vcproj_file):
    new_name = os.path.splitext(vcproj_file)[0] + ".vcxproj"
    
    if not os.path.exists(new_name):
        system.run_cmd("vcupgrade", [vcproj_file])
    
    return new_name
Example #4
0
 def stage(self):
     if not os.path.exists(self.dest_dir):
         os.mkdir(self.dest_dir)
     
     if self._src_needs_update(self.dest_dir, self.svn_dir):
         logging.getLogger().info("Copying to build directory...")      
         system.run_cmd("svn",  ["export", "--force", self.svn_dir, self.dest_dir])
Example #5
0
 def fetch(self):
     if not os.path.exists(os.path.join(self.git_dir, "HEAD")):
         logging.getLogger().info("Cloning {0}...".format(os.path.basename(self.url)))
         system.run_cmd("git", ["clone", "--bare", self.url, self.git_dir])
     else:
         logging.getLogger().info("Updating {0}...".format(os.path.basename(self.git_dir)))
         system.run_cmd("git", ["--git-dir=" + self.git_dir, "fetch"])
Example #6
0
 def stage(self):
     if not os.path.exists(self.dest_dir):
         os.mkdir(self.dest_dir)
     
     if self._src_needs_update(self.dest_dir, self.hg_dir):
         old_cwd = os.getcwd()
         os.chdir(self.hg_dir)
         
         logging.getLogger().info("Checking out {0}...".format(self.revision))        
         system.run_cmd("hg",  ["archive", "-S", "-y", "-r", self.revision, "-t", "files", self.dest_dir])
         
         os.chdir(old_cwd)
Example #7
0
 def fetch(self):
     if not os.path.exists(os.path.join(self.hg_dir, ".hg")):
         logging.getLogger().info("Cloning {0}...".format(os.path.basename(self.url)))
         system.run_cmd("hg", ["clone", "--noupdate", self.url, self.hg_dir])
     else:
         old_cwd = os.getcwd()
         os.chdir(self.hg_dir)
         
         logging.getLogger().info("Updating {0}...".format(os.path.basename(self.hg_dir)))
         system.run_cmd("hg", ["pull"])
         
         os.chdir(old_cwd)
Example #8
0
 def stage(self):
     if not os.path.exists(self.dest_dir):
         os.mkdir(self.dest_dir)
     
     if self._src_needs_update(self.dest_dir, self.git_dir):
         options = ["--git-dir=" + self.git_dir, 
                    "--work-tree=" + self.dest_dir, 
                    "checkout", "-q", "-f"]
         if self.revision:
             options.append(self.revision)
         
         logging.getLogger().info("Checking out {0}...".format(self.revision))
         system.run_cmd("git",  options)
Example #9
0
 def fetch(self):
     if not os.path.exists(os.path.join(self.svn_dir, ".svn")):
         options = ["checkout", self.url, self.svn_dir]
         if self.revision:
             options.extend(["-r", self.revision])
         
         logging.getLogger().info("Checking out {0}...".format(os.path.basename(self.url)))
         system.run_cmd("svn", options)
     else:
         if not self.revision:
             old_cwd = os.getcwd()
             os.chdir(self.svn_dir)
             
             logging.getLogger().info("Updating {0}...".format(os.path.basename(self.svn_dir)))
             system.run_cmd("svn", ["up"])
             
             os.chdir(old_cwd)
Example #10
0
def cmd_archive(path=None):
    if path is None:
        path = os.path.dirname(config.global_config().current_bundle())
    
    bundle_name = os.path.basename(config.global_config().current_bundle())
    archive_path = os.path.join(path, bundle_name)
    
    if config.os_name() == "win":
        try:
            system.run_cmd("7z", ["a", "-r", 
                           archive_path + ".7z", 
                           config.global_config().current_bundle()])
        except exceptions.CalledProcessError as e:
            if e.returncode != 1:
                raise
    else:
        system.run_cmd("zip", ["-r", 
                               archive_path + ".zip", 
                               config.global_config().current_bundle()])
Example #11
0
def distutils(context, debug=False):
    if context.os_name == "win":
        tmp_site_packages = context.install_dir + "\\Lib\site-packages"
        makedirs(tmp_site_packages, exist_ok=True)
        context.env["PYTHONPATH"] = tmp_site_packages
        context.env["INCLUDE"] += context.bundle_path + "\\include\python2.7;"
        context.env["LIB"] += context.bundle_path + "\\lib;"
    
    if debug:
        system.run_cmd("python", ["setup.py", "build", "--debug"])
    
    system.run_cmd("python", ["setup.py", "build"])
    system.run_cmd("python", ["setup.py", "install", "--prefix=" + context.install_dir])
Example #12
0
def configure(context, options=[]):
    args = ["--prefix=" + context.install_dir]
    args.extend(options)
    system.run_cmd("./configure", args)