diff --git a/direct/src/dist/FreezeTool.py b/direct/src/dist/FreezeTool.py index 31dd818fb8..ea6919802f 100644 --- a/direct/src/dist/FreezeTool.py +++ b/direct/src/dist/FreezeTool.py @@ -1735,7 +1735,7 @@ class Freezer: return target def generateRuntimeFromStub(self, target, stub_file, use_console, fields={}, - log_append=False): + log_append=False, log_filename_strftime=False): self.__replacePaths() # We must have a __main__ module to make an exe file. @@ -1906,9 +1906,12 @@ class Freezer: # A null entry marks the end of the module table. blob += struct.pack(entry_layout, 0, 0, 0) + # These flags should match the enum in deploy-stub.c flags = 0 if log_append: flags |= 1 + if log_filename_strftime: + flags |= 2 # Compose the header we will be writing to the stub, to tell it # where to find the module data blob, as well as other variables. diff --git a/direct/src/dist/commands.py b/direct/src/dist/commands.py index 633931d8fa..f430a2b2dc 100644 --- a/direct/src/dist/commands.py +++ b/direct/src/dist/commands.py @@ -247,6 +247,7 @@ class build_apps(setuptools.Command): self.extra_prc_data = '' self.default_prc_dir = None self.log_filename = None + self.log_filename_strftime = False self.log_append = False self.requirements_path = os.path.join(os.getcwd(), 'requirements.txt') self.use_optimized_wheels = True @@ -786,7 +787,7 @@ class build_apps(setuptools.Command): 'prc_executable_args_envvar': None, 'main_dir': None, 'log_filename': self.expand_path(self.log_filename, platform), - }, self.log_append) + }, self.log_append, self.log_filename_strftime) stub_file.close() if temp_file: diff --git a/pandatool/src/deploy-stub/deploy-stub.c b/pandatool/src/deploy-stub/deploy-stub.c index 21b99b2fb0..cd5e0fa2ad 100644 --- a/pandatool/src/deploy-stub/deploy-stub.c +++ b/pandatool/src/deploy-stub/deploy-stub.c @@ -39,6 +39,7 @@ /* Stored in the flags field of the blobinfo structure below. */ enum Flags { F_log_append = 1, + F_log_filename_strftime = 2, }; /* Define an exposed symbol where we store the offset to the module data. */ @@ -786,6 +787,14 @@ int main(int argc, char *argv[]) { } if (log_filename != NULL) { + char log_filename_buf[PATH_MAX]; + if (blobinfo.flags & F_log_filename_strftime) { + log_filename_buf[0] = 0; + time_t now = time(NULL); + if (strftime(log_filename_buf, sizeof(log_filename_buf), log_filename, localtime(&now)) > 0) { + log_filename = &log_filename_buf; + } + } setup_logging(log_filename, (blobinfo.flags & F_log_append) != 0); }