Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
Revert "Revert "Update API to support the new content roots (#1640)""
Browse files Browse the repository at this point in the history
This reverts commit e2476ee.
  • Loading branch information
farmaazon committed Jul 8, 2021
1 parent 2e2a804 commit c40d8e5
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 79 deletions.
58 changes: 36 additions & 22 deletions src/js/lib/client/tasks/signArchives.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ const resRoot = path.join(contentRoot, 'Resources')

// TODO: Refactor this once we have a better wau to get the used engine version.
// See the tracking issue for more information https://github.com/enso-org/ide/issues/1359
const ENGINE = '0.2.11'
const ENGINE = '0.2.12'
const ID = '"Developer ID Application: New Byte Order Sp. z o. o. (NM77WTZJFQ)"'
// Placeholder name for temporary archives.
const tmpArchive = 'temporary_archive.zip'

const GRAALVM = 'graalvm-ce-java11-21.1.0';

// Helper to execute a command in a given directory and return the output.
const run = (cmd, cwd) => child_process.execSync(cmd, { shell: true, cwd }).toString()

Expand Down Expand Up @@ -126,124 +128,136 @@ const toSign = [
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.jartool.jmod',
jarContent: ['bin/jarsigner', 'bin/jar'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.jdeps.jmod',
jarContent: ['bin/javap', 'bin/jdeprscan', 'bin/jdeps'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.jstatd.jmod',
jarContent: ['bin/jstatd'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.pack.jmod',
jarContent: ['bin/unpack200', 'bin/pack200'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.hotspot.agent.jmod',
jarContent: ['bin/jhsdb'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.jfr.jmod',
jarContent: ['bin/jfr'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.rmic.jmod',
jarContent: ['bin/rmic'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'java.rmi.jmod',
jarContent: ['bin/rmid', 'bin/rmiregistry'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'java.base.jmod',
jarContent: ['bin/java', 'bin/keytool', 'lib/jspawnhelper'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.jlink.jmod',
jarContent: ['bin/jmod', 'bin/jlink', 'bin/jimage'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.scripting.nashorn.shell.jmod',
jarContent: ['bin/jjs'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.jcmd.jmod',
jarContent: ['bin/jstack', 'bin/jcmd', 'bin/jps', 'bin/jmap', 'bin/jstat', 'bin/jinfo'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.jshell.jmod',
jarContent: ['bin/jshell'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.compiler.jmod',
jarContent: ['bin/javac', 'bin/serialver'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'java.scripting.jmod',
jarContent: ['bin/jrunscript'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.jdi.jmod',
jarContent: ['bin/jdb'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.javadoc.jmod',
jarContent: ['bin/javadoc'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.jconsole.jmod',
jarContent: ['bin/jconsole'],
},
{
jarDir:
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
jarName: 'jdk.javadoc.jmod',
jarContent: ['bin/javadoc'],
},
]

// Extra files that need to be signed.
const extra = [
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/MacOS/libjli.dylib',
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/languages/llvm/native/bin/ld.lld',
`enso/runtime/${GRAALVM}/Contents/MacOS/libjli.dylib`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/llvm/native/bin/ld.lld`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/MASS/libs/MASS.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/cluster/libs/cluster.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/nnet/libs/nnet.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/rpart/libs/rpart.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/lattice/libs/lattice.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/nlme/libs/nlme.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/class/libs/class.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/spatial/libs/spatial.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/foreign/libs/foreign.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/Matrix/libs/Matrix.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/KernSmooth/libs/KernSmooth.so`,
`enso/runtime/${GRAALVM}/Contents/Home/languages/R/library/survival/libs/survival.so`,
]

exports.default = async function () {
Expand Down
7 changes: 4 additions & 3 deletions src/js/lib/project-manager/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ async function get_project_manager_url(): Promise<string> {
const config = await get_build_config()
const target_platform = config.target
console.log('webpack target ' + target_platform)
// Usually it is a good idea to synchronize this constant with `ENGINE_VERSION_FOR_NEW_PROJECTS` in
// src/rust/ide/src/ide/initializer.rs. See also https://github.com/enso-org/ide/issues/1359
const version = '0.2.11'
// This constant MUST be synchronized with `ENGINE` constant in src/js/lib/client/tasks/signArchives.js.
// Also it is usually a good idea to synchronize it with `ENGINE_VERSION_FOR_NEW_PROJECTS` in
// src/rust/ide/src/controller/project.rs. See also https://github.com/enso-org/ide/issues/1359
const version = '0.2.12'
let base_url: string = 'https://github.com/enso-org/'
base_url += 'enso/releases/download/'
base_url += `enso-${version}/enso-project-manager-${version}`
Expand Down
52 changes: 31 additions & 21 deletions src/rust/ide/lib/enso-protocol/src/language_server/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
use crate::prelude::*;

use crate::language_server::MockClient;
use crate::language_server::API;
use crate::language_server::MockClient;
use crate::language_server::types::ContentRoot;
use crate::language_server::types::ContentRootType;

use uuid::Uuid;
use utils::fail::FallibleResult;
Expand Down Expand Up @@ -39,30 +41,41 @@ pub struct Connection {
/// LS client that has already initialized protocol.
#[derivative(Debug="ignore")]
pub client:Box<dyn API>,
/// Content roots obtained during initialization. Guaranteed to be non-empty.
content_roots:Vec<Uuid>,
/// The Project content root, being an only obligatory content root received.
project_root:ContentRoot,
/// Content roots obtained during initialization other than the `project_root`].
content_roots:Vec<ContentRoot>,
}

impl Connection {
/// Takes a client, generates ID for it and initializes the protocol.
pub async fn new(client:impl API + 'static, client_id:Uuid) -> FallibleResult<Self> {
let client = Box::new(client);
let init_response = client.init_protocol_connection(&client_id).await;
let init_response = init_response.map_err(|e| FailedToInitializeProtocol(e.into()))?;
let content_roots = init_response.content_roots;
if content_roots.is_empty() {
Err(MissingContentRoots.into())
} else {
Ok(Connection {client_id,client,content_roots})
}
let client = Box::new(client);
let init_response = client.init_protocol_connection(&client_id).await;
let init_response = init_response.map_err(|e| FailedToInitializeProtocol(e.into()))?;
let mut content_roots = init_response.content_roots;
let project_root = Self::extract_project_root(&mut content_roots)?;
Ok(Connection {client_id,client,project_root,content_roots})
}

fn extract_project_root(content_roots:&mut Vec<ContentRoot>) -> FallibleResult<ContentRoot> {
use ContentRootType::*;
let opt_index = content_roots.iter().position(|cr| cr.content_root_type == Project);
let index = opt_index.ok_or(MissingContentRoots)?;
Ok(content_roots.drain(index..=index).next().unwrap())
}

/// Creates a connection which wraps a mock client.
pub fn new_mock(client:MockClient) -> Connection {
Connection {
client : Box::new(client),
client_id : default(),
content_roots : vec![default()],
client : Box::new(client),
client_id : default(),
project_root : ContentRoot {
id : default(),
content_root_type : ContentRootType::Project,
name : "Project".to_owned()
},
content_roots : default(),
}
}

Expand All @@ -72,14 +85,11 @@ impl Connection {
}

/// Returns the first content root.
pub fn content_root(&self) -> Uuid {
// Guaranteed to be non-empty thanks to check in `new` and implementation of `new_mock`.
self.content_roots[0]
}
pub fn project_root(&self) -> &ContentRoot { &self.project_root }

/// Lists all content roots for this LS connection.
pub fn content_roots(&self) -> &Vec<Uuid> {
&self.content_roots
pub fn content_roots(&self) -> impl Iterator<Item=&ContentRoot> {
std::iter::once(&self.project_root).chain(self.content_roots.iter())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::language_server::SuggestionsDatabaseEntry;
#[serde(rename_all="camelCase")]
pub struct InitProtocolConnection {
/// List of Root IDs.
pub content_roots:Vec<Uuid>,
pub content_roots:Vec<ContentRoot>,
}

/// Response of `file_read` method.
Expand Down
12 changes: 10 additions & 2 deletions src/rust/ide/lib/enso-protocol/src/language_server/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ fn test_file_requests() {
#[test]
fn test_protocol_connection() {
let init_protocol_connection_response = response::InitProtocolConnection {
content_roots: vec![uuid::Uuid::default()]
content_roots: vec![ContentRoot {
id : default(),
content_root_type : ContentRootType::Project,
name : "Project".to_owned()
}]
};
test_request(
|client| client.init_protocol_connection(&uuid::Uuid::default()),
Expand All @@ -270,7 +274,11 @@ fn test_protocol_connection() {
"clientId" : "00000000-0000-0000-0000-000000000000"
}),
json!({
"contentRoots" : ["00000000-0000-0000-0000-000000000000"]
"contentRoots" : [{
"id" : "00000000-0000-0000-0000-000000000000",
"type" : "Project",
"name" : "Project",
}]
}),
init_protocol_connection_response
);
Expand Down
33 changes: 33 additions & 0 deletions src/rust/ide/lib/enso-protocol/src/language_server/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,39 @@ impl FileSystemObject {



// =====================
// === Content Roots ===
// =====================

/// The type of the annotated content root.
#[derive(Clone,Copy,Debug,Deserialize,Eq,Hash,PartialEq,Serialize)]
pub enum ContentRootType {
/// The project home.
Project,
/// System root `/` on unix systems, or drive root on Windows. In Windows’ case, there may be
/// multiple [`Root`] entries corresponding to the various drives.
Root,
/// The user’s home directory.
Home,
/// An Enso library location.
Library,
/// A content root that has been added by the IDE (unused for now).
Custom
}

/// A content root represents a location on a real file-system that has been virtualized for use in
/// the Cloud.
#[allow(missing_docs)]
#[derive(Clone,Debug,Deserialize,Eq,Hash,PartialEq,Serialize)]
#[serde(rename_all="camelCase")]
pub struct ContentRoot {
pub id:Uuid,
#[serde(rename="type")]
pub content_root_type : ContentRootType,
pub name : String,
}



// ================
// === Position ===
Expand Down
Loading

0 comments on commit c40d8e5

Please sign in to comment.