2012-09-22 03:09:40 +04:00
|
|
|
ATOM_SRC_PATH = File.dirname(__FILE__)
|
2012-10-09 21:42:38 +04:00
|
|
|
DOT_ATOM_PATH = ENV['HOME'] + "/.atom"
|
2012-08-27 01:29:46 +04:00
|
|
|
BUILD_DIR = 'atom-build'
|
|
|
|
|
2012-12-20 05:10:12 +04:00
|
|
|
require 'erb'
|
|
|
|
|
2012-09-22 02:03:59 +04:00
|
|
|
desc "Build Atom via `xcodebuild`"
|
2013-02-13 23:57:42 +04:00
|
|
|
task :build => "create-xcode-project" do
|
2013-01-29 01:02:27 +04:00
|
|
|
command = "xcodebuild -target Atom -configuration Release SYMROOT=#{BUILD_DIR}"
|
2012-08-31 03:46:57 +04:00
|
|
|
output = `#{command}`
|
2012-08-27 01:29:46 +04:00
|
|
|
if $?.exitstatus != 0
|
|
|
|
$stderr.puts "Error #{$?.exitstatus}:\n#{output}"
|
|
|
|
exit($?.exitstatus)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-16 19:56:33 +04:00
|
|
|
desc "Create xcode project from gyp file"
|
2013-02-17 20:56:27 +04:00
|
|
|
task "create-xcode-project" => "update-cef" do
|
2012-10-16 19:56:33 +04:00
|
|
|
`rm -rf atom.xcodeproj`
|
|
|
|
`gyp --depth=. atom.gyp`
|
|
|
|
end
|
|
|
|
|
2013-02-17 20:56:27 +04:00
|
|
|
desc "Update CEF to the latest version specified by the prebuilt-cef submodule"
|
|
|
|
task "update-cef" => "bootstrap" do
|
|
|
|
output = `prebuilt-cef/script/download -f cef 2>&1`
|
|
|
|
if $?.exitstatus != 0
|
|
|
|
$stderr.puts "Error #{$?.exitstatus}:\n#{output}"
|
|
|
|
exit($?.exitstatus)
|
|
|
|
end
|
|
|
|
Dir.glob('cef/*.gypi').each do |filename|
|
|
|
|
`sed -i '' -e "s/'include\\//'cef\\/include\\//" -e "s/'libcef_dll\\//'cef\\/libcef_dll\\//" #{filename}`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-16 19:56:33 +04:00
|
|
|
task "bootstrap" do
|
|
|
|
`script/bootstrap`
|
|
|
|
end
|
|
|
|
|
2012-09-22 02:03:59 +04:00
|
|
|
desc "Creates symlink from `application_path() to /Applications/Atom and creates `atom` cli app"
|
2013-02-07 23:09:23 +04:00
|
|
|
task :install => [:clean, :build] do
|
2012-09-22 03:09:40 +04:00
|
|
|
path = application_path()
|
|
|
|
exit 1 if not path
|
|
|
|
|
|
|
|
# Install Atom.app
|
|
|
|
dest = "/Applications/#{File.basename(path)}"
|
|
|
|
`rm -rf #{dest}`
|
|
|
|
`cp -r #{path} #{File.expand_path(dest)}`
|
|
|
|
|
|
|
|
# Install cli atom
|
2013-02-14 00:24:15 +04:00
|
|
|
usr_bin_path = "/opt/github/bin"
|
2012-09-22 03:13:54 +04:00
|
|
|
cli_path = "#{usr_bin_path}/atom"
|
2012-09-22 02:03:59 +04:00
|
|
|
|
2012-12-20 05:10:12 +04:00
|
|
|
template = ERB.new CLI_SCRIPT
|
|
|
|
namespace = OpenStruct.new(:application_path => dest, :resource_path => ATOM_SRC_PATH)
|
|
|
|
File.open(cli_path, "w") do |f|
|
|
|
|
f.write template.result(namespace.instance_eval { binding })
|
|
|
|
f.chmod(0755)
|
|
|
|
end
|
2012-09-22 03:13:54 +04:00
|
|
|
|
2012-10-09 20:49:58 +04:00
|
|
|
Rake::Task["create-dot-atom"].invoke()
|
2012-10-09 21:42:38 +04:00
|
|
|
Rake::Task["clone-default-bundles"].invoke()
|
2012-10-09 20:49:58 +04:00
|
|
|
|
2013-02-14 00:24:15 +04:00
|
|
|
puts "\033[32mType `atom` to start Atom! In Atom press `cmd-,` to edit your `~/.atom` directory\033[0m"
|
2012-10-09 20:49:58 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Creates .atom file if non exists"
|
|
|
|
task "create-dot-atom" do
|
2013-02-14 00:24:15 +04:00
|
|
|
dot_atom_template_path = ATOM_SRC_PATH + "/dot-atom"
|
2013-01-31 22:18:25 +04:00
|
|
|
|
|
|
|
if File.exists?(DOT_ATOM_PATH)
|
|
|
|
user_config = "#{DOT_ATOM_PATH}/user.coffee"
|
|
|
|
old_user_config = "#{DOT_ATOM_PATH}/atom.coffee"
|
|
|
|
|
|
|
|
if File.exists?(old_user_config)
|
|
|
|
`mv #{old_user_config} #{user_config}`
|
|
|
|
puts "\033[32mRenamed #{old_user_config} to #{user_config}\033[0m"
|
|
|
|
end
|
2013-02-14 00:24:15 +04:00
|
|
|
else
|
|
|
|
`mkdir "#{DOT_ATOM_PATH}"`
|
|
|
|
`cp -r "#{dot_atom_template_path}/" "#{DOT_ATOM_PATH}"/`
|
|
|
|
`cp -r "#{ATOM_SRC_PATH}/themes/" "#{DOT_ATOM_PATH}"/themes/`
|
2013-01-31 22:18:25 +04:00
|
|
|
end
|
2012-10-09 21:42:38 +04:00
|
|
|
end
|
|
|
|
|
2013-01-03 21:57:13 +04:00
|
|
|
desc "Clone default bundles into vendor/bundles directory"
|
|
|
|
task "clone-default-bundles" do
|
2013-01-03 23:02:03 +04:00
|
|
|
`git submodule --quiet sync`
|
|
|
|
`git submodule --quiet update --recursive --init`
|
2012-10-09 21:42:38 +04:00
|
|
|
end
|
2012-09-22 03:09:40 +04:00
|
|
|
|
2012-08-27 01:29:46 +04:00
|
|
|
desc "Clean build Atom via `xcodebuild`"
|
|
|
|
task :clean do
|
2012-09-11 04:03:39 +04:00
|
|
|
output = `xcodebuild clean`
|
2012-12-27 02:38:25 +04:00
|
|
|
`rm -rf #{application_path()}`
|
|
|
|
`rm -rf #{BUILD_DIR}`
|
2013-02-07 03:10:25 +04:00
|
|
|
`rm -rf /tmp/atom-compiled-scripts`
|
2012-08-27 01:29:46 +04:00
|
|
|
end
|
|
|
|
|
2012-09-19 03:49:49 +04:00
|
|
|
desc "Run the specs"
|
2012-10-10 02:18:58 +04:00
|
|
|
task :test => ["clean", "clone-default-bundles"] do
|
2012-11-12 20:44:16 +04:00
|
|
|
`pkill Atom`
|
2013-01-29 04:49:41 +04:00
|
|
|
Rake::Task["run"].invoke("--test --resource-path=#{ATOM_SRC_PATH}")
|
2012-09-19 03:49:49 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Run the benchmarks"
|
|
|
|
task :benchmark do
|
2012-09-22 00:27:19 +04:00
|
|
|
Rake::Task["run"].invoke("--benchmark")
|
2012-09-19 03:49:49 +04:00
|
|
|
end
|
|
|
|
|
2012-09-11 04:03:39 +04:00
|
|
|
task :nof do
|
2013-02-14 23:37:47 +04:00
|
|
|
system %{find . -name *spec.coffee | grep --invert-match --regexp "#{BUILD_DIR}\\|##package-name##" | xargs sed -E -i "" "s/f+(it|describe) +(['\\"])/\\1 \\2/g"}
|
2012-09-11 04:03:39 +04:00
|
|
|
end
|
|
|
|
|
2012-12-14 21:14:22 +04:00
|
|
|
task :tags do
|
2013-01-16 21:25:07 +04:00
|
|
|
system %{find src native cef vendor -not -name "*spec.coffee" -type f -print0 | xargs -0 ctags}
|
2012-12-14 21:14:22 +04:00
|
|
|
end
|
|
|
|
|
2012-08-27 01:29:46 +04:00
|
|
|
def application_path
|
2012-09-19 03:49:49 +04:00
|
|
|
applications = FileList["#{BUILD_DIR}/**/Atom.app"]
|
|
|
|
if applications.size == 0
|
|
|
|
$stderr.puts "No Atom application found in directory `#{BUILD_DIR}`"
|
|
|
|
elsif applications.size > 1
|
|
|
|
$stderr.puts "Multiple Atom applications found \n\t" + applications.join("\n\t")
|
|
|
|
else
|
|
|
|
return applications.first
|
2012-08-27 01:29:46 +04:00
|
|
|
end
|
|
|
|
|
2012-09-19 03:49:49 +04:00
|
|
|
return nil
|
2012-08-27 01:29:46 +04:00
|
|
|
end
|
2012-12-20 05:10:12 +04:00
|
|
|
|
|
|
|
CLI_SCRIPT = <<-EOF
|
|
|
|
#!/bin/sh
|
|
|
|
open <%= application_path %> -n --args --resource-path="<%= resource_path %>" --executed-from="$(pwd)" --pid=$$ $@
|
|
|
|
|
|
|
|
# Used to exit process when atom is used as $EDITOR
|
|
|
|
on_die() {
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
trap 'on_die' SIGQUIT SIGTERM
|
|
|
|
|
|
|
|
# Don't exit process if we were told to wait.
|
|
|
|
while [ "$#" -gt "0" ]; do
|
|
|
|
case $1 in
|
|
|
|
-W|--wait)
|
|
|
|
WAIT=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $WAIT ]; then
|
|
|
|
while true; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
fi
|
2012-12-27 09:06:29 +04:00
|
|
|
EOF
|