2012-09-22 03:09:40 +04:00
|
|
|
ATOM_SRC_PATH = File.dirname(__FILE__)
|
2013-03-02 01:45:24 +04:00
|
|
|
BUILD_DIR = '/tmp/atom-build'
|
2012-08-27 01:29:46 +04:00
|
|
|
|
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-03-05 03:38:06 +04:00
|
|
|
command = "xcodebuild -target Atom 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-03-13 16:15:41 +04:00
|
|
|
task "create-xcode-project" => ["update-cef", "update-node"] do
|
2012-10-16 19:56:33 +04:00
|
|
|
`rm -rf atom.xcodeproj`
|
Use gyp's rules functionality to compile .coffee/.cson files
Instead of finding and compiling all .coffee/.cson files in
script/copy-files-to-bundle, we now tell gyp how to do this for us. It
works like this:
1. Rakefile invokes the new script/generate-sources-gypi script to
generate sources.gypi. This file lists all the .coffee/.cson files in
the src, static, and vendor directories, as well as a new
compiled_sources_dir variable that specifies where the compiled
versions of the files should be placed.
2. atom.gyp includes sources.gypi.
3. atom.gyp has a new target, generated_sources, which contains all the
.coffee/.cson files, and uses two rules to tell gyp how to compile
them. The rules invoke the new script/compile-coffee and
script/compile-cson files once for each file.
4. gyp generates one Makefile for each rule to actually perform the
compilation.
5. script/copy-files-to-bundle now takes the compiled_sources_dir
variable as an argument, and copies files both from there and from
the repository into the Resources directory.
By putting the compilation into a different target, we can do it in
parallel with compiling/linking our binaries. And gyp automatically runs
make using -j$(sysctl -n hw.ncpu), so compilation of .coffee/.cson files
happens in parallel, too.
These changes reduce clean build time on my MacBook Pro from 55 seconds
to 46 seconds.
2013-03-04 20:32:06 +04:00
|
|
|
`script/generate-sources-gypi`
|
2013-04-10 21:55:58 +04:00
|
|
|
version = %{-D version="#{ENV['VERSION']}"} if ENV['VERSION']
|
2013-04-10 21:57:46 +04:00
|
|
|
code_sign = %{-D code_sign="#{ENV['CODE_SIGN']}"} if ENV['CODE_SIGN']
|
|
|
|
`gyp --depth=. #{code_sign} #{version} atom.gyp`
|
2012-10-16 19:56:33 +04:00
|
|
|
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
|
2013-03-23 15:55:48 +04:00
|
|
|
exit 1 unless system %{script/update-cefode}
|
2013-02-17 20:56:27 +04:00
|
|
|
Dir.glob('cef/*.gypi').each do |filename|
|
|
|
|
`sed -i '' -e "s/'include\\//'cef\\/include\\//" -e "s/'libcef_dll\\//'cef\\/libcef_dll\\//" #{filename}`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-13 16:15:41 +04:00
|
|
|
desc "Download node binary"
|
|
|
|
task "update-node" do
|
2013-04-04 17:18:21 +04:00
|
|
|
`script/update-node v0.10.3`
|
2013-03-13 16:15:41 +04:00
|
|
|
end
|
|
|
|
|
2013-03-01 22:19:03 +04:00
|
|
|
desc "Download debug symbols for CEF"
|
|
|
|
task "download-cef-symbols" => "update-cef" do
|
2013-03-23 15:55:48 +04:00
|
|
|
sh %{script/update-cefode -s}
|
2013-03-01 22:19:03 +04:00
|
|
|
end
|
|
|
|
|
2012-10-16 19:56:33 +04:00
|
|
|
task "bootstrap" do
|
|
|
|
`script/bootstrap`
|
|
|
|
end
|
|
|
|
|
2013-02-25 21:20:26 +04:00
|
|
|
desc "Copies Atom.app to /Applications and creates `atom` cli app"
|
2013-03-28 18:09:23 +04:00
|
|
|
task :install => [:build] do
|
2012-09-22 03:09:40 +04:00
|
|
|
path = application_path()
|
|
|
|
exit 1 if not path
|
|
|
|
|
|
|
|
# Install Atom.app
|
2013-02-25 21:20:26 +04:00
|
|
|
dest_path = "/Applications/#{File.basename(path)}"
|
|
|
|
`rm -rf #{dest_path}`
|
2013-03-02 01:12:02 +04:00
|
|
|
`cp -a #{path} #{File.expand_path(dest_path)}`
|
2012-09-22 03:09:40 +04:00
|
|
|
|
2013-02-24 20:16:15 +04:00
|
|
|
# Install atom cli
|
2013-02-26 00:40:59 +04:00
|
|
|
if File.directory?("/opt/boxen")
|
|
|
|
cli_path = "/opt/boxen/bin/atom"
|
2013-03-05 00:45:24 +04:00
|
|
|
elsif File.directory?("/opt/github")
|
2013-02-26 00:40:59 +04:00
|
|
|
cli_path = "/opt/github/bin/atom"
|
2013-03-05 00:45:24 +04:00
|
|
|
elsif File.directory?("/usr/local")
|
|
|
|
cli_path = "/usr/local/bin/atom"
|
|
|
|
else
|
|
|
|
raise "Missing directory for `atom` binary"
|
2013-02-26 00:40:59 +04:00
|
|
|
end
|
|
|
|
|
2013-02-25 21:20:26 +04:00
|
|
|
FileUtils.cp("#{ATOM_SRC_PATH}/atom.sh", cli_path)
|
|
|
|
FileUtils.chmod(0755, cli_path)
|
2013-02-24 20:16:15 +04:00
|
|
|
|
2012-10-09 21:42:38 +04:00
|
|
|
Rake::Task["clone-default-bundles"].invoke()
|
2012-10-09 20:49:58 +04:00
|
|
|
|
2013-02-25 21:20:26 +04:00
|
|
|
puts "\033[32mAtom is installed at `#{dest_path}`. Atom cli is installed at `#{cli_path}`\033[0m"
|
2012-10-09 20:49:58 +04:00
|
|
|
end
|
|
|
|
|
2013-02-27 04:43:15 +04:00
|
|
|
task "setup-codesigning" do
|
|
|
|
ENV['CODE_SIGN'] = "Developer ID Application: GitHub"
|
|
|
|
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-03-28 18:06:41 +04:00
|
|
|
`rm -rf /tmp/atom-coffee-cache`
|
2013-03-19 23:33:16 +04:00
|
|
|
`rm -rf node_modules`
|
2013-03-27 19:05:00 +04:00
|
|
|
`rm -rf cef`
|
2012-08-27 01:29:46 +04:00
|
|
|
end
|
|
|
|
|
2012-09-19 03:49:49 +04:00
|
|
|
desc "Run the specs"
|
2013-04-03 23:11:43 +04:00
|
|
|
task :test => ["update-cef", "clone-default-bundles", "build"] do
|
2012-11-12 20:44:16 +04:00
|
|
|
`pkill Atom`
|
2013-02-15 01:36:28 +04:00
|
|
|
if path = application_path()
|
2013-03-19 23:33:16 +04:00
|
|
|
cmd = "#{path}/Contents/MacOS/Atom --test --resource-path=#{ATOM_SRC_PATH}"
|
2013-02-15 01:36:28 +04:00
|
|
|
system(cmd)
|
|
|
|
exit($?.exitstatus)
|
|
|
|
else
|
|
|
|
exit(1)
|
|
|
|
end
|
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-03-05 08:05:42 +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
|
|
|
|
|
2013-04-09 23:49:41 +04:00
|
|
|
namespace :docs do
|
2013-04-11 03:01:54 +04:00
|
|
|
namespace :app do
|
2013-04-10 03:02:24 +04:00
|
|
|
desc "Builds the API docs in src/app"
|
2013-04-11 03:01:54 +04:00
|
|
|
task :build do
|
2013-04-19 08:05:20 +04:00
|
|
|
system %{./node_modules/coffee-script/bin/coffee ./node_modules/biscotto/bin/biscotto -- -o docs/api src/app/}
|
2013-04-10 03:02:24 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Lists the stats for API doc coverage in src/app"
|
|
|
|
task :stats do
|
2013-04-19 08:05:20 +04:00
|
|
|
system %{./node_modules/coffee-script/bin/coffee ./node_modules/biscotto/bin/biscotto -- --statsOnly src/app/}
|
2013-04-10 03:02:24 +04:00
|
|
|
end
|
2013-04-19 05:51:23 +04:00
|
|
|
|
|
|
|
desc "Show which docs are missing"
|
|
|
|
task :missing do
|
2013-04-19 08:05:20 +04:00
|
|
|
system %{./node_modules/coffee-script/bin/coffee ./node_modules/biscotto/bin/biscotto -- --listMissing src/app/}
|
2013-04-19 05:51:23 +04:00
|
|
|
end
|
2013-04-11 03:01:54 +04:00
|
|
|
end
|
2013-04-06 00:54:56 +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
|