From cf105f276c55b7a02b87c527bc01f56ef3df306b Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 28 Dec 2016 20:23:27 +0100 Subject: [PATCH 01/10] More alignment fixes for 32-byte AVX --- dtool/src/dtoolbase/deletedBufferChain.cxx | 4 ++-- dtool/src/dtoolbase/dtoolbase.h | 5 +++++ panda/src/linmath/lsimpleMatrix.h | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dtool/src/dtoolbase/deletedBufferChain.cxx b/dtool/src/dtoolbase/deletedBufferChain.cxx index 122edf8837..557b6ce9d8 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.cxx +++ b/dtool/src/dtoolbase/deletedBufferChain.cxx @@ -71,7 +71,7 @@ allocate(size_t size, TypeHandle type_handle) { // Allocate memory, and make sure the object starts at the proper alignment. void *mem = NeverFreeMemory::alloc(alloc_size); - intptr_t pad = ((intptr_t)flag_reserved_bytes - (intptr_t)mem) % MemoryHook::get_memory_alignment(); + intptr_t pad = (-(intptr_t)flag_reserved_bytes - (intptr_t)mem) % MemoryHook::get_memory_alignment(); obj = (ObjectNode *)((uintptr_t)mem + pad); #ifdef USE_DELETEDCHAINFLAG @@ -80,7 +80,7 @@ allocate(size_t size, TypeHandle type_handle) { void *ptr = node_to_buffer(obj); -#ifdef _DEBUG +#ifndef NDEBUG assert(((uintptr_t)ptr % MemoryHook::get_memory_alignment()) == 0); #endif diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index b192f24055..c6cbbd7f46 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -339,21 +339,26 @@ typedef struct _object PyObject; #define ALIGN_4BYTE #define ALIGN_8BYTE #define ALIGN_16BYTE +#define ALIGN_32BYTE #define ALIGN_64BYTE #elif defined(_MSC_VER) #define ALIGN_4BYTE __declspec(align(4)) #define ALIGN_8BYTE __declspec(align(8)) #define ALIGN_16BYTE __declspec(align(16)) +#define ALIGN_32BYTE __declspec(align(32)) #define ALIGN_64BYTE __declspec(align(64)) #elif defined(__GNUC__) #define ALIGN_4BYTE __attribute__ ((aligned (4))) #define ALIGN_8BYTE __attribute__ ((aligned (8))) #define ALIGN_16BYTE __attribute__ ((aligned (16))) +#define ALIGN_32BYTE __attribute__ ((aligned (32))) #define ALIGN_64BYTE __attribute__ ((aligned (64))) #else #define ALIGN_4BYTE #define ALIGN_8BYTE #define ALIGN_16BYTE +#define ALIGN_32BYTE +#define ALIGN_64BYTE #endif // Do we need to implement memory-alignment enforcement within the MemoryHook diff --git a/panda/src/linmath/lsimpleMatrix.h b/panda/src/linmath/lsimpleMatrix.h index 0ba2dc1196..5669e18be3 100644 --- a/panda/src/linmath/lsimpleMatrix.h +++ b/panda/src/linmath/lsimpleMatrix.h @@ -58,7 +58,9 @@ private: #endif // HAVE_EIGEN // This is as good a place as any to define this alignment macro. -#ifdef LINMATH_ALIGN +#if defined(LINMATH_ALIGN) && defined(HAVE_EIGEN) && defined(__AVX__) +#define ALIGN_LINMATH ALIGN_32BYTE +#elif defined(LINMATH_ALIGN) #define ALIGN_LINMATH ALIGN_16BYTE #else #define ALIGN_LINMATH From fa851ae5acb2b0ce06a2ae425f896ce7acb983c4 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Jan 2017 22:42:05 +0100 Subject: [PATCH 02/10] Allow custom version to be passed on to makewheel when building with --wheel --- makepanda/makepanda.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 95dc6d791b..c96d188bcb 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -52,6 +52,7 @@ RUNTIME=0 DISTRIBUTOR="" VERSION=None DEBVERSION=None +WHLVERSION=None RPMRELEASE="1" GIT_COMMIT=None P3DSUFFIX=None @@ -163,7 +164,7 @@ def usage(problem): def parseopts(args): global INSTALLER,WHEEL,RTDIST,RUNTIME,GENMAN,DISTRIBUTOR,VERSION global COMPRESSOR,THREADCOUNT,OSXTARGET,OSX_ARCHS,HOST_URL - global DEBVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX,RTDIST_VERSION + global DEBVERSION,WHLVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX,RTDIST_VERSION global STRDXSDKVERSION, WINDOWS_SDK, MSVC_VERSION, BOOUSEINTELCOMPILER longopts = [ "help","distributor=","verbose","runtime","osxtarget=", @@ -206,8 +207,11 @@ def parseopts(args): elif (option=="--arch"): target_arch = value.strip() elif (option=="--nocolor"): DisableColors() elif (option=="--version"): - VERSION=value - if (len(VERSION.split(".")) != 3): raise Exception + match = re.match(r'^\d+\.\d+\.\d+', value) + if not match: + usage("version requires three digits") + WHLVERSION = value + VERSION = match.group() elif (option=="--lzma"): COMPRESSOR="lzma" elif (option=="--override"): AddOverride(value.strip()) elif (option=="--static"): SetLinkAllStatic(True) @@ -7257,7 +7261,7 @@ try: if WHEEL: ProgressOutput(100.0, "Building wheel") from makewheel import makewheel - makewheel(VERSION, GetOutputDir()) + makewheel(WHLVERSION, GetOutputDir()) finally: SaveDependencyCache() From 40ea0ab7869a77093d4d60fe31f01fcf58d60089 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Jan 2017 22:46:57 +0100 Subject: [PATCH 03/10] cppparser: support directives __LINE__, __FILE__, __has_include --- dtool/src/cppparser/cppPreprocessor.cxx | 247 +++++++++++++++++------- dtool/src/cppparser/cppPreprocessor.h | 3 + 2 files changed, 177 insertions(+), 73 deletions(-) diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index 83050d3c41..feda153530 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -809,6 +809,8 @@ expand_manifests(const string &input_expr, bool expand_undefined, // Here's an identifier. Is it "defined"? if (ident == "defined") { expand_defined_function(expr, q, p); + } else if (expand_undefined && ident == "__has_include") { + expand_has_include_function(expr, q, p, loc); } else { // Is it a manifest? Manifests::const_iterator mi = _manifests.find(ident); @@ -817,6 +819,20 @@ expand_manifests(const string &input_expr, bool expand_undefined, expand_manifest_inline(expr, q, p, manifest); manifest_found = true; + } else if (ident == "__FILE__") { + // Special case: this is a dynamic definition. + string file = string("\"") + loc.file._filename_as_referenced.get_fullpath() + "\""; + expr = expr.substr(0, q) + file + expr.substr(p); + p = q + file.size(); + manifest_found = true; + + } else if (ident == "__LINE__") { + // So is this. + string line = format_string(loc.first_line); + expr = expr.substr(0, q) + line + expr.substr(p); + p = q + line.size(); + manifest_found = true; + } else if (expand_undefined && ident != "true" && ident != "false") { // It is not found. Expand it to 0, but only if we are currently // parsing an #if expression. @@ -1486,14 +1502,10 @@ handle_undef_directive(const string &args, const YYLTYPE &loc) { */ void CPPPreprocessor:: handle_ifdef_directive(const string &args, const YYLTYPE &loc) { - Manifests::const_iterator mi = _manifests.find(args); - if (mi != _manifests.end()) { - // The macro is defined. We continue. - return; + if (!is_manifest_defined(args)) { + // The macro is undefined. Skip stuff. + skip_false_if_block(true); } - - // The macro is undefined. Skip stuff. - skip_false_if_block(true); } /** @@ -1501,17 +1513,12 @@ handle_ifdef_directive(const string &args, const YYLTYPE &loc) { */ void CPPPreprocessor:: handle_ifndef_directive(const string &args, const YYLTYPE &loc) { - Manifests::const_iterator mi = _manifests.find(args); - if (mi == _manifests.end()) { - // The macro is undefined. We continue. - return; + if (is_manifest_defined(args)) { + // The macro is defined. Skip stuff. + skip_false_if_block(true); } - - // The macro is defined. Skip stuff. - skip_false_if_block(true); } - /** * */ @@ -1593,6 +1600,8 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { _angle_includes.insert(filename); } } + } else { + warning("Ignoring invalid #include directive", loc); } filename.set_text(); @@ -1600,71 +1609,30 @@ handle_include_directive(const string &args, const YYLTYPE &loc) { // Now look for the filename. If we didn't use angle quotes, look first in // the current directory. - bool found_file = false; CPPFile::Source source = CPPFile::S_none; - if (okflag) { - found_file = false; + if (find_include(filename, angle_quotes, source)) { + _last_c = '\0'; - // Search the current directory. - if (!angle_quotes && !found_file && filename.exists()) { - found_file = true; + // If it was explicitly named on the command-line, mark it S_local. + filename.make_canonical(); + if (_explicit_files.count(filename)) { source = CPPFile::S_local; } - // Search the same directory as the includer. - if (!angle_quotes && !found_file) { - Filename match(get_file()._filename.get_dirname(), filename); - if (match.exists()) { - filename = match; - found_file = true; - source = CPPFile::S_alternate; - } + CPPFile file(filename, filename_as_referenced, source); + + // Don't include it if we included it before and it had #pragma once. + ParsedFiles::const_iterator it = _parsed_files.find(file); + if (it != _parsed_files.end() && it->_pragma_once) { + return; } - // Now search the angle-include-path - if (angle_quotes && !found_file && filename.resolve_filename(_angle_include_path)) { - found_file = true; - source = CPPFile::S_system; - } - - // Now search the quote-include-path - if (!angle_quotes && !found_file) { - for (size_t dir=0; dir<_quote_include_path.get_num_directories(); dir++) { - Filename match(_quote_include_path.get_directory(dir), filename); - if (match.exists()) { - filename = match; - found_file = true; - source = _quote_include_kind[dir]; - } - } - } - - if (!found_file) { - warning("Cannot find " + filename.get_fullpath(), loc); - } else { - _last_c = '\0'; - - // If it was explicitly named on the command-line, mark it S_local. - filename.make_canonical(); - if (_explicit_files.count(filename)) { - source = CPPFile::S_local; - } - - CPPFile file(filename, filename_as_referenced, source); - - // Don't include it if we included it before and it had #pragma once. - ParsedFiles::const_iterator it = _parsed_files.find(file); - if (it != _parsed_files.end() && it->_pragma_once) { - return; - } - - if (!push_file(file)) { - warning("Unable to read " + filename.get_fullpath(), loc); - } + if (!push_file(file)) { + warning("Unable to read " + filename.get_fullpath(), loc); } } else { - warning("Ignoring invalid #include directive", loc); + warning("Cannot find " + filename.get_fullpath(), loc); } } @@ -1779,6 +1747,69 @@ skip_false_if_block(bool consider_elifs) { _save_comments = true; } +/** + * Returns true if the given manifest is defined. + */ +bool CPPPreprocessor:: +is_manifest_defined(const string &manifest_name) { + Manifests::const_iterator mi = _manifests.find(manifest_name); + if (mi != _manifests.end()) { + return true; + } + + if (manifest_name == "__has_include" || + manifest_name == "__FILE__" || + manifest_name == "__LINE__") { + // Special built-in directives that are considered "defined". + return true; + } + + return false; +} + +/** + * Locates the given filename. Changes the first argument to the full path. + */ +bool CPPPreprocessor:: +find_include(Filename &filename, bool angle_quotes, CPPFile::Source &source) { + // Now look for the filename. If we didn't use angle quotes, look first in + // the current directory. + if (!angle_quotes && filename.exists()) { + source = CPPFile::S_local; + return true; + } + + // Search the same directory as the includer. + if (!angle_quotes) { + Filename match(get_file()._filename.get_dirname(), filename); + if (match.exists()) { + filename = match; + source = CPPFile::S_alternate; + return true; + } + } + + // Now search the angle-include-path + if (angle_quotes && filename.resolve_filename(_angle_include_path)) { + source = CPPFile::S_system; + return true; + } + + // Now search the quote-include-path + if (!angle_quotes) { + for (size_t dir = 0; dir < _quote_include_path.get_num_directories(); ++dir) { + Filename match(_quote_include_path.get_directory(dir), filename); + if (match.exists()) { + filename = match; + source = _quote_include_kind[dir]; + return true; + } + } + } + + return false; +} + /** * */ @@ -1885,6 +1916,14 @@ get_identifier(int c) { if (mi != _manifests.end() && !should_ignore_manifest((*mi).second)) { return expand_manifest((*mi).second); } + if (name == "__FILE__") { + return get_literal(SIMPLE_STRING, loc, loc.file._filename_as_referenced); + } + if (name == "__LINE__") { + YYSTYPE result; + result.u.integer = loc.first_line; + return CPPToken(INTEGER, loc, "", result); + } // Check for keywords. int kw = check_keyword(name); @@ -2227,9 +2266,7 @@ expand_defined_function(string &expr, size_t q, size_t &p) { vector_string args; extract_manifest_args_inline("defined", 1, -1, args, expr, p); if (args.size() >= 1) { - const string &manifest_name = args[0]; - Manifests::const_iterator mi = _manifests.find(manifest_name); - if (mi != _manifests.end()) { + if (is_manifest_defined(args[0])) { // The macro is defined; the result is "1". result = "1"; } else { @@ -2242,6 +2279,70 @@ expand_defined_function(string &expr, size_t q, size_t &p) { p = q + result.size(); } +/** + * Expands the __has_include(manifest) function to either 1 or 0, depending on + * whether the include file exists. + */ +void CPPPreprocessor:: +expand_has_include_function(string &expr, size_t q, size_t &p, YYLTYPE loc) { + bool found_file = false; + + // Skip whitespace till paren. + while (p < expr.size() && isspace(expr[p])) { + p++; + } + size_t args_begin = p + 1; + + vector_string args; + extract_manifest_args_inline("__has_include", 1, -1, args, expr, p); + + if (!args.empty() && args[0].size() >= 2) { + Filename filename; + bool angle_quotes = false; + + string inc = args[0]; + + // Just to play things safe, since our manifest-expansion logic might not + // filter out quotes and angle brackets properly, we'll only expand + // manifests if we don't begin with a quote or bracket. + if (!inc.empty() && (inc[0] != '"' && inc[0] != '<')) { + inc = expand_manifests(inc, false, loc); + } + + if (inc[0] == '"' && inc[inc.size() - 1] == '"') { + filename = inc.substr(1, inc.size() - 2); + } else if (inc[0] == '<' && inc[inc.size() - 1] == '>') { + filename = inc.substr(1, inc.size() - 2); + if (!_noangles) { + // If _noangles is true, we don't make a distinction between angle + // brackets and quote marks--all #inc statements are treated the + // same, as if they used quote marks. + angle_quotes = true; + } + } else { + loc.last_column += loc.first_column + p - 2; + loc.first_column += args_begin; + warning("invalid argument for __has_include() directive", loc); + expr = expr.substr(0, q) + "0" + expr.substr(p); + p = q + 1; + return; + } + + filename.set_text(); + + CPPFile::Source source = CPPFile::S_none; + found_file = find_include(filename, angle_quotes, source); + } else { + loc.last_column += loc.first_column + p - 2; + loc.first_column += args_begin; + warning("invalid argument for __has_include() directive", loc); + } + + string result = found_file ? "1" : "0"; + expr = expr.substr(0, q) + result + expr.substr(p); + p = q + result.size(); +} + /** * */ diff --git a/dtool/src/cppparser/cppPreprocessor.h b/dtool/src/cppparser/cppPreprocessor.h index e375b259dd..e119211596 100644 --- a/dtool/src/cppparser/cppPreprocessor.h +++ b/dtool/src/cppparser/cppPreprocessor.h @@ -143,6 +143,8 @@ private: void handle_error_directive(const string &args, const YYLTYPE &loc); void skip_false_if_block(bool consider_elifs); + bool is_manifest_defined(const string &manifest_name); + bool find_include(Filename &filename, bool angle_quotes, CPPFile::Source &source); CPPToken get_quoted_char(int c); CPPToken get_quoted_string(int c); @@ -153,6 +155,7 @@ private: void extract_manifest_args(const string &name, int num_args, int va_arg, vector_string &args); void expand_defined_function(string &expr, size_t q, size_t &p); + void expand_has_include_function(string &expr, size_t q, size_t &p, YYLTYPE loc); void expand_manifest_inline(string &expr, size_t q, size_t &p, const CPPManifest *manifest); void extract_manifest_args_inline(const string &name, int num_args, From 40e981e485c383367d5f2a9bacf2b906ea90df2d Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Jan 2017 22:47:58 +0100 Subject: [PATCH 04/10] makepanda: enable C++11 support by default --- makepanda/makepanda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index c96d188bcb..92f7edb5f7 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1194,7 +1194,7 @@ def CompileCxx(obj,src,opts): if (COMPILER=="GCC"): if (src.endswith(".c")): cmd = GetCC() +' -fPIC -c -o ' + obj - else: cmd = GetCXX()+' -ftemplate-depth-70 -fPIC -c -o ' + obj + else: cmd = GetCXX()+' -std=gnu++0x -ftemplate-depth-70 -fPIC -c -o ' + obj for (opt, dir) in INCDIRECTORIES: if (opt=="ALWAYS") or (opt in opts): cmd += ' -I' + BracketNameWithQuotes(dir) for (opt, dir) in FRAMEWORKDIRECTORIES: From 9facf874aba9b2b051b8cd1f0e62bb8baf68cda3 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 4 Jan 2017 23:53:24 +0100 Subject: [PATCH 05/10] Let compiler synthesize QuadDef move assignment operator This hopefully fixes a compile issue with older clang versions. --- panda/src/text/textAssembler.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/panda/src/text/textAssembler.h b/panda/src/text/textAssembler.h index 1215765bf5..64b4c7ef03 100644 --- a/panda/src/text/textAssembler.h +++ b/panda/src/text/textAssembler.h @@ -212,21 +212,6 @@ private: typedef pmap GeomCollectorMap; struct QuadDef { - // Copying this class is a performance hotspot, hence we define the move - // constructor. - ALWAYS_INLINE QuadDef() {} - ALWAYS_INLINE QuadDef(const QuadDef ©) : - _dimensions(copy._dimensions), _uvs(copy._uvs), - _slantl(copy._slantl), _slanth(copy._slanth), - _glyph(copy._glyph) {} - -#ifdef USE_MOVE_SEMANTICS - ALWAYS_INLINE QuadDef(QuadDef &&from) NOEXCEPT : - _dimensions(from._dimensions), _uvs(from._uvs), - _slantl(from._slantl), _slanth(from._slanth), - _glyph(move(from._glyph)) {} -#endif - LVecBase4 _dimensions; LVecBase4 _uvs; PN_stdfloat _slantl, _slanth; From 603f0eb3b18b72b8fe85b6710c8c63fbb80330c8 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 4 Jan 2017 16:28:38 -0800 Subject: [PATCH 06/10] fix occasional crash in PNMImage::quick_filter_from() --- panda/src/pnmimage/pnm-image-filter.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/pnmimage/pnm-image-filter.cxx b/panda/src/pnmimage/pnm-image-filter.cxx index ac57b20b23..63398ad3c1 100644 --- a/panda/src/pnmimage/pnm-image-filter.cxx +++ b/panda/src/pnmimage/pnm-image-filter.cxx @@ -696,7 +696,7 @@ box_filter_line(const PNMImage &image, // Get the final (partial) xel float x_contrib = x1 - (float)x_last; - if (x_contrib > 0.0001f) { + if (x_contrib > 0.0001f && x < image.get_x_size()) { box_filter_xel(image, x, y, x_contrib, y_contrib, color, pixel_count); } @@ -728,7 +728,7 @@ box_filter_region(const PNMImage &image, // Get the final (partial) row float y_contrib = y1 - (float)y_last; - if (y_contrib > 0.0001f) { + if (y_contrib > 0.0001f && y < image.get_y_size()) { box_filter_line(image, x0, y, x1, y_contrib, color, pixel_count); } From c4d232b0be9de4e64fd067d8deb3ebe7953b0da5 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 4 Jan 2017 16:56:09 -0800 Subject: [PATCH 07/10] publish PfmVizzer destructor to fix leak --- panda/src/grutil/pfmVizzer.I | 4 ++++ panda/src/grutil/pfmVizzer.h | 1 + 2 files changed, 5 insertions(+) diff --git a/panda/src/grutil/pfmVizzer.I b/panda/src/grutil/pfmVizzer.I index 6a0a5a23bc..2185248829 100644 --- a/panda/src/grutil/pfmVizzer.I +++ b/panda/src/grutil/pfmVizzer.I @@ -19,6 +19,10 @@ get_pfm() { return _pfm; } +INLINE PfmVizzer:: +~PfmVizzer() { +} + /** * Returns the reference to the PfmFile manipulated by this PfmVizzer. */ diff --git a/panda/src/grutil/pfmVizzer.h b/panda/src/grutil/pfmVizzer.h index 7b466f0ee3..e8423f8dd1 100644 --- a/panda/src/grutil/pfmVizzer.h +++ b/panda/src/grutil/pfmVizzer.h @@ -30,6 +30,7 @@ class GeomVertexWriter; class EXPCL_PANDA_GRUTIL PfmVizzer { PUBLISHED: PfmVizzer(PfmFile &pfm); + INLINE ~PfmVizzer(); INLINE PfmFile &get_pfm(); INLINE const PfmFile &get_pfm() const; From 127cbc3b3840dace259d092353a3251aa8942693 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 5 Jan 2017 17:15:42 +0100 Subject: [PATCH 08/10] Windows installer improvements and fixes: - copy .ico file - write installer log to install.log - restore python DLL to bin directory --- makepanda/installer.nsi | 70 +++++++++++++++++++++++++++++++++++------ makepanda/makepanda.py | 17 +++++----- 2 files changed, 70 insertions(+), 17 deletions(-) diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index d934cc4ee0..d004d15006 100755 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -141,8 +141,9 @@ SectionGroup "Panda3D Libraries" SetDetailsPrint listonly SetOutPath "$INSTDIR" - File "${BUILT}\LICENSE" - File /r /x CVS "${BUILT}\ReleaseNotes" + File /nonfatal "${BUILT}\LICENSE" + File /nonfatal "${BUILT}\ReleaseNotes" + File /nonfatal "${BUILT}\pandaIcon.ico" SetOutPath $INSTDIR\etc File /r "${BUILT}\etc\*" @@ -532,15 +533,17 @@ Section "Sample programs" SecSamples WriteINIStr $INSTDIR\Manual.url "InternetShortcut" "URL" "https://www.panda3d.org/manual/index.php" WriteINIStr $INSTDIR\Samples.url "InternetShortcut" "URL" "https://www.panda3d.org/manual/index.php/Sample_Programs_in_the_Distribution" SetOutPath $INSTDIR - CreateShortCut "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk" "$INSTDIR\Manual.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Panda3D Manual" - CreateShortCut "$SMPROGRAMS\${TITLE}\Panda3D Website.lnk" "$INSTDIR\Website.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Panda3D Website" - CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Program Manual.lnk" "$INSTDIR\Samples.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Sample Program Manual" + CreateShortCut "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk" "$INSTDIR\Manual.url" "" "$INSTDIR\pandaIcon.ico" 0 "" "" "Panda3D Manual" + CreateShortCut "$SMPROGRAMS\${TITLE}\Panda3D Website.lnk" "$INSTDIR\Website.url" "" "$INSTDIR\pandaIcon.ico" 0 "" "" "Panda3D Website" + CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Program Manual.lnk" "$INSTDIR\Samples.url" "" "$INSTDIR\pandaIcon.ico" 0 "" "" "Sample Program Manual" FindFirst $0 $1 $INSTDIR\samples\* loop: StrCmp $1 "" done StrCmp $1 "." next StrCmp $1 ".." next + FindFirst $2 $3 $INSTDIR\samples\$1\*.py + StrCmp $3 "" next Push $1 Push "-" Push " " @@ -557,14 +560,13 @@ Section "Sample programs" SecSamples DetailPrint "Creating shortcuts for sample program $READABLE" CreateDirectory "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE" SetOutPath $INSTDIR\samples\$1 - WriteINIStr $INSTDIR\samples\$1\ManualPage.url "InternetShortcut" "URL" "http://panda3d.org/wiki/index.php/Sample_Programs:_$MANPAGE" - CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\Manual Page.lnk" "$INSTDIR\samples\$1\ManualPage.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Manual Entry on this Sample Program" + WriteINIStr $INSTDIR\samples\$1\ManualPage.url "InternetShortcut" "URL" "https://www.panda3d.org/wiki/index.php/Sample_Programs:_$MANPAGE" + CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\Manual Page.lnk" "$INSTDIR\samples\$1\ManualPage.url" "" "$INSTDIR\pandaIcon.ico" 0 "" "" "Manual Entry on this Sample Program" CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\View Source Code.lnk" "$INSTDIR\samples\$1" - FindFirst $2 $3 $INSTDIR\samples\$1\*.py iloop: StrCmp $3 "" idone - CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\Run $3.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Run $3" - CreateShortCut "$INSTDIR\samples\$1\Run $3.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Run $3" + CreateShortCut "$SMPROGRAMS\${TITLE}\Sample Programs\$READABLE\Run $3.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\pandaIcon.ico" 0 SW_SHOWMINIMIZED "" "Run $3" + CreateShortCut "$INSTDIR\samples\$1\Run $3.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\pandaIcon.ico" 0 SW_SHOWMINIMIZED "" "Run $3" FindNext $2 $3 goto iloop idone: @@ -684,6 +686,10 @@ Section -post DetailPrint "Broadcasting WM_WININICHANGE message..." SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=500 + # Now dump the log to disk. + StrCpy $0 "$INSTDIR\install.log" + Push $0 + Call DumpLog SectionEnd Section Uninstall @@ -1235,3 +1241,47 @@ done: Exch $R3 FunctionEnd + +!define LVM_GETITEMCOUNT 0x1004 +!define LVM_GETITEMTEXT 0x102D + +Function DumpLog + Exch $5 + Push $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $6 + + FindWindow $0 "#32770" "" $HWNDPARENT + GetDlgItem $0 $0 1016 + StrCmp $0 0 exit + FileOpen $5 $5 "w" + StrCmp $5 "" exit + SendMessage $0 ${LVM_GETITEMCOUNT} 0 0 $6 + System::Alloc ${NSIS_MAX_STRLEN} + Pop $3 + StrCpy $2 0 + System::Call "*(i, i, i, i, i, i, i, i, i) i \ + (0, 0, 0, 0, 0, r3, ${NSIS_MAX_STRLEN}) .r1" + loop: StrCmp $2 $6 done + System::Call "User32::SendMessageA(i, i, i, i) i \ + ($0, ${LVM_GETITEMTEXT}, $2, r1)" + System::Call "*$3(&t${NSIS_MAX_STRLEN} .r4)" + FileWrite $5 "$4$\r$\n" + IntOp $2 $2 + 1 + Goto loop + done: + FileClose $5 + System::Free $1 + System::Free $3 + exit: + Pop $6 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 + Exch $5 +FunctionEnd diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 92f7edb5f7..2e54cc2058 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2871,11 +2871,13 @@ if tp_dir is not None: CopyAllFiles(GetOutputDir() + "/bin/", tp_dir + "extras/bin/") if not PkgSkip("PYTHON") and not RTDIST: - #XXX rdb I don't think we need to copy over the Python DLL, do we? - #pydll = "/" + SDK["PYTHONVERSION"].replace(".", "") - #if (GetOptimize() <= 2): pydll += "_d.dll" - #else: pydll += ".dll" - #CopyFile(GetOutputDir() + "/bin" + pydll, SDK["PYTHON"] + pydll) + # We need to copy the Python DLL to the bin directory for now. + pydll = "/" + SDK["PYTHONVERSION"].replace(".", "") + if GetOptimize() <= 2: + pydll += "_d.dll" + else: + pydll += ".dll" + CopyFile(GetOutputDir() + "/bin" + pydll, SDK["PYTHON"] + pydll) #for fn in glob.glob(SDK["PYTHON"] + "/vcruntime*.dll"): # CopyFile(GetOutputDir() + "/bin/", fn) @@ -2949,6 +2951,7 @@ if GetTarget() == 'windows': # Convert to Windows newlines so they can be opened by notepad. WriteFile(GetOutputDir() + "/LICENSE", ReadFile("doc/LICENSE"), newline='\r\n') WriteFile(GetOutputDir() + "/ReleaseNotes", ReadFile("doc/ReleaseNotes"), newline='\r\n') + CopyFile(GetOutputDir() + "/pandaIcon.ico", "panda/src/configfiles/pandaIcon.ico") else: CopyFile(GetOutputDir()+"/", "doc/LICENSE") CopyFile(GetOutputDir()+"/", "doc/ReleaseNotes") @@ -6596,7 +6599,7 @@ def MakeInstallerNSIS(file, title, installdir): AddToPathEnv("PATH", GetOutputDir() + "\\bin") AddToPathEnv("PATH", GetOutputDir() + "\\plugins") - cmd = sys.executable + " -B -u direct\\src\\plugin_installer\\make_installer.py" + cmd = sys.executable + " -B -u " + os.path.join("direct", "src", "plugin_installer", "make_installer.py") cmd += " --version %s --regview %s" % (VERSION, regview) if GetTargetArch() == 'x64': @@ -6605,7 +6608,7 @@ def MakeInstallerNSIS(file, title, installdir): cmd += " --install \"$PROGRAMFILES32\\Panda3D\" " oscmd(cmd) - shutil.move("direct\\src\\plugin_installer\\p3d-setup.exe", file) + shutil.move(os.path.join("direct", "src", "plugin_installer", "p3d-setup.exe"), file) return print("Building "+title+" installer at %s" % (file)) From 53752bd3762cd9dbe9d7ba38c14594ff058367b2 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 5 Jan 2017 17:22:11 +0100 Subject: [PATCH 09/10] Remove packpanda and eggcacher, don't require libpython on Linux --- direct/src/directbase/ppython.cxx | 106 ---- direct/src/directscripts/eggcacher.py | 11 +- direct/src/directscripts/packpanda.nsi | 831 ------------------------- direct/src/directscripts/packpanda.py | 424 ------------- makepanda/installer.nsi | 9 +- makepanda/makepanda.py | 22 +- makepanda/makepandacore.py | 2 +- makepanda/makewheel.py | 1 - 8 files changed, 20 insertions(+), 1386 deletions(-) delete mode 100644 direct/src/directbase/ppython.cxx delete mode 100755 direct/src/directscripts/packpanda.nsi delete mode 100755 direct/src/directscripts/packpanda.py diff --git a/direct/src/directbase/ppython.cxx b/direct/src/directbase/ppython.cxx deleted file mode 100644 index e460de766c..0000000000 --- a/direct/src/directbase/ppython.cxx +++ /dev/null @@ -1,106 +0,0 @@ -// This is a little wrapper to make it easy to run a python program from the -// command line. Basically, it just interfaces to the Python API and imports -// the module that was specified by the IMPORT_MODULE preprocessor definition -// when it was compiled. - -#include "dtoolbase.h" - -#undef _POSIX_C_SOURCE -#undef _XOPEN_SOURCE -#include -#if PY_MAJOR_VERSION >= 3 -#include -#endif - -#ifndef IMPORT_MODULE -#error IMPORT_MODULE must be defined when compiling ppython.cxx ! -#endif - -#define _STRINGIFY(s) #s -#define STRINGIFY(s) _STRINGIFY(s) -#define IMPORT_MODULE_STR STRINGIFY(IMPORT_MODULE) - -#if defined(_WIN32) && PY_MAJOR_VERSION >= 3 -// As Py_SetProgramName expects a wchar_t*, it's easiest to just use the wmain -// entry point. -int wmain(int argc, wchar_t *argv[]) { - Py_SetProgramName(argv[0]); - -#elif PY_MAJOR_VERSION >= 3 -// Convert from UTF-8 to wchar_t*. -int main(int argc, char *mb_argv[]) { - wchar_t **argv = new wchar_t*[argc + 1]; - for (int i = 0; i < argc; ++i) { - size_t len = mbstowcs(NULL, mb_argv[i], 0); - argv[i] = new wchar_t[len + 1]; - mbstowcs(argv[i], mb_argv[i], len); - argv[i][len] = 0; - } - // Just for good measure - argv[argc] = NULL; - - Py_SetProgramName(argv[0]); - -#else -// Python 2. -int main(int argc, char *argv[]) { - Py_SetProgramName(argv[0]); -#endif - - // On Windows, we need to set pythonhome correctly. We'll try to find - // ppython.exe on the path and set pythonhome to its location. -#ifdef _WIN32 -#if PY_MAJOR_VERSION >= 3 - // Py_SetPythonHome expects a wchar_t in Python 3. - wchar_t *path = _wgetenv(L"PATH"); - wchar_t *result = wcstok(path, L";"); - while (result != NULL) { - struct _stat st; - wchar_t *ppython = (wchar_t*) malloc(wcslen(result) * 2 + 26); - wcscpy(ppython, result); - wcscat(ppython, L"\\python.exe"); - if (_wstat(ppython, &st) == 0) { - Py_SetPythonHome(result); - free(ppython); - break; - } - result = wcstok(NULL, L";"); - free(ppython); - } -#else - char *path = getenv("PATH"); - char *result = strtok(path, ";"); - while (result != NULL) { - struct stat st; - char *ppython = (char*) malloc(strlen(result) + 13); - strcpy(ppython, result); - strcat(ppython, "\\ppython.exe"); - if (stat(ppython, &st) == 0) { - Py_SetPythonHome(result); - free(ppython); - break; - } - result = strtok(NULL, ";"); - free(ppython); - } -#endif -#endif - - Py_Initialize(); - - if (Py_VerboseFlag) { - fprintf(stderr, "Python %s\\n%s\\n", Py_GetVersion(), Py_GetCopyright()); - } - - PySys_SetArgv(argc, argv); - - int sts = 0; - PyObject* m = PyImport_ImportModule(IMPORT_MODULE_STR); - if (m <= 0) { - PyErr_Print(); - sts = 1; - } - - Py_Finalize(); - return sts; -} diff --git a/direct/src/directscripts/eggcacher.py b/direct/src/directscripts/eggcacher.py index ad11303fe0..6dcee8e2d3 100644 --- a/direct/src/directscripts/eggcacher.py +++ b/direct/src/directscripts/eggcacher.py @@ -87,8 +87,13 @@ class EggCacher: TexturePool.releaseAllTextures() progress += size -cacher = EggCacher(sys.argv[1:]) -# Dummy main function so this can be added to console_scripts. -def main(): +def main(args=None): + if args is None: + args = sys.argv[1:] + + cacher = EggCacher(args) return 0 + +if __name__ == '__main__': + sys.exit(main()) diff --git a/direct/src/directscripts/packpanda.nsi b/direct/src/directscripts/packpanda.nsi deleted file mode 100755 index 73c9011d9a..0000000000 --- a/direct/src/directscripts/packpanda.nsi +++ /dev/null @@ -1,831 +0,0 @@ -; Panda3D installation script for the Nullsoft Installation System (NSIS). -; Jon Parise -; with Ben Johnson -; with Jason Pratt -; mangled by Josh Yelon - -; Caller needs to define these variables: -; -; COMPRESSOR - either zlib or lzma -; NAME - name of what we're building (ie, "Panda3D" or "Airblade") -; SMDIRECTORY - where to put this in the start menu (ie, "Panda3D 1.1.0" or "Airblade 1.1.0") -; INSTALLDIR - where to install the program (ie, "C:\Program Files\Panda3D-1.1.0") -; OUTFILE - where to put the output file (ie, "..\nsis-output.exe") -; LICENSE - location of the license file (ie, "C:\Airblade\LICENSE.TXT") -; LANGUAGE - name of the Language file to use (ie, "English" or "Panda3DEnglish") -; RUNTEXT - text for run-box at end of installation (ie, "Run the Panda Greeting Card") -; IBITMAP - name of installer bitmap (ie, "C:\Airblade\Airblade.bmp") -; UBITMAP - name of uninstaller bitmap (ie, "C:\Airblade\Airblade.bmp") -; -; PANDA - location of panda install tree. -; PYVER - version of Python that Panda was built with (ie, "2.7") -; PANDACONF - name of panda config directory - usually $PANDA\etc -; PSOURCE - location of the panda source-tree if available, OR location of panda install tree. -; PYEXTRAS - directory containing python extras, if any. -; REGVIEW - either 32 or 64, depending on the build architecture. -; -; PPGAME - directory containing prepagaged game, if any (ie, "C:\My Games\Airblade") -; PPMAIN - python program containing prepackaged game, if any (ie, "Airblade.py") -; PPICON - file containing icon of prepackaged game. -; - -!include "MUI.nsh" -!include "WinMessages.nsh" -Name "${NAME}" -InstallDir "${INSTALLDIR}" -OutFile "${OUTFILE}" - -SetCompress auto -SetCompressor ${COMPRESSOR} - -!define MUI_WELCOMEFINISHPAGE_BITMAP "${IBITMAP}" -!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${UBITMAP}" - -!define MUI_ABORTWARNING -!define MUI_FINISHPAGE_NOREBOOTSUPPORT -!define MUI_FINISHPAGE_RUN -!define MUI_FINISHPAGE_RUN_FUNCTION runFunction -!define MUI_FINISHPAGE_RUN_TEXT "${RUNTEXT}" - -!insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_LICENSE "${LICENSE}" -!insertmacro MUI_PAGE_DIRECTORY -!insertmacro MUI_PAGE_INSTFILES -!insertmacro MUI_PAGE_FINISH - -!insertmacro MUI_UNPAGE_WELCOME -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES -!insertmacro MUI_UNPAGE_FINISH - -!insertmacro MUI_LANGUAGE "${LANGUAGE}" - -ShowInstDetails nevershow -ShowUninstDetails nevershow - -LicenseData "${LICENSE}" - -InstType "Typical" - -!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS - -var READABLE -var MANPAGE -var TUTNAME - -Function runFunction - !ifdef PPGAME - ExecShell "open" "$SMPROGRAMS\${SMDIRECTORY}\Play ${NAME}.lnk" - !else - ExecShell "open" "$SMPROGRAMS\${SMDIRECTORY}\Panda Manual.lnk" - !endif -FunctionEnd - -Section "${SMDIRECTORY}" SecCore - SectionIn 1 2 3 RO - - SetDetailsPrint none - SetOutPath $INSTDIR - SetOverwrite try - - SetOutPath $INSTDIR - File "${PANDA}\LICENSE" - SetOutPath $INSTDIR\bin - File /r "${PANDA}\bin\*.dll" - File /nonfatal /r "${PANDA}\bin\*.pyd" - File /nonfatal /r "${PANDA}\bin\Microsoft.*.manifest" - SetOutPath $INSTDIR\etc - File /r "${PANDACONF}\*" - SetOutPath $INSTDIR\direct\directscripts - File /r /x CVS /x Opt?-Win32 "${PANDA}\direct\directscripts\*" - SetOutPath $INSTDIR\direct\filter - File /r /x CVS /x Opt?-Win32 "${PANDA}\direct\filter\*.sha" - SetOutPath $INSTDIR\direct - File /r /x CVS /x Opt?-Win32 "${PANDA}\direct\*.py" - Delete "$INSTDIR\panda3d.py" - Delete "$INSTDIR\panda3d.pyc" - Delete "$INSTDIR\panda3d.pyo" - SetOutPath $INSTDIR\pandac - File /r "${PANDA}\pandac\*.py" - SetOutPath $INSTDIR\panda3d - File /r "${PANDA}\panda3d\*.py" - File /r "${PANDA}\panda3d\*.pyd" - SetOutPath $INSTDIR\python - File /r "${PANDA}\python\*" - RMDir /r "$SMPROGRAMS\${SMDIRECTORY}" - CreateDirectory "$SMPROGRAMS\${SMDIRECTORY}" - - !ifdef PPGAME - - SetOutPath $INSTDIR\models - File /r /x CVS "${PANDA}\models\*" - SetOutPath $INSTDIR\bin - File /r "${PANDA}\bin\eggcacher.exe" - SetOutpath $INSTDIR\game - File /r "${PPGAME}\*" - CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Play ${NAME}.lnk" "$INSTDIR\python\ppython.exe" "-E ${PPMAIN}" "$INSTDIR\${PPICON}" 0 SW_SHOWMINIMIZED "" "Play ${NAME}" - # Preload all EGG files into the model-cache - SetOutPath $INSTDIR - SetDetailsPrint textonly - SetDetailsView show - nsExec::ExecToLog '"$INSTDIR\bin\eggcacher.exe" --concise game' - SetDetailsPrint none - SetDetailsView hide - - !else - - SetOutPath $INSTDIR\plugins - File /nonfatal /r "${PANDA}\plugins\*.dle" - File /nonfatal /r "${PANDA}\plugins\*.dlo" - File /nonfatal /r "${PANDA}\plugins\*.mll" - File /nonfatal /r "${PANDA}\plugins\*.mel" - File /nonfatal /r "${PANDA}\plugins\*.ms" - File "${PSOURCE}\doc\INSTALLING-PLUGINS.TXT" - SetOutPath $INSTDIR\pandac\input - File /r "${PANDA}\pandac\input\*" - SetOutPath $INSTDIR\bin - File /r "${PANDA}\bin\*.exe" - File /nonfatal /r "${PANDA}\bin\*.p3d" - SetOutPath $INSTDIR\lib - File /r /x *.exp "${PANDA}\lib\*" - SetOutPath $INSTDIR\include - File /r /x *.exp "${PANDA}\include\*" - SetOutPath $INSTDIR\Pmw - File /r /x CVS "${PANDA}\Pmw\*" - SetOutPath $INSTDIR\NSIS - File /r /x CVS "${NSISDIR}\*" - SetOutPath $INSTDIR - File /r /x CVS "${PANDA}\ReleaseNotes" - !ifdef PYEXTRAS - SetOutPath $INSTDIR\python\lib - File /nonfatal /r "${PYEXTRAS}\*" - !endif - SetOutPath $INSTDIR\models - File /r /x CVS "${PANDA}\models\*" - SetOutPath $INSTDIR\samples - File /nonfatal /r /x CVS "${PSOURCE}\samples\*" - MessageBox MB_YESNO|MB_ICONQUESTION \ - "EGG caching is about to begin.$\nThis process may take a couple minute and approximately 270 MB of RAM.$\nWARNING : It might stuck if your computer resources are low.$\n$\nDo you really want to do this optional step ?" \ - IDNO SkipCaching - # Preload all EGG files into the model-cache - SetOutPath $INSTDIR - SetDetailsPrint both - SetDetailsView show - nsExec::ExecToLog '"$INSTDIR\bin\eggcacher.exe" --concise models samples' - SetDetailsPrint none - SetDetailsView hide - SkipCaching: - - SetOutPath $INSTDIR - WriteINIStr $INSTDIR\Website.url "InternetShortcut" "URL" "http://panda3d.org/" - WriteINIStr $INSTDIR\Manual.url "InternetShortcut" "URL" "http://panda3d.org/wiki/index.php" - WriteINIStr $INSTDIR\Samples.url "InternetShortcut" "URL" "http://panda3d.org/wiki/index.php/Sample_Programs_in_the_Distribution" - SetOutPath $INSTDIR - CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Manual.lnk" "$INSTDIR\Manual.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Panda Manual" - CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Panda Website.lnk" "$INSTDIR\Website.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Panda Website" - CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Sample Program Manual.lnk" "$INSTDIR\Samples.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Sample Program Manual" - - FindFirst $0 $1 $INSTDIR\samples\* - loop: - StrCmp $1 "" done - StrCmp $1 "." next - StrCmp $1 ".." next - Push $1 - Push "-" - Push " " - Call StrRep - Pop $R0 - StrCpy $READABLE $R0 - Push $1 - Push "-" - Push "_" - Call StrRep - Pop $R0 - StrCpy $MANPAGE $R0 - CreateDirectory "$SMPROGRAMS\${SMDIRECTORY}\Sample Programs\$READABLE" - SetOutPath $INSTDIR\samples\$1 - WriteINIStr $INSTDIR\samples\$1\ManualPage.url "InternetShortcut" "URL" "http://panda3d.org/wiki/index.php/Sample_Programs:_$MANPAGE" - CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Sample Programs\$READABLE\Manual Page.lnk" "$INSTDIR\samples\$1\ManualPage.url" "" "$INSTDIR\bin\eggcacher.exe" 0 "" "" "Manual Entry on this Sample Program" - CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Sample Programs\$READABLE\View Source Code.lnk" "$INSTDIR\samples\$1" - FindFirst $2 $3 $INSTDIR\samples\$1\Tut-*.py - iloop: - StrCmp $3 "" idone - StrCpy $TUTNAME $3 -3 4 - Push $TUTNAME - Push "-" - Push " " - Call StrRep - Pop $R0 - StrCpy $TUTNAME $R0 - CreateShortCut "$SMPROGRAMS\${SMDIRECTORY}\Sample Programs\$READABLE\Run $TUTNAME.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Run $TUTNAME" - CreateShortCut "$INSTDIR\samples\$1\Run $TUTNAME.lnk" "$INSTDIR\python\python.exe" "-E $3" "$INSTDIR\bin\eggcacher.exe" 0 SW_SHOWMINIMIZED "" "Run $TUTNAME" - FindNext $2 $3 - goto iloop - idone: - next: - FindNext $0 $1 - Goto loop - done: - - !endif - -SectionEnd - - -Section -post - - !ifdef REGVIEW - SetRegView ${REGVIEW} - !endif - - !ifndef PPGAME - - # Add the "bin" directory to the PATH. - Push "$INSTDIR\python" - Call RemoveFromPath - Push "$INSTDIR\python\Scripts" - Call RemoveFromPath - Push "$INSTDIR\bin" - Call RemoveFromPath - Push "$INSTDIR\python" - Call AddToPath - Push "$INSTDIR\python\Scripts" - Call AddToPath - Push "$INSTDIR\bin" - Call AddToPath - - ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" "" - StrCmp $0 "$INSTDIR\python" RegPath 0 - StrCmp $0 "" RegPath 0 - - MessageBox MB_YESNO|MB_ICONQUESTION \ - "Your system already has a copy of Python installed. Panda3D installs its own copy of Python ${PYVER}, which will install alongside your existing copy. Would you like to make Panda's copy the default Python? If you choose 'No', you will have to configure your existing copy of Python to use the Panda3D libraries, keeping in mind that this version of Panda3D can only run with Python ${PYVER}." \ - IDNO SkipRegPath - - RegPath: - DetailPrint "Adding registry keys for python..." - WriteRegStr HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" "" "$INSTDIR\python" - SkipRegPath: - !endif - - DetailPrint "Adding the uninstaller ..." - Delete "$INSTDIR\uninst.exe" - WriteUninstaller "$INSTDIR\uninst.exe" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SMDIRECTORY}" "DisplayName" "${SMDIRECTORY}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SMDIRECTORY}" "UninstallString" '"$INSTDIR\uninst.exe"' - SetOutPath $INSTDIR - CreateShortcut "$SMPROGRAMS\${SMDIRECTORY}\Uninstall ${NAME}.lnk" "$INSTDIR\uninst.exe" "" - -SectionEnd - -Section Uninstall - - !ifdef REGVIEW - SetRegView ${REGVIEW} - !endif - - !ifndef PPGAME - Push "$INSTDIR\python" - Call un.RemoveFromPath - Push "$INSTDIR\python\Scripts" - Call un.RemoveFromPath - Push "$INSTDIR\bin" - Call un.RemoveFromPath - - ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" "" - StrCmp $0 "$INSTDIR\python" 0 SkipUnReg - DeleteRegKey HKLM "Software\Python\PythonCore\${PYVER}" - SkipUnReg: - !endif - - Delete "$INSTDIR\uninst.exe" - RMDir /r "$SMPROGRAMS\${SMDIRECTORY}" - RMDir /r "$INSTDIR" - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SMDIRECTORY}" - -SectionEnd - -# --[ Utility Functions ]------------------------------------------------------ - -; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91 -Function IsNT - Push $0 - ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion - StrCmp $0 "" 0 IsNT_yes - ; we are not NT. - Pop $0 - Push 0 - Return - IsNT_yes: - ; NT!!! - Pop $0 - Push 1 -FunctionEnd - -; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91 -Function un.IsNT - Push $0 - ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion - StrCmp $0 "" 0 unIsNT_yes - ; we are not NT. - Pop $0 - Push 0 - Return - unIsNT_yes: - ; NT!!! - Pop $0 - Push 1 -FunctionEnd - -; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91 -Function StrStr - Push $0 - Exch - Pop $0 ; $0 now have the string to find - Push $1 - Exch 2 - Pop $1 ; $1 now have the string to find in - Exch - Push $2 - Push $3 - Push $4 - Push $5 - StrCpy $2 -1 - StrLen $3 $0 - StrLen $4 $1 - IntOp $4 $4 - $3 - unStrStr_loop: - IntOp $2 $2 + 1 - IntCmp $2 $4 0 0 unStrStrReturn_notFound - StrCpy $5 $1 $3 $2 - StrCmp $5 $0 unStrStr_done unStrStr_loop - unStrStrReturn_notFound: - StrCpy $2 -1 - unStrStr_done: - Pop $5 - Pop $4 - Pop $3 - Exch $2 - Exch 2 - Pop $0 - Pop $1 -FunctionEnd - -; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91 -Function un.StrStr - Push $0 - Exch - Pop $0 ; $0 now have the string to find - Push $1 - Exch 2 - Pop $1 ; $1 now have the string to find in - Exch - Push $2 - Push $3 - Push $4 - Push $5 - StrCpy $2 -1 - StrLen $3 $0 - StrLen $4 $1 - IntOp $4 $4 - $3 - unStrStr_loop: - IntOp $2 $2 + 1 - IntCmp $2 $4 0 0 unStrStrReturn_notFound - StrCpy $5 $1 $3 $2 - StrCmp $5 $0 unStrStr_done unStrStr_loop - unStrStrReturn_notFound: - StrCpy $2 -1 - unStrStr_done: - Pop $5 - Pop $4 - Pop $3 - Exch $2 - Exch 2 - Pop $0 - Pop $1 -FunctionEnd - -; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91 -; Commentary and smarter ';' checking by Jon Parise -Function AddToPath - Exch $0 - Push $1 - Push $2 - Push $3 - Call IsNT - Pop $1 - - StrCmp $1 1 AddToPath_NT - ; We're not on NT, so modify the AUTOEXEC.BAT file. - StrCpy $1 $WINDIR 2 - FileOpen $1 "$1\autoexec.bat" a - FileSeek $1 0 END - GetFullPathName /SHORT $0 $0 - FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n" - FileClose $1 - Goto AddToPath_done - - AddToPath_NT: - ReadRegStr $1 HKCU "Environment" "PATH" - Call IsUserAdmin - Pop $3 - ; If this is an Admin user, use the System env. variable instead of the user's env. variable - StrCmp $3 1 0 +2 - ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" - - ; If the PATH string is empty, jump over the mangling routines. - StrCmp $1 "" AddToPath_NTdoIt - - ; Pull off the last character of the PATH string. If it's a semicolon, - ; we don't need to add another one, so jump to the section where we - ; append the new PATH component(s). - StrCpy $2 $1 1 -1 - StrCmp $2 ";" AddToPath_NTAddPath AddToPath_NTAddSemi - - AddToPath_NTAddSemi: - StrCpy $1 "$1;" - Goto AddToPath_NTAddPath - AddToPath_NTAddPath: - StrCpy $0 "$1$0" - Goto AddToPath_NTdoIt - AddToPath_NTdoIt: - Call IsUserAdmin - Pop $3 - StrCmp $3 1 0 NotAdmin - WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $0 - Goto AddToPath_done - - NotAdmin: - WriteRegExpandStr HKCU "Environment" "PATH" $0 - AddToPath_done: - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - -; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91 -Function RemoveFromPath - Exch $0 - Push $1 - Push $2 - Push $3 - Push $4 - Push $5 - Call IsNT - Pop $1 - StrCmp $1 1 unRemoveFromPath_NT - ; Not on NT - StrCpy $1 $WINDIR 2 - FileOpen $1 "$1\autoexec.bat" r - GetTempFileName $4 - FileOpen $2 $4 w - GetFullPathName /SHORT $0 $0 - StrCpy $0 "SET PATH=%PATH%;$0" - SetRebootFlag true - Goto unRemoveFromPath_dosLoop - - unRemoveFromPath_dosLoop: - FileRead $1 $3 - StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop - StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop - StrCmp $3 "$0" unRemoveFromPath_dosLoop - StrCmp $3 "" unRemoveFromPath_dosLoopEnd - FileWrite $2 $3 - Goto unRemoveFromPath_dosLoop - - unRemoveFromPath_dosLoopEnd: - FileClose $2 - FileClose $1 - StrCpy $1 $WINDIR 2 - Delete "$1\autoexec.bat" - CopyFiles /SILENT $4 "$1\autoexec.bat" - Delete $4 - Goto unRemoveFromPath_done - - unRemoveFromPath_NT: - StrLen $2 $0 - Call IsUserAdmin - Pop $5 - StrCmp $5 1 0 NotAdmin - ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" - Push $1 - Push $0 - Call StrStr ; Find $0 in $1 - Pop $0 ; pos of our dir - IntCmp $0 -1 unRemoveFromPath_done - ; else, it is in path - StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir - IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') - IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. - StrLen $0 $1 - StrCpy $1 $1 $0 $2 - StrCpy $3 "$3$1" - WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - Goto unRemoveFromPath_done - - - NotAdmin: - ReadRegStr $1 HKCU "Environment" "PATH" - Push $1 - Push $0 - Call StrStr ; Find $0 in $1 - Pop $0 ; pos of our dir - IntCmp $0 -1 unRemoveFromPath_done - ; else, it is in path - StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir - IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') - IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. - StrLen $0 $1 - StrCpy $1 $1 $0 $2 - StrCpy $3 "$3$1" - WriteRegExpandStr HKCU "Environment" "PATH" $3 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - unRemoveFromPath_done: - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - -; From: http://nsis.sourceforge.net/archive/viewpage.php?pageid=91 -Function un.RemoveFromPath - Exch $0 - Push $1 - Push $2 - Push $3 - Push $4 - Push $5 - Call un.IsNT - Pop $1 - StrCmp $1 1 unRemoveFromPath_NT - ; Not on NT - StrCpy $1 $WINDIR 2 - FileOpen $1 "$1\autoexec.bat" r - GetTempFileName $4 - FileOpen $2 $4 w - GetFullPathName /SHORT $0 $0 - StrCpy $0 "SET PATH=%PATH%;$0" - SetRebootFlag true - Goto unRemoveFromPath_dosLoop - - unRemoveFromPath_dosLoop: - FileRead $1 $3 - StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop - StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop - StrCmp $3 "$0" unRemoveFromPath_dosLoop - StrCmp $3 "" unRemoveFromPath_dosLoopEnd - FileWrite $2 $3 - Goto unRemoveFromPath_dosLoop - - unRemoveFromPath_dosLoopEnd: - FileClose $2 - FileClose $1 - StrCpy $1 $WINDIR 2 - Delete "$1\autoexec.bat" - CopyFiles /SILENT $4 "$1\autoexec.bat" - Delete $4 - Goto unRemoveFromPath_done - - unRemoveFromPath_NT: - StrLen $2 $0 - Call un.IsUserAdmin - Pop $5 - StrCmp $5 1 0 NotAdmin - ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" - Push $1 - Push $0 - Call un.StrStr ; Find $0 in $1 - Pop $0 ; pos of our dir - IntCmp $0 -1 unRemoveFromPath_done - ; else, it is in path - StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir - IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') - IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. - StrLen $0 $1 - StrCpy $1 $1 $0 $2 - StrCpy $3 "$3$1" - WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" $3 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - Goto unRemoveFromPath_done - - - NotAdmin: - ReadRegStr $1 HKCU "Environment" "PATH" - Push $1 - Push $0 - Call un.StrStr ; Find $0 in $1 - Pop $0 ; pos of our dir - IntCmp $0 -1 unRemoveFromPath_done - ; else, it is in path - StrCpy $3 $1 $0 ; $3 now has the part of the path before our dir - IntOp $2 $2 + $0 ; $2 now contains the pos after our dir in the path (';') - IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon. - StrLen $0 $1 - StrCpy $1 $1 $0 $2 - StrCpy $3 "$3$1" - WriteRegExpandStr HKCU "Environment" "PATH" $3 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - unRemoveFromPath_done: - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - -; From: http://nsis.sourceforge.net/archive/nsisweb.php?page=329&instances=0,11 -; Localized by Ben Johnson (bkj@andrew.cmu.edu) -Function IsUserAdmin - Push $0 - Push $1 - Push $2 - Push $3 - Call IsNT - Pop $1 - - ClearErrors - UserInfo::GetName - ;IfErrors Win9x - Pop $2 - UserInfo::GetAccountType - Pop $3 - - ; Compare results of IsNT with "1" - StrCmp $1 1 0 NotNT - ;This is NT - - - StrCmp $3 "Admin" 0 NotAdmin - ; Observation: I get here when running Win98SE. (Lilla) - ; The functions UserInfo.dll looks for are there on Win98 too, - ; but just don't work. So UserInfo.dll, knowing that admin isn't required - ; on Win98, returns admin anyway. (per kichik) - ; MessageBox MB_OK 'User "$R1" is in the Administrators group' - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 1 - Return - - NotAdmin: - ; You should still check for an empty string because the functions - ; UserInfo.dll looks for may not be present on Windows 95. (per kichik) - - #StrCmp $2 "" Win9x - #StrCpy $0 0 - ;MessageBox MB_OK 'User "$2" is in the "$3" group' - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 0 - Return - - ;Because we use IsNT, this is redundant. - #Win9x: - # ; comment/message below is by UserInfo.nsi author: - # ; This one means you don't need to care about admin or - # ; not admin because Windows 9x doesn't either - # ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!" - # StrCpy $0 0 - - NotNT: - ;We are not NT - ;Win9x doesn't have "admin" users. - ;Let the user do whatever. - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 1 - -FunctionEnd - -Function un.IsUserAdmin - Push $0 - Push $1 - Push $2 - Push $3 - Call un.IsNT - Pop $1 - - ClearErrors - UserInfo::GetName - ;IfErrors Win9x - Pop $2 - UserInfo::GetAccountType - Pop $3 - - ; Compare results of IsNT with "1" - StrCmp $1 1 0 NotNT - ;This is NT - - - StrCmp $3 "Admin" 0 NotAdmin - ; Observation: I get here when running Win98SE. (Lilla) - ; The functions UserInfo.dll looks for are there on Win98 too, - ; but just don't work. So UserInfo.dll, knowing that admin isn't required - ; on Win98, returns admin anyway. (per kichik) - ; MessageBox MB_OK 'User "$R1" is in the Administrators group' - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 1 - Return - - NotAdmin: - ; You should still check for an empty string because the functions - ; UserInfo.dll looks for may not be present on Windows 95. (per kichik) - - #StrCmp $2 "" Win9x - #StrCpy $0 0 - ;MessageBox MB_OK 'User "$2" is in the "$3" group' - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 0 - Return - - ;Because we use IsNT, this is redundant. - #Win9x: - # ; comment/message below is by UserInfo.nsi author: - # ; This one means you don't need to care about admin or - # ; not admin because Windows 9x doesn't either - # ;MessageBox MB_OK "Error! This DLL can't run under Windows 9x!" - # StrCpy $0 0 - - NotNT: - ;We are not NT - ;Win9x doesn't have "admin" users. - ;Let the user do whatever. - Pop $3 - Pop $2 - Pop $1 - Pop $0 - - Push 1 - -FunctionEnd - -Function StrRep - - ;Written by dirtydingus 2003-02-20 04:30:09 - ; USAGE - ;Push String to do replacement in (haystack) - ;Push String to replace (needle) - ;Push Replacement - ;Call StrRep - ;Pop $R0 result - ;StrCpy $Result STR $R0 - - Exch $R4 ; $R4 = Replacement String - Exch - Exch $R3 ; $R3 = String to replace (needle) - Exch 2 - Exch $R1 ; $R1 = String to do replacement in (haystack) - Push $R2 ; Replaced haystack - Push $R5 ; Len (needle) - Push $R6 ; len (haystack) - Push $R7 ; Scratch reg - StrCpy $R2 "" - StrLen $R5 $R3 - StrLen $R6 $R1 -loop: - StrCpy $R7 $R1 $R5 - StrCmp $R7 $R3 found - StrCpy $R7 $R1 1 ; - optimization can be removed if U know len needle=1 - StrCpy $R2 "$R2$R7" - StrCpy $R1 $R1 $R6 1 - StrCmp $R1 "" done loop -found: - StrCpy $R2 "$R2$R4" - StrCpy $R1 $R1 $R6 $R5 - StrCmp $R1 "" done loop -done: - StrCpy $R3 $R2 - Pop $R7 - Pop $R6 - Pop $R5 - Pop $R2 - Pop $R1 - Pop $R4 - Exch $R3 - -FunctionEnd - diff --git a/direct/src/directscripts/packpanda.py b/direct/src/directscripts/packpanda.py deleted file mode 100755 index c195017f04..0000000000 --- a/direct/src/directscripts/packpanda.py +++ /dev/null @@ -1,424 +0,0 @@ -############################################################################# -# -# packpanda - this is a tool that packages up a panda game into a -# convenient, easily-downloaded windows executable. Packpanda runs on linux -# and windows - on linux, it builds .debs and .rpms, on windows it relies on -# NSIS, the nullsoft scriptable install system, to do the hard work. -# -# This is intentionally a very simplistic game-packer with very -# limited options. The goal is simplicity, not feature richness. -# There are dozens of complex, powerful packaging tools already out -# there. This one is for people who just want to do it quick and -# easy. -# -############################################################################## - -import sys, os, getopt, shutil, py_compile, subprocess - -OPTIONLIST = [ -("dir", 1, "Name of directory containing game"), -("name", 1, "Human-readable name of the game"), -("version", 1, "Version number to add to game name"), -("rmdir", 2, "Delete all directories with given name"), -("rmext", 2, "Delete all files with given extension"), -("fast", 0, "Use fast compression instead of good compression"), -("bam", 0, "Generate BAM files, change default-model-extension to BAM"), -("pyc", 0, "Generate PYC files"), -] - -def ParseFailure(): - print("") - print("packpanda usage:") - print("") - for (opt, hasval, explanation) in OPTIONLIST: - if (hasval): - print(" --%-10s %s"%(opt+" x", explanation)) - else: - print(" --%-10s %s"%(opt+" ", explanation)) - sys.exit(1) - -def ParseOptions(args): - try: - options = {} - longopts = [] - for (opt, hasval, explanation) in OPTIONLIST: - if (hasval==2): - longopts.append(opt+"=") - options[opt] = [] - elif (hasval==1): - longopts.append(opt+"=") - options[opt] = "" - else: - longopts.append(opt) - options[opt] = 0 - opts, extras = getopt.getopt(args, "", longopts) - for option, value in opts: - for (opt, hasval, explanation) in OPTIONLIST: - if (option == "--"+opt): - if (hasval==2): options[opt].append(value) - elif (hasval==1): options[opt] = value - else: options[opt] = 1 - return options - except: ParseFailure(); - -OPTIONS = ParseOptions(sys.argv[1:]) - -############################################################################## -# -# Locate the relevant trees. -# -############################################################################## - -PANDA=None -for dir in sys.path: - if (dir != "") and os.path.exists(os.path.join(dir,"direct")) and os.path.exists(os.path.join(dir,"pandac")): - PANDA=os.path.abspath(dir) -if (PANDA is None): - sys.exit("Cannot locate the panda root directory in the python path (cannot locate directory containing direct and pandac).") -print("PANDA located at "+PANDA) - -if (os.path.exists(os.path.join(PANDA,"..","makepanda","makepanda.py"))) and (sys.platform != "win32" or os.path.exists(os.path.join(PANDA,"..","thirdparty","win-nsis","makensis.exe"))): - PSOURCE=os.path.abspath(os.path.join(PANDA,"..")) - if (sys.platform == "win32"): - NSIS=os.path.abspath(os.path.join(PANDA,"..","thirdparty","win-nsis")) -else: - PSOURCE=PANDA - if (sys.platform == "win32"): - NSIS=os.path.join(PANDA,"nsis") - -############################################################################## -# -# Identify the main parts of the game: DIR, NAME, MAIN, ICON, BITMAP, etc -# -############################################################################## - -VER=OPTIONS["version"] -DIR=OPTIONS["dir"] -if (DIR==""): - print("You must specify the --dir option.") - ParseFailure() -DIR=os.path.abspath(DIR) -MYDIR=os.path.abspath(os.getcwd()) -BASENAME=os.path.basename(DIR) -if (OPTIONS["name"] != ""): - NAME=OPTIONS["name"] -else: - NAME=BASENAME -SMDIRECTORY=NAME -if (VER!=""): SMDIRECTORY=SMDIRECTORY+" "+VER -PYTHONV="python"+sys.version[:3] -LICENSE=os.path.join(DIR, "license.txt") -OUTFILE=os.path.basename(DIR) -if (VER!=""): OUTFILE=OUTFILE+"-"+VER -if (sys.platform == "win32"): - ICON=os.path.join(DIR, "icon.ico") - BITMAP=os.path.join(DIR, "installer.bmp") - OUTFILE=os.path.abspath(OUTFILE+".exe") - INSTALLDIR='C:\\'+os.path.basename(DIR) - if (VER!=""): INSTALLDIR=INSTALLDIR+"-"+VER - COMPRESS="lzma" - if (OPTIONS["fast"]): COMPRESS="zlib" -if (OPTIONS["pyc"]): MAIN="main.pyc" -else: MAIN="main.py" - -def PrintFileStatus(label, file): - if (os.path.exists(file)): - print("%-15s: %s"%(label, file)) - else: - print("%-15s: %s (MISSING)"%(label, file)) - -PrintFileStatus("Dir", DIR) -print("%-15s: %s"%("Name", NAME)) -print("%-15s: %s"%("Start Menu", SMDIRECTORY)) -PrintFileStatus("Main", os.path.join(DIR, MAIN)) -if (sys.platform == "win32"): - PrintFileStatus("Icon", ICON) - PrintFileStatus("Bitmap", BITMAP) -PrintFileStatus("License", LICENSE) -print("%-15s: %s"%("Output", OUTFILE)) -if (sys.platform == "win32"): - print("%-15s: %s"%("Install Dir", INSTALLDIR)) - -if (os.path.isdir(DIR)==0): - sys.exit("Difficulty reading "+DIR+". Cannot continue.") - -if (os.path.isfile(os.path.join(DIR, "main.py"))==0): - sys.exit("Difficulty reading main.py. Cannot continue.") - -if (os.path.isfile(LICENSE)==0): - LICENSE=os.path.join(PANDA,"LICENSE") - -if (sys.platform == "win32") and (os.path.isfile(BITMAP)==0): - BITMAP=os.path.join(NSIS,"Contrib","Graphics","Wizard","nsis.bmp") - -if (sys.platform == "win32"): - if (os.path.isfile(ICON)==0): - PPICON="bin\\ppython.exe" - else: - PPICON="game\\icon.ico" - -############################################################################## -# -# Copy the game to a temporary directory, so we can modify it safely. -# -############################################################################## - -def limitedCopyTree(src, dst, rmdir): - if (os.path.isdir(src)): - if (os.path.basename(src) in rmdir): - return - if (not os.path.isdir(dst)): os.mkdir(dst) - for x in os.listdir(src): - limitedCopyTree(os.path.join(src,x), os.path.join(dst,x), rmdir) - else: - shutil.copyfile(src, dst) - - -TMPDIR=os.path.abspath("packpanda-TMP") -if (sys.platform == "win32"): - TMPGAME=os.path.join(TMPDIR,"game") - TMPETC=os.path.join(TMPDIR,"etc") -else: - TMPGAME=os.path.join(TMPDIR,"usr","share","games",BASENAME,"game") - TMPETC=os.path.join(TMPDIR,"usr","share","games",BASENAME,"etc") -print("") -print("Copying the game to "+TMPDIR+"...") -if (os.path.exists(TMPDIR)): - try: shutil.rmtree(TMPDIR) - except: sys.exit("Cannot delete "+TMPDIR) -try: - os.mkdir(TMPDIR) - rmdir = {} - for x in OPTIONS["rmdir"]: - rmdir[x] = 1 - if not os.path.isdir( TMPGAME ): - os.makedirs(TMPGAME) - limitedCopyTree(DIR, TMPGAME, rmdir) - if not os.path.isdir( TMPETC ): - os.makedirs(TMPETC) - if sys.platform == "win32": - limitedCopyTree(os.path.join(PANDA, "etc"), TMPETC, {}) - else: - shutil.copyfile("/etc/Config.prc", os.path.join(TMPETC, "Config.prc")) - shutil.copyfile("/etc/Confauto.prc", os.path.join(TMPETC, "Confauto.prc")) -except: sys.exit("Cannot copy game to "+TMPDIR) - -############################################################################## -# -# If --bam requested, change default-model-extension .egg to bam. -# -############################################################################## - -def ReadFile(wfile): - try: - srchandle = open(wfile, "rb") - data = srchandle.read() - srchandle.close() - return data - except: exit("Cannot read "+wfile) - -def WriteFile(wfile,data): - try: - dsthandle = open(wfile, "wb") - dsthandle.write(data) - dsthandle.close() - except: exit("Cannot write "+wfile) - -if OPTIONS["bam"]: - CONF=ReadFile(os.path.join(TMPETC,"Confauto.prc")) - CONF=CONF.replace("default-model-extension .egg","default-model-extension .bam") - WriteFile(os.path.join(TMPETC,"Confauto.prc"), CONF) - -############################################################################## -# -# Compile all py files, convert all egg files. -# -# We do this as a sanity check, even if the user -# hasn't requested that his files be compiled. -# -############################################################################## - -if (sys.platform == "win32"): - EGG2BAM=os.path.join(PANDA,"bin","egg2bam.exe") -else: - EGG2BAM=os.path.join(PANDA,"bin","egg2bam") - -def egg2bam(file,bam): - present = os.path.exists(bam) - if (present): bam = "packpanda-TMP.bam"; - cmd = 'egg2bam -noabs -ps rel -pd . "'+file+'" -o "'+bam+'"' - print("Executing: "+cmd) - if (sys.platform == "win32"): - res = os.spawnl(os.P_WAIT, EGG2BAM, cmd) - else: - res = os.system(cmd) - if (res != 0): sys.exit("Problem in egg file: "+file) - if (present) or (OPTIONS["bam"]==0): - os.unlink(bam) - -def py2pyc(file): - print("Compiling python "+file) - pyc = file[:-3]+'.pyc' - pyo = file[:-3]+'.pyo' - if (os.path.exists(pyc)): os.unlink(pyc) - if (os.path.exists(pyo)): os.unlink(pyo) - try: py_compile.compile(file) - except: sys.exit("Cannot compile "+file) - if (OPTIONS["pyc"]==0): - if (os.path.exists(pyc)): - os.unlink(pyc) - if (os.path.exists(pyo)): - os.unlink(pyo) - -def CompileFiles(file): - if (os.path.isfile(file)): - if (file.endswith(".egg")): - egg2bam(file, file[:-4]+'.bam') - elif (file.endswith(".egg.pz") or file.endswith(".egg.gz")): - egg2bam(file, file[:-7]+'.bam') - elif (file.endswith(".py")): - py2pyc(file) - else: pass - elif (os.path.isdir(file)): - for x in os.listdir(file): - CompileFiles(os.path.join(file, x)) - -def DeleteFiles(file): - base = os.path.basename(file).lower() - if (os.path.isdir(file)): - for pattern in OPTIONS["rmdir"]: - if pattern.lower() == base: - print("Deleting "+file) - shutil.rmtree(file) - return - for x in os.listdir(file): - DeleteFiles(os.path.join(file, x)) - else: - for ext in OPTIONS["rmext"]: - if base[-(len(ext) + 1):] == ("." + ext).lower(): - print("Deleting "+file) - os.unlink(file) - return - -print("") -print("Compiling BAM and PYC files...") -os.chdir(TMPGAME) -CompileFiles(".") -DeleteFiles(".") - -############################################################################## -# -# Now make the installer. Yay! -# -############################################################################## - -INSTALLER_DEB_FILE=""" -Package: BASENAME -Version: VERSION -Section: games -Priority: optional -Architecture: ARCH -Essential: no -Depends: PYTHONV -Provides: BASENAME -Description: NAME -Maintainer: Unknown -""" - -INSTALLER_SPEC_FILE=""" -Summary: NAME -Name: BASENAME -Version: VERSION -Release: 1 -Group: Amusement/Games -License: See license file -BuildRoot: TMPDIR -BuildRequires: PYTHONV -%description -NAME -%files -%defattr(-,root,root) -/usr/bin/BASENAME -/usr/lib/games/BASENAME -/usr/share/games/BASENAME -""" - -RUN_SCRIPT=""" -#!/bin/sh -cd /usr/share/games/BASENAME/game -PYTHONPATH=/usr/lib/games/BASENAME:/usr/share/games/BASENAME -LD_LIBRARY_PATH=/usr/lib/games/BASENAME -PYTHONV MAIN -""" - -if (sys.platform == "win32"): - CMD="\""+NSIS+"\\makensis.exe\" /V2 " - CMD=CMD+'/DCOMPRESSOR="'+COMPRESS+'" ' - CMD=CMD+'/DNAME="'+NAME+'" ' - CMD=CMD+'/DSMDIRECTORY="'+SMDIRECTORY+'" ' - CMD=CMD+'/DINSTALLDIR="'+INSTALLDIR+'" ' - CMD=CMD+'/DOUTFILE="'+OUTFILE+'" ' - CMD=CMD+'/DLICENSE="'+LICENSE+'" ' - CMD=CMD+'/DLANGUAGE="English" ' - CMD=CMD+'/DRUNTEXT="Play '+NAME+'" ' - CMD=CMD+'/DIBITMAP="'+BITMAP+'" ' - CMD=CMD+'/DUBITMAP="'+BITMAP+'" ' - CMD=CMD+'/DPANDA="'+PANDA+'" ' - CMD=CMD+'/DPANDACONF="'+TMPETC+'" ' - CMD=CMD+'/DPSOURCE="'+PSOURCE+'" ' - CMD=CMD+'/DPPGAME="'+TMPGAME+'" ' - CMD=CMD+'/DPPMAIN="'+MAIN+'" ' - CMD=CMD+'/DPPICON="'+PPICON+'" ' - CMD=CMD+'"'+PSOURCE+'\\direct\\directscripts\\packpanda.nsi"' - - print("") - print(CMD) - print("packing...") - subprocess.call(CMD) -else: - os.chdir(MYDIR) - os.system("mkdir -p %s/usr/bin" % TMPDIR) - os.system("mkdir -p %s/usr/share/games/%s" % (TMPDIR, BASENAME)) - os.system("mkdir -p %s/usr/lib/games/%s" % (TMPDIR, BASENAME)) - os.system("cp --recursive %s/direct %s/usr/share/games/%s/direct" % (PANDA, TMPDIR, BASENAME)) - os.system("cp --recursive %s/pandac %s/usr/share/games/%s/pandac" % (PANDA, TMPDIR, BASENAME)) - os.system("cp --recursive %s/models %s/usr/share/games/%s/models" % (PANDA, TMPDIR, BASENAME)) - os.system("cp --recursive %s/Pmw %s/usr/share/games/%s/Pmw" % (PANDA, TMPDIR, BASENAME)) - os.system("cp %s %s/usr/share/games/%s/LICENSE" % (LICENSE, TMPDIR, BASENAME)) - os.system("cp --recursive /usr/lib/panda3d/* %s/usr/lib/games/%s/" % (TMPDIR, BASENAME)) - - # Make the script to run the game - txt = RUN_SCRIPT[1:].replace("BASENAME",BASENAME).replace("PYTHONV",PYTHONV).replace("MAIN",MAIN) - WriteFile(TMPDIR+"/usr/bin/"+BASENAME, txt) - os.system("chmod +x "+TMPDIR+"/usr/bin/"+BASENAME) - - if (os.path.exists("/usr/bin/rpmbuild")): - os.system("rm -rf %s/DEBIAN" % TMPDIR) - os.system("rpm -E '%_target_cpu' > packpanda-TMP.txt") - ARCH=ReadFile("packpanda-TMP.txt").strip() - os.remove("packpanda-TMP.txt") - txt = INSTALLER_SPEC_FILE[1:].replace("VERSION",VER).replace("TMPDIR",TMPDIR) - txt = txt.replace("BASENAME",BASENAME).replace("NAME",NAME).replace("PYTHONV",PYTHONV) - WriteFile("packpanda-TMP.spec", txt) - os.system("rpmbuild --define '_rpmdir "+TMPDIR+"' -bb packpanda-TMP.spec") - os.system("mv "+ARCH+"/"+BASENAME+"-"+VER+"-1."+ARCH+".rpm .") - os.rmdir(ARCH) - os.remove("packpanda-TMP.spec") - - if (os.path.exists("/usr/bin/dpkg-deb")): - os.system("dpkg --print-architecture > packpanda-TMP.txt") - ARCH=ReadFile("packpanda-TMP.txt").strip() - os.remove("packpanda-TMP.txt") - txt = INSTALLER_DEB_FILE[1:].replace("VERSION",str(VER)).replace("PYTHONV",PYTHONV) - txt = txt.replace("BASENAME",BASENAME).replace("NAME",NAME).replace("ARCH",ARCH) - os.system("mkdir -p %s/DEBIAN" % TMPDIR) - os.system("cd %s ; (find usr -type f -exec md5sum {} \;) > DEBIAN/md5sums" % TMPDIR) - WriteFile(TMPDIR+"/DEBIAN/control",txt) - os.system("dpkg-deb -b "+TMPDIR+" "+BASENAME+"_"+VER+"_"+ARCH+".deb") - - if not(os.path.exists("/usr/bin/rpmbuild") or os.path.exists("/usr/bin/dpkg-deb")): - exit("To build an installer, either rpmbuild or dpkg-deb must be present on your system!") - -# Dummy main function so this can be added to console_scripts. -def main(): - return 0 diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index d004d15006..c5e76fc766 100755 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -619,13 +619,10 @@ Section -post DetailPrint "Preloading .egg files into the model cache..." SetDetailsPrint listonly - ; We need to set the $PATH for eggcacher. SetOutPath $INSTDIR - ReadEnvStr $R0 "PATH" - StrCpy $R0 "$INSTDIR\python;$INSTDIR\bin;$R0" - System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", R0).r2' - - nsExec::ExecToLog '"$INSTDIR\bin\eggcacher.exe" --concise models samples' + nsExec::ExecToLog '"$INSTDIR\python\python.exe" -m direct.directscripts.eggcacher --concise models samples' + Pop $0 + DetailPrint "Command returned exit status $0" SetDetailsPrint both DetailPrint "Writing the uninstaller ..." diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 2e54cc2058..4faa683f87 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -90,7 +90,7 @@ PkgListSet(["PYTHON", "DIRECT", # Python support "ROCKET", "AWESOMIUM", # GUI libraries "CARBON", "COCOA", # Mac OS X toolkits "X11", # Unix platform support - "PANDATOOL", "PVIEW", "DEPLOYTOOLS", "DIRECTSCRIPTS",# Toolchain + "PANDATOOL", "PVIEW", "DEPLOYTOOLS", # Toolchain "SKEL", # Example SKEL project "PANDAFX", # Some distortion special lenses "PANDAPARTICLESYSTEM", # Built in particle system @@ -172,7 +172,7 @@ def parseopts(args): "version=","lzma","no-python","threads=","outputdir=","override=", "static","host=","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=", "directx-sdk=", "windows-sdk=", "msvc-version=", "clean", "use-icl", - "universal", "target=", "arch=", "git-commit=", + "universal", "target=", "arch=", "git-commit=", "no-directscripts", "use-touchinput", "no-touchinput"] anything = 0 optimize = "" @@ -224,6 +224,7 @@ def parseopts(args): # Backward compatibility, OPENGL was renamed to GL elif (option=="--use-opengl"): PkgEnable("GL") elif (option=="--no-opengl"): PkgDisable("GL") + elif (option=="--no-directscripts"): pass elif (option=="--directx-sdk"): STRDXSDKVERSION = value.strip().lower() if STRDXSDKVERSION == '': @@ -832,7 +833,11 @@ if (COMPILER=="GCC"): SmartPkgEnable("ROCKET", "", rocket_libs, "Rocket/Core.h") if not PkgSkip("PYTHON"): - SmartPkgEnable("PYTHON", "", SDK["PYTHONVERSION"], (SDK["PYTHONVERSION"], SDK["PYTHONVERSION"] + "/Python.h"), tool = SDK["PYTHONVERSION"] + "-config") + python_lib = SDK["PYTHONVERSION"] + if not RTDIST: + # We don't link anything in the SDK with libpython. + python_lib = "" + SmartPkgEnable("PYTHON", "", python_lib, (SDK["PYTHONVERSION"], SDK["PYTHONVERSION"] + "/Python.h"), tool = SDK["PYTHONVERSION"] + "-config") SmartPkgEnable("OPENSSL", "openssl", ("ssl", "crypto"), ("openssl/ssl.h", "openssl/crypto.h")) SmartPkgEnable("ZLIB", "zlib", ("z"), "zlib.h") @@ -4996,17 +5001,6 @@ if (PkgSkip("DIRECT")==0): OPTS=['DIR:direct/src/directbase', 'PYTHON'] TargetAdd('p3directbase_directbase.obj', opts=OPTS+['BUILDING:DIRECT'], input='directbase.cxx') - if not PkgSkip("PYTHON") and not RTDIST and not RUNTIME and not PkgSkip("DIRECTSCRIPTS"): - DefSymbol("BUILDING:PACKPANDA", "IMPORT_MODULE", "direct.directscripts.packpanda") - TargetAdd('packpanda.obj', opts=OPTS+['BUILDING:PACKPANDA'], input='ppython.cxx') - TargetAdd('packpanda.exe', input='packpanda.obj') - TargetAdd('packpanda.exe', opts=['PYTHON']) - - DefSymbol("BUILDING:EGGCACHER", "IMPORT_MODULE", "direct.directscripts.eggcacher") - TargetAdd('eggcacher.obj', opts=OPTS+['BUILDING:EGGCACHER'], input='ppython.cxx') - TargetAdd('eggcacher.exe', input='eggcacher.obj') - TargetAdd('eggcacher.exe', opts=['PYTHON']) - # # DIRECTORY: direct/src/dcparser/ # diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 2eb4342b06..ee903a3940 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -1574,7 +1574,7 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None, location = os.path.join(GetOutputDir(), "lib", os.path.basename(location)) LibName(target_pkg, location) else: - print(GetColor("cyan") + "Couldn't find library lib" + libname + " in thirdparty directory " + pkg.lower() + GetColor()) + print(GetColor("cyan") + "Couldn't find library lib" + libname + " in thirdparty directory " + thirdparty_dir + GetColor()) for d, v in defs.values(): DefSymbol(target_pkg, d, v) diff --git a/makepanda/makewheel.py b/makepanda/makewheel.py index 6d3b6fdf72..56fb43133e 100644 --- a/makepanda/makewheel.py +++ b/makepanda/makewheel.py @@ -551,7 +551,6 @@ def makewheel(version, output_dir, platform=default_platform): # Add a panda3d-tools directory containing the executables. entry_points = '[console_scripts]\n' entry_points += 'eggcacher = direct.directscripts.eggcacher:main\n' - entry_points += 'packpanda = direct.directscripts.packpanda:main\n' tools_init = '' for file in os.listdir(bin_dir): basename = os.path.splitext(file)[0] From 816b2ac3ba3f35b209dfde8afe6eee40cba358b7 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 5 Jan 2017 23:24:52 +0100 Subject: [PATCH 10/10] C++11 polyfills. This should fix Snow Leopard build. --- dtool/src/dtoolbase/dtoolbase_cc.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index eb99381c01..eb7afc9048 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -75,6 +75,7 @@ typedef int ios_seekdir; #endif #include +#include #ifdef HAVE_NAMESPACE using namespace std; @@ -114,6 +115,18 @@ typedef ios::iostate ios_iostate; typedef ios::seekdir ios_seekdir; #endif +// Apple has an outdated libstdc++. Not all is lost, though, as we can fill +// in some important missing functions. +#if defined(__GLIBCXX__) && __GLIBCXX__ <= 20070719 +template struct remove_reference {typedef T type;}; +template struct remove_reference {typedef T type;}; +template struct remove_reference{typedef T type;}; + +template typename remove_reference::type &&move(T &&t) { + return static_cast::type&&>(t); +} +#endif + #ifdef _MSC_VER #define ALWAYS_INLINE __forceinline #elif defined(__GNUC__) @@ -153,7 +166,7 @@ typedef ios::seekdir ios_seekdir; #elif defined(__GNUC__) && (__cplusplus >= 201103L) // GCC // GCC defines several macros which we can query. List of all supported -// builtin macros: https:gcc.gnu.orgprojectscxx0x.html +// builtin macros: https://gcc.gnu.org/projects/cxx-status.html # if __cpp_constexpr >= 200704 # define CONSTEXPR constexpr # endif