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-09-22 02:03:59 +04:00
|
|
|
desc "Build Atom via `xcodebuild`"
|
|
|
|
task :build => "create-project" do
|
2012-08-31 03:46:57 +04:00
|
|
|
command = "xcodebuild -target Atom configuration=Release SYMROOT=#{BUILD_DIR}"
|
|
|
|
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"
|
|
|
|
task "create-project" => "bootstrap" do
|
|
|
|
`rm -rf atom.xcodeproj`
|
|
|
|
`gyp --depth=. atom.gyp`
|
|
|
|
end
|
|
|
|
|
|
|
|
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"
|
2012-09-22 03:09:40 +04:00
|
|
|
task :install => :build do
|
|
|
|
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
|
2012-09-24 21:42:53 +04:00
|
|
|
usr_bin_path = default_usr_bin_path = "/opt/github/bin"
|
2012-09-22 03:13:54 +04:00
|
|
|
cli_path = "#{usr_bin_path}/atom"
|
2012-10-16 20:05:38 +04:00
|
|
|
stable_cli_path = "#{usr_bin_path}/atom-stable"
|
2012-09-22 03:09:40 +04:00
|
|
|
|
2012-10-10 01:37:10 +04:00
|
|
|
if !File.exists?(usr_bin_path)
|
2012-09-22 03:13:54 +04:00
|
|
|
$stderr.puts "ERROR: Failed to install atom cli tool at '#{usr_bin_path}'"
|
2012-09-22 03:09:40 +04:00
|
|
|
exit 1
|
|
|
|
end
|
2012-09-22 02:03:59 +04:00
|
|
|
|
2012-09-22 03:13:54 +04:00
|
|
|
`echo '#!/bin/sh\nopen #{dest} -n --args --resource-path="#{ATOM_SRC_PATH}" --executed-from="$(pwd)" $@' > #{cli_path} && chmod 755 #{cli_path}`
|
2012-10-16 20:05:38 +04:00
|
|
|
`echo '#!/bin/sh\nopen #{dest} -n --args --resource-path="#{ATOM_SRC_PATH}" --executed-from="$(pwd)" --stable $@' > #{stable_cli_path} && chmod 755 #{stable_cli_path}`
|
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
|
|
|
|
|
|
|
puts "\033[32mType `atom` to start Atom! In Atom press `cmd-,` to edit your `.atom` directory\033[0m"
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Creates .atom file if non exists"
|
|
|
|
task "create-dot-atom" do
|
2012-09-22 03:09:40 +04:00
|
|
|
dot_atom_template_path = ATOM_SRC_PATH + "/.atom"
|
|
|
|
replace_dot_atom = false
|
2012-10-10 01:38:31 +04:00
|
|
|
next if File.exists?(DOT_ATOM_PATH)
|
2012-09-22 02:03:59 +04:00
|
|
|
|
2012-10-09 21:42:38 +04:00
|
|
|
`rm -rf "#{DOT_ATOM_PATH}"`
|
|
|
|
`mkdir "#{DOT_ATOM_PATH}"`
|
|
|
|
`cp "#{dot_atom_template_path}/atom.coffee" "#{DOT_ATOM_PATH}"`
|
2012-10-11 02:28:22 +04:00
|
|
|
`cp "#{dot_atom_template_path}/bundles" "#{DOT_ATOM_PATH}"`
|
2012-09-22 02:03:59 +04:00
|
|
|
|
2012-10-09 20:49:58 +04:00
|
|
|
for path in Dir.entries(dot_atom_template_path)
|
2012-10-10 05:16:33 +04:00
|
|
|
next if ["..", ".", "atom.coffee", "bundles"].include? path
|
2012-10-09 21:42:38 +04:00
|
|
|
`ln -s "#{dot_atom_template_path}/#{path}" "#{DOT_ATOM_PATH}"`
|
2012-09-22 02:03:59 +04:00
|
|
|
end
|
2012-10-09 21:42:38 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Clone default bundles into .atom directory"
|
|
|
|
task "clone-default-bundles" => "create-dot-atom" do
|
2012-10-10 04:18:54 +04:00
|
|
|
bundles = {
|
2012-10-18 01:28:19 +04:00
|
|
|
"https://github.com/textmate/css.tmbundle.git" => "aa549903ff01e9ba7dc0bd83f2cfe7ab54feab2d",
|
|
|
|
"https://github.com/textmate/html.tmbundle.git" => "af4fef34e1df538eda9a166912047b610530ece0",
|
2012-10-17 03:09:37 +04:00
|
|
|
"https://github.com/textmate/javascript.tmbundle.git" => "58e81b0eae498c9a4eb6e395368df3b7a01d9851",
|
2012-10-18 01:28:19 +04:00
|
|
|
"https://github.com/textmate/ruby-on-rails.tmbundle.git" => "7c410a098f0e343d52f70b4f9c08b8669d0a594c",
|
2012-10-11 04:29:31 +04:00
|
|
|
"https://github.com/textmate/ruby.tmbundle.git" => "daad8ef03de9630e74578a046240fd9acc63b8b5",
|
2012-10-18 01:28:19 +04:00
|
|
|
"https://github.com/textmate/text.tmbundle.git" => "061224bd78fd98d02035466cdd959bf29995c2c5",
|
|
|
|
"https://github.com/jashkenas/coffee-script-tmbundle.git" => "20d9b95240bbbc27565c74c7227b8c6eb9049f78",
|
|
|
|
"https://github.com/cburyta/puppet-textmate.tmbundle.git" => "5ef4949b2c964bace86782573cb952751ca77f5e",
|
2012-10-11 04:29:31 +04:00
|
|
|
"https://github.com/textmate/c.tmbundle.git" => "c8a6516c1131055bfcd1bca5e2ee6567c2f50058",
|
2012-10-27 20:07:59 +04:00
|
|
|
"https://github.com/textmate/objective-c.tmbundle.git" => "b0826e645a3d8ca37dd625a56935d49cc8eeb9fc",
|
2012-10-10 04:18:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for bundle_url, sha in bundles
|
2012-10-09 21:42:38 +04:00
|
|
|
bundle_dir = bundle_url[/([^\/]+?)(\.git)?$/, 1]
|
|
|
|
dest_path = File.join(DOT_ATOM_PATH, "bundles", bundle_dir)
|
2012-10-17 04:23:29 +04:00
|
|
|
if File.exists? dest_path
|
|
|
|
`cd #{dest_path} && git fetch --quiet`
|
|
|
|
else
|
|
|
|
`git clone --quiet #{bundle_url} #{dest_path}`
|
|
|
|
end
|
|
|
|
|
|
|
|
`cd #{dest_path} && git reset --quiet --hard #{sha}`
|
2012-10-09 21:42:38 +04:00
|
|
|
end
|
|
|
|
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-08-27 01:29:46 +04:00
|
|
|
end
|
|
|
|
|
2012-09-19 03:49:49 +04:00
|
|
|
desc "Run Atom"
|
2012-09-22 00:27:19 +04:00
|
|
|
task :run, [:atom_arg] => :build do |name, args|
|
2012-09-19 03:49:49 +04:00
|
|
|
if path = application_path()
|
2012-09-22 00:27:19 +04:00
|
|
|
cmd = "#{path}/Contents/MacOS/Atom #{args[:atom_arg]} 2> /dev/null"
|
2012-10-10 02:09:22 +04:00
|
|
|
system(cmd)
|
|
|
|
exit($?.exitstatus)
|
2012-09-19 03:49:49 +04:00
|
|
|
else
|
|
|
|
exit(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
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`
|
2012-09-22 00:27:19 +04:00
|
|
|
Rake::Task["run"].invoke("--test")
|
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
|
2012-10-19 22:59:10 +04:00
|
|
|
system %{find . -name *spec.coffee | grep -v atom-build | 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
|
2012-12-17 22:33:16 +04:00
|
|
|
system %{find src native -not -name "*spec.coffee" -type f | xargs 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
|