From 78b5c94cb0d3309c5f040d7d6b8b1b4a4d8128ef Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 24 Aug 2019 17:36:50 -0400 Subject: [PATCH] jpm updates. Add better error message if no c compiler detected on windows. --- CHANGELOG.md | 2 ++ auxbin/jpm | 1 + auxlib/cook.janet | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bb0b8a0..6772471d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. ## Unreleased +- jpm detects if not in a Developer Command prompt on windows for a better error message. +- jpm install git submodules in dependencies - Change default fiber stack limit to the maximum value of a 32 bit signed integer. - Some bug fixes with `jpm` - Add `os/arch` to get ISA that janet was compiled for diff --git a/auxbin/jpm b/auxbin/jpm index 00f62d4e..13917bd2 100755 --- a/auxbin/jpm +++ b/auxbin/jpm @@ -37,6 +37,7 @@ Keys are: --libpath : The directory containing janet C libraries (libjanet.*). Defaults to $JANET_LIBPATH. --optimize : Optimization level for natives. Defaults to 2. --compiler : C compiler to use for natives. Defaults to cc (cl on windows). + --archiver : C compiler to use for static libraries. Defaults to ar (lib on windows). --linker : C linker to use for linking natives. Defaults to cc (link on windows). --cflags : Extra compiler flags for native modules. --lflags : Extra linker flags for native modules. diff --git a/auxlib/cook.janet b/auxlib/cook.janet index fe6b77c0..94064df6 100644 --- a/auxlib/cook.janet +++ b/auxlib/cook.janet @@ -144,6 +144,16 @@ (error (string "option :" key " not set"))) ret) +(defn check-cc + "Ensure we have a c compiler" + [] + (if is-win + (do + (if (os/getenv "INCLUDE") (break)) + (error "Run jpm or load cook.janet inside a Developer Command Prompt. + jpm needs a c compiler to compile natives. You can install the MSVC compiler at ")) + (do))) + # # Importing a file # @@ -269,6 +279,7 @@ (def defines [;(make-defines (opt opts :defines {})) ;entry-defines]) (def headers (or (opts :headers) [])) (rule dest [src ;headers] + (check-cc) (print "compiling " dest "...") (if is-win (shell cc ;defines "/c" ;cflags (string "/Fo" dest) src) @@ -300,6 +311,7 @@ (def lflags [;(opt opts :lflags default-lflags) ;(if (opts :static) [] dynamic-lflags)]) (rule target objects + (check-cc) (print "linking " target "...") (if is-win (shell ld ;lflags (string "/OUT:" target) ;objects (win-import-library)) @@ -310,6 +322,7 @@ [opts target & objects] (def ar (opt opts :archiver default-archiver)) (rule target objects + (check-cc) (print "creating static library " target "...") (if is-win (shell ar "/nologo" (string "/out:" target) ;objects) @@ -357,6 +370,7 @@ # Create executable's janet image (def cimage_dest (string dest ".c")) (rule dest [source] + (check-cc) (print "generating executable c source...") # Load entry environment and get main function. (def entry-env (dofile source))