Merge pull request #1035 from atom/win-bootstrap-native-modules

Windows Support
This commit is contained in:
Matt Colyer 2013-10-29 09:15:59 -07:00
commit a49fd569e3
10 changed files with 110 additions and 76 deletions

View File

@ -8,14 +8,24 @@ _ = require 'underscore-plus'
packageJson = require './package.json'
module.exports = (grunt) ->
appName = 'Atom.app'
[major, minor, patch] = packageJson.version.split('.')
tmpDir = if process.platform is 'win32' then os.tmpdir() else '/tmp'
buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build')
shellAppDir = path.join(buildDir, appName)
contentsDir = path.join(shellAppDir, 'Contents')
appDir = path.join(contentsDir, 'Resources', 'app')
installDir = path.join('/Applications', appName)
if process.platform is 'win32'
appName = 'Atom'
tmpDir = os.tmpdir()
installRoot = process.env.ProgramFiles
buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build')
shellAppDir = path.join(buildDir, appName)
appDir = path.join(shellAppDir, 'resources', 'app')
else
appName = 'Atom.app'
tmpDir = '/tmp'
installRoot = '/Applications'
buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build')
shellAppDir = path.join(buildDir, appName)
contentsDir = path.join(shellAppDir, 'Contents')
appDir = path.join(contentsDir, 'Resources', 'app')
installDir = path.join(installRoot, appName)
coffeeConfig =
options:
@ -178,4 +188,8 @@ module.exports = (grunt) ->
grunt.registerTask('ci', ['update-atom-shell', 'build', 'set-development-version', 'lint', 'test'])
grunt.registerTask('deploy', ['partial-clean', 'update-atom-shell', 'build', 'codesign'])
grunt.registerTask('docs', ['markdown:guides', 'build-docs'])
grunt.registerTask('default', ['update-atom-shell', 'build', 'set-development-version', 'install'])
defaultTasks = ['update-atom-shell', 'build']
defaultTasks.push('set-development-version') if process.platform is 'darwin'
defaultTasks.push('install')
grunt.registerTask('default', defaultTasks)

View File

@ -9,7 +9,7 @@
"bugs": {
"url": "https://github.com/atom/atom/issues"
},
"atomShellVersion": "0.6.4",
"atomShellVersion": "0.6.6",
"dependencies": {
"async": "0.2.6",
"bootstrap": "git://github.com/twbs/bootstrap.git#v3.0.0",
@ -17,22 +17,22 @@
"coffee-script": "1.6.3",
"coffeestack": "0.6.0",
"emissary": "0.6.0",
"first-mate": "0.4.0",
"first-mate": "0.5.0",
"fuzzaldrin": "0.1.0",
"git-utils": "0.26.0",
"git-utils": "0.28.0",
"guid": "0.0.10",
"jasmine-focused": "~0.15.0",
"mkdirp": "0.3.5",
"less-cache": "0.9.0",
"nslog": "0.1.0",
"oniguruma": "0.21.0",
"oniguruma": "0.22.0",
"optimist": "0.4.0",
"pathwatcher": "0.5.0",
"pathwatcher": "0.8.0",
"pegjs": "0.7.0",
"plist": "git://github.com/nathansobo/node-plist.git",
"q": "0.9.7",
"rimraf": "2.1.4",
"scandal": "0.5.0",
"scandal": "0.6.0",
"season": "0.13.0",
"semver": "1.1.4",
"space-pen": "2.0.0",
@ -83,9 +83,9 @@
"find-and-replace": "0.32.0",
"fuzzy-finder": "0.15.0",
"gfm": "0.5.0",
"gists": "0.6.0",
"git-diff": "0.12.0",
"gists": "0.5.0",
"github-sign-in": "0.8.0",
"github-sign-in": "0.9.0",
"go-to-line": "0.8.0",
"grammar-selector": "0.8.0",
"image-view": "0.7.0",
@ -93,13 +93,13 @@
"markdown-preview": "0.12.0",
"metrics": "0.8.0",
"package-generator": "0.14.0",
"release-notes": "0.8.0",
"release-notes": "0.9.0",
"settings-view": "0.33.0",
"snippets": "0.11.0",
"spell-check": "0.8.0",
"spell-check": "0.9.0",
"status-bar": "0.15.0",
"styleguide": "0.9.0",
"symbols-view": "0.14.0",
"symbols-view": "0.15.0",
"tabs": "0.7.0",
"terminal": "0.14.0",
"timecop": "0.7.0",
@ -110,41 +110,41 @@
"whitespace": "0.7.0",
"wrap-guide": "0.4.0",
"language-c": "0.1.0",
"language-c": "0.2.0",
"language-clojure": "0.1.0",
"language-coffee-script": "0.1.0",
"language-css": "0.1.0",
"language-git": "0.1.0",
"language-css": "0.2.0",
"language-git": "0.2.0",
"language-go": "0.2.0",
"language-html": "0.1.0",
"language-hyperlink": "0.2.0",
"language-java": "0.1.0",
"language-javascript": "0.2.0",
"language-json": "0.1.0",
"language-html": "0.2.0",
"language-hyperlink": "0.3.0",
"language-java": "0.2.0",
"language-javascript": "0.3.0",
"language-json": "0.2.0",
"language-less": "0.1.0",
"language-make": "0.1.0",
"language-mustache": "0.1.0",
"language-objective-c": "0.1.0",
"language-objective-c": "0.2.0",
"language-pegjs": "0.1.0",
"language-perl": "0.1.0",
"language-php": "0.1.0",
"language-perl": "0.2.0",
"language-php": "0.2.0",
"language-property-list": "0.2.0",
"language-puppet": "0.1.0",
"language-python": "0.1.0",
"language-ruby-on-rails": "0.2.0",
"language-ruby": "0.2.0",
"language-sass": "0.2.0",
"language-shellscript": "0.1.0",
"language-source": "0.1.0",
"language-sql": "0.1.0",
"language-text": "0.1.0",
"language-puppet": "0.2.0",
"language-python": "0.2.0",
"language-ruby": "0.4.0",
"language-ruby-on-rails": "0.3.0",
"language-sass": "0.3.0",
"language-shellscript": "0.2.0",
"language-source": "0.2.0",
"language-sql": "0.2.0",
"language-text": "0.2.0",
"language-todo": "0.2.0",
"language-xml": "0.1.0",
"language-xml": "0.2.0",
"language-yaml": "0.1.0"
},
"private": true,
"scripts": {
"preinstall": "true",
"test": "script/test"
"preinstall": "node -e 'process.exit(0)'",
"test": "node script/test"
}
}

View File

@ -1,6 +1,5 @@
#!/usr/bin/env node
var safeExec = require('./utils/child-process-wrapper.js').safeExec;
var exec = require('child_process').exec;
var path = require('path');
// Executes an array of commands one by one.
@ -18,15 +17,6 @@ function joinCommands() {
return Array.prototype.slice.call(arguments, 0).join(commandSeparator);
}
function checkDependencies() {
exec("cmake -h", function(error) {
if (error) {
console.error("Error: cmake is required to build Atom.")
process.exit(1);
}
});
}
var echoNewLine = process.platform == 'win32' ? 'echo.' : 'echo';
var commands = [
'git submodule --quiet sync',
@ -37,6 +27,5 @@ var commands = [
'node node_modules/.bin/apm install --silent'
];
checkDependencies()
process.chdir(path.dirname(__dirname));
executeCommands(commands, process.exit);

View File

@ -1,4 +1,4 @@
startTime = new Date().getTime()
startTime = Date.now()
autoUpdater = require 'auto-updater'
crashReporter = require 'crash-reporter'
@ -8,11 +8,17 @@ fs = require 'fs'
module = require 'module'
path = require 'path'
optimist = require 'optimist'
nslog = require 'nslog'
# TODO: NSLog is missing .lib on windows
nslog = require 'nslog' unless process.platform is 'win32'
dialog = require 'dialog'
console.log = (args...) ->
nslog(args.map((arg) -> JSON.stringify(arg)).join(" "))
# TODO: Make NSLog work as expected
output = args.map((arg) -> JSON.stringify(arg)).join(" ")
if process.platform == 'darwin'
nslog(output)
else
fs.writeFileSync('debug.log', output, flag: 'a')
process.on 'uncaughtException', (error={}) ->
nslog(error.message) if error.message?
@ -56,7 +62,7 @@ delegate.browserMainParts.preMainMessageLoopRun = ->
AtomApplication = require './atom-application'
AtomApplication.open(args)
console.log("App load time: #{new Date().getTime() - startTime}ms")
console.log("App load time: #{Date.now() - startTime}ms")
global.devResourcePath = path.join(app.getHomeDir(), 'github', 'atom')

View File

@ -38,6 +38,18 @@ fsExtensions =
catch e
relativePath
# Public: Is the given path absolute?
#
# * pathToCheck:
# The relative or absolute path to check.
#
# Returns true if the path is absolute, false otherwise.
isAbsolute: (pathToCheck='') ->
if process.platform is 'win32'
pathToCheck[1] is ':' # C:\ style
else
pathToCheck[0] is '/' # /usr style
# Public: Returns true if a file or folder at the specified path exists.
exists: (pathToCheck) ->
# TODO: rename to existsSync
@ -290,7 +302,7 @@ fsExtensions =
pathToResolve = args.pop()
loadPaths = args
if pathToResolve[0] is '/'
if @isAbsolute(pathToResolve)
if extensions and resolvedPath = @resolveExtension(pathToResolve, extensions)
return resolvedPath
else

View File

@ -157,7 +157,7 @@ class Project
if uri?.match(/[A-Za-z0-9+-.]+:\/\//) # leave path alone if it has a scheme
uri
else
uri = path.join(@getPath(), uri) unless uri[0] == '/'
uri = path.join(@getPath(), uri) unless fsUtils.isAbsolute(uri)
fsUtils.absolute uri
# Public: Make the given path relative to the project directory.

View File

@ -11,7 +11,11 @@ module.exports = (grunt) ->
rm shellAppDir
mkdir path.dirname(buildDir)
cp 'atom-shell/Atom.app', shellAppDir
if process.platform is 'darwin'
cp 'atom-shell/Atom.app', shellAppDir
else if process.platform is 'win32'
cp 'atom-shell', shellAppDir
mkdir appDir
@ -37,7 +41,6 @@ module.exports = (grunt) ->
path.join('git-utils', 'deps')
path.join('oniguruma', 'deps')
path.join('vendor', 'apm')
path.join('vendor', 'bootstrap', 'docs')
]
ignoredPaths = ignoredPaths.map (ignoredPath) -> "(#{ignoredPath})"
nodeModulesFilter = new RegExp(ignoredPaths.join('|'))
@ -50,8 +53,11 @@ module.exports = (grunt) ->
cp 'src', path.join(appDir, 'src'), filter: /.+\.(cson|coffee)$/
cp 'static', path.join(appDir, 'static')
grunt.file.recurse path.join('resources', 'mac'), (sourcePath, rootDirectory, subDirectory='', filename) ->
unless /.+\.plist/.test(sourcePath)
grunt.file.copy(sourcePath, path.resolve(appDir, '..', subDirectory, filename))
if process.platform is 'darwin'
grunt.file.recurse path.join('resources', 'mac'), (sourcePath, rootDirectory, subDirectory='', filename) ->
unless /.+\.plist/.test(sourcePath)
grunt.file.copy(sourcePath, path.resolve(appDir, '..', subDirectory, filename))
grunt.task.run('compile', 'copy-info-plist')
dependencies = ['compile']
dependencies.push('copy-info-plist') if process.platform is 'darwin'
grunt.task.run(dependencies...)

View File

@ -4,18 +4,24 @@ walkdir = require 'walkdir'
module.exports = (grunt) ->
cp: (source, destination, {filter}={}) ->
walkdir.sync source, (sourcePath, stats) ->
return if filter?.test(sourcePath)
unless grunt.file.exists(source)
grunt.fatal("Cannot copy non-existent #{source.cyan} to #{destination.cyan}")
destinationPath = path.join(destination, path.relative(source, sourcePath))
if stats.isSymbolicLink()
grunt.file.mkdir(path.dirname(destinationPath))
fs.symlinkSync(fs.readlinkSync(sourcePath), destinationPath)
else if stats.isFile()
grunt.file.copy(sourcePath, destinationPath)
try
walkdir.sync source, (sourcePath, stats) ->
return if filter?.test(sourcePath)
if grunt.file.exists(destinationPath)
fs.chmodSync(destinationPath, fs.statSync(sourcePath).mode)
destinationPath = path.join(destination, path.relative(source, sourcePath))
if stats.isSymbolicLink()
grunt.file.mkdir(path.dirname(destinationPath))
fs.symlinkSync(fs.readlinkSync(sourcePath), destinationPath)
else if stats.isFile()
grunt.file.copy(sourcePath, destinationPath)
if grunt.file.exists(destinationPath)
fs.chmodSync(destinationPath, fs.statSync(sourcePath).mode)
catch error
grunt.fatal(error)
grunt.log.writeln("Copied #{source.cyan} to #{destination.cyan}.")

View File

@ -157,6 +157,7 @@ module.exports = (grunt) ->
if newVersion and newVersion isnt previousVersion
grunt.log.writeln("Rebuilding native modules for new atom-shell version #{newVersion.cyan}.")
cmd = path.join('node_modules', '.bin', 'apm')
cmd += ".cmd" if process.platform is 'win32'
spawn {cmd, args: ['rebuild']}, (error) -> callback(error)
else
callback()

2
vendor/apm vendored

@ -1 +1 @@
Subproject commit 6e0142697c3e7c9a4b6688647d3ece6857d41384
Subproject commit 8b629a043be3b9c8cbce5b062eeef98af76e5676