From cd42fc5cc8dfda473643f40d359fc3d68d7906fb Mon Sep 17 00:00:00 2001
From: "John W. Parent" <45471568+johnwparent@users.noreply.github.com>
Date: Tue, 14 Mar 2023 19:46:49 -0400
Subject: Libogg and libtheora: build on windows (#35099)
Adds builders appropriate for building these packages on Windows.
It is intended that builds on other platforms are unaffected (e.g.
they build with Autotools as before on Linux).
---
var/spack/repos/builtin/packages/libogg/package.py | 37 +++++++-
.../libtheora/libtheora-inc-external-ogg.patch | 35 +++++++
.../repos/builtin/packages/libtheora/package.py | 102 +++++++++++++++++++--
3 files changed, 163 insertions(+), 11 deletions(-)
create mode 100644 var/spack/repos/builtin/packages/libtheora/libtheora-inc-external-ogg.patch
(limited to 'var')
diff --git a/var/spack/repos/builtin/packages/libogg/package.py b/var/spack/repos/builtin/packages/libogg/package.py
index c0fad6bbf3..c82794e9ba 100644
--- a/var/spack/repos/builtin/packages/libogg/package.py
+++ b/var/spack/repos/builtin/packages/libogg/package.py
@@ -3,10 +3,13 @@
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import os
+
+from spack.build_systems.generic import GenericBuilder
from spack.package import *
-class Libogg(AutotoolsPackage):
+class Libogg(CMakePackage, AutotoolsPackage, Package):
"""Ogg is a multimedia container format, and the native file and stream
format for the Xiph.org multimedia codecs."""
@@ -24,3 +27,35 @@ class Libogg(AutotoolsPackage):
sha256="0f4d289aecb3d5f7329d51f1a72ab10c04c336b25481a40d6d841120721be485",
when="@1.3.4 platform=darwin",
)
+ build_system(
+ conditional("cmake", when="@1.3.4:"),
+ conditional("generic", when="@1.3.2 platform=windows"),
+ "autotools",
+ default="autotools",
+ )
+
+
+class GenericBuilder(GenericBuilder):
+ phases = ["build", "install"]
+
+ def is_64bit(self):
+ return "64" in self.pkg.spec.target.family
+
+ def build(self, spec, prefix):
+ if spec.satisfies("%msvc"):
+ plat_tools = self.pkg.compiler.msvc_version
+ else:
+ raise RuntimeError("Package does not support non MSVC compilers on Windows")
+ ms_build_args = ["libogg_static.vcxproj", "/p:PlatformToolset=v%s" % plat_tools]
+ msbuild(*ms_build_args)
+
+ def install(self, spec, prefix):
+ mkdirp(prefix.include.ogg)
+ mkdirp(prefix.lib)
+ mkdirp(prefix.share)
+ install(
+ os.path.join(self.pkg.stage.source_path, "include", "ogg", "*.h"), prefix.include.ogg
+ )
+ plat_prefix = "x64" if self.is_64bit() else "x86"
+ install(os.path.join(plat_prefix, "Debug", "*.lib"), prefix.lib)
+ install_tree(os.path.join(self.pkg.stage.source_path, "doc"), prefix.share)
diff --git a/var/spack/repos/builtin/packages/libtheora/libtheora-inc-external-ogg.patch b/var/spack/repos/builtin/packages/libtheora/libtheora-inc-external-ogg.patch
new file mode 100644
index 0000000000..fd88480e7c
--- /dev/null
+++ b/var/spack/repos/builtin/packages/libtheora/libtheora-inc-external-ogg.patch
@@ -0,0 +1,35 @@
+diff --git a/win32/VS2008/libogg.vsprops b/win32/VS2008/libogg.vsprops
+index 1355b50..8b3c5b8 100644
+--- a/win32/VS2008/libogg.vsprops
++++ b/win32/VS2008/libogg.vsprops
+@@ -6,11 +6,11 @@
+ >
+
+
+