Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianAN committed Jun 2, 2024
2 parents 4011441 + 9eaa10f commit 05b848b
Show file tree
Hide file tree
Showing 40 changed files with 260 additions and 137 deletions.
3 changes: 3 additions & 0 deletions .github/prepare-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ chmod +x artifacts/bleep-x86_64-pc-linux/bleep
chmod +x artifacts/bleep-x86_64-apple-darwin/bleep
(cd artifacts/bleep-x86_64-apple-darwin && tar cvfz "$CWD/work/release/bleep-x86_64-apple-darwin.tar.gz" bleep)

chmod +x artifacts/bleep-arm64-apple-darwin/bleep
(cd artifacts/bleep-arm64-apple-darwin && tar cvfz "$CWD/work/release/bleep-arm64-apple-darwin.tar.gz" bleep)

(cd artifacts/bleep-x86_64-pc-win32 && zip -r "$CWD/work/release/bleep-x86_64-pc-win32.zip" bleep.exe)

42 changes: 22 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ jobs:
- os: ubuntu-20.04
file_name: bleep
artifact_name: bleep-x86_64-pc-linux
- os: macos-latest
- os: macos-13
file_name: bleep
artifact_name: bleep-x86_64-apple-darwin
- os: macos-latest
file_name: bleep
artifact_name: bleep-arm64-apple-darwin
- os: windows-latest
file_name: bleep.exe
artifact_name: bleep-x86_64-pc-win32
Expand Down Expand Up @@ -95,30 +98,29 @@ jobs:
if: runner.os == 'Windows'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: '22.3.1'
java-version: '17'
components: 'native-image'

distribution: 'graalvm-community' # See 'Options' section below for all available distributions
java-version: '21.0.2'
native-image-job-reports: 'true'
- name: Build native image 3 (windows)
run: bleep native-image ${{ matrix.file_name }}
shell: cmd
if: runner.os == 'Windows'

- name: Test binary after build 1 (windows)
shell: cmd
env:
CI: true
# todo: fix tests on windows
run: .\${{ matrix.file_name }} --dev compile --no-color jvm3
if: runner.os == 'Windows'

- name: Test binary after build 2 (windows)
shell: cmd
env:
CI: true
# todo: fix tests on windows
run: .\${{ matrix.file_name }} selftest
if: runner.os == 'Windows'
# todo: fix tests on windows
# - name: Test binary after build 1 (windows)
# shell: cmd
# env:
# CI: true
# run: .\${{ matrix.file_name }} --dev compile --no-color jvm3
# if: runner.os == 'Windows'

# - name: Test binary after build 2 (windows)
# shell: cmd
# env:
# CI: true
# # todo: fix tests on windows
# run: .\${{ matrix.file_name }} selftest
# if: runner.os == 'Windows'

- name: Temporarily save package
uses: actions/upload-artifact@v2
Expand Down
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@
url = git@github.com:bleep-build/librarymanagement.git
branch = develop
update = rebase
[submodule "liberated/libdaemon-jvm"]
path = liberated/libdaemon-jvm
url = git@github.com:bleep-build/libdaemon-jvm
branch = process-handle
update = rebase
1 change: 0 additions & 1 deletion bleep-cli/src/scala/bleep/commands/BuildDiff.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bleep
package commands

import bleep.{BuildLoader, Lazy}
import com.monovore.decline.Opts

import scala.collection.immutable.SortedSet
Expand Down
1 change: 0 additions & 1 deletion bleep-cli/src/scala/bleep/commands/BuildDiffBloop.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bleep
package commands

import bleep.{BuildLoader, Lazy}
import bloop.config.{Config, ConfigCodecs}
import cats.Show
import cats.syntax.show.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bleep
package commands

import bleep.RelPath
import bleep.internal.{writeYamlLogged, FileUtils}
import bleep.logging.Logger
import bleep.rewrites.BuildRewrite
Expand Down
1 change: 0 additions & 1 deletion bleep-cli/src/scala/bleep/commands/BuildShow.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bleep
package commands

import bleep.BleepException
import bloop.config.ConfigCodecs
import cats.data.NonEmptyList

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bleep
package commands

import bleep.BleepException
import bleep.logging.Logger

case class CompileServerSetMode(logger: Logger, userPaths: UserPaths, mode: model.CompileServerMode) extends BleepCommand {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bleep
package commands

import bleep.BleepException
import bleep.bsp.BleepRifleLogger
import bleep.internal.FileUtils
import bleep.logging.Logger
Expand Down
21 changes: 21 additions & 0 deletions bleep-cli/src/scala/bleep/commands/CoursierInstallation.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package bleep.commands

import bleep.BleepExecutable

import java.nio.file.{Files, Path}

/** Coursier uses a wrapper script to call the bleep binary. This detects if it's a coursier installation where the wrapper script is present.
*/
object CoursierInstallation {
def unapply(exec: BleepExecutable): Option[(Path, BleepExecutable.Binary)] =
exec match {
case binary: BleepExecutable.Binary =>
val scriptPath = binary.command.getParent.resolve("bleep")
val isCoursierPath = binary.command.toAbsolutePath.toString.contains("coursier")
if (isCoursierPath && Files.exists(scriptPath)) {
Some((scriptPath, binary))
} else None
case BleepExecutable.CurrentJava(command, args) => None
case BleepExecutable.DownloadedJava(command, args) => None
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import bleep.logging.Logger
case class InstallBashTabCompletions(logger: Logger) extends BleepCommand {
override def run(): Either[BleepException, Unit] = {
val programName = BleepExecutable.findCurrentBleep(logger) match {
case Some(binary: BleepExecutable.Binary) => binary.command.getFileName.toString
case Some(CoursierInstallation(scriptPath, _)) => scriptPath.getFileName.toString
case Some(binary: BleepExecutable.Binary) => binary.command.getFileName.toString
case _ =>
logger.warn("Doesn't know name of a Bleep executable. Falling back to 'bleep'")
"bleep"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import java.nio.file.Path
case class InstallZshTabCompletions(userPaths: UserPaths, logger: Logger) extends BleepCommand {
override def run(): Either[BleepException, Unit] = {
val programName = BleepExecutable.findCurrentBleep(logger) match {
case Some(binary: BleepExecutable.Binary) => binary.command.getFileName.toString
case Some(CoursierInstallation(scriptPath, _)) => scriptPath.getFileName.toString
case Some(binary: BleepExecutable.Binary) => binary.command.getFileName.toString
case _ =>
logger.warn("Doesn't know name of a Bleep executable. Falling back to 'bleep'")
"bleep"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import bleep.logging.Logger
import bleep.nosbt.librarymanagement
import bloop.config.Config
import coursier.core.{Classifier, Configuration, Extension, Module, ModuleName, Organization, Publication, Type}
import io.github.davidgregory084.{DevMode, TpolecatPlugin}
import org.typelevel.sbt.tpolecat.{DevMode, TpolecatPlugin}

import java.net.URI
import java.nio.file.{Path, Paths}
Expand Down
5 changes: 3 additions & 2 deletions bleep-core/src/scala/bleep/GenBloopFiles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import bloop.config.{Config, ConfigCodecs}
import com.github.plokhotnyuk.jsoniter_scala.core.{writeToString, WriterConfig}
import coursier.Classifier
import coursier.core.{Configuration, Extension}
import io.github.davidgregory084.{DevMode, TpolecatPlugin}
import org.typelevel.sbt.tpolecat.{DevMode, TpolecatPlugin}

import java.nio.charset.StandardCharsets.UTF_8
import java.nio.file.{Files, Path}
Expand Down Expand Up @@ -376,7 +376,8 @@ object GenBloopFiles {
options = templateDirs.fill.opts(scalacOptions).render,
jars = resolvedScalaCompiler,
analysis = Some(projectPaths.incrementalAnalysis),
setup = Some(setup)
setup = Some(setup),
bridgeJars = None
)
}

Expand Down
8 changes: 6 additions & 2 deletions bleep-core/src/scala/bleep/bootstrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ object bootstrap {
else {
val chosen =
build.explodedProjects.flatMap { case (crossProjectName, p) =>
val folder = pre.buildPaths.project(crossProjectName, p).dir
if (folder.startsWith(pre.buildPaths.cwd)) Some(crossProjectName)
val projectPaths = pre.buildPaths.project(crossProjectName, p)
val underFolder = projectPaths.dir.startsWith(pre.buildPaths.cwd)
def underSources = projectPaths.sourcesDirs.all.exists(_.startsWith(pre.buildPaths.cwd))
def underResources = projectPaths.resourcesDirs.all.exists(_.startsWith(pre.buildPaths.cwd))
val underAny = underFolder || underSources || underResources
if (underAny) Some(crossProjectName)
else None
}.toArray

Expand Down
2 changes: 1 addition & 1 deletion bleep-core/src/scala/bleep/bsp/BleepRifleLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.io.OutputStream
import java.nio.charset.StandardCharsets
import bloop.rifle.BloopRifleLogger

class BleepRifleLogger(logger: Logger) extends BloopRifleLogger {
class BleepRifleLogger(val logger: Logger) extends BloopRifleLogger {
val bloopLogger = logger.withPath("bloop")
val bloopRifleLogger = logger.withPath("bloop-rifle")

Expand Down
30 changes: 19 additions & 11 deletions bleep-core/src/scala/bleep/bsp/SetupBloopRifle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bleep
package bsp

import bleep.internal.FileUtils
import bleep.logging.Logger
import bleep.model.CompileServerMode
import bloop.rifle.BloopRifleConfig

Expand All @@ -22,7 +23,7 @@ object SetupBloopRifle {
): BloopRifleConfig = {
val default = BloopRifleConfig
.default(
BloopRifleConfig.Address.DomainSocket(bspSocketFile(userPaths, compileServerMode, resolvedJvm.jvm)),
BloopRifleConfig.Address.DomainSocket(bspSocketFile(bleepRifleLogger.logger, userPaths, compileServerMode, resolvedJvm.jvm)),
bloopClassPath(resolver),
FileUtils.TempDir.toFile
)
Expand Down Expand Up @@ -61,16 +62,22 @@ object SetupBloopRifle {
val tmpDir = dir.getParent / s".${dir.getFileName}.tmp-$socketId"
try {
Files.createDirectories(tmpDir)
if (!Properties.isWin)
if (!Properties.isWin) {
Files.setPosixFilePermissions(
tmpDir,
java.util.Set.of(PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE)
)
try Files.move(tmpDir, dir, StandardCopyOption.ATOMIC_MOVE)
catch {
()
}
try {
Files.move(tmpDir, dir, StandardCopyOption.ATOMIC_MOVE)
()
} catch {
case _: AtomicMoveNotSupportedException =>
try Files.move(tmpDir, dir)
catch {
try {
Files.move(tmpDir, dir)
()
} catch {
case _: FileAlreadyExistsException =>
}
case _: FileAlreadyExistsException =>
Expand All @@ -82,7 +89,7 @@ object SetupBloopRifle {
}
dir
}
def bspSocketFile(userPaths: UserPaths, mode: model.CompileServerMode, jvm: model.Jvm): Path = {
def bspSocketFile(logger: Logger, userPaths: UserPaths, mode: model.CompileServerMode, jvm: model.Jvm): Path = {
val somewhatRandomIdentifier = Try(ProcessHandle.current.pid) match {
case Failure(_) =>
val r = new Random
Expand All @@ -105,10 +112,11 @@ object SetupBloopRifle {
case model.CompileServerMode.NewEachInvocation =>
Runtime.getRuntime.addShutdownHook(
new Thread("delete-bloop-bsp-named-socket") {
override def run() = {
FileUtils.deleteDirectory(socket)
()
}
override def run(): Unit =
try FileUtils.deleteDirectory(socket)
catch {
case x: FileSystemException => logger.warn(s"Failed to delete $socket at shutdown: ${x.getMessage}")
}
}
)

Expand Down
1 change: 0 additions & 1 deletion bleep-core/src/scala/bleep/commands/Clean.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bleep
package commands

import bleep.BleepException
import bleep.internal.FileUtils

import java.nio.file.{Files, Path}
Expand Down
1 change: 0 additions & 1 deletion bleep-core/src/scala/bleep/commands/Evicted.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package bleep
package commands

import bleep.BleepException
import bleep.depcheck.CheckEvictions
import bleep.model.VersionCombo
import bleep.nosbt.librarymanagement
Expand Down
20 changes: 13 additions & 7 deletions bleep-core/src/scala/bleep/commands/SourceGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package bleep
package commands

import bleep.internal.{traverseish, TransitiveProjects}

import bleep.model.{CrossProjectName, ScriptDef}
import bloop.rifle.BuildServer

case class SourceGen(watch: Boolean, projects: Array[model.CrossProjectName]) extends BleepCommandRemote(watch) {
case class SourceGen(watch: Boolean, projectNames: Array[model.CrossProjectName]) extends BleepCommandRemote(watch) {
override def watchableProjects(started: Started): TransitiveProjects = {
val scriptProjects = for {
projectName <- projects
projectName <- projectNames
p = started.build.explodedProjects(projectName)
sourceGen <- p.sourcegen.values.iterator
scriptProject = sourceGen match {
Expand All @@ -18,9 +18,15 @@ case class SourceGen(watch: Boolean, projects: Array[model.CrossProjectName]) ex
TransitiveProjects(started.build, scriptProjects)
}

override def runWithServer(started: Started, bloop: BuildServer): Either[BleepException, Unit] =
traverseish.runAll(projects) { projectName =>
val scripts = started.build.explodedProjects(projectName).sourcegen.values.toList
Script.run(started, bloop, scripts, args = List("--project", projectName.value), watch = false)
override def runWithServer(started: Started, bloop: BuildServer): Either[BleepException, Unit] = {
val byScript: Map[ScriptDef, Array[CrossProjectName]] =
projectNames
.flatMap(projectName => started.build.explodedProjects(projectName).sourcegen.values.map(script => (script, projectName)))
.groupMap { case (s, _) => s } { case (_, pn) => pn }

traverseish.runAll(byScript) { case (script, projectNames) =>
val args = projectNames.toList.flatMap(pn => List("--project", pn.value))
Script.run(started, bloop, List(script), args = args, watch = false)
}
}
}
4 changes: 4 additions & 0 deletions bleep-site-in/installing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ There is an action available to install Bleep. It picks up the wanted Bleep vers
- uses: bleep-build/bleep-setup-action@0.0.1
```
## Nix
Checkout [bleep-flake](https://github.com/KristianAN/bleep-flake)
## Manual installation
You can download it manually from [GitHub releases](https://github.com/oyvindberg/bleep/releases) (expand "assets")
Loading

0 comments on commit 05b848b

Please sign in to comment.