Skip to content

Commit

Permalink
Initial distribution build toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
viatsko committed Aug 11, 2011
1 parent 54b2135 commit d091b59
Show file tree
Hide file tree
Showing 8 changed files with 495 additions and 5 deletions.
135 changes: 135 additions & 0 deletions build-distribution.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<project name="Idea Parser language scripted build file" default="assemble"
basedir=".">

<!-- set global properties for this build -->
<property name="work" location="build"/>
<property name="dist" location="dist"/>

<property name="parser.plugin" value="${dist}/idea-parser3.jar"/>

<property name="idea.community.build"
location="${user.home}/Projects/ideaIC-107.105/"/>

<property name="target.platform" value="current"/>

<property name="parser.ide.target.package"
value="${dist}/parser-ide-${target.platform}.zip"/>

<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<!--<mkdir dir="${target.root}" />-->

<echo message="Assembling ParserIde into archive: ${parser.ide.target.package}"/>
<condition property="is.darwin">
<equals arg1="${target.platform}" arg2="darwin"/>
</condition>
</target>

<target name="resources" depends="init"
description="Builds the ParserIde resources jar">
<echo message="Using Idea Community build from: ${idea.community.build}"/>

<jar destfile="${dist}/parseride-resources.jar">
<fileset dir="${basedir}/parseride/resources" includes="**/*.*"/>
<zipfileset src="${idea.community.build}/lib/resources.jar"
includes="idea/IdeaActions.xml"
fullpath="idea/ParserIdeActions.xml"/>
<zipfileset src="${idea.community.build}/lib/resources.jar"
includes="META-INF/IdeaPlugin.xml"
fullpath="META-INF/ParserIdePlugin.xml"/>
</jar>
</target>

<target name="fix.Info.plist" depends="init" if="is.darwin">
<replaceregexp
file="${idea.community.build}/Contents/Info.plist"
byline="false"
match="(&lt;key&gt;idea.platform.prefix&lt;/key&gt;[\r\n \t]+&lt;string&gt;)Idea(&lt;/string&gt;)"
replace="\1ParserIde\2"
/>

<replaceregexp
file="${idea.community.build}/Contents/Info.plist"
byline="false"
match="(&lt;key&gt;idea.paths.selector&lt;/key&gt;[\r\n \t]+&lt;string&gt;)[^&lt;]+(&lt;/string&gt;)"
replace="\1.ParserIde1\2"
/>

<replaceregexp
file="${idea.community.build}/Contents/Info.plist"
byline="false"
match="(&lt;key&gt;CFBundleName&lt;/key&gt;[\r\n \t]+&lt;string&gt;)[^&lt;]+(&lt;/string&gt;)"
replace="\1Parser Ide\2"
/>

<replaceregexp
file="${idea.community.build}/Contents/Info.plist"
byline="false"
match="(&lt;key&gt;CFBundleIdentifier&lt;/key&gt;[\r\n \t]+&lt;string&gt;)[^&lt;]+(&lt;/string&gt;)"
replace="\1idea-parser3\2"
/>

<replaceregexp
file="${idea.community.build}/Contents/Info.plist"
byline="false"
match="(&lt;key&gt;CFBundleGetInfoString&lt;/key&gt;[\r\n \t]+&lt;string&gt;)[^&lt;]+(&lt;/string&gt;)"
replace="\1ParserIde 1.0.0, build (git)\2"
/>

<replaceregexp
file="${idea.community.build}/Contents/Info.plist"
byline="false"
match="(&lt;key&gt;CFBundleShortVersionString&lt;/key&gt;[\r\n \t]+&lt;string&gt;)[^&lt;]+(&lt;/string&gt;)"
replace="\11.0.0\2"
/>

<replaceregexp
file="${idea.community.build}/Contents/Info.plist"
byline="false"
match="(&lt;key&gt;CFBundleVersion&lt;/key&gt;[\r\n \t]+&lt;string&gt;)[^&lt;]+(&lt;/string&gt;)"
replace="\11.0.0 (git)\2"
/>
</target>

<target name="assemble" depends="clean,init,resources,fix.Info.plist"
description="compile the source">

<concat destfile="${work}/idea.properties" force="true">
<fileset dir="${idea.community.build}/bin" includes="idea.properties"/>
<footer trimleading="yes">idea.platform.prefix=ParserIde</footer>
</concat>

<replaceregexp
file="${work}/idea.properties"
byline="true"
match="^(?:# )?idea.(config|system|plugins|log).path=([^/]+)/\.[^/]+/(config|system)"
replace="idea.\1.path=\2/.ParserIde1/\3"/>

<fixcrlf srcdir="${idea.community.build}/bin" includes="*.bat" eol="dos"/>

<zip file="${parser.ide.target.package}" preserve0permissions="true">

<zipfileset dir="${idea.community.build}" prefix="go-ide"
includes="**/*"
excludes="bin/*.sh,bin/fsnotifier*,bin/idea.properties,bin/*.exe"/>

<zipfileset file="${work}/idea.properties" prefix="go-ide/bin"/>

<zipfileset dir="${idea.community.build}" prefix="go-ide"
includes="bin/*.sh,bin/fsnotifier*,bin/*.exe" filemode="755"/>

<zipfileset file="${parser.plugin}"
prefix="parseride/plugins/idea-parser3/lib/"/>

<zipfileset file="${dist}/parseride-resources.jar" prefix="parseride/lib/"/>
</zip>

</target>

<target name="clean" description="clean up">
<delete file="${parser.ide.target.package}.zip"/>
</target>

</project>
10 changes: 5 additions & 5 deletions build-package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@

<target name="compile" depends="clean,init" description="compile the source ">
<javac2 destdir="${build}" includeantruntime="false">
<src path="${main-src}"></src>
<src path="${jreformator-src}"></src>
<src path="${idea-support-src}"></src>
<src path="${idea-errorreporting-client-src}"></src>
<src path="${als-java-toolkit-src}"></src>
<src path="${main-src}"/>
<src path="${jreformator-src}"/>
<src path="${idea-support-src}"/>
<src path="${idea-errorreporting-client-src}"/>
<src path="${als-java-toolkit-src}"/>

<classpath>
<fileset dir="${idea.community.build}" includes="**/*.jar"/>
Expand Down
107 changes: 107 additions & 0 deletions parseride/dmgLayout.applescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
on run -- for testing in script editor
process_disk_image("Parser Ide")
end run

on process_disk_image(volumeName)
tell application "Finder"
tell disk (volumeName as string)
open

set theXOrigin to 20
set theYOrigin to 80
set theWidth to 400
set theHeight to 300

set theBottomRightX to (theXOrigin + theWidth)
set theBottomRightY to (theYOrigin + theHeight)
set dsStore to "\"" & "/Volumes/Parser Ide/" & ".DS_STORE\""
-- do shell script "rm " & dsStore

tell container window
set current view to icon view
set toolbar visible to false
set statusbar visible to false
set the bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
set statusbar visible to false
end tell

set opts to the icon view options of container window
tell opts
set icon size to 128
set arrangement to not arranged
end tell

set background picture of opts to file ".background:about.png"

-- Positioning
set position of item "Parser Ide.app" to {100, 190}
set position of item "/Applications" to {300, 180}
close
open

-- Custom icons
-- my copyIconOfTo(artPath & "/ApplicationsIcon", "/Volumes/" & volumeName & "/Applications")

-- Label colors
-- set label index of item "Adium.app" to 6
-- set label index of item "License.txt" to 7
-- set label index of item "Changes.txt" to 7
-- set label index of item "Applications" to 4

update without registering applications
-- Force saving of the size
delay 2

tell container window
set statusbar visible to false
set the bounds to {theXOrigin, theYOrigin, theBottomRightX - 10, theBottomRightY - 10}
end tell

update without registering applications
end tell

delay 1

tell disk (volumeName as string)
tell container window
set statusbar visible to false
set the bounds to {theXOrigin, theYOrigin, theBottomRightX, theBottomRightY}
end tell

update without registering applications
end tell

--give the finder some time to write the .DS_Store file
delay 3

set waitTime to 0
set ejectMe to false
repeat while ejectMe is false
delay 1
set waitTime to waitTime + 1

if (do shell script "[ -f " & dsStore & " ]; echo $?") = "0" then set ejectMe to true
end repeat
log "waited " & waitTime & " seconds for .DS_STORE to be created."
end tell
end process_disk_image

on copyIconOfTo(aFileOrFolderWithIcon, aFileOrFolder)
tell application "Finder" to set f to POSIX file aFileOrFolderWithIcon as alias
-- grab the file's icon
my CopyOrPaste(f, "c")
-- now the icon is in the clipboard
tell application "Finder" to set c to POSIX file aFileOrFolder as alias
my CopyOrPaste(result, "v")
end copyIconOfTo

on CopyOrPaste(i, cv)
tell application "Finder"
activate
open information window of i
end tell
tell application "System Events" to tell process "Finder" to tell window 1
keystroke tab -- select icon button
keystroke (cv & "w") using command down (* (copy or paste) + close window *)
end tell -- window 1 then process Finder then System Events
end CopyOrPaste
57 changes: 57 additions & 0 deletions parseride/make_dmg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
#
# Author: Alexandre Normand (https://github.com/alexandre-normand)
# Date: July 30th, 2011
#
# Making the dmg file

DMG_TEMP_NAME=${DMG_TEMP_NAME:-parserIdeTemp.dmg}
SRC_FOLDER=${SRC_FOLDER:-`pwd`/../dist/darwin_amd64}
BACKGROUND_FILE=${BACKGROUND_FILE:-./resources/parseride/about.png}
IMAGE_FILE=${IMAGE_FILE:-$FOLDER_DIST/parseride-mac.dmg}

echo "Cleaning out old $IMAGE_FILE"
test -f "$IMAGE_FILE" && rm -f "$IMAGE_FILE"
echo "Adding symlink Applications to $SRC_FOLDER..."
ln -fs /Applications $SRC_FOLDER

echo "Creating disk image..."
test -f "${DMG_TEMP_NAME}" && rm -f "${DMG_TEMP_NAME}"
hdiutil create -srcfolder "$SRC_FOLDER" -volname "Parser Ide" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size 600m "${DMG_TEMP_NAME}"

echo "Mounting image..."
MOUNT_DIR="/Volumes/Parser Ide"
echo "Mount directory: $MOUNT_DIR"
DEV_NAME=$(hdiutil attach -readwrite -noverify -noautoopen "${DMG_TEMP_NAME}" | egrep '^/dev/' | sed 1q | awk '{print $1}')
echo "Device name: $DEV_NAME"

mkdir "$MOUNT_DIR/.background"
cp "$BACKGROUND_FILE" "$MOUNT_DIR/.background/$BACKGROUND_FILE_NAME"

# run applescript
echo "Applying layout: osascript dmgLayout.applescript process_disk_image \"Parser Ide\""
osascript dmgLayout.applescript process_disk_image "Parser Ide"
echo "Done doing layout..."
sleep 6

# make sure it's not world writeable
echo "Fixing permissions..."
chmod +x "${MOUNT_DIR}/Parser Ide.app/Contents/MacOS/idea"
# workaround: output is sent to /dev/null to supress permission errors when chmodding .Trashes
chmod -Rf go-w "${MOUNT_DIR}" >& /dev/null || true
echo "Done fixing permissions."

# make the top window open itself on mount:
if [ -x /usr/local/bin/openUp ]; then
echo "Applying openUp..."
/usr/local/bin/openUp "${MOUNT_DIR}"
fi

# unmount
echo "Unmounting disk image..."
hdiutil detach "${DEV_NAME}"

# compress image
echo "Compressing disk image..."
hdiutil convert "${DMG_TEMP_NAME}" -format UDZO -imagekey zlib-level=9 -o "$IMAGE_FILE"
rm -f "${DMG_TEMP_NAME}"
Loading

0 comments on commit d091b59

Please sign in to comment.