@@ -57,8 +57,7 @@ const shdc_urls = {
57
57
'osx_a64' : 'https://github.com/floooh/sokol-tools-bin/raw/${shdc_full_hash} /bin/osx_arm64/sokol-shdc'
58
58
}
59
59
const shdc_version_file = os.join_path (cache_dir, 'sokol-shdc.version' )
60
- const shdc = shdc_exe ()
61
- const shdc_exe_name = 'sokol-shdc.exe'
60
+ const shdc_exe = os.join_path (cache_dir, 'sokol-shdc.exe' )
62
61
63
62
struct Options {
64
63
show_help bool
@@ -192,7 +191,7 @@ fn compile_shader(opt CompileOptions, shader_file string) ! {
192
191
}
193
192
194
193
cmd :=
195
- '${os.quoted_path(shdc )} --input ${os.quoted_path(shader_file)} --output ${os.quoted_path(out_file)} --slang ' +
194
+ '${os.quoted_path(shdc_exe )} --input ${os.quoted_path(shader_file)} --output ${os.quoted_path(out_file)} --slang ' +
196
195
os.quoted_path (slangs.join (':' ))
197
196
if opt.verbose {
198
197
eprintln ('${tool_name} executing:\n ${cmd} ' )
@@ -238,18 +237,18 @@ fn ensure_external_tools(opt Options) ! {
238
237
return
239
238
}
240
239
241
- is_shdc_available := os.is_file (shdc )
242
- is_shdc_executable := os.is_executable (shdc )
240
+ is_shdc_available := os.is_file (shdc_exe )
241
+ is_shdc_executable := os.is_executable (shdc_exe )
243
242
if opt.verbose {
244
243
eprintln ('reading version from ${shdc_version_file} ...' )
245
244
version := os.read_file (shdc_version_file) or { 'unknown' }
246
- eprintln ('${tool_name} using sokol-shdc version ${version} at "${shdc } "' )
245
+ eprintln ('${tool_name} using sokol-shdc version ${version} at "${shdc_exe } "' )
247
246
eprintln ('executable: ${is_shdc_executable} ' )
248
247
eprintln (' available: ${is_shdc_available} ' )
249
248
if is_shdc_available {
250
- eprintln (' file path: ${shdc } ' )
251
- eprintln (' file size: ${os.file_size(shdc )} ' )
252
- eprintln (' file time: ${time.unix_microsecond(os.file_last_mod_unix(shdc ),
249
+ eprintln (' file path: ${shdc_exe } ' )
250
+ eprintln (' file size: ${os.file_size(shdc_exe )} ' )
251
+ eprintln (' file time: ${time.unix_microsecond(os.file_last_mod_unix(shdc_exe ),
253
252
0)}' )
254
253
}
255
254
}
@@ -260,13 +259,6 @@ fn ensure_external_tools(opt Options) ! {
260
259
download_shdc (opt)!
261
260
}
262
261
263
- // shdc_exe returns an absolute path to the `sokol-shdc` tool.
264
- // Please note that the tool isn't guaranteed to actually be present, nor is
265
- // it guaranteed that it can be invoked.
266
- fn shdc_exe () string {
267
- return os.join_path (cache_dir, shdc_exe_name)
268
- }
269
-
270
262
// download_shdc downloads the `sokol-shdc` tool to an OS specific cache directory.
271
263
fn download_shdc (opt Options) ! {
272
264
// We want to use the same, runtime, OS type as this tool is invoked on.
@@ -284,19 +276,18 @@ fn download_shdc(opt Options) ! {
284
276
if opt.verbose {
285
277
eprintln ('> update_to_shdc_version: ${update_to_shdc_version} | shdc_version: ${shdc_version} ' )
286
278
}
287
- file := shdc_exe ()
288
279
if opt.verbose {
289
- if shdc_version != update_to_shdc_version && os.exists (file ) {
280
+ if shdc_version != update_to_shdc_version && os.exists (shdc_exe ) {
290
281
eprintln ('${tool_name} updating sokol-shdc to version ${shdc_version} ...' )
291
282
} else {
292
283
eprintln ('${tool_name} installing sokol-shdc version ${update_to_shdc_version} ...' )
293
284
}
294
285
}
295
- if os.exists (file ) {
296
- os.rm (file )!
286
+ if os.exists (shdc_exe ) {
287
+ os.rm (shdc_exe )!
297
288
}
298
289
299
- mut dtmp_file , dtmp_path := util.temp_file (util.TempFileOptions{ path: os.dir (file ) })!
290
+ mut dtmp_file , dtmp_path := util.temp_file (util.TempFileOptions{ path: os.dir (shdc_exe ) })!
300
291
dtmp_file.close ()
301
292
if opt.verbose {
302
293
eprintln ('${tool_name} downloading sokol-shdc from ${download_url} ' )
@@ -308,11 +299,7 @@ fn download_shdc(opt Options) ! {
308
299
// Make it executable
309
300
os.chmod (dtmp_path, 0o775 )!
310
301
// Move downloaded file in place
311
- os.mv (dtmp_path, file)!
312
- if runtime_os in ['linux' , 'macos' ] {
313
- // Use the .exe file ending to minimize platform friction.
314
- os.mv (file, shdc)!
315
- }
302
+ os.mv (dtmp_path, shdc_exe)!
316
303
// Update internal version file
317
304
os.write_file (shdc_version_file, shdc_version)!
318
305
}
0 commit comments