Skip to content

Commit 75787ae

Browse files
committed
Added Intel PIN tool
1 parent 3bfb4d1 commit 75787ae

3 files changed

Lines changed: 123 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
from mlc import utils
2+
import os
3+
import subprocess
4+
5+
6+
def preprocess(i):
7+
8+
os_info = i['os_info']
9+
10+
env = i['env']
11+
12+
exe = 'pin.exe' if os_info['platform'] == 'windows' else 'pin'
13+
14+
if env.get('MLC_INTEL_PINTOOL_DIR_PATH', '') == '':
15+
if env.get('MLC_EXTRACT_EXTRACTED_SUBDIR_PATH', '') != '':
16+
env['MLC_INTEL_PINTOOL_DIR_PATH'] = env['MLC_EXTRACT_EXTRACTED_SUBDIR_PATH']
17+
elif env.get('MLC_EXTRACT_EXTRACTED_PATH', '') != '':
18+
env['MLC_INTEL_PINTOOL_DIR_PATH'] = env['MLC_EXTRACT_EXTRACTED_PATH']
19+
else:
20+
return {'return': 1, 'error': 'Intel PINTOOL path not found'}
21+
22+
if 'MLC_INTEL_PINTOOL_BIN_WITH_PATH' not in env:
23+
if env.get('MLC_INTEL_PINTOOL_DIR_PATH', '') != '':
24+
pintool_path = env['MLC_INTEL_PINTOOL_DIR_PATH']
25+
if os.path.exists(os.path.join(pintool_path, 'pin')):
26+
env['MLC_TMP_PATH'] = pintool_path
27+
28+
r = i['automation'].find_artifact({'file_name': exe,
29+
'env': env,
30+
'os_info': os_info,
31+
'default_path_env_key': 'PATH',
32+
'detect_version': True,
33+
'env_path_key': 'MLC_INTEL_PINTOOL_BIN_WITH_PATH',
34+
'run_script_input': i['run_script_input'],
35+
'recursion_spaces': i['recursion_spaces']})
36+
if r['return'] > 0:
37+
return r
38+
39+
return {'return': 0}
40+
41+
42+
def detect_version(i):
43+
r = i['automation'].parse_version({'match_text': r'Pin: pin-([\d.]+)-',
44+
'group_number': 1,
45+
'env_key': 'MLC_INTEL_PINTOOL_VERSION',
46+
'which_env': i['env']})
47+
if r['return'] > 0:
48+
return r
49+
version = r['version']
50+
51+
print(i['recursion_spaces'] + ' Detected version: {}'.format(version))
52+
53+
return {'return': 0, 'version': version}
54+
55+
56+
def postprocess(i):
57+
58+
env = i['env']
59+
state = i['state']
60+
61+
r = detect_version(i)
62+
if r['return'] > 0:
63+
return r
64+
65+
env['MLC_GET_DEPENDENT_CACHED_PATH'] = env['MLC_INTEL_PINTOOL_BIN_WITH_PATH']
66+
if '+PATH' not in env:
67+
env['+PATH'] = []
68+
69+
os_info = i['os_info']
70+
71+
return {'return': 0}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
alias: get-intel-pin-tool
2+
automation_alias: script
3+
automation_uid: 5b4e0237da074764
4+
cache: true
5+
category: MLC Utils
6+
deps:
7+
- tags: detect,os
8+
- enable_if_env:
9+
MLC_DOWNLOAD_URL:
10+
- true
11+
extra_cache_tags: intel,pin,tool,pintool
12+
force_cache: true
13+
skip_if_env:
14+
MLC_INTEL_PINTOOL_DIR_PATH:
15+
- true
16+
tags: download-and-extract,_extract
17+
update_tags_from_env_with_prefix:
18+
_url.:
19+
- MLC_DOWNLOAD_URL
20+
input_mapping:
21+
pintool_dir: MLC_INTEL_PINTOOL_DIR_PATH
22+
new_env_keys:
23+
- MLC_INTEL_PINTOOL_DIR_PATH
24+
- MLC_INTEL_PINTOOL_BIN_WITH_PATH
25+
- MLC_INTEL_PINTOOL_VERSION
26+
- +PATH
27+
new_state_keys: []
28+
post_deps: []
29+
posthook_deps: []
30+
tags:
31+
- get-intel-pin-tool
32+
- get-intel-pintool
33+
- get
34+
- intel
35+
- pintool
36+
- pin
37+
tests:
38+
run_inputs:
39+
- {}
40+
uid: a187464b1a794f23
41+
variations:
42+
version.4.0:
43+
default: true
44+
env:
45+
MLC_DOWNLOAD_URL: https://software.intel.com/sites/landingpage/pintool/downloads/pin-external-4.0-99633-g5ca9893f2-gcc-linux.tar.gz
46+
group: version

script/get-intel-pin-tool/run.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
pintool_bin=${MLC_INTEL_PINTOOL_BIN_WITH_PATH}
3+
echo "${pintool_bin} -version"
4+
5+
${pintool_bin} -version > tmp-ver.out
6+
test $? -eq 0 || exit $?

0 commit comments

Comments
 (0)