diff options
author | John Parent <john.parent@kitware.com> | 2021-10-22 14:00:02 -0400 |
---|---|---|
committer | Peter Scheibel <scheibel1@llnl.gov> | 2022-03-17 09:01:01 -0700 |
commit | 3a994032f8143a2bdbfe5c61baeb12b1bd2fed60 (patch) | |
tree | 6d4e357f96f071bb50c62cb7238bb85f0431c6b7 /var/spack/repos/builtin/packages/perl/package.py | |
parent | 90c773488c59e57c19ecca5635c1ae7f70e56076 (diff) | |
download | spack-3a994032f8143a2bdbfe5c61baeb12b1bd2fed60.tar.gz spack-3a994032f8143a2bdbfe5c61baeb12b1bd2fed60.tar.bz2 spack-3a994032f8143a2bdbfe5c61baeb12b1bd2fed60.tar.xz spack-3a994032f8143a2bdbfe5c61baeb12b1bd2fed60.zip |
Spack on Windows package ports
CMake - Windows Bootstrap (#25825)
Remove hardcoded cmake compiler (#26410)
Revert breaking cmake changes
Ensure no autotools on Windows
Perl on Windows (#26612)
Python source build windows (#26313)
Reconfigure sysconf for Windows
Python2.6 compatibility
Fxixup new sbang tests for windows
Ruby support (#28287)
Add NASM support (#28319)
Add mock Ninja package for testing
Diffstat (limited to 'var/spack/repos/builtin/packages/perl/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/perl/package.py | 107 |
1 files changed, 88 insertions, 19 deletions
diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py index 0d666b41d3..714c7e3a7b 100644 --- a/var/spack/repos/builtin/packages/perl/package.py +++ b/var/spack/repos/builtin/packages/perl/package.py @@ -11,15 +11,20 @@ # Author: Justin Too <justin@doubleotoo.com> # Date: September 6, 2015 # + import os import re from contextlib import contextmanager from llnl.util.lang import match_predicate +from llnl.util.symlink import symlink from spack import * from spack.operating_systems.mac_os import macos_version +host = spack.platforms.host() +is_windows = str(host) == 'windows' + class Perl(Package): # Perl doesn't use Autotools, it should subclass Package """Perl 5 is a highly capable, feature-rich programming language with over @@ -64,15 +69,16 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package extendable = True - # Bind us below gdbm-1.20 due to API change: https://github.com/Perl/perl5/issues/18915 - depends_on('gdbm@:1.19') - # :5.28 needs gdbm@:1:14.1: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133295 - depends_on('gdbm@:1.14.1', when='@:5.28.0') - depends_on('berkeley-db') - depends_on('bzip2') - depends_on('zlib') - # :5.24.1 needs zlib@:1.2.8: https://rt.cpan.org/Public/Bug/Display.html?id=120134 - depends_on('zlib@:1.2.8', when='@5.20.3:5.24.1') + if not is_windows: + # Bind us below gdbm-1.20 due to API change: https://github.com/Perl/perl5/issues/18915 + depends_on('gdbm@:1.19') + # :5.28 needs gdbm@:1:14.1: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=133295 + depends_on('gdbm@:1.14.1', when='@:5.28.0') + depends_on('berkeley-db') + depends_on('bzip2') + depends_on('zlib') + # :5.24.1 needs zlib@:1.2.8: https://rt.cpan.org/Public/Bug/Display.html?id=120134 + depends_on('zlib@:1.2.8', when='@5.20.3:5.24.1') # there has been a long fixed issue with 5.22.0 with regard to the ccflags # definition. It is well documented here: @@ -181,6 +187,23 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package perm = os.stat(filename).st_mode os.chmod(filename, perm | 0o200) + @property + def nmake_arguments(self): + args = [] + if self.spec.satisfies('%msvc'): + args.append('CCTYPE=%s' % self.compiler.msvc_version) + else: + raise RuntimeError("Perl unsupported for non MSVC compilers on Windows") + args.append('INST_TOP="%s"' % self.prefix.replace('/', '\\')) + args.append("INST_ARCH=\\$(ARCHNAME)") + if self.spec.satisfies('~shared'): + args.append("ALL_STATIC=%s" % "define") + if self.spec.satisfies('~threads'): + args.extend(["USE_MULTI=undef", "USE_ITHREADS=undef", "USE_IMP_SYS=undef"]) + if not host.is_64bit(): + args.append("WIN64=undef") + return args + def configure_args(self): spec = self.spec prefix = self.prefix @@ -229,30 +252,69 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package return config_args def configure(self, spec, prefix): + if is_windows: + return configure = Executable('./Configure') configure(*self.configure_args()) def build(self, spec, prefix): - make() + if is_windows: + pass + else: + make() @run_after('build') @on_package_attributes(run_tests=True) def build_test(self): - make('test') + if is_windows: + win32_dir = os.path.join(self.stage.source_path, "win32") + with working_dir(win32_dir): + nmake('test', ignore_quotes=True) + else: + make('test') def install(self, spec, prefix): - make('install') + if is_windows: + win32_dir = os.path.join(self.stage.source_path, "win32") + with working_dir(win32_dir): + nmake('install', *self.nmake_arguments, ignore_quotes=True) + else: + make('install') + + @run_after('install') + def symlink_windows(self): + if not is_windows: + return + win_install_path = os.path.join(self.prefix.bin, "MSWin32") + if host.is_64bit(): + win_install_path += "-x64" + else: + win_install_path += "-x86" + if self.spec.satisfies("+threads"): + win_install_path += "-multi-thread" + else: + win_install_path += "-perlio" + + for f in os.listdir(os.path.join(self.prefix.bin, win_install_path)): + lnk_path = os.path.join(self.prefix.bin, f) + src_path = os.path.join(win_install_path, f) + if not os.path.exists(lnk_path): + symlink(src_path, lnk_path) @run_after('install') def install_cpanm(self): spec = self.spec - + maker = make + win_prefix = '' + if is_windows: + maker = nmake + win_prefix = self.stage.source_path if '+cpanm' in spec: - with working_dir(join_path('cpanm', 'cpanm')): + with working_dir(join_path(win_prefix, 'cpanm', 'cpanm')): perl = spec['perl'].command perl('Makefile.PL') - make() - make('install') + maker() + maker('install') def _setup_dependent_env(self, env, dependent_spec, deptypes): """Set PATH and PERL5LIB to include the extension and @@ -295,6 +357,9 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package mkdirp(module.perl_lib_dir) def setup_build_environment(self, env): + if is_windows: + return + spec = self.spec if (spec.version <= Version('5.34.0') @@ -321,7 +386,8 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package frustrates filter_file on some filesystems (NFSv4), so make them temporarily writable. """ - + if is_windows: + return kwargs = {'ignore_absent': True, 'backup': False, 'string': False} # Find the actual path to the installed Config.pm file. @@ -409,8 +475,11 @@ class Perl(Package): # Perl doesn't use Autotools, it should subclass Package Executable: the Perl command """ for ver in ('', self.spec.version): - path = os.path.join(self.prefix.bin, '{0}{1}'.format( - self.spec.name, ver)) + ext = '' + if is_windows: + ext = '.exe' + path = os.path.join(self.prefix.bin, '{0}{1}{2}'.format( + self.spec.name, ver, ext)) if os.path.exists(path): return Executable(path) else: |