Skip to content

Commit

Permalink
Clean up get-llvm
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsuresh committed Oct 7, 2022
1 parent 4667eeb commit a94896e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
3 changes: 1 addition & 2 deletions cm-mlops/script/get-gcc/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ def preprocess(i):
recursion_spaces = i['recursion_spaces']

file_name_c = 'gcc.exe' if os_info['platform'] == 'windows' else 'gcc'
file_name_cpp = 'g++.exe' if os_info['platform'] == 'windows' else 'g++'
if 'CM_GCC_INSTALLED_PATH' not in env:
if 'CM_GCC_BIN_WITH_PATH' not in env:
r = i['automation'].find_artifact({'file_name': file_name_c,
'env': env,
'os_info':os_info,
Expand Down
19 changes: 9 additions & 10 deletions cm-mlops/script/get-llvm/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ def preprocess(i):
recursion_spaces = i['recursion_spaces']

file_name_c = 'clang.exe' if os_info['platform'] == 'windows' else 'clang'
file_name_cpp = 'clang++.exe' if os_info['platform'] == 'windows' else 'clang++'
env['FILE_NAME_C'] = file_name_c
env['FILE_NAME_CPP'] = file_name_cpp
if 'CM_LLVM_INSTALLED_PATH' not in env:
if 'CM_LLVM_CLANG_BIN_WITH_PATH' not in env:

r = i['automation'].find_artifact({'file_name': file_name_c,
'env': env,
Expand All @@ -30,8 +28,6 @@ def preprocess(i):
else:
return r

env['CM_LLVM_INSTALLED_PATH'] = r['found_path']

return {'return':0}

def detect_version(i):
Expand All @@ -53,21 +49,24 @@ def postprocess(i):
env = i['env']
r = detect_version(i)
if r['return'] >0: return r

version = env['CM_LLVM_CLANG_VERSION']
env['CM_LLVM_CLANG_CACHE_TAGS'] = 'version-'+version
env['CM_COMPILER_CACHE_TAGS'] = 'version-'+version+',family-llvm'
env['CM_COMPILER_FAMILY'] = 'LLVM'
env['CM_COMPILER_VERSION'] = env['CM_LLVM_CLANG_VERSION']

file_name_c = env['FILE_NAME_C']
file_name_cpp = env['FILE_NAME_CPP']
found_path = env['CM_LLVM_INSTALLED_PATH']
found_file_path = env['CM_LLVM_CLANG_BIN_WITH_PATH']

found_path = os.path.dirname(found_file_path)
file_name_c = os.path.basename(found_file_path)
file_name_cpp = file_name_c.replace("clang", "clang++")

env['CM_LLVM_CLANG_BIN']=file_name_c
env['CM_LLVM_CLANG_BIN_WITH_PATH']=os.path.join(found_path, file_name_c)

# General compiler for general program compilation
env['CM_C_COMPILER_BIN']=file_name_c
env['CM_C_COMPILER_WITH_PATH']=os.path.join(found_path, file_name_c)
env['CM_C_COMPILER_WITH_PATH']=found_file_path

env['CM_CXX_COMPILER_BIN']=file_name_cpp
env['CM_CXX_COMPILER_WITH_PATH']=os.path.join(found_path, file_name_cpp)
Expand Down
3 changes: 1 addition & 2 deletions cm-mlops/script/get-llvm/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash
clang_bin=${CM_LLVM_INSTALLED_PATH}/${FILE_NAME_C}
clang_bin=${CM_LLVM_CLANG_BIN_WITH_PATH:-$clang_bin}
clang_bin=${CM_LLVM_CLANG_BIN_WITH_PATH}
${clang_bin} --version > tmp-ver.out
test $? -eq 0 || exit 1
3 changes: 1 addition & 2 deletions cm-mlops/script/get-python3/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def preprocess(i):

recursion_spaces = i['recursion_spaces']

if env.get('CM_PYTHON_INSTALLED_PATH','') == '':
if 'CM_PYTHON_BIN_WITH_PATH' not in env:
file_name = 'python.exe' if os_info['platform'] == 'windows' else 'python3'

r = i['automation'].find_artifact({'file_name': file_name,
Expand Down Expand Up @@ -52,7 +52,6 @@ def postprocess(i):

version = r['version']

# Depends if we come directly from install, or we use get first and then
found_file_path = env['CM_PYTHON_BIN_WITH_PATH']

found_path = os.path.dirname(found_file_path)
Expand Down
3 changes: 3 additions & 0 deletions cm-mlops/script/install-llvm-prebuilt/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def preprocess(i):
recursion_spaces = i['recursion_spaces']

need_version = env.get('CM_VERSION','')
clang_file_name = "clang"
if need_version == '':
return {'return':1, 'error':'internal problem - CM_VERSION is not defined in env'}

Expand All @@ -28,6 +29,7 @@ def preprocess(i):

elif os_info['platform'] == 'windows':
package_name = 'LLVM-' + need_version + '-win' + host_os_bits + '.exe'
clang_file_name = "clang.exe"

print('')
print('WARNING: Please copy the following path and then paste it')
Expand Down Expand Up @@ -108,6 +110,7 @@ def preprocess(i):
env['CM_LLVM_PACKAGE'] = filename

env['CM_LLVM_INSTALLED_PATH'] = os.path.join(os.getcwd(), 'bin')
env['CM_LLVM_CLANG_BIN_WITH_PATH'] = os.path.join(os.getcwd(), 'bin', clang_file_name)
env['CM_TMP_GET_DEPENDENT_CACHED_PATH'] = os.getcwd()

return {'return':0}
5 changes: 4 additions & 1 deletion cm-mlops/script/install-llvm-src/_cm.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"cache": true,
"post_deps": [
{
"tags": "get,llvm"
"tags": "get,llvm",
"skip_if_env": {
"CM_TMP_REQUIRE_INSTALL": [ "yes" ]
}
}
],
"tags": [
Expand Down
5 changes: 3 additions & 2 deletions cm-mlops/script/install-llvm-src/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ def preprocess(i):
return {'return':1, 'error':'internal problem - CM_VERSION is not defined in env'}

print (recursion_spaces + ' # Requested version: {}'.format(need_version))

clang_file_name = "clang"
env['CM_GIT_CHECKOUT'] = 'llvmorg-' + need_version

env['CM_LLVM_INSTALLED_PATH'] = os.path.join(os.getcwd(), 'install', 'bin')
env['CM_TMP_FAIL_IF_NOT_FOUND'] = 'yes'
env['CM_LLVM_CLANG_BIN_WITH_PATH'] = os.path.join(os.getcwd(), 'bin', clang_file_name)
env['CM_TMP_GET_DEPENDENT_CACHED_PATH'] = os.getcwd()

return {'return':0}

0 comments on commit a94896e

Please sign in to comment.