-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bundled sdk detector. Add initial form for adding go sdk to a pro…
…ject. added initial linux packaging. Added scripted packaging
- Loading branch information
Showing
13 changed files
with
465 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#!/bin/bash | ||
|
||
SOURCE_PATH_GO=~/Tools/google-go/release/ | ||
SOURCE_PATH_IDEA=~/Work/IntellijIdea/idea/ | ||
SOURCE_PATH_GO_PLUGIN=~/Work/google-go-language/ | ||
|
||
RELEASE_TAG_GO="release.r58.1" | ||
RELEASE_TAG_IDEA=idea/107.322 | ||
|
||
function validate_go_sdk_location { | ||
|
||
if [ ! -d "${SOURCE_PATH_GO}" ]; then | ||
echo "Error: '${SOURCE_PATH_GO}' is not a folder" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "${SOURCE_PATH_GO}/.hg" ]; then | ||
echo "Error: '${SOURCE_PATH_GO}' is not a go checkout folder (is missing Mercurial metadata)" | ||
exit 1 | ||
fi | ||
|
||
pushd "${SOURCE_PATH_GO}" >/dev/null | ||
ACTUAL_RELEASE_TAG_GO=`hg identify -t` | ||
if [ "xrelease ${RELEASE_TAG_GO}" != "x${ACTUAL_RELEASE_TAG_GO}" ]; then | ||
echo "Error: Go Source code is at the wrong tag: ${ACTUAL_RELEASE_TAG_GO}." | ||
echo -e " Try this:" | ||
echo -e "\tpushd '${SOURCE_PATH_GO}' && hg pull && hg update -r ${RELEASE_TAG_GO} && popd" | ||
exit 1 | ||
fi | ||
|
||
echo "GOOD: Go SDK sources are at the proper release ('${RELEASE_TAG_GO}' vs '${ACTUAL_RELEASE_TAG_GO}')" | ||
popd >/dev/null | ||
} | ||
|
||
function validate_idea_community_location() { | ||
|
||
if [ ! -d "$SOURCE_PATH_IDEA" ]; then | ||
echo "Error: '$SOURCE_PATH_IDEA' is not a folder" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "$SOURCE_PATH_IDEA/.git" ]; then | ||
echo "Error: '$SOURCE_PATH_IDEA' is not a idea checkout folder (is missing Git metadata)" | ||
exit 1 | ||
fi | ||
|
||
pushd "$SOURCE_PATH_IDEA" >/dev/null | ||
ACTUAL_RELEASE_TAG_IDEA=`git describe` | ||
if [ "x$RELEASE_TAG_IDEA" != "x$ACTUAL_RELEASE_TAG_IDEA" ]; then | ||
echo "Error: Intellij Idea Community source tree is at the wrong tag: $ACTUAL_RELEASE_TAG_IDEA" | ||
echo -e " Try this:" | ||
echo -e "\tpushd '$SOURCE_PATH_IDEA' && git pull && git checkout $RELEASE_TAG_IDEA && popd" | ||
exit 1 | ||
fi | ||
|
||
echo "GOOD: Intellij Idea Community source tree is at the proper release ('$RELEASE_TAG_IDEA' vs '$ACTUAL_RELEASE_TAG_IDEA')" | ||
popd >/dev/null | ||
} | ||
|
||
function build_go_sdk() { | ||
echo "Clean building Go Sdk" | ||
|
||
pushd "$SOURCE_PATH_GO/src" | ||
|
||
# fixup for when you also have a weekly go installed inside on your system. | ||
/home/mtoader/Tools/google-go/release/bin | ||
PATH=${SOURCE_PATH_GO}bin:$PATH | ||
|
||
export PATH | ||
# call the build | ||
echo $PATH | ||
./clean.bash && ./all.bash && popd | ||
|
||
# rm -r $IDEASOURCEPATH/build/conf/mac/go-sdk | ||
# cp -r $GOSOURCEPATH $IDEASOURCEPATH/build/conf/mac/go-sdk | ||
} | ||
|
||
function build_idea_community() { | ||
cp "$SOURCE_PATH_GO_PLUGIN/go-ide/resources/idea_community_{about,logo}.png" "$SOURCE_PATH_IDEA/community-resources/src" | ||
|
||
echo "Cleanly building Idea Community" | ||
pushd ${SOURCE_PATH_IDEA} | ||
|
||
# the default build target in Intellij Community will do a clean,build | ||
ant | ||
} | ||
|
||
validate_go_sdk_location | ||
validate_idea_community_location | ||
|
||
build_go_sdk && build_idea_community | ||
#build_idea_community | ||
|
||
exit 0; | ||
|
||
# Build the go sdk | ||
cd $GOSOURCEPATH/src | ||
./all.bash | ||
rm -r $IDEASOURCEPATH/build/conf/mac/go-sdk | ||
cp -r $GOSOURCEPATH $IDEASOURCEPATH/build/conf/mac/go-sdk | ||
|
||
# Copy Go logo and about images | ||
cp $PLUGINSOURCEPATH/go-ide/resources/idea_community_about.png $IDEASOURCEPATH/community-resources/src/ | ||
cp $PLUGINSOURCEPATH/go-ide/resources/idea_community_logo.png $IDEASOURCEPATH/community-resources/src/ | ||
|
||
cd $IDEASOURCEPATH | ||
ant build | ||
VERSION=$(cat build.txt) | ||
cp $IDEASOURCEPATH/out/artifacts/ideaIC-$VERSION.mac.zip $PLUGINSOURCEPATH/go-ide | ||
cd $PLUGINSOURCEPATH/go-ide | ||
rm -r Community\ Edition-IC-$VERSION.app | ||
unzip ideaIC-$VERSION.mac.zip | ||
|
||
unzip ../google-go-language.zip -d Community\ Edition-IC-$VERSION.app/plugins | ||
rm ideaIC-$VERSION.mac.zip | ||
|
||
echo "Now open up dmgCreator to make the dmg." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<project name="Idea Google Go language scripted build file" default="package" basedir="."> | ||
|
||
<!-- set global properties for this build --> | ||
<property name="src" location="src"/> | ||
<property name="build" location="."/> | ||
<property name="dist" location="dist"/> | ||
<property name="idea.community.build" location="${user.home}/Tools/idea-IU-107.322/" /> | ||
<property name="target.plugin.name" value="ro.redeul.google.go" /> | ||
|
||
<taskdef name="javac2" classname="com.intellij.ant.Javac2"> | ||
<classpath> | ||
<pathelement location="${idea.community.build}/redist/forms_rt.jar"/> | ||
<pathelement location="${idea.community.build}/redist/javac2.jar"/> | ||
<pathelement location="${idea.community.build}/redist/annotations.jar"/> | ||
<fileset dir="${idea.community.build}" includes="**/*.jar" /> | ||
</classpath> | ||
|
||
</taskdef> | ||
|
||
<target name="init"> | ||
<!-- Create the time stamp --> | ||
<tstamp/> | ||
<!-- Create the build directory structure used by compile --> | ||
<mkdir dir="${build}"/> | ||
<!--<mkdir dir="${dist}"/>--> | ||
|
||
</target> | ||
|
||
<target name="compile" depends="clean,init" description="compile the source "> | ||
<!-- Compile the java code from ${src} into ${build} --> | ||
<javac2 srcdir="${src}" destdir="${build}" includeantruntime="false" > | ||
<classpath> | ||
<fileset dir="${idea.community.build}" includes="**/*.jar" /> | ||
</classpath> | ||
<compilerarg value="-Xlint:deprecation" /> | ||
</javac2> | ||
</target> | ||
|
||
<target name="package" depends="compile" description="generate the distribution"> | ||
<!-- Create the distribution directory --> | ||
|
||
<mkdir dir="${dist}"/> | ||
|
||
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --> | ||
<!--<jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>--> | ||
<jar jarfile="${dist}/${target.plugin.name}.jar"> | ||
<fileset dir="${build}" includes="**/*.*" /> | ||
<fileset dir="${src}" excludes="**/*.java" /> | ||
</jar> | ||
|
||
</target> | ||
|
||
<target name="clean" description="clean up"> | ||
<!-- Delete the ${build} and ${dist} directory trees --> | ||
<delete dir="${build}"/> | ||
<delete dir="${dist}"/> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/ro/redeul/google/go/components/GoBundledSdkDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package ro.redeul.google.go.components; | ||
|
||
import com.intellij.openapi.application.ApplicationManager; | ||
import com.intellij.openapi.application.PathManager; | ||
import com.intellij.openapi.components.ApplicationComponent; | ||
import com.intellij.openapi.projectRoots.ProjectJdkTable; | ||
import com.intellij.openapi.projectRoots.Sdk; | ||
import com.intellij.openapi.projectRoots.SdkModificator; | ||
import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl; | ||
import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil; | ||
import org.jetbrains.annotations.NotNull; | ||
import ro.redeul.google.go.config.sdk.GoSdkType; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* Author: Toader Mihai Claudiu <mtoader@gmail.com> | ||
* <p/> | ||
* Date: 7/26/11 | ||
* Time: 1:17 PM | ||
*/ | ||
public class GoBundledSdkDetector implements ApplicationComponent { | ||
|
||
@Override | ||
public void initComponent() { | ||
final ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); | ||
|
||
Sdk[] sdks = jdkTable.getAllJdks(); | ||
|
||
for (Sdk sdk : sdks) { | ||
System.out.println("Sdk: " + sdk.getName()); | ||
} | ||
|
||
String homePath = PathManager.getHomePath() + "/bundled-go/go-sdk"; | ||
|
||
final ProjectJdkImpl newJdk; | ||
try { | ||
final GoSdkType goSdkType = GoSdkType.getInstance(); | ||
String newSdkName = SdkConfigurationUtil.createUniqueSdkName(goSdkType, homePath, Arrays.asList(sdks)); | ||
newJdk = new ProjectJdkImpl(newSdkName, goSdkType); | ||
newJdk.setHomePath(homePath); | ||
System.out.println("new jdk: " + newJdk); | ||
ApplicationManager.getApplication().runWriteAction(new Runnable() { | ||
@Override | ||
public void run() { | ||
final SdkModificator sdkModificator = newJdk.getSdkModificator(); | ||
goSdkType.setupSdkPaths(newJdk); | ||
jdkTable.addJdk(newJdk); | ||
} | ||
}); | ||
|
||
} catch (Exception e) { | ||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. | ||
} | ||
} | ||
|
||
@Override | ||
public void disposeComponent() { | ||
System.out.println("dispose"); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getComponentName() { | ||
return "GoBundledSdkDetector"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.