Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweaks to tidal binary, and add to linux workflow #882

Merged
merged 4 commits into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/listener-build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
run: |
cabal update
cabal build --enable-tests tidal-listener
cabal build

- name: move GHC libs and configs
run: |
Expand Down Expand Up @@ -104,12 +105,14 @@ jobs:
- name: fake gcc
run: |
mkdir -p tidal-listener/binary/haskell-libs/bin/
cp -r tidal-listener/fake_gcc.sh tidal-listener/binary/haskell-libs/bin/fake_gcc.sh
cp tidal-listener/fake_gcc.sh tidal-listener/binary/haskell-libs/bin/fake_gcc.sh
sed -i 's/cc/bin\/fake_gcc.sh/g' tidal-listener/binary/haskell-libs/settings
chmod 755 tidal-listener/binary/haskell-libs/bin/fake_gcc.sh

- name: move executable
run: cp -r dist-newstyle/build/x86_64-linux/ghc-${{ matrix.ghc }}/tidal-listener-0.1.0.0/x/tidal-listener/build/tidal-listener/tidal-listener tidal-listener/binary/tidal-listener
run: |
cp dist-newstyle/build/x86_64-linux/ghc-${{ matrix.ghc }}/tidal-listener-0.1.0.0/x/tidal-listener/build/tidal-listener/tidal-listener tidal-listener/binary/tidal-listener
cp dist-newstyle/build/x86_64-linux/ghc-${{ matrix.ghc }}/tidal-1.7.10/x/tidal/build/tidal/tidal tidal-listener/binary/tidal

- name: zip files
run: |
Expand Down
12 changes: 7 additions & 5 deletions main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ main = do
$ catch (core tidal)
$ \ (e :: SomeException) -> message stderr $ show e

core :: C.Stream -> I.InterpreterT IO ()
core tidal = do
message stdout "safe-tidal-cli starts"
message stdout "[tidal] starting..."
-- more settings at
-- https://github.com/tidalcycles/tidali/blob/master/src/Main.hs
I.set [ I.languageExtensions
Expand All @@ -63,19 +64,20 @@ core tidal = do
, "Sound.Tidal.Safe.Boot"
]
-- FIXME: replace lazy IO by some streaming mechanism?
message stdout "safe-tidal-cli has loaded modules"
message stdout "[tidal] modules loaded..."
input <- liftIO getContents
message stdout "safe-tidal-cli has acquired input"
message stdout "[tidal] ready"
mapM_ (work tidal . unlines) $ blocks $ lines input
message stdout "safe-tidal-cli is done"

second :: Int
second = 10^6 :: Int

-- | will show at most 10 lines, at most 80 chars per line,
-- and run (evaluation and print) for at most 1 second
message :: Handle -> String -> I.InterpreterT IO ()
message h s = do
let safe = unlines . safe_list 10 ["..."] . map (safe_list 120 "...") . lines
let safe = unlines . safe_list 20 ["..."] . map (safe_list 120 "...") . lines
liftIO $ void $ timeout (1 * second) $ do
hPutStrLn h (safe s) ; hFlush h

Expand All @@ -89,7 +91,7 @@ safe_list n msg xs =

work :: C.Stream -> String -> I.InterpreterT IO ()
work tidal contents =
( if take 2 contents `elem` [ ":t", ":i", ":d" ]
( if take 2 contents `elem` [ ":t", ":i", ":d", ":s" ]
then do
-- https://github.com/haskell-hint/hint/issues/101
message stderr $ "not implemented " <> contents
Expand Down