def fix_mingw(self): # On Windows, if the user is not allowed to create symbolic links or if # the Python version is older than 3.8, tarfile creates an empty # directory instead of creating a symlink. This affects the `mingw` # dir which is supposed to be a symlink to `usr/x86_64-w64-mingw32` sysroot = os.path.join(self.prefix, 'x86_64-w64-mingw32/sysroot') mingwdir = os.path.join(sysroot, 'mingw') if not os.path.islink(mingwdir) and os.path.isdir(mingwdir): shutil.rmtree(mingwdir) shell.symlink('usr/x86_64-w64-mingw32', 'mingw', sysroot) # In cross-compilation gcc does not create a prefixed cpp cpp_exe = os.path.join(self.prefix, 'bin', 'cpp.exe') host_cpp_exe = os.path.join(self.prefix, 'bin', 'x86_64-w64-mingw32-cpp.exe') shutil.copyfile(cpp_exe, host_cpp_exe)
def fix_mingw(self): if self.arch == Architecture.X86: try: shutil.rmtree('/mingw/lib') except Exception: pass if self.platform == Platform.WINDOWS: # Tar does not create correctly the mingw symlink sysroot = os.path.join(self.prefix, 'x86_64-w64-mingw32/sysroot') mingwdir = os.path.join(sysroot, 'mingw') # The first time the toolchain is extracted it creates a file with # symlink if not os.path.isdir(mingwdir): os.remove(mingwdir) # Otherwise we simply remove the directory and link back the sysroot else: shutil.rmtree(mingwdir) shell.symlink('usr/x86_64-w64-mingw32', 'mingw', sysroot) # In cross-compilation gcc does not create a prefixed cpp cpp_exe = os.path.join(self.prefix, 'bin', 'cpp.exe') host_cpp_exe = os.path.join(self.prefix, 'bin', 'x86_64-w64-mingw32-cpp.exe') shutil.copyfile(cpp_exe, host_cpp_exe)
def create_bundle(self, target_dir=None): ''' Creates the bundle structure Commands -> Versions/Current/Commands Headers -> Versions/Current/Headers Libraries -> Versions/Current/Libraries Home -> Versions/Current Resources -> Versions/Current/Resources Versions/Current -> Version/$VERSION/$ARCH Framework -> Versions/Current/Famework ''' if target_dir: tmp = target_dir else: tmp = tempfile.mkdtemp() #if self.config.target_arch == Architecture.UNIVERSAL: # arch_dir = '' #else: # arch_dir = self.config.target_arch vdir = os.path.join('Versions', self.package.sdk_version) #, arch_dir) rdir = '%s/Resources/' % vdir os.makedirs(os.path.join(tmp, rdir), exist_ok=True if target_dir else False) links = { 'Versions/Current': '%s' % self.package.sdk_version, 'Resources': 'Versions/Current/Resources', 'Commands': 'Versions/Current/Commands', 'Headers': 'Versions/Current/Headers', 'Libraries': 'Versions/Current/Libraries' } inner_links = {'Commands': 'bin', 'Libraries': 'lib'} # Create the frameworks Info.plist file framework_plist = FrameworkPlist( self.package.name, self.package.org, self.package.version, self.package.shortdesc, self.package.config.min_osx_sdk_version) framework_plist.save(os.path.join(tmp, rdir, 'Info.plist')) # Add a link from Framework to Versions/Current/Framework if self.package.osx_framework_library is not None: name, link = self.package.osx_framework_library # Framework -> Versions/Current/Famework links[name] = 'Versions/Current/%s' % name # Create all links for dest, src in links.items(): shell.symlink(src, dest, tmp) inner_tmp = os.path.join(tmp, vdir) for dest, src in inner_links.items(): shell.symlink(src, dest, inner_tmp) # Copy the framework library to Versions/$VERSION/$ARCH/Framework if self.package.osx_framework_library is not None \ and os.path.exists(os.path.join(self.config.prefix, link)): shutil.copy(os.path.join(self.config.prefix, link), os.path.join(tmp, vdir, name)) return tmp
def _add_applications_link(self): # Create link to /Applications applications_link = os.path.join(self.approot, 'Applications') shell.symlink('/Applications', applications_link)