Skip to content

Commit

Permalink
Merge pull request #1859 from AllenInstitute/feature/1859-add-macosx-…
Browse files Browse the repository at this point in the history
…support

Add MacOSX support without hardware
  • Loading branch information
t-b authored Dec 1, 2023
2 parents ed24e5d + ec0a2c1 commit cfbd238
Show file tree
Hide file tree
Showing 31 changed files with 538 additions and 51 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ exclude: |
# patch and svg files always have trailing whitespace
.*patch$|
.*svg$
# don't touch MacOSX XOPs
^XOPs-MacOSX-IP9-64bit|
) # end alternations
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
9 changes: 9 additions & 0 deletions Packages/MIES/MIES_CheckInstallation.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -243,30 +243,39 @@ Function CHI_CheckInstallation()
printf "Mies version info: Valid \"%s...\" (Nice!)\r", StringFromList(0, miesVersion, "\r")
endif

#ifdef WINDOWS
CHI_CheckXOP(listOfXOPs, "itcxop2-64.xop", "ITC XOP", state)
CHI_CheckXOP(listOfXOPs, "AxonTelegraph64.xop", "Axon Telegraph XOP", state)
CHI_CheckXOP(listOfXOPs, "MultiClamp700xCommander64.xop", "Multi Clamp Commander XOP", state)
#endif

// one operation/function of each non-hardware XOP needs to be called in CheckCompilation_IGNORE()
CHI_CheckXOP(listOfXOPs, "JSON-64.xop", "JSON XOP", state)
CHI_CheckXOP(listOfXOPs, "ZeroMQ-64.xop", "ZeroMQ XOP", state)
CHI_CheckXOP(listOfXOPs, "TUF-64.xop", "TUF XOP", state)

#ifdef WINDOWS
CHI_CheckXOP(listOfXOPs, "MiesUtils-64.xop", "MiesUtils XOP", state)
CHI_CheckXOP(listOfXOPs, "mies-nwb2-compound-XOP-64.xop", "NWBv2 compound XOP", state)
#endif

CHI_CheckJSONXOPVersion(state)
#ifdef WINDOWS
CHI_CheckITCXOPVersion(state)
#endif
CHI_CheckTUFXOPVersion(state)

printf "Results: %d checks, %d number of errors\r", state.numTries, state.numErrors

#ifdef WINDOWS
STRUCT CHI_InstallationState stateExtended
CHI_InitInstallationState(stateExtended)
printf "\rChecking extended installation:\r"

CHI_CheckXOP(listOfXOPs, "NIDAQmx64.xop", "NI-DAQ MX XOP", stateExtended, expectedHash = CHI_NIDAQ_XOP_64_HASH)

printf "Results: %d checks, %d number of errors\r", stateExtended.numTries, stateExtended.numErrors
#endif
ControlWindowToFront()

return state.numErrors
Expand Down
10 changes: 8 additions & 2 deletions Packages/MIES/MIES_DAEphys.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ End
Function/S DAP_GetNIDeviceList()
variable i, j, numPattern, numDevices
string propList
string devList, pattern, allDevices, device
string devList, pattern, device
string allDevices = ""

SVAR globalNIDevList = $GetNIDeviceList()
devList = globalNIDevList
Expand All @@ -59,7 +60,10 @@ Function/S DAP_GetNIDeviceList()

numPattern = ItemsInList(NI_DAC_PATTERNS, "|")

#if defined(WINDOWS)
allDevices = HW_NI_ListDevices()
#endif

numDevices = ItemsInList(allDevices)

for(i = 0;i < numDevices;i += 1)
Expand Down Expand Up @@ -94,7 +98,7 @@ End
/// @brief Returns a list of ITC devices for DAC, #NONE if there are none
Function/S DAP_GetITCDeviceList()

string devList
string devList = ""

SVAR globalITCDevList = $GetITCDeviceList()
devList = globalITCDevList
Expand All @@ -103,7 +107,9 @@ Function/S DAP_GetITCDeviceList()
return devList
endif

#if defined(WINDOWS)
devList = HW_ITC_ListDevices()
#endif

if(!IsEmpty(devList))
globalITCDevList = devList
Expand Down
92 changes: 77 additions & 15 deletions Packages/MIES/MIES_GlobalStringAndVariableAccess.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,35 @@ Function/S GetMiesVersion()
return path
End

/// @brief Return a text wave with absolute paths to git binaries with HFS `:` separators
///
/// The paths may not exist.
Function/WAVE GetPossiblePathsToGit()

string userName

#if defined(WINDOWS)
// standard locations for 32bit and 64bit standalone git versions
Make/FREE/T/N=(5) paths
paths[0] = "C:Program Files:Git:mingw64:bin:git.exe"
paths[1] = "C:Program Files (x86):Git:bin:git.exe"
paths[2] = "C:Program Files:Git:cmd:git.exe"

// Atlassian Sourcetree (Embedded git)
userName = GetSystemUserName()
paths[3] = "C::Users:" + userName + ":AppData:Local:Atlassian:SourceTree:git_local:mingw32:bin:git.exe"

// user installation of git for windows
paths[4] = "C::Users:" + userName + ":AppData:Local:Programs:Git:cmd:git.exe"
#elif defined(MACINTOSH)
Make/T/FREE paths = {"Macintosh HD:usr:bin:git"}
#else
ASSERT(0, "Unsupported OS")
#endif

return paths
End

/// @brief Return the version string for the mies-igor project
///
/// The mies version looks like
Expand All @@ -161,42 +190,38 @@ End
/// @returns the mies version
static Function/S CreateMiesVersion()

string path, cmd, topDir, version, gitPathCandidates, gitPath
string path, cmd, topDir, version, gitPath
string userName, gitDir, fullVersionPath
variable refNum, numEntries, i
variable refNum

// set path to the toplevel directory in the mies folder structure
path = ParseFilePath(1, FunctionPath(""), ":", 1, 2)
fullVersionPath = path + "version.txt"

topDir = ParseFilePath(5, path, "*", 0, 0)
topDir = path
gitDir = topDir + ".git"
if(FolderExists(gitDir))
// topDir is a git repository

// standard locations for 32bit and 64bit standalone git versions
gitPathCandidates = "C:\\Program Files\\Git\\mingw64\\bin\\git.exe;C:\\Program Files (x86)\\Git\\bin\\git.exe;C:\\Program Files\\Git\\cmd\\git.exe"
WAVE/T gitPathCandidates = GetPossiblePathsToGit()

// Atlassian Sourcetree (Embedded git)
userName = GetSystemUserName()
gitPathCandidates = AddListItem("C:\\Users\\" + userName + "\\AppData\\Local\\Atlassian\\SourceTree\\git_local\\mingw32\\bin\\git.exe", gitPathCandidates, ";", Inf)

// user installation of git for windows
gitPathCandidates = AddListItem("C:\\Users\\" + userName + "\\AppData\\Local\\Programs\\Git\\cmd\\git.exe", gitPathCandidates, ";", Inf)

numEntries = ItemsInList(gitPathCandidates)
for(i = 0; i < numEntries; i += 1)
gitPath = StringFromList(i, gitPathCandidates)
for(gitPath : gitPathCandidates)
if(!FileExists(gitPath))
continue
endif

gitPath = HFSPathToNative(gitPath)
gitDir = HFSPathToNative(gitDir)
topDir = HFSPathToNative(topDir)

// git is installed, try to regenerate version.txt
DEBUGPRINT("Found git at: ", str=gitPath)

// delete the old version.txt so that we can be sure to get the correct one afterwards
DeleteFile/Z fullVersionPath
DEBUGPRINT("Folder is a git repository: ", str=topDir)

#if defined(WINDOWS)
// explanation:
// cmd /C "<full path to git.exe> --git-dir=<mies repository .git> describe <options> redirect everything into <mies respository>/version.txt"
sprintf cmd "cmd.exe /C \"\"%s\" --git-dir=\"%s\" describe --always --tags --match \"Release_*\" > \"%sversion.txt\" 2>&1\"", gitPath, gitDir, topDir
Expand Down Expand Up @@ -225,7 +250,44 @@ static Function/S CreateMiesVersion()
sprintf cmd "cmd.exe /C \"\"%s\" --git-dir=\"%s\" submodule--helper status >> \"%sversion.txt\" 2>&1\"", gitPath, gitDir, topDir
DEBUGPRINT("Cmd to execute: ", str=cmd)
ExecuteScriptText/B/Z cmd
#elif defined(MACINTOSH)

sprintf cmd "do shell script \"%s --version\"", gitPath
DEBUGPRINT("Cmd to execute: ", str=cmd)
ExecuteScriptText/UNQ/Z cmd
if(V_flag)
printf "Missing functional git executable, please install the \"Xcode commandline tools\" via \"xcode-select --install\" in Terminal.\r"
ControlWindowToFront()
break
endif

sprintf cmd "do shell script \"%s --git-dir='%s' describe --always --tags --match 'Release_*' > '%sversion.txt' 2>&1\"", gitPath, gitDir, topDir
DEBUGPRINT("Cmd to execute: ", str=cmd)
ExecuteScriptText/UNQ/Z cmd
ASSERT(!V_flag, "We have git installed but could not regenerate version.txt")

sprintf cmd "do shell script \"printf 'Date and time of last commit: ' >> '%sversion.txt' 2>&1\"", topDir
DEBUGPRINT("Cmd to execute: ", str=cmd)
ExecuteScriptText/UNQ/Z cmd
ASSERT(!V_flag, "We have git installed but could not regenerate version.txt")

sprintf cmd "do shell script \"%s --git-dir='%s' log -1 --pretty=format:%%cI%%n >> '%sversion.txt' 2>&1\"", gitPath, gitDir, topDir
DEBUGPRINT("Cmd to execute: ", str=cmd)
ExecuteScriptText/UNQ/Z cmd
ASSERT(!V_flag, "We have git installed but could not regenerate version.txt")

sprintf cmd "do shell script \"echo 'Submodule status:' >> '%sversion.txt' 2>&1\"", topDir
DEBUGPRINT("Cmd to execute: ", str=cmd)
ExecuteScriptText/UNQ/Z cmd
ASSERT(!V_flag, "We have git installed but could not regenerate version.txt")

// see comment in WINDOWS branch
sprintf cmd "do shell script \"%s --git-dir='%s' submodule--helper status >> '%sversion.txt' 2>&1\"", gitPath, gitDir, topDir
DEBUGPRINT("Cmd to execute: ", str=cmd)
ExecuteScriptText/UNQ/Z cmd
#else
ASSERT(0, "Unsupported OS")
#endif
break
endfor
endif
Expand Down
13 changes: 11 additions & 2 deletions Packages/MIES/MIES_Menu.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,28 @@ Function MEN_CreateIssueOnGithub()

body += "```\nAvailable NI devices with their properties:\n"

#ifdef WINDOWS
ref = CaptureHistoryStart()
HW_NI_PrintPropertiesOfDevices()
str = CaptureHistory(ref, 1)

print "b"
#endif

body += str

body += "```\n\n"

sprintf url, "https://github.com/AllenInstitute/MIES/issues/new?title=%s&body=%s", URLEncode(title), URLEncode(body)

#if defined(WINDOWS)
BrowseURL(url)
#elif defined(MACINTOSH)
printf "##############################\r"
print body
printf "##############################\r"
printf "Please paste the text between the hashtags into a new issue at: https://github.com/AllenInstitute/MIES/issues/new\r"
#else
ASSSERT(0, "Unsupported OS")
#endif
End

Function MEN_ClearPackageSettings()
Expand Down
24 changes: 22 additions & 2 deletions Packages/MIES/MIES_Utilities.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1795,14 +1795,13 @@ Function IsDriveValid(absPath)
return FolderExists(drive)
End

/// @brief Return the windows drive letter of the given path
/// @brief Return the drive letter of the given path (Windows) or the volume name (Macintosh)
Function/S GetDrive(string path)

string drive

path = GetHFSPath(path)
drive = StringFromList(0, path, ":")
ASSERT(strlen(drive) == 1, "Expected a single letter for the drive")

return drive
end
Expand Down Expand Up @@ -2053,7 +2052,14 @@ End

/// @brief Return the path converted to a HFS style (aka ":" separated) path
threadsafe Function/S GetHFSPath(string path)

#if defined(WINDOWS)
return ParseFilePath(5, path, ":", 0, 0)
#elif defined(MACINTOSH)
return ParseFilePath(5, path, "*", 0, 0)
#else
ASSERT_TS(0, "Unsupported OS")
#endif
End

/// @brief Set the given bit mask in var
Expand Down Expand Up @@ -6733,3 +6739,17 @@ threadsafe Function FindRightMostHighBit(uint64 value)

return NaN
End

#ifdef MACINTOSH

threadsafe Function MU_RunningInMainThread()
TUFXOP_RunningInMainThread

return V_value
End

threadsafe Function MU_GetFreeDiskSpace(string path)
ASSERT_TS(0, "Not implemented")
End

#endif
15 changes: 12 additions & 3 deletions Packages/MIES_Include.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
// These are sphinx substitutions destined for Packages/doc/installation_subst.txt.
// They are defined here so that we can parse them from within IP.
//
// .. |IgorPro9Nightly| replace:: `Igor Pro 9 <https://www.byte-physics.de/Downloads/WinIgor9_01APR2023.zip>`__
// .. |IgorPro9WindowsNightly| replace:: `Igor Pro 9 (Windows) <https://www.byte-physics.de/Downloads/WinIgor9_01APR2023.zip>`__
// .. |IgorPro9MacOSXNightly| replace:: `Igor Pro 9 (MacOSX) <https://www.byte-physics.de/Downloads/MacIgor9_18Aug2023.dmg>`__

#pragma IgorVersion=9.00

Expand Down Expand Up @@ -53,12 +54,20 @@ End

static Function/S GetDownloadLink()

string igorMajorVersion, text, lineWithLink, url
string igorMajorVersion, text, lineWithLink, url, os

igorMajorVersion = StringByKey("IGORVERS", IgorInfo(0))[0]

#if defined(WINDOWS)
os = "Windows"
#elif defined(MACINTHOSH)
os = "MacOSX"
#else
ASSERT_TS(0, "Unsupported OS")
#endif

text = ProcedureText("", 0, "MIES_Include.ipf")
lineWithLink = GrepList(text, "\\Q|IgorPro" + igorMajorVersion + "Nightly|\\E", 0, "\r")
lineWithLink = GrepList(text, "\\Q|IgorPro" + igorMajorVersion + os + "Nightly|\\E", 0, "\r")
SplitString/E=".*<(.*)>.*" lineWithLink, url

if(V_Flag != 1)
Expand Down
Loading

0 comments on commit cfbd238

Please sign in to comment.