Last active
August 29, 2015 14:06
-
-
Save pauloremoli/37270c18513c687fb085 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import sys | |
import subprocess | |
# Function to configure the project using | |
def configure_command(source_dir, output_dir, params): | |
if ( os.path.exists(output_dir) == False): | |
os.mkdir(output_dir) | |
print ('Created output dir...') | |
os.chdir(output_dir) | |
command_cmake = 'cmake ' | |
for param in params: | |
command_cmake += param + ' ' | |
command_cmake += source_dir | |
print ('Generating project...') | |
# Execute build command | |
execute_command(command_cmake) | |
# Function to build the project | |
def make_command(output_dir, params, project_name): | |
print ('Compiling ' + project_name + '...') | |
command = '' | |
os.chdir(output_dir) | |
#Build for linux | |
if (sys.platform.startswith('linux')): | |
command = 'make ' | |
for param in params: | |
command += param + ' ' | |
#Build for windows | |
elif (sys.platform.startswith('win')): | |
command = 'SET MSBuildEmitSolution=1' | |
execute_command(command) | |
command = 'msbuild ' + project_name + '.sln ' | |
for param in params: | |
print (param) | |
command += param + ' ' | |
# Execute build command | |
execute_command(command) | |
# Function to install the project | |
def install_command(params): | |
print ('Installing...') | |
#Build for linux | |
if (sys.platform.startswith('linux')): | |
command = 'make install ' | |
# Execute build command | |
execute_command(command) | |
print ('Install successfully\n') | |
if (sys.platform.startswith('win')): | |
command = 'msbuild INSTALL.vcxproj ' | |
for param in params: | |
print (param) | |
command += param + ' ' | |
execute_command(command) | |
# Function to create a package to the project, | |
def package_command(output_dir, params): | |
print ('Creating package...') | |
#Build for linux | |
if (sys.platform.startswith('linux')): | |
command = 'make package ' | |
# Execute build command | |
execute_command(command) | |
print ('Make package successfully\n') | |
if (sys.platform.startswith('win')): | |
command = 'msbuild PACKAGE.vcxproj ' | |
for param in params: | |
print (param) | |
command += param + ' ' | |
execute_command(command) | |
def execute_command(command): | |
try: | |
subprocess.check_call(command, shell=True) | |
except Exception: | |
print ('----------------------------') | |
exit() | |
if __name__ == '__main__': | |
mdl() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment