Skip to content

Commit d2c6fc3

Browse files
committed
Move and package hipcc and hipconfig scripts from HIPAMD to HIPCC
1 parent 0f2f8ed commit d2c6fc3

File tree

7 files changed

+1033
-0
lines changed

7 files changed

+1033
-0
lines changed

amd/hipcc/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ else()
9292
endif()
9393
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}")
9494

95+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin
96+
DESTINATION .
97+
USE_SOURCE_PERMISSIONS)
9598
install(FILES
9699
"LICENSE.txt"
97100
"README.md"

amd/hipcc/bin/hipcc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env perl
2+
# Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
22+
# Need perl > 5.10 to use logic-defined or
23+
use 5.006; use v5.10.1;
24+
25+
use warnings;
26+
27+
use File::Basename;
28+
use File::Spec::Functions 'catfile';
29+
30+
# TODO: By default select perl script until change incorporated in HIP build script.
31+
my $USE_PERL_SCRIPT = $ENV{'HIP_USE_PERL_SCRIPTS'};
32+
$USE_PERL_SCRIPT //= 1; # use defined-or assignment operator. Use env var, but if not defined default to 1.
33+
34+
my $isWindows = ($^O eq 'MSWin32' or $^O eq 'msys');
35+
# escapes args with quotes SWDEV-341955
36+
foreach $arg (@ARGV) {
37+
if ($isWindows) {
38+
$arg =~ s/[^-a-zA-Z0-9_=+,.:\/\\ ]/\\$&/g;
39+
}
40+
}
41+
42+
my $SCRIPT_DIR=dirname(__FILE__);
43+
if ($USE_PERL_SCRIPT) {
44+
#Invoke hipcc.pl
45+
my $HIPCC_PERL=catfile($SCRIPT_DIR, '/hipcc.pl');
46+
system($^X, $HIPCC_PERL, @ARGV);
47+
} else {
48+
$BIN_NAME="/hipcc.bin";
49+
if ($isWindows) {
50+
$BIN_NAME="/hipcc.bin.exe";
51+
}
52+
my $HIPCC_BIN=catfile($SCRIPT_DIR, $BIN_NAME);
53+
if ( -e $HIPCC_BIN ) {
54+
#Invoke hipcc.bin
55+
system($HIPCC_BIN, @ARGV);
56+
} else {
57+
print "hipcc.bin not present; Install HIPCC binaries before proceeding";
58+
exit(-1);
59+
}
60+
}
61+
62+
# Because of this wrapper we need to check
63+
# the output of the system command for perl and bin
64+
# else the failures are ignored and build fails silently
65+
if ($? == -1) {
66+
exit($?);
67+
}
68+
elsif ($? & 127) {
69+
exit($?);
70+
}
71+
else {
72+
$CMD_EXIT_CODE = $? >> 8;
73+
}
74+
exit($CMD_EXIT_CODE);

amd/hipcc/bin/hipcc.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@set HIPCC="%~dp0hipcc"
2+
@perl %HIPCC% %*

0 commit comments

Comments
 (0)