Skip to content
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

Win64 installation #10

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
build/*.*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do simply:

build/

build/CMakeFiles/2.8.12.2/CMakeASMCompiler.cmake
build/CMakeFiles/2.8.12.2/CMakeCCompiler.cmake
build/CMakeFiles/2.8.12.2/CMakeCXXCompiler.cmake
build/CMakeFiles/2.8.12.2/CMakeDetermineCompilerABI_C.bin
build/CMakeFiles/2.8.12.2/CMakeDetermineCompilerABI_CXX.bin
build/CMakeFiles/2.8.12.2/CMakeRCCompiler.cmake
build/CMakeFiles/2.8.12.2/CMakeSystem.cmake
build/CMakeFiles/2.8.12.2/CompilerIdC/CMakeCCompilerId.c
build/CMakeFiles/2.8.12.2/CompilerIdC/CMakeCCompilerId.exe
build/CMakeFiles/2.8.12.2/CompilerIdC/CMakeCCompilerId.obj
build/CMakeFiles/2.8.12.2/CompilerIdCXX/CMakeCXXCompilerId.cpp
build/CMakeFiles/2.8.12.2/CompilerIdCXX/CMakeCXXCompilerId.exe
build/CMakeFiles/2.8.12.2/CompilerIdCXX/CMakeCXXCompilerId.obj
build/CMakeFiles/CheckTypeSize/SIZEOF_VOID_P.bin
build/CMakeFiles/CheckTypeSize/SIZEOF_VOID_P.c
build/CMakeFiles/cmake.check_cache
build/CMakeFiles/CMakeDirectoryInformation.cmake
build/CMakeFiles/CMakeError.log
build/CMakeFiles/CMakeOutput.log
build/CMakeFiles/CMakeRuleHashes.txt
build/CMakeFiles/Makefile.cmake
build/CMakeFiles/Makefile2
build/CMakeFiles/progress.marks
build/CMakeFiles/TargetDirectories.txt
build/luarocks/cmake_install.cmake
build/luarocks/CMakeFiles/CMakeDirectoryInformation.cmake
build/luarocks/CMakeFiles/progress.marks
build/luarocks/Makefile
build/luarocks/src/bin/luarocks.bat
build/luarocks/src/bin/luarocks-admin.bat
build/luarocks/src/luarocks/config.lua
build/luarocks/src/luarocks/site_config.lua
build/Makefile
build/LUA_DEV
bld07/*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bld07/ is non-standard :-) fine with it personally, but I reckon it'd be cleaner to remove it, on the hwole

x86/*
x64/*
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,43 @@ is free, it has no GUI, but it is just fine with CMake.

# Installation

On Windows - use command prompt with appropritate environment (e.g. VS2013 Native Tools Command Prompt)

```sh
git clone https://github.com/torch/luajit-rocks.git
git clone https://github.com/diz-vara/luajit-rocks.git

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For purposes of PR, I think this should point to torch, rather than diz-vara.

cd luajit-rocks
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/your/prefix
```
Choose the destination - (e.g. d:/luainstall) - it will be '/your/prefix'

Then under Unix systems:
```sh
cmake .. -DCMAKE_INSTALL_PREFIX=/your/prefix
make install
```

Under Windows:
```sh
nmake install
cmake .. -DCMAKE_INSTALL_PREFIX=/your/prefix -DWITH_LUAJIT21=ON -G "NMake Makefiles" -DWIN32=1
nmake
cmake -DCMAKE_INSTALL_PREFIX=/your/prefix -DWITH_LUAJIT21=ON -G "NMake Makefiles" -DWIN32=1 -P cmake_install.cmake
```

Under Windows - remember to update your environment variables. Assuming that your/prefix is d:/luainstall :
Copy link

@hughperkins hughperkins Sep 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this a variable, rahter than d:/luatinstall. eg %LUA_INSTALL%

```sh
set LUA_CPATH=d:\luainstall?.DLL;d:\luainstall\LIB\?.DLL;?.DLL
set LUA_DEV=d:/luainstall
set LUA_PATH=;;d:\luainstall\?;d:\luainstall\lua\?\init.lua;d:\luainstall\?.lua
```

Then install packages you need:
luarocks install torch
luarocks install nn
luarocks install nnx
etc...


Note: we do not recommend (nor we support) installation under Cygwin.

## Additional CMake flags
Expand Down
10 changes: 10 additions & 0 deletions lua-5.1/src/lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
#ifndef lua_h
#define lua_h

#ifdef WIN32
# ifndef LUA_WIN
# define LUA_WIN
# endif
# ifndef _WIN32

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be cleaner to not mess wit hthe lua sourcecode I reckon? I think I'd prefer these in our CMakeLists perhaps?

# define _WIN32
# endif
#endif


#include <stdarg.h>
#include <stddef.h>

Expand Down
11 changes: 11 additions & 0 deletions lua-5.2/src/lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
#ifndef lua_h
#define lua_h

#ifdef WIN32
# ifndef LUA_WIN
# define LUA_WIN
# endif
# ifndef _WIN32
# define _WIN32
# endif
#endif



#include <stdarg.h>
#include <stddef.h>

Expand Down
15 changes: 15 additions & 0 deletions luajit-2.0/src/lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
#ifndef lua_h
#define lua_h

#ifdef WIN32
# ifndef LUA_WIN
# define LUA_WIN
# endif
# ifndef _WIN32
# define _WIN32
# endif

# if !defined LUA_LIB & !defined LUA_CORE & !defined luajit_c & !defined _LJ_ARCH_H & !defined _LJ_DEF_H & !defined _LJ_OBJ_H
# pragma comment( lib, "libluajit.lib")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to use the linker options instead of #pragma.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I odnt know what this pragma does, but concur with the comment by Ark-kun, if that's indeed what this does.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hughperkins this pragma just links with the library - but only in certain cases (if module is not a part of the 'core' itself). It can be moved to the options - if somebody will implement these conditions in CMake

# endif

#endif


#include <stdarg.h>
#include <stddef.h>

Expand Down
16 changes: 16 additions & 0 deletions luajit-2.1/src/lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@
#ifndef lua_h
#define lua_h

#ifdef WIN32
# ifndef LUA_WIN
# define LUA_WIN
# endif
# ifndef _WIN32
# define _WIN32
# endif

# if !defined LUA_LIB & !defined LUA_CORE & !defined luajit_c & !defined _LJ_ARCH_H & !defined _LJ_DEF_H & !defined _LJ_OBJ_H
# pragma comment( lib, "libluajit.lib")
# endif

#endif



#include <stdarg.h>
#include <stddef.h>

Expand Down
5 changes: 4 additions & 1 deletion luajit-2.1/src/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
** In Windows, any exclamation mark ('!') in the path is replaced by the
** path of the directory of the executable file of the current process.
*/

#define LUA_BUILD_AS_DLL 1

#define LUA_LDIR "!\\lua\\"
#define LUA_CDIR "!\\"
#define LUA_PATH_DEFAULT \
Expand Down Expand Up @@ -135,7 +138,7 @@
#define LUA_API __declspec(dllimport)
#endif
#else
#define LUA_API extern
#define LUA_API extern "C"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we should be messing around wit hthe original lua source code? We can simply add extern "C" in our own c++ header files?

#ifdef __cplusplus
extern "C"
#endif
    #include "luaconf.h"
#ifdef __cplusplus
}
#endif

#endif

#define LUALIB_API LUA_API
Expand Down
2 changes: 2 additions & 0 deletions luarocks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ IF(WIN32)
INSTALL(FILES ${WINUTILS_DLL_FILES} DESTINATION "${INSTALL_BIN_SUBDIR}")

SET(WINUTILS_EXE_FILES
win32/bin/cmake.cmd
win32/bin/7z.exe win32/bin/chmod.exe win32/bin/cp.exe
win32/bin/find.exe win32/bin/ls.exe win32/bin/md5sum.exe
win32/bin/mkdir.exe win32/bin/mv.exe win32/bin/objdump.exe
Expand Down Expand Up @@ -85,6 +86,7 @@ ENDIF()

SET(LUAROCKS_FILES
fs/unix/tools.lua fs/unix.lua fs/win32/tools.lua fs/win32.lua fs/lua.lua
fs/x64/tools.lua fs/x64.lua
persist.lua list.lua require.lua repos.lua dir.lua make_manifest.lua
command_line.lua install.lua build/command.lua build/cmake.lua
build/make.lua build/builtin.lua fetch/cvs.lua fetch/git.lua
Expand Down
6 changes: 4 additions & 2 deletions luarocks/src/luarocks/build/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function builtin.run(rockspec)
"-l" .. (variables.MSVCRT or "m"), "-luser32")
return ok, wrapname
end
elseif cfg.is_platform("win32") then
elseif cfg.is_platform("win32") or cfg.is_platform('x64') then
compile_object = function(object, source, defines, incdirs)
local extras = {}
add_flags(extras, "-D%s", defines)
Expand All @@ -116,7 +116,8 @@ function builtin.run(rockspec)
def:write("EXPORTS\n")
def:write("luaopen_"..name:gsub("%.", "_").."\n")
def:close()
local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras))
-- diz --- local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove the dead code?

local ok = execute(variables.LD, "-dll", "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras))
local basedir = ""
if name:find("%.") ~= nil then
basedir = name:gsub("%.%w+$", "\\")
Expand All @@ -127,6 +128,7 @@ function builtin.run(rockspec)
if ok and fs.exists(manifestfile) then
ok = execute(variables.MT, "-manifest", manifestfile, "-outputresource:"..basedir..basename..".dll;2")
end
--- diz --- io.read()
return ok
end
compile_wrapper_binary = function(fullname, name)
Expand Down
12 changes: 6 additions & 6 deletions luarocks/src/luarocks/cfg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -293,22 +293,22 @@ local defaults = {
}

if detected.windows then
local full_prefix = site_config.LUAROCKS_PREFIX.."\\"..cfg.major_version
local full_prefix = site_config.LUAROCKS_PREFIX --.."\\"..cfg.major_version
extra_luarocks_module_dir = full_prefix.."\\lua\\?.lua"

home_config_file = home_config_file and home_config_file:gsub("\\","/")
defaults.fs_use_modules = false
defaults.arch = "win32-"..proc
defaults.platforms = {"win32", "windows" }
defaults.arch = "x64-"..proc
defaults.platforms = {"x64", "windows" }
defaults.lib_extension = "dll"
defaults.external_lib_extension = "dll"
defaults.obj_extension = "obj"
defaults.external_deps_dirs = { "c:/external/" }
defaults.variables.LUA_BINDIR = site_config.LUA_BINDIR and site_config.LUA_BINDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/bin"
defaults.variables.LUA_INCDIR = site_config.LUA_INCDIR and site_config.LUA_INCDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/include"
defaults.variables.LUA_LIBDIR = site_config.LUA_LIBDIR and site_config.LUA_LIBDIR:gsub("\\", "/") or "c:/lua"..cfg.lua_version.."/lib"
defaults.cmake_generator = "MinGW Makefiles"
defaults.makefile = "Makefile.win"
defaults.cmake_generator = "NMake Makefiles"
defaults.makefile = "Makefile"
defaults.variables.MAKE = "nmake"
defaults.variables.CC = "cl"
defaults.variables.RC = "rc"
Expand All @@ -323,7 +323,7 @@ if detected.windows then
"MKDIR", "MV", "PWD", "RMDIR", "TEST", "UNAME", "WGET" }
for _, var in ipairs(bins) do
if defaults.variables[var] then
defaults.variables[var] = full_prefix.."\\tools\\"..defaults.variables[var]
defaults.variables[var] = full_prefix..defaults.variables[var]
end
end

Expand Down
1 change: 1 addition & 0 deletions luarocks/src/luarocks/config.lua.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rocks_trees = {
}

rocks_servers = {
[[https://raw.githubusercontent.com/diz-vara/rocks/master]],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to remove this, for torch distribution

[[https://raw.githubusercontent.com/torch/rocks/master]],
[[https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master]]
}
5 changes: 3 additions & 2 deletions luarocks/src/luarocks/config.lua.win.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ rocks_trees = {
}

rocks_servers = {
[[https://raw.githubusercontent.com/torch/rocks/master]],
[[https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master]]
[[https://raw.githubusercontent.com/diz-vara/rocks/master]],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we want this in official torch distribution?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hughperkins Not for official, certainly! I keep my repo in the list for some windows-specific changes (eg in luaffifb, imgraph).
It would be OK to remove it - but we should check every rock in the official repo

[[https://raw.githubusercontent.com/torch/rocks/master]],
[[https://raw.githubusercontent.com/rocks-moonscript-org/moonrocks-mirror/master]]
}

variables = {
Expand Down
Loading