Exemplo n.º 1
0
def upgrade_sln(proto_sln: str, compiler: args.Compiler):
    devenv = os.path.join(get_vs_root(compiler), 'devenv.exe')
    print(devenv)
    print(proto_sln)
    if core.is_windows():
        core.flush()
        subprocess.check_call([devenv, proto_sln, '/upgrade'])
Exemplo n.º 2
0
def upgrade_sln(proto_sln: str, compiler: args.Compiler):
    """upgrade a old solution to the current compiler"""
    devenv = get_path_to_devenv(compiler)
    print('Upgrading ', proto_sln, flush=True)
    if core.is_windows():
        subprocess.check_call([devenv, proto_sln, '/upgrade'])
    print('Upgrade done!', flush=True)
Exemplo n.º 3
0
 def build_cmd(self, install: bool):
     cmd = ['cmake', '--build', '.']
     if install:
         cmd.append('--target')
         cmd.append('install')
     cmd.append('--config')
     cmd.append('Release')
     if core.is_windows():
         core.flush()
         subprocess.check_call(cmd, cwd=self.build_folder)
     else:
         print('Calling build on cmake', self.build_folder)
Exemplo n.º 4
0
 def build_cmd(self, install: bool):
     """run cmake build step"""
     cmd = ['cmake', '--build', '.']
     if install:
         cmd.append('--target')
         cmd.append('install')
     cmd.append('--config')
     cmd.append('Release')
     if core.is_windows():
         core.flush()
         subprocess.check_call(cmd, cwd=self.build_folder)
     else:
         print('Calling build on cmake', self.build_folder, flush=True)
Exemplo n.º 5
0
def list_projects_in_solution(path: str) -> typing.List[str]:
    """list all projects in a solution file"""
    project_list = []
    solution_folder = os.path.dirname(path)
    with open(path) as solution_file:
        for line in solution_file:
            match = SOLUTION_PROJECT_REGEX.match(line)
            if match:
                subfolder = match.group(1)
                if not core.is_windows():
                    subfolder = subfolder.replace('\\', '/')
                print(subfolder, flush=True)
                project_list.append(os.path.join(solution_folder, subfolder))
    return project_list
Exemplo n.º 6
0
def get_path_to_devenv(compiler: args.Compiler):
    """gets the path to devenv for the current compiler"""
    # warn if default value?
    devenv = r'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe'
    if core.is_windows():
        vswhere = VSWHERE_EXE
        cmd = [
            vswhere, '-version',
            determine_version_for_vswhere(compiler), '-property', 'productPath'
        ]
        devenv = subprocess.check_output(cmd).decode("utf-8").strip()
        print('devenv is ', devenv, flush=True)

    return devenv
Exemplo n.º 7
0
 def config(self):
     command = ['cmake']
     for arg in self.arguments:
         argument = '-D{}={}'.format(arg.name, arg.value) if arg.type is None else '-D{}:{}={}'.format(arg.name, arg.type, arg.value)
         print('Setting CMake argument for config', argument)
         command.append(argument)
     command.append(self.source_folder)
     command.append('-G')
     command.append(self.generator)
     core.verify_dir_exist(self.build_folder)
     if core.is_windows():
         core.flush()
         subprocess.check_call(command, cwd=self.build_folder)
     else:
         print('Configuring cmake', command)
Exemplo n.º 8
0
def list_projects_in_solution(path: str) -> typing.List[str]:
    ret = []
    dir = os.path.dirname(path)
    pl = re.compile(r'Project\("[^"]+"\) = "[^"]+", "([^"]+)"')
    with open(path) as sln:
        for line in sln:
            # Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "richtext", "wx_richtext.vcxproj", "{7FB0902D-8579-5DCE-B883-DAF66A885005}"
            m = pl.match(line)
            if m:
                subfolder = m.group(1)
                if not core.is_windows():
                    subfolder = subfolder.replace('\\', '/')
                print(subfolder)
                ret.append(os.path.join(dir, subfolder))
    return ret
Exemplo n.º 9
0
def msbuild(sln: str, compiler: args.Compiler, platform: args.Platform, libraries: typing.Optional[typing.List[str]]):
    msbuild_cmd = ['msbuild']
    if libraries is not None:
        msbuild_cmd.append('/t:' + ';'.join(libraries))
    msbuild_cmd.append('/p:Configuration=Release')
    # https://blogs.msdn.microsoft.com/vcblog/2016/02/24/stuck-on-an-older-toolset-version-move-to-visual-studio-2015-without-upgrading-your-toolset/
    # https://stackoverflow.com/questions/33380128/visual-studio-2015-command-line-retarget-solution
    msbuild_cmd.append('/p:PlatformToolset=' + args.get_msbuild_toolset(compiler))
    msbuild_cmd.append('/p:Platform=' + args.platform_as_string(platform))
    msbuild_cmd.append(sln)
    if core.is_windows():
        core.flush()
        subprocess.check_call(msbuild_cmd)
    else:
        print(msbuild_cmd)
Exemplo n.º 10
0
def get_vs_root(compiler: args.Compiler):
    # warn if default value?
    # todo: determine path based on compiler
    vs_root = r'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE'
    if core.is_windows():
        import winreg
        with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\VisualStudio\\14.0') as st:
            val = winreg.QueryValueEx(st, 'InstallDir')
            vs = val[0]
            vs_root = vs
            print('Got path from registry')
        print("This is the vs solution path...", vs_root)
        core.flush()

    return vs_root
Exemplo n.º 11
0
def find_msbuild(compiler: args.Compiler):
    """find path to msbuild"""
    # warn if default value?
    msbuild_path = 'msbuild'
    if core.is_windows():
        vswhere = VSWHERE_EXE
        cmd = [
            vswhere, '-version',
            determine_version_for_vswhere(compiler), '-requires',
            'Microsoft.Component.MSBuild', '-find',
            'MSBuild\\**\\Bin\\MSBuild.exe'
        ]
        msbuild_path = subprocess.check_output(cmd).decode("utf-8").strip()
        print('msbuild from vswhere is ', msbuild_path, flush=True)

    return msbuild_path
Exemplo n.º 12
0
def msbuild(sln: str, compiler: args.Compiler, platform: args.Platform,
            libraries: typing.Optional[typing.List[str]]):
    """run the msbuild command"""
    msbuild_cmd = [find_msbuild(compiler)]
    print('Msbuild is ', msbuild_cmd[0], flush=True)
    if libraries is not None:
        msbuild_cmd.append('/t:' + ';'.join(libraries))
    msbuild_cmd.append('/p:Configuration=Release')
    # https://blogs.msdn.microsoft.com/vcblog/2016/02/24/stuck-on-an-older-toolset-version-move-to-visual-studio-2015-without-upgrading-your-toolset/
    # https://stackoverflow.com/questions/33380128/visual-studio-2015-command-line-retarget-solution
    msbuild_cmd.append('/p:PlatformToolset=' +
                       args.get_msbuild_toolset(compiler))
    msbuild_cmd.append('/p:Platform=' + args.platform_as_string(platform))
    msbuild_cmd.append(sln)
    if core.is_windows():
        subprocess.check_call(msbuild_cmd)
    else:
        print(msbuild_cmd, flush=True)
Exemplo n.º 13
0
 def config(self):
     """run cmake configure step"""
     command = ['cmake']
     for arg in self.arguments:
         argument = arg.format_cmake_argument()
         print('Setting CMake argument for config', argument, flush=True)
         command.append(argument)
     command.append(self.source_folder)
     command.append('-G')
     command.append(self.generator.generator)
     if self.generator.arch is not None:
         command.append('-A')
         command.append(self.generator.arch)
     core.verify_dir_exist(self.build_folder)
     if core.is_windows():
         core.flush()
         subprocess.check_call(command, cwd=self.build_folder)
     else:
         print('Configuring cmake', command, flush=True)