build.pl
96 lines
| 2.1 KiB
| text/plain
|
PerlLexer
/ tools / build.pl
Jani Honkonen
|
r1132 | use File::Basename; | |
use feature "switch"; | |||
Jani Honkonen
|
r1203 | use lib 'tools'; | |
Jani Honkonen
|
r1134 | use Jobs; | |
Jani Honkonen
|
r1132 | ||
# read command line params | |||
my $jobname = shift; | |||
Jani Honkonen
|
r1134 | # get script directory | |
my $scriptdir = File::Basename::dirname($0); | |||
Jani Honkonen
|
r1133 | ||
Jani Honkonen
|
r1132 | # read ini file | |
my $inifile = $scriptdir . "/jobs.ini"; | |||
Jani Honkonen
|
r1134 | my %job = Jobs::get($inifile, $jobname); | |
Jani Honkonen
|
r1132 | ||
# examine the platform | |||
Jani Honkonen
|
r1134 | given ($job{'Platform'}) { | |
Jani Honkonen
|
r1140 | ||
Jani Honkonen
|
r1132 | when ("Win7") { | |
Jani Honkonen
|
r1143 | ||
$scriptdir =~ s/\//\\/g; # replace / -> \ | |||
Jani Honkonen
|
r1140 | ||
Jani Honkonen
|
r1132 | # construct a build command | |
Jani Honkonen
|
r1134 | if ($job{'ToolChain'} eq "mingw") { | |
Jani Honkonen
|
r1140 | run($scriptdir . "\\build_win_mingw.bat", $job{'QtDir'}, $job{'Config'}, $job{'MinGWDir'}); | |
Jani Honkonen
|
r1132 | } | |
Jani Honkonen
|
r1140 | elsif ($job{'ToolChain'} eq "vs2005") { | |
run($scriptdir . "\\build_win_vs2005.bat", $job{'QtDir'}, $job{'Config'}); | |||
Jani Honkonen
|
r1132 | } | |
Jani Honkonen
|
r1140 | elsif ($job{'ToolChain'} eq "vs2008") { | |
run($scriptdir . "\\build_win_vs2008.bat", $job{'QtDir'}, $job{'Config'}); | |||
Jani Honkonen
|
r1132 | } | |
Jani Honkonen
|
r1140 | elsif ($job{'ToolChain'} eq "vs2010") { | |
run($scriptdir . "\\build_win_vs2010.bat", $job{'QtDir'}, $job{'Config'}); | |||
} | |||
Jani Honkonen
|
r1156 | elsif ($job{'ToolChain'} eq "vs2010-64bit") { | |
run($scriptdir . "\\build_win_vs2010_64bit.bat", $job{'QtDir'}, $job{'Config'}); | |||
} | |||
Jani Honkonen
|
r1140 | else { | |
die "Unknown toolchain!"; | |||
Jani Honkonen
|
r1132 | } | |
} | |||
Jani Honkonen
|
r1140 | ||
when ("Mac") { | |||
# setup build environment | |||
$ENV{'QTDIR'} = $job{'QtDir'}; | |||
$ENV{'PATH'} = $job{'QtDir'} . "/bin:" . $ENV{'PATH'}; | |||
# run qmake | |||
my $cmd; | |||
if ($job{'ToolChain'} eq "clang") { | |||
run("qmake -r -spec unsupported/macx-clang CONFIG+=" . $job{'Config'}); | |||
} | |||
elsif ($job{'ToolChain'} eq "gcc") { | |||
run("qmake -r CONFIG+=" . $job{'Config'}); | |||
} | |||
else { | |||
die "Unknown toolchain!"; | |||
} | |||
# run make | |||
run("make"); | |||
} | |||
Jani Honkonen
|
r1153 | when ("Linux") { | |
# setup build environment | |||
$ENV{'QTDIR'} = $job{'QtDir'}; | |||
$ENV{'PATH'} = $job{'QtDir'} . "/bin:" . $ENV{'PATH'}; | |||
# run qmake | |||
my $cmd; | |||
if ($job{'ToolChain'} eq "gcc") { | |||
run("qmake -r CONFIG+=" . $job{'Config'}); | |||
} | |||
else { | |||
die "Unknown toolchain!"; | |||
} | |||
# run make | |||
Jani Honkonen
|
r1156 | run("make -j 4"); | |
Jani Honkonen
|
r1153 | } | |
Jani Honkonen
|
r1132 | default { | |
Jani Honkonen
|
r1134 | die "Unknown platform " . $job{'Platform'}; | |
Jani Honkonen
|
r1132 | } | |
Jani Honkonen
|
r1140 | } | |
sub run { | |||
my $cmd; | |||
foreach (@_) { | |||
$cmd .= "$_ "; | |||
} | |||
print "running : $cmd\n"; | |||
system(@_) == 0 or die "system \"$cmd\" failed: $?"; | |||
Jani Honkonen
|
r1132 | } |