Skip to content

Commit

Permalink
Revert "Update API to support the new content roots (enso-org/ide#1640)"
Browse files Browse the repository at this point in the history
This reverts commit e266f03.


Original commit: enso-org/ide@e2476ee
  • Loading branch information
farmaazon committed Jun 29, 2021
1 parent 74cf628 commit dd94908
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 191 deletions.
58 changes: 22 additions & 36 deletions ide/src/js/lib/client/tasks/signArchives.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ 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.12'
const ENGINE = '0.2.11'
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 @@ -128,136 +126,124 @@ const toSign = [
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.jartool.jmod',
jarContent: ['bin/jarsigner', 'bin/jar'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.jdeps.jmod',
jarContent: ['bin/javap', 'bin/jdeprscan', 'bin/jdeps'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.jstatd.jmod',
jarContent: ['bin/jstatd'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.pack.jmod',
jarContent: ['bin/unpack200', 'bin/pack200'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.hotspot.agent.jmod',
jarContent: ['bin/jhsdb'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.jfr.jmod',
jarContent: ['bin/jfr'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.rmic.jmod',
jarContent: ['bin/rmic'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'java.rmi.jmod',
jarContent: ['bin/rmid', 'bin/rmiregistry'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'java.base.jmod',
jarContent: ['bin/java', 'bin/keytool', 'lib/jspawnhelper'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.jlink.jmod',
jarContent: ['bin/jmod', 'bin/jlink', 'bin/jimage'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.scripting.nashorn.shell.jmod',
jarContent: ['bin/jjs'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.jcmd.jmod',
jarContent: ['bin/jstack', 'bin/jcmd', 'bin/jps', 'bin/jmap', 'bin/jstat', 'bin/jinfo'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.jshell.jmod',
jarContent: ['bin/jshell'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.compiler.jmod',
jarContent: ['bin/javac', 'bin/serialver'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'java.scripting.jmod',
jarContent: ['bin/jrunscript'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.jdi.jmod',
jarContent: ['bin/jdb'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.javadoc.jmod',
jarContent: ['bin/javadoc'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.jconsole.jmod',
jarContent: ['bin/jconsole'],
},
{
jarDir:
`enso/runtime/${GRAALVM}/Contents/Home/jmods`,
'enso/runtime/graalvm-ce-java11-21.0.0.2/Contents/Home/jmods',
jarName: 'jdk.javadoc.jmod',
jarContent: ['bin/javadoc'],
},
]

// Extra files that need to be signed.
const extra = [
`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`,
'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',
]

exports.default = async function () {
Expand Down
7 changes: 3 additions & 4 deletions ide/src/js/lib/project-manager/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ 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)
// 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'
// 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'
let base_url: string = 'https://github.com/enso-org/'
base_url += 'enso/releases/download/'
base_url += `enso-${version}/enso-project-manager-${version}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
use crate::prelude::*;

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

use uuid::Uuid;
use utils::fail::FallibleResult;
Expand Down Expand Up @@ -41,41 +39,30 @@ pub struct Connection {
/// LS client that has already initialized protocol.
#[derivative(Debug="ignore")]
pub client:Box<dyn API>,
/// 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>,
/// Content roots obtained during initialization. Guaranteed to be non-empty.
content_roots:Vec<Uuid>,
}

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 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())
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})
}
}

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

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

/// Returns the first content root.
pub fn project_root(&self) -> &ContentRoot { &self.project_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]
}

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

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<ContentRoot>,
pub content_roots:Vec<Uuid>,
}

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

Please sign in to comment.