Nick: heijligen E-mail: none Board: not-flashrom Contents: From 88b28aad11102aaec2c97077dce07e05654f14ab Mon Sep 17 00:00:00 2001 From: Thomas Heijligen Date: Fri, 31 Oct 2025 17:56:21 +0100 Subject: [PATCH] windows experiments --- hdtv/plugins/textInterface.py | 20 ++++++++++---------- hdtv/rootext/__init__.py | 6 ++++-- hdtv/rootext/calibration/CMakeLists.txt | 2 ++ hdtv/rootext/calibration/Calibration.hh | 6 +++++- hdtv/rootext/display/DisplayBlock.hh | 2 +- hdtv/rootext/display/DisplayCut.hh | 2 +- hdtv/rootext/display/DisplayObj.hh | 2 +- hdtv/rootext/display/LinkDef.h | 2 +- hdtv/rootext/display/MTViewer.hh | 2 +- hdtv/rootext/display/Marker.hh | 2 +- hdtv/rootext/display/Painter.hh | 2 +- hdtv/rootext/display/View.hh | 2 +- hdtv/rootext/display/View1D.hh | 2 +- hdtv/rootext/display/View2D.hh | 2 +- hdtv/rootext/display/Viewer.hh | 2 +- hdtv/rootext/display/XMarker.hh | 2 +- hdtv/rootext/display/YMarker.hh | 2 +- hdtv/rootext/dlmgr.py | 16 +++++++++++----- hdtv/rootext/fit/Integral.hh | 2 +- 19 files changed, 46 insertions(+), 32 deletions(-) diff --git a/hdtv/plugins/textInterface.py b/hdtv/plugins/textInterface.py index 8ad729b..2937ac3 100644 --- a/hdtv/plugins/textInterface.py +++ b/hdtv/plugins/textInterface.py @@ -21,10 +21,10 @@ TextInterface functions """ -import fcntl +# import fcntl import pydoc import struct -import termios +# import termios from html import escape from prompt_toolkit.application import Application @@ -146,14 +146,14 @@ class TextInterface(hdtv.ui.SimpleUI): super().msg(html=html, end=end) def _updateTerminalSize(self): - try: - h, w, hp, wp = struct.unpack( - "HHHH", - fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack("HHHH", 0, 0, 0, 0)), - ) - self.canvasheight = h - self.canvaswidth = w - except: + #try: + # h, w, hp, wp = struct.unpack( + # "HHHH", + # fcntl.ioctl(0, termios.TIOCGWINSZ, struct.pack("HHHH", 0, 0, 0, 0)), + # ) + # self.canvasheight = h + # self.canvaswidth = w + #except: self.canvasheight = 30 self.canvaswidth = 1050 diff --git a/hdtv/rootext/__init__.py b/hdtv/rootext/__init__.py index 462116f..eb2fb40 100644 --- a/hdtv/rootext/__init__.py +++ b/hdtv/rootext/__init__.py @@ -2,8 +2,10 @@ import os modules = ["mfile-root", "fit", "calibration", "display"] - -libfmt = "lib%s.so" +if os.name == "nt": + libfmt = "%s.dll" +else: + libfmt = "lib%s.so" def UpdateRootIncludePath(): diff --git a/hdtv/rootext/calibration/CMakeLists.txt b/hdtv/rootext/calibration/CMakeLists.txt index c73ce7e..da7dc7b 100644 --- a/hdtv/rootext/calibration/CMakeLists.txt +++ b/hdtv/rootext/calibration/CMakeLists.txt @@ -25,6 +25,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) root_generate_dictionary(G__${MODULE} ${HEADERS} MODULE ${MODULE} LINKDEF LinkDef.h) add_library(${MODULE} SHARED ${SOURCES} G__${MODULE}.cxx) add_library(hdtv::${MODULE} ALIAS ${MODULE}) + + target_link_libraries(${MODULE} PUBLIC ROOT::Core ROOT::Hist ROOT::Graf ROOT::Gui) set_target_properties(${MODULE} PROPERTIES RESOURCE "${CMAKE_CURRENT_BINARY_DIR}/lib${MODULE}.rootmap;${CMAKE_CURRENT_BINARY_DIR}/lib${MODULE}_rdict.pcm" diff --git a/hdtv/rootext/calibration/Calibration.hh b/hdtv/rootext/calibration/Calibration.hh index d7b9d39..50d443a 100644 --- a/hdtv/rootext/calibration/Calibration.hh +++ b/hdtv/rootext/calibration/Calibration.hh @@ -25,6 +25,8 @@ #include +#include + class TAxis; class TArrayD; @@ -43,7 +45,7 @@ namespace HDTV { * This then corresponds to an energy E = cal0. However, this needs not be * true for spectra read e.g. from ROOT files. */ -class Calibration { +class R__DLLEXPORT Calibration { public: Calibration() = default; @@ -85,6 +87,8 @@ private: std::vector fCal; std::vector fCalDeriv; void UpdateDerivative(); + + ClassDef(Calibration, 1) }; } // end namespace HDTV diff --git a/hdtv/rootext/display/DisplayBlock.hh b/hdtv/rootext/display/DisplayBlock.hh index 565489d..fa006ea 100644 --- a/hdtv/rootext/display/DisplayBlock.hh +++ b/hdtv/rootext/display/DisplayBlock.hh @@ -33,7 +33,7 @@ namespace Display { //! DisplayBlock: common baseclass for DisplayFunc and DisplaySpec // FIXME: think of a better name? -class DisplayBlock : public DisplayObj { +class __declspec(dllexport) DisplayBlock : public DisplayObj { friend class Painter; public: diff --git a/hdtv/rootext/display/DisplayCut.hh b/hdtv/rootext/display/DisplayCut.hh index f2e4f8a..2697bb3 100644 --- a/hdtv/rootext/display/DisplayCut.hh +++ b/hdtv/rootext/display/DisplayCut.hh @@ -30,7 +30,7 @@ class TCutG; namespace HDTV { namespace Display { -class DisplayCut { +class __declspec(dllexport) DisplayCut { public: class CutPoint { public: diff --git a/hdtv/rootext/display/DisplayObj.hh b/hdtv/rootext/display/DisplayObj.hh index d83327a..3c3829f 100644 --- a/hdtv/rootext/display/DisplayObj.hh +++ b/hdtv/rootext/display/DisplayObj.hh @@ -35,7 +35,7 @@ class DisplayStack; class View1D; //! An object being displayed in a View1D widget -class DisplayObj { +class __declspec(dllexport) DisplayObj { public: DisplayObj() : fZIndex{0}, fVisible{true} {} virtual ~DisplayObj(); diff --git a/hdtv/rootext/display/LinkDef.h b/hdtv/rootext/display/LinkDef.h index 7e7df6c..bddfae8 100644 --- a/hdtv/rootext/display/LinkDef.h +++ b/hdtv/rootext/display/LinkDef.h @@ -19,5 +19,5 @@ #pragma link C++ class HDTV::Display::YMarker; #pragma link C++ class HDTV::Display::MTViewer+; #pragma link C++ class HDTV::Display::Viewer+; - +#pragma link C++ class HDTV::Calibration; #endif diff --git a/hdtv/rootext/display/MTViewer.hh b/hdtv/rootext/display/MTViewer.hh index ae3fbdc..9fb9246 100644 --- a/hdtv/rootext/display/MTViewer.hh +++ b/hdtv/rootext/display/MTViewer.hh @@ -39,7 +39,7 @@ namespace Display { //! Class implementing a window (ROOT TGMainFrame) containing a View2D widget //! and a statusbar. -class MTViewer : public TGMainFrame { +class R__DLLEXPORT MTViewer : public TGMainFrame { public: MTViewer(UInt_t w, UInt_t h, TH2 *mat, const char *title, bool copy = false); MTViewer(UInt_t w, UInt_t h, THnSparse *mat, const char *title); diff --git a/hdtv/rootext/display/Marker.hh b/hdtv/rootext/display/Marker.hh index 0a03e3a..eb26004 100644 --- a/hdtv/rootext/display/Marker.hh +++ b/hdtv/rootext/display/Marker.hh @@ -36,7 +36,7 @@ namespace HDTV { namespace Display { //! A marker (displayed as a horizontal or vertical line) -class Marker : public DisplayObj { +class __declspec(dllexport) Marker : public DisplayObj { friend class Painter; friend class DisplayStack; diff --git a/hdtv/rootext/display/Painter.hh b/hdtv/rootext/display/Painter.hh index f80dfec..ca7d116 100644 --- a/hdtv/rootext/display/Painter.hh +++ b/hdtv/rootext/display/Painter.hh @@ -73,7 +73,7 @@ class XMarker; class YMarker; //! Helper class to do the actual painting of objects on screen -class Painter { +class R__DLLEXPORT Painter { public: Painter(); diff --git a/hdtv/rootext/display/View.hh b/hdtv/rootext/display/View.hh index bb24029..41a0d7c 100644 --- a/hdtv/rootext/display/View.hh +++ b/hdtv/rootext/display/View.hh @@ -41,7 +41,7 @@ namespace Display { //! Code shared between View1D and View2D /** Presently, this implements mostly the XOR cursor. */ -class View : public TGFrame { +class R__DLLEXPORT View : public TGFrame { public: View(const TGWindow *p, UInt_t w, UInt_t h); diff --git a/hdtv/rootext/display/View1D.hh b/hdtv/rootext/display/View1D.hh index 2f6d2db..8322151 100644 --- a/hdtv/rootext/display/View1D.hh +++ b/hdtv/rootext/display/View1D.hh @@ -48,7 +48,7 @@ namespace HDTV { namespace Display { //! Class implementing a display widget for 1d objects (spectra, functions, ...) -class View1D : public View { +class R__DLLEXPORT View1D : public View { friend class DisplayObj; friend class DisplayBlock; diff --git a/hdtv/rootext/display/View2D.hh b/hdtv/rootext/display/View2D.hh index 3a6832b..4b09455 100644 --- a/hdtv/rootext/display/View2D.hh +++ b/hdtv/rootext/display/View2D.hh @@ -46,7 +46,7 @@ namespace HDTV { namespace Display { //! View2D: Class implementing a scrollable matrix display -class View2D : public View { +class R__DLLEXPORT View2D : public View { public: View2D(const TGWindow *p, UInt_t w, UInt_t h, TH2 *mat); ~View2D() override; diff --git a/hdtv/rootext/display/Viewer.hh b/hdtv/rootext/display/Viewer.hh index 4e99643..46de9ff 100644 --- a/hdtv/rootext/display/Viewer.hh +++ b/hdtv/rootext/display/Viewer.hh @@ -38,7 +38,7 @@ class View1D; //! Class implementing a window (ROOT TGMainFrame) containing a View1D widget //! and a statusbar -class Viewer : public TGMainFrame { +class R__DLLEXPORT Viewer : public TGMainFrame { // FIXME: uncommenting the following line causes the inherited CloseWindow() // signal to stop working. The reason is not presently understood, however, // the line does not seem to be needed. diff --git a/hdtv/rootext/display/XMarker.hh b/hdtv/rootext/display/XMarker.hh index cadde15..f6868df 100644 --- a/hdtv/rootext/display/XMarker.hh +++ b/hdtv/rootext/display/XMarker.hh @@ -35,7 +35,7 @@ class View1D; //! A vertical marker (marking a point on the X axis) /** Note: The position of a marker is considered to be in energy units if no calibration is given, and in channel units otherwise. */ -class XMarker : public Marker { +class R__DLLEXPORT XMarker : public Marker { friend class Painter; public: diff --git a/hdtv/rootext/display/YMarker.hh b/hdtv/rootext/display/YMarker.hh index 48df899..64454d1 100644 --- a/hdtv/rootext/display/YMarker.hh +++ b/hdtv/rootext/display/YMarker.hh @@ -31,7 +31,7 @@ namespace Display { class View1D; //! A horizontal marker (marking a point on the Y axis) -class YMarker : public Marker { +class R__DLLEXPORT YMarker : public Marker { public: YMarker(int n, double p1, double p2 = 0.0, int col = 5); void PaintRegion(UInt_t x1, UInt_t x2, Painter &painter) override { diff --git a/hdtv/rootext/dlmgr.py b/hdtv/rootext/dlmgr.py index 577274a..a414662 100644 --- a/hdtv/rootext/dlmgr.py +++ b/hdtv/rootext/dlmgr.py @@ -26,6 +26,7 @@ import shutil import subprocess import sys import tempfile +import pathlib import ROOT @@ -37,7 +38,7 @@ __version__ = get_versions()["version"] del get_versions cachedir = os.path.join( - os.getenv("XDG_CACHE_HOME", os.path.join(os.environ["HOME"], ".cache")), "hdtv" + os.getenv("XDG_CACHE_HOME", os.path.join(pathlib.Path.home(), ".cache")), "hdtv" ) usrdir = os.path.join( cachedir, "%d-%d-%s" % (sys.hexversion, ROOT.gROOT.GetVersionInt(), __version__) @@ -105,17 +106,22 @@ def BuildLibrary(name, dir): srcdir = os.path.join(os.path.dirname(__file__), name) # with tempfile.TemporaryDirectory() as tmpdir: TOOD: Not available in python2 tmpdir = tempfile.mkdtemp() + print("---") + print("dir: %s" % dir) + print("srcdir: %s" % srcdir) + print("tmpdir: %s" % tmpdir) + subprocess.check_call( [ "cmake", - srcdir, "-DCMAKE_INSTALL_PREFIX=%s" % dir, - "-DCMAKE_BUILD_TYPE=Release", + srcdir, ], cwd=tmpdir, ) - subprocess.check_call(["cmake", "--build", ".", "-j"], cwd=tmpdir) - subprocess.check_call(["cmake", "--build", ".", "--target", "install"], cwd=tmpdir) + + subprocess.check_call(["cmake", "--build", ".", "--config Release"], cwd=tmpdir) + subprocess.check_call(["cmake", "--install", "."], cwd=tmpdir) shutil.rmtree(tmpdir) hdtv.ui.info(f"Rebuild library {(libfmt % name)} in {dir}") diff --git a/hdtv/rootext/fit/Integral.hh b/hdtv/rootext/fit/Integral.hh index 4643701..5ff7543 100644 --- a/hdtv/rootext/fit/Integral.hh +++ b/hdtv/rootext/fit/Integral.hh @@ -79,7 +79,7 @@ public: //! Helper class to calculate various statistical moments (integral, mean, ...) //! of a histogram -class Integral { +class R__DLLEXPORT Integral { public: /*! Constructor * \param b1 First bin in sum (inclusive) -- 2.51.1.windows.1