From ad60a7e46e85966dde782a27051e2f7a3bed3d94 Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Thu, 13 Aug 2015 01:39:34 -0400 Subject: [PATCH 1/2] Update project files to build with libuv and the timer module --- project/msvc2013/wren/wren.vcxproj | 14 ++++++------ project/msvc2013/wren/wren.vcxproj.filters | 6 ++++++ script/libuv.py | 25 ++++++++++++++++++---- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/project/msvc2013/wren/wren.vcxproj b/project/msvc2013/wren/wren.vcxproj index 24e392ce..43510214 100644 --- a/project/msvc2013/wren/wren.vcxproj +++ b/project/msvc2013/wren/wren.vcxproj @@ -42,13 +42,13 @@ true $(VC_IncludePath);$(WindowsSDK_IncludePath);$(SolutionDir)..\..\src\include - $(SolutionDir)..\..\build\vs\$(Configuration)\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86) + $(SolutionDir)..\..\build\vs\$(Configuration)\;$(SolutionDir)..\..\build\libuv\Release\lib\;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86) $(SolutionDir)..\..\build\vs\$(Configuration)\ false $(SolutionDir)..\..\src\include;$(IncludePath) - $(SolutionDir)..\..\build\vs\$(Configuration)\;$(LibraryPath) + $(SolutionDir)..\..\build\vs\$(Configuration)\;$(SolutionDir)..\..\build\libuv\Release\lib\;$(LibraryPath) $(SolutionDir)..\..\build\vs\$(Configuration)\ @@ -58,12 +58,12 @@ Level3 Disabled WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\..\src;..\..\..\include + ..\..\..\src;..\..\..\src\cli;..\..\..\src\module;..\..\..\include;..\..\..\build\libuv\include Console true - wren_static_d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + wren_static_d.lib;libuv.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) @@ -75,25 +75,27 @@ true true WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\..\src;..\..\..\include + ..\..\..\src;..\..\..\src\cli;..\..\..\src\module;..\..\..\include;..\..\..\build\libuv\include Console true true true - wren_static.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + wren_static.lib;libuv.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + diff --git a/project/msvc2013/wren/wren.vcxproj.filters b/project/msvc2013/wren/wren.vcxproj.filters index 3a0dd345..a1ad1f12 100644 --- a/project/msvc2013/wren/wren.vcxproj.filters +++ b/project/msvc2013/wren/wren.vcxproj.filters @@ -24,6 +24,9 @@ Source Files + + Source Files + @@ -35,5 +38,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/script/libuv.py b/script/libuv.py index b3cd7f7a..ea3d6ef4 100755 --- a/script/libuv.py +++ b/script/libuv.py @@ -22,6 +22,25 @@ def ensure_dir(dir): os.makedirs(dir) +def rmtree_onerror(func, path, exc_info): + """ + Error handler for ``shutil.rmtree``. + + If the error is due to an access error (read only file) + it attempts to add write permission and then retries. + + If the error is for another reason it re-raises the error. + + Usage : ``shutil.rmtree(path, onerror=rmtree_onerror)`` + """ + import stat + if not os.access(path, os.W_OK): + # Is the error an access error? + os.chmod(path, stat.S_IWUSR) + func(path) + else: + raise + def download_libuv(): """Clones libuv into build/libuv and checks out the right version.""" @@ -30,7 +49,7 @@ def download_libuv(): # version number in this script changes. if os.path.isdir(LIB_UV_DIR): print("Cleaning output directory...") - shutil.rmtree(LIB_UV_DIR) + shutil.rmtree(LIB_UV_DIR, onerror=rmtree_onerror) ensure_dir("build") @@ -84,9 +103,7 @@ def build_libuv_linux(): def build_libuv_windows(): - # TODO: Implement me! - print("Building for Windows not implemented yet.") - sys.exit(1) + run(["cmd", "/c", "vcbuild.bat", "release"], cwd=LIB_UV_DIR) def build_libuv(): From c46519eeda16c11d3352b8b96a55995687d0163c Mon Sep 17 00:00:00 2001 From: Rohan Singh Date: Sun, 16 Aug 2015 09:32:38 -0400 Subject: [PATCH 2/2] Don't use rmtree on Windows if it's going to cause problems --- script/libuv.py | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/script/libuv.py b/script/libuv.py index ea3d6ef4..b43e5ad2 100755 --- a/script/libuv.py +++ b/script/libuv.py @@ -22,25 +22,15 @@ def ensure_dir(dir): os.makedirs(dir) -def rmtree_onerror(func, path, exc_info): - """ - Error handler for ``shutil.rmtree``. - - If the error is due to an access error (read only file) - it attempts to add write permission and then retries. - - If the error is for another reason it re-raises the error. - - Usage : ``shutil.rmtree(path, onerror=rmtree_onerror)`` - """ - import stat - if not os.access(path, os.W_OK): - # Is the error an access error? - os.chmod(path, stat.S_IWUSR) - func(path) +def remove_dir(dir): + """Recursively removes dir.""" + + if platform.system() == "Windows": + # rmtree gives up on readonly files on Windows + # rd doesn't like paths with forward slashes + subprocess.check_call(['cmd', '/c', 'rd', '/s', '/q', dir.replace('/', '\\')]) else: - raise - + shutil.rmtree(LIB_UV_DIR) def download_libuv(): """Clones libuv into build/libuv and checks out the right version.""" @@ -49,7 +39,7 @@ def download_libuv(): # version number in this script changes. if os.path.isdir(LIB_UV_DIR): print("Cleaning output directory...") - shutil.rmtree(LIB_UV_DIR, onerror=rmtree_onerror) + remove_dir(LIB_UV_DIR) ensure_dir("build")