Skip to content

Commit d0ceda2

Browse files
authored
Merge pull request #10125 from hzeller/feature-20260413-zipfs-init
Don't use the same macro expression multiple times.
2 parents f4f68a3 + 7ea9f11 commit d0ceda2

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

bazel/tcl_library_init.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@
1212

1313
#include "tcl.h"
1414

15+
// In tcl 9, we can use the //zipfs:/ virtual file system (unless
16+
// we specifically disabled with the --//bazel:use_zipfs=False flag)
1517
#if TCL_MAJOR_VERSION >= 9 && !defined(USE_TCL_RUNFILE_INIT)
18+
#define USE_ZIPFS_INIT 1
19+
#else
20+
#define USE_ZIPFS_INIT 0
21+
#endif
22+
23+
#if USE_ZIPFS_INIT
1624
#include "bazel/tcl_resources_zip_data.h"
1725
#else
1826

@@ -31,6 +39,7 @@
3139

3240
namespace in_bazel {
3341

42+
#if !USE_ZIPFS_INIT
3443
// Avoid adding any dependencies like boost.filesystem
3544
// Returns path to running binary if possible.
3645
static std::string GetProgramLocation()
@@ -53,12 +62,13 @@ static std::string GetProgramLocation()
5362
}
5463
return Tcl_GetNameOfExecutable();
5564
}
65+
#endif
5666

5767
static std::optional<std::string> TclLibraryMountPoint(Tcl_Interp* interp)
5868
{
5969
// In tcl9, we can use //zipfs:/ otherwise we need to point to the
6070
// directory where the tcl library files are extracted.
61-
#if TCL_MAJOR_VERSION >= 9 && !defined(USE_TCL_RUNFILE_INIT)
71+
#if USE_ZIPFS_INIT
6272
if (TclZipfs_MountBuffer(
6373
interp, kTclResourceZip, sizeof(kTclResourceZip), "/app", 0)
6474
!= TCL_OK) {

0 commit comments

Comments
 (0)