-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows #261
base: master
Are you sure you want to change the base?
Windows #261
Changes from 59 commits
5772c9f
f6b8528
a67a388
6f61ce1
dfc31cb
eda9cdd
4a4a842
26dc5c3
588dd69
0e91553
4222bd9
5509fe7
bce797f
306976f
bf1d7f3
87f82a5
8bd1c80
8ba523c
9b65e03
05a84ab
0f09ac6
20d2c4b
d698bb6
376aa90
0864b60
5a68550
7f59fb2
b7b0638
7f12ca1
443639b
f4fcd0a
017566d
b8d269b
7eb58c3
173ad8c
38796e1
e0617cb
9cd8d6c
843a404
ccc8bb8
7c628a0
11fe38d
9e1f472
cc28ed6
5e32023
4d1437d
40be07b
6dff5ca
c7260e0
941a91f
9894693
fd7f577
285242e
734e348
5647ae0
277b252
41fccbe
f48895d
e1b48c9
44c5029
b4a12a7
d9f072d
537e967
e800c94
67afdb6
ff37594
2536cd7
2dba2b2
6b4ae52
81186cb
67bf2fd
c1e4c98
decaa9a
21f5742
f94c148
32a24f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
src/deps/*/* | ||
src/*.o | ||
src/howl | ||
src/howl.exe | ||
*.bc | ||
*.bak | ||
site/build/ | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Copyright 2016 The Howl Developers | ||
-- License: MIT (see LICENSE.md at the top-level directory of the distribution) | ||
|
||
ffi = require 'ffi' | ||
|
||
ffi.cdef [[ | ||
typedef void* HANDLE; | ||
typedef void* PVOID; | ||
typedef int DWORD; | ||
typedef int BOOL; | ||
typedef char* LPTSTR; | ||
typedef const char* LPCTSTR; | ||
|
||
DWORD GetProcessId(HANDLE process); | ||
HANDLE _get_osfhandle(int fd); | ||
BOOL TerminateProcess(HANDLE process, unsigned int exitcode); | ||
int AddFontResourceExA(LPCTSTR lpszFilename, DWORD fl, PVOID pdv); | ||
BOOL SetFileAttributesA(LPCTSTR file, DWORD attrs); | ||
|
||
int fr_private; | ||
]] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ Where options can be any of: | |
]=] | ||
|
||
local path_separator = jit.os == 'Windows' and '\\' or '/' | ||
local path_prefix = jit.os == 'Windows' and '\\\\.\\' or '' | ||
app_root = path_prefix .. app_root | ||
|
||
local function parse_args(argv) | ||
local options = { | ||
|
@@ -162,12 +164,27 @@ local function main(args) | |
set_package_path('lib', 'lib/ext', 'lib/ext/moonscript') | ||
require 'howl.moonscript_support' | ||
table.insert(package.loaders, 2, bytecode_loader()) | ||
require 'howl.cdefs.fontconfig' | ||
ffi.C.FcConfigAppFontAddDir(nil, table.concat({app_root, 'fonts'}, path_separator)) | ||
require 'ljglibs.cdefs.glib' | ||
|
||
howl = auto_module('howl') | ||
require('howl.globals') | ||
|
||
local font_dir = table.concat({app_root, 'fonts'}, path_separator) | ||
if ffi.os == 'Windows' then | ||
require 'howl.cdefs.windows' | ||
local fonts = howl.io.File(font_dir).children | ||
for _, font in ipairs(fonts) do | ||
local loaded = ffi.C.AddFontResourceExA(font.path, ffi.C.fr_private, nil) | ||
if loaded == 0 then | ||
print('failed to load font ' .. font.path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nilnor Still needs the flush. Not really sure why... |
||
io:flush() | ||
end | ||
end | ||
else | ||
require 'howl.cdefs.fontconfig' | ||
ffi.C.FcConfigAppFontAddDir(nil, font_dir) | ||
end | ||
|
||
_G.log = require('howl.log') | ||
local args = parse_args(argv) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ GFileInfo = require 'ljglibs.gio.file_info' | |
glib = require 'ljglibs.glib' | ||
import PropertyObject from howl.util.moon | ||
append = table.insert | ||
ffi = require 'ffi' | ||
|
||
file_types = { | ||
[tonumber GFileInfo.TYPE_DIRECTORY]: 'directory', | ||
|
@@ -16,15 +17,25 @@ file_types = { | |
[tonumber GFileInfo.TYPE_UNKNOWN]: 'unknown', | ||
} | ||
|
||
local File | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Left over? Doesn't seem to be needed. |
||
|
||
platform_tmpname = -> | ||
-- os.tmpname is broken on Windows and returns a filename prefixed with \. | ||
-- This causes a lot of "Access denied"-related errors. | ||
filename = assert os.tmpname! | ||
-- Remove the prefix \. | ||
filename = filename\sub 2 if ffi.os == 'Windows' | ||
filename | ||
|
||
class File extends PropertyObject | ||
|
||
tmpfile: -> | ||
file = File assert os.tmpname! | ||
file.touch if not file.exists | ||
file = File platform_tmpname! | ||
file\touch! if not file.exists | ||
file | ||
|
||
tmpdir: -> | ||
with File os.tmpname! | ||
with File platform_tmpname! | ||
\delete! if .exists | ||
\mkdir! | ||
|
||
|
@@ -35,7 +46,7 @@ class File extends PropertyObject | |
error err if not status | ||
|
||
is_absolute: (path) -> | ||
(path\match('^/') or path\match('^%a:\\\\')) != nil | ||
(path\match('^/') or path\match('^%a:\\')) != nil | ||
|
||
expand_path: (path) -> | ||
res = path\gsub "~#{File.separator}", File.home_dir.path .. File.separator | ||
|
@@ -79,7 +90,7 @@ class File extends PropertyObject | |
@property size: get: => @_info!.size | ||
@property exists: get: => @gfile.exists | ||
@property readable: get: => @exists and @_info('access')\get_attribute_boolean 'access::can-read' | ||
@property etag: get: => @exists and @_info('etag').etag | ||
@property etag: get: => @exists and @_info('etag').etag or nil | ||
@property modified_at: get: => @exists and @_info('time')\get_attribute_uint64 'time::modified' | ||
@property short_path: get: => @path\gsub "^#{File.home_dir.path}", '~' | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could/should we add a specific README with installation instructions on Windows? I'm thinking of basic steps from start to finish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be in a readme (e.g.
README.windows.md
), or do you think it would be better as a page on the site (e.g.getit.windows.html
), as a parallel togetit.html
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a separate page on the site would be best, we could just reference to that from the README.