This is an automated email from the ASF dual-hosted git repository. silver pushed a commit to branch haskell-release in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit 07865f3111b51eb998cc568285bebdf3848e3353 Author: silver-ymz <[email protected]> AuthorDate: Thu Sep 14 20:05:42 2023 +0800 chore(bindings/haskell): make cargo build type same with cabal Signed-off-by: silver-ymz <[email protected]> --- .github/workflows/bindings_haskell.yml | 14 +++++++++----- .github/workflows/docs.yml | 12 ++++++++---- bindings/haskell/Setup.hs | 15 +++++++++------ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/.github/workflows/bindings_haskell.yml b/.github/workflows/bindings_haskell.yml index 32d6b13c1..c483b990b 100644 --- a/.github/workflows/bindings_haskell.yml +++ b/.github/workflows/bindings_haskell.yml @@ -54,15 +54,19 @@ jobs: - name: Restore haskell cache uses: actions/cache/restore@v3 with: - key: ${{ runner.os }}-haskell-${{ hashFiles('**/*.cabal') }} - path: ~/.cabal/store + key: ${{ runner.os }}-haskell-${{ hashFiles('**/*.cabal', '**/Setup.hs') }} + path: | + ~/.cabal/store + bindings/haskell/dist-newstyle restore-keys: ${{ runner.os }}-haskell- - name: Build & Test working-directory: "bindings/haskell" run: | - LD_LIBRARY_PATH=../../target/release cabal test + LD_LIBRARY_PATH=../../target/debug cabal test - name: Save haskell cache uses: actions/cache/save@v3 with: - key: ${{ runner.os }}-haskell-${{ hashFiles('**/*.cabal') }} - path: ~/.cabal/store + key: ${{ runner.os }}-haskell-${{ hashFiles('**/*.cabal', '**/Setup.hs') }} + path: | + ~/.cabal/store + bindings/haskell/dist-newstyle diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 97b677a83..1821f870c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -199,8 +199,10 @@ jobs: - name: Restore haskell cache uses: actions/cache/restore@v3 with: - key: ${{ runner.os }}-haskell-${{ hashFiles('**/*.cabal') }} - path: ~/.cabal/store + key: ${{ runner.os }}-haskell-${{ hashFiles('**/*.cabal', '**/Setup.hs') }} + path: | + ~/.cabal/store + bindings/haskell/dist-newstyle restore-keys: ${{ runner.os }}-haskell- - name: Build Docs @@ -212,8 +214,10 @@ jobs: - name: Save haskell cache uses: actions/cache/save@v3 with: - key: ${{ runner.os }}-haskell-${{ hashFiles('**/*.cabal') }} - path: ~/.cabal/store + key: ${{ runner.os }}-haskell-${{ hashFiles('**/*.cabal', '**/Setup.hs') }} + path: | + ~/.cabal/store + bindings/haskell/dist-newstyle - name: Upload docs uses: actions/upload-artifact@v3 diff --git a/bindings/haskell/Setup.hs b/bindings/haskell/Setup.hs index 5a2c6048e..65a8ca896 100644 --- a/bindings/haskell/Setup.hs +++ b/bindings/haskell/Setup.hs @@ -41,7 +41,7 @@ rustConfHook (description, buildInfo) flags = do let packageDescription = localPkgDescr localBuildInfo library = fromJust $ PD.library packageDescription libraryBuildInfo = PD.libBuildInfo library - dir <- getLibDir + dir <- getLibDir $ fromFlagOrDefault False (configProf flags) return localBuildInfo { localPkgDescr = @@ -60,24 +60,27 @@ rustConfHook (description, buildInfo) flags = do rustBuildHook :: PD.PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO () rustBuildHook pkg_descr lbi hooks flags = do putStrLn "Building Rust code..." - rawSystemExit (fromFlag $ buildVerbosity flags) "cargo" ["build", "--release"] + let cargoArgs = if isRelease then ["build", "--release"] else ["build"] + rawSystemExit (fromFlag $ buildVerbosity flags) "cargo" cargoArgs createHSLink putStrLn "Build Rust code success!" buildHook simpleUserHooks pkg_descr lbi hooks flags where createHSLink = do - dir <- getLibDir + dir <- getLibDir isRelease ghcVersion <- init <$> readProcess "ghc" ["--numeric-version"] "" let srcPath = dir ++ "/libopendal_hs." ++ getDynamicLibExtension lbi let destPath = dir ++ "/libopendal_hs-ghc" ++ ghcVersion ++ "." ++ getDynamicLibExtension lbi exist <- doesFileExist destPath when (not exist) $ createFileLink srcPath destPath + isRelease = withProfLib lbi -getLibDir :: IO String -getLibDir = do +getLibDir :: Bool -> IO String +getLibDir isRelease = do cargoPath <- readProcess "cargo" ["locate-project", "--workspace", "--message-format=plain"] "" let dir = take (length cargoPath - 11) cargoPath -- <dir>/Cargo.toml -> <dir> - return $ dir ++ "/target/release" + let targetDir = if isRelease then "release" else "debug" + return $ dir ++ "/target/" ++ targetDir getDynamicLibExtension :: LocalBuildInfo -> String getDynamicLibExtension lbi =
