Skip to content

Commit

Permalink
cmake - improve NO_ENCRYPT flag
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardGe committed Jun 20, 2024
1 parent 24fb85b commit d14726e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ include(${CMAKE_SOURCE_DIR}/contrib/Orochi/Orochi/enable_cuew.cmake)

# Base output directory
set(BASE_OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dist/bin)
file(MAKE_DIRECTORY "${BASE_OUTPUT_DIR}/Debug")
file(MAKE_DIRECTORY "${BASE_OUTPUT_DIR}/Release")

# Set output directories for each build configuration
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} Debug Release RelWithDebInfo MinSizeRel)
Expand Down Expand Up @@ -293,6 +295,9 @@ endif()

if(NOT NO_ENCRYPT)
target_compile_definitions(${HIPRT_NAME} PRIVATE HIPRT_ENCRYPT )
set(ENV{HIPRT_NO_ENCRYPT} "OFF")
else()
set(ENV{HIPRT_NO_ENCRYPT} "ON")
endif()

if(HIPRT_PREFER_HIP_5)
Expand Down
9 changes: 8 additions & 1 deletion tools/stringify.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
defines = {}
replaced = []

# A classic usage is to have this optional temporary env var created during the cmake process (through the 'NO_ENCRYPT' cmake option) before calling this python script.
# If this env var is ON, it overides the encyption and disable it.
no_encrypt = os.getenv('HIPRT_NO_ENCRYPT') == 'ON'

def encrypt(message, key):
file = open('./tmp.txt',mode='w')
file.write(message)
Expand Down Expand Up @@ -81,7 +85,7 @@ def printfile(filename, ans, enablePrint, api):
if( ekey != '' ):
b = a
else:
b = ('"'+a.replace("\"", "\\\"").replace("'", "\\'") + '\\n"')
b = ('"'+a.replace("\\", "\\\\").replace("\"", "\\\"").replace("'", "\\'") + '\\n"')
ans += ''+b+'\n'
return ans

Expand Down Expand Up @@ -109,6 +113,9 @@ def stringify(filename, stringname, api):

if len(argvs) >= 3:
ekey = argvs[2]
if no_encrypt:
ekey = ''


#files = ['IntegratorGpuLightSamplerTestKernel.cl','Math.cl']

Expand Down

0 comments on commit d14726e

Please sign in to comment.