diff --git a/appveyor.yml b/appveyor.yml index 7e002fd9..f5911540 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,7 +22,6 @@ install: - build_win test - choco install nsis -y -pre - build_win dist - - call "C:\Program Files (x86)\NSIS\makensis.exe" janet-installer.nsi build: off diff --git a/auxlib/cook.janet b/auxlib/cook.janet index 9d5118cc..5ff11b70 100644 --- a/auxlib/cook.janet +++ b/auxlib/cook.janet @@ -15,7 +15,7 @@ (def- sep (if is-win "\\" "/")) (def- objext (if is-win ".obj" ".o")) (def- modext (if is-win ".dll" ".so")) -(def- statext (if is-win ".lib" ".a")) +(def- statext (if is-win ".static.lib" ".a")) (def- absprefix (if is-win "C:\\" "/")) # @@ -113,24 +113,24 @@ (def default-compiler (if is-win "cl" "cc")) (def default-linker (if is-win "link" "cc")) -(def default-archiver (if is-win "lib" "ar")) +(def default-archiver (if is-win "link" "ar")) # Default flags for natives, but not required -(def default-lflags []) +(def default-lflags (if is-win ["/nologo"] [])) (def default-cflags (if is-win - [] + ["/nologo"] ["-std=c99" "-Wall" "-Wextra"])) # Required flags for dynamic libraries. These # are used no matter what for dynamic libraries. (def- dynamic-cflags (if is-win - ["/nologo"] + [] ["-fpic"])) (def- dynamic-lflags (if is-win - ["/nologo" "/DLL"] + ["/DLL"] (if is-mac ["-shared" "-undefined" "dynamic_lookup"] ["-shared"]))) @@ -277,7 +277,7 @@ (error "cannot find libpath: provide --libpath or JANET_LIBPATH")) (string (dyn :libpath JANET_LIBPATH) sep - (if is-win "libjanet.lib" "libjanet.a"))) + "libjanet.a")) (defn- win-import-library "On windows, an import library is needed to link to a dll statically." @@ -304,7 +304,7 @@ (rule target objects (print "linking " target "...") (if is-win - (shell ld ;lflags (string "/OUT:" target) (if standalone (libjanet) (win-import-library)) ;objects) + (shell ld ;lflags (string "/OUT:" target) ;objects (if standalone (libjanet) (win-import-library))) (shell ld ;cflags `-o` target ;objects ;(if standalone [(libjanet)] []) ;lflags)))) (defn- archive-c @@ -314,7 +314,7 @@ (rule target objects (print "creating static library " target "...") (if is-win - (do (print "Not Yet Implemented!") (os/exit 1)) + (shell ar "/lib" "/nologo" (string "/out:" target) ;objects) (shell ar "rcs" target ;objects)))) (defn- create-buffer-c-impl @@ -529,7 +529,7 @@ int main(int argc, const char **argv) { (install-rule lname path) # Make static module - (unless (or is-win (dyn :nostatic)) + (unless (dyn :nostatic) (def opts (merge @{:entry-name name} opts)) (def sname (string "build" sep name statext)) (def sobjext (string ".static" objext)) diff --git a/build_win.bat b/build_win.bat index be3170d3..14dd1961 100644 --- a/build_win.bat +++ b/build_win.bat @@ -13,11 +13,13 @@ @if "%1"=="clean" goto CLEAN @if "%1"=="test" goto TEST @if "%1"=="dist" goto DIST +@if "%1"=="install" goto INSTALL @rem Set compile and link options here @setlocal @set JANET_COMPILE=cl /nologo /Isrc\include /Isrc\conf /c /O2 /W3 /LD /D_CRT_SECURE_NO_WARNINGS @set JANET_LINK=link /nologo +@set JANET_LINK_STATIC=lib /nologo mkdir build mkdir build\core @@ -42,7 +44,7 @@ mkdir build\boot @%JANET_COMPILE% /Fobuild\boot\boot.gen.obj build\boot.gen.c @if errorlevel 1 goto :BUILDFAIL -@rem Build the bootstrap interpretter +@rem Build the bootstrap interpreter for %%f in (src\core\*.c) do ( @%JANET_COMPILE% /DJANET_BOOTSTRAP /Fobuild\boot\%%~nf.obj %%f @if errorlevel 1 goto :BUILDFAIL @@ -78,13 +80,21 @@ for %%f in (src\mainclient\*.c) do ( %JANET_LINK% /out:janet.exe build\core\*.obj build\mainclient\*.obj build\core_image.obj build\janet_win.res @if errorlevel 1 goto :BUILDFAIL +@rem Build static library (libjanet.a) +@rem %JANET_LINK_STATIC% /out:build\libjanet.a build\core\*.obj build\core_image.obj +@rem @if errorlevel 1 goto :BUILDFAIL + +@rem Build dynamic library (janet.dll) +@rem %JANET_LINK% /out:build\janet.dll /dll build\core\*.obj build\core_image.obj +@rem @if errorlevel 1 goto :BUILDFAIL + @rem Gen amlag setlocal enabledelayedexpansion set "amalg_files=" for %%f in (src\core\*.c) do ( set "amalg_files=!amalg_files! %%f" ) -janet.exe tools\amalg.janet src\core\util.h src\core\state.h src\core\gc.h src\core\vector.h src\core\fiber.h src\core\regalloc.h src\core\compile.h src\core\emit.h src\core\symcache.h %amalg_files% build\core_image.c > build\janet.c +build\janet.exe tools\amalg.janet src\core\util.h src\core\state.h src\core\gc.h src\core\vector.h src\core\fiber.h src\core\regalloc.h src\core\compile.h src\core\emit.h src\core\symcache.h %amalg_files% build\core_image.c > build\janet.c echo === Successfully built janet.exe for Windows === echo === Run 'build_win test' to run tests. == @@ -107,8 +117,9 @@ exit /b 0 @rem Clean build artifacts :CLEAN -del janet.exe janet.exp janet.lib +del *.exe *.lib *.exp rd /s /q build +rd /s /q dist exit /b 0 @rem Run tests @@ -131,13 +142,28 @@ copy README.md dist\README.md copy janet.lib dist\janet.lib copy janet.exp dist\janet.exp + copy src\include\janet.h dist\janet.h copy src\conf\janetconf.h dist\janetconf.h +@rem copy build\janet.dll dist\janet.dll +@rem copy build\libjanet.a dist\libjanet.a + copy auxlib\cook.janet dist\cook.janet +copy auxlib\path.janet dist\path.janet copy auxbin\jpm dist\jpm copy tools\jpm.bat dist\jpm.bat + +@rem Create installer +"C:\Program Files (x86)\NSIS\makensis.exe" janet-installer.nsi +exit /b 0 + +:INSTALL +@rem Run the installer. (Installs to the local user with default settings) +FOR %%a in (janet-*-windows-installer.exe) DO ( + %%a /S /D=%userprofile%\AppData\Local\Janet\ +) exit /b 0 :TESTFAIL diff --git a/janet-installer.nsi b/janet-installer.nsi index 8cbb35b6..17b070ca 100644 --- a/janet-installer.nsi +++ b/janet-installer.nsi @@ -8,6 +8,7 @@ VIFileVersion "${PRODUCT_VERSION}" !define MULTIUSER_EXECUTIONLEVEL Highest !define MULTIUSER_MUI !define MULTIUSER_INSTALLMODE_COMMANDLINE +!define MULTIUSER_USE_PROGRAMFILES64 !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "Software\Janet\${VERSION}" !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "" !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "Software\Janet\${VERSION}" @@ -75,6 +76,7 @@ function .onInit functionEnd section "Janet" BfWSection + createDirectory "$INSTDIR\Library" createDirectory "$INSTDIR\C" createDirectory "$INSTDIR\bin" @@ -91,12 +93,14 @@ section "Janet" BfWSection file /oname=Library\cook.janet auxlib\cook.janet file /oname=Library\path.janet auxlib\path.janet - # C headers + # C headers and library files file /oname=C\janet.h dist\janet.h file /oname=C\janetconf.h dist\janetconf.h file /oname=C\janet.lib dist\janet.lib file /oname=C\janet.exp dist\janet.exp file /oname=C\janet.c dist\janet.c + #file /oname=C\janet.dll dist\janet.dll + #file /oname=C\libjanet.a dist\libjanet.a # Documentation file /oname=docs\docs.html dist\doc.html diff --git a/tools/FileAssociation.nsh b/tools/FileAssociation.nsh deleted file mode 100644 index df5a7dee..00000000 --- a/tools/FileAssociation.nsh +++ /dev/null @@ -1,192 +0,0 @@ -/* -_____________________________________________________________________________ - - File Association -_____________________________________________________________________________ - - Based on code taken from http://nsis.sourceforge.net/File_Association - - Usage in script: - 1. !include "FileAssociation.nsh" - 2. [Section|Function] - ${FileAssociationFunction} "Param1" "Param2" "..." $var - [SectionEnd|FunctionEnd] - - FileAssociationFunction=[RegisterExtension|UnRegisterExtension] - -_____________________________________________________________________________ - - ${RegisterExtension} "[executable]" "[extension]" "[description]" - -"[executable]" ; executable which opens the file format - ; -"[extension]" ; extension, which represents the file format to open - ; -"[description]" ; description for the extension. This will be display in Windows Explorer. - ; - - - ${UnRegisterExtension} "[extension]" "[description]" - -"[extension]" ; extension, which represents the file format to open - ; -"[description]" ; description for the extension. This will be display in Windows Explorer. - ; - -_____________________________________________________________________________ - - Macros -_____________________________________________________________________________ - - Change log window verbosity (default: 3=no script) - - Example: - !include "FileAssociation.nsh" - !insertmacro RegisterExtension - ${FileAssociation_VERBOSE} 4 # all verbosity - !insertmacro UnRegisterExtension - ${FileAssociation_VERBOSE} 3 # no script -*/ - - -!ifndef FileAssociation_INCLUDED -!define FileAssociation_INCLUDED - -!include Util.nsh - -!verbose push -!verbose 3 -!ifndef _FileAssociation_VERBOSE - !define _FileAssociation_VERBOSE 3 -!endif -!verbose ${_FileAssociation_VERBOSE} -!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE` -!verbose pop - -!macro FileAssociation_VERBOSE _VERBOSE - !verbose push - !verbose 3 - !undef _FileAssociation_VERBOSE - !define _FileAssociation_VERBOSE ${_VERBOSE} - !verbose pop -!macroend - - - -!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION - !verbose push - !verbose ${_FileAssociation_VERBOSE} - Push `${_DESCRIPTION}` - Push `${_EXTENSION}` - Push `${_EXECUTABLE}` - ${CallArtificialFunction} RegisterExtension_ - !verbose pop -!macroend - -!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION - !verbose push - !verbose ${_FileAssociation_VERBOSE} - Push `${_EXTENSION}` - Push `${_DESCRIPTION}` - ${CallArtificialFunction} UnRegisterExtension_ - !verbose pop -!macroend - - - -!define RegisterExtension `!insertmacro RegisterExtensionCall` -!define un.RegisterExtension `!insertmacro RegisterExtensionCall` - -!macro RegisterExtension -!macroend - -!macro un.RegisterExtension -!macroend - -!macro RegisterExtension_ - !verbose push - !verbose ${_FileAssociation_VERBOSE} - - Exch $R2 ;exe - Exch - Exch $R1 ;ext - Exch - Exch 2 - Exch $R0 ;desc - Exch 2 - Push $0 - Push $1 - - ReadRegStr $1 HKCR $R1 "" ; read current file association - StrCmp "$1" "" NoBackup ; is it empty - StrCmp "$1" "$R0" NoBackup ; is it our own - WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value -NoBackup: - WriteRegStr HKCR $R1 "" "$R0" ; set our file association - - ReadRegStr $0 HKCR $R0 "" - StrCmp $0 "" 0 Skip - WriteRegStr HKCR "$R0" "" "$R0" - WriteRegStr HKCR "$R0\shell" "" "open" - WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0" -Skip: - WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"' - WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0" - WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"' - - Pop $1 - Pop $0 - Pop $R2 - Pop $R1 - Pop $R0 - - !verbose pop -!macroend - - - -!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall` -!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall` - -!macro UnRegisterExtension -!macroend - -!macro un.UnRegisterExtension -!macroend - -!macro UnRegisterExtension_ - !verbose push - !verbose ${_ - -FileAssociation_VERBOSE} - - Exch $R1 ;desc - Exch - Exch $R0 ;ext - Exch - Push $0 - Push $1 - - ReadRegStr $1 HKCR $R0 "" - StrCmp $1 $R1 0 NoOwn ; only do this if we own it - ReadRegStr $1 HKCR $R0 "backup_val" - StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key - DeleteRegKey HKCR $R0 - Goto NoOwn - -Restore: - WriteRegStr HKCR $R0 "" $1 - DeleteRegValue HKCR $R0 "backup_val" - DeleteRegKey HKCR $R1 ;Delete key with association name settings - -NoOwn: - - Pop $1 - Pop $0 - Pop $R1 - Pop $R0 - - !verbose pop -!macroend - -!endif # !FileAssociation_INCLUDED