-
Notifications
You must be signed in to change notification settings - Fork 17
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 support #75
Open
devnote-dev
wants to merge
9
commits into
jessedoyle:master
Choose a base branch
from
devnote-dev:windows
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Windows support #75
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1180f10
feat: replace makefiles with justfiles
devnote-dev 53d83be
chore: update shard info
devnote-dev b2c5cf1
fix: update win32 specific bindings and link
devnote-dev 271b613
fix: include gettimeofday win binding
devnote-dev 77be94e
fix(ext): use correct output location
devnote-dev a9e0c89
feat(ext): include gettimeofday impl for windows
devnote-dev d4f1593
chore: re-add makefiles
devnote-dev 1ed8565
revert: use make for postinstall
devnote-dev 0485ad8
fix: include dir change
devnote-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
set shell := ["bash", "-uc"] | ||
set windows-shell := ["cmd.exe", "/c"] | ||
|
||
cc := if os() == "windows" { | ||
if `where gcc 2>NUL || exit 0` == "" { | ||
if `where clang 2>NUL || exit 0` == "" { | ||
error("cannot find C compiler") | ||
} else { | ||
trim(replace(`where clang`, "\\", "\\\\")) | ||
} | ||
} else { | ||
replace(`where gcc`, "\\", "\\\\") | ||
} | ||
} else { | ||
"cc" | ||
} | ||
|
||
cflags := "-pedantic -c -std=c99 -O2 -fstrict-aliasing -fomit-frame-pointer" | ||
current := justfile_directory() | ||
output := join(current, "..", "src", ".build") | ||
|
||
[unix] | ||
build: | ||
mkdir -p {{output}} | ||
{{cc}} -o {{output}}/libduktape.o {{current}}/duktape.c {{cflags}} | ||
|
||
mkdir -p {{output}}/lib | ||
ar rcs {{output}}/lib/libduktape.a {{output}}/libduktape.o | ||
|
||
mkdir -p {{output}}/include | ||
cp {{current}}/duktape.h {{current}}/duk_config.h {{output}}/include | ||
|
||
[windows] | ||
build compiler="{{cc}}": | ||
mkdir {{output}}\lib | ||
{{compiler}} -o {{output}}\lib\duktape.lib {{current}}\duktape.c {{cflags}} -fuse-ld=llvm-lib | ||
|
||
mkdir {{output}}\include | ||
copy {{current}}\duktape.h + {{current}}\duk_config.h {{output}}\include | ||
|
||
[unix] | ||
clean: | ||
-rm -rf {{output}} | ||
-rm -rf {{current}}/.crystal | ||
|
||
[windows] | ||
clean: | ||
-rmdir /q /s {{output}} | ||
-rmdir /q /s {{current}}\.crystal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
set shell := ["bash", "-uc"] | ||
set windows-shell := ["cmd.exe", "/c"] | ||
|
||
current := invocation_directory() | ||
crystal := if os() == "windows" { trim(`where crystal`) } else { trim(`which crystal`) } | ||
|
||
default: | ||
@just build | ||
|
||
[unix] | ||
all_spec output="{{current}}\\.build": | ||
-mkdir -p {{current}}/.build | ||
{{crystal}} build -o {{output}} spec/all_spec.cr --warnings all | ||
|
||
[windows] | ||
all_spec output="{{current}}/.build": | ||
-mkdir {{current}}\.build | ||
{{crystal}} build -o {{output}} spec\all_spec.cr --warnings all | ||
|
||
[unix] | ||
build output=".build/duktape": | ||
-mkdir -p {{current}}/.build | ||
{{crystal}} build -o {{output}} src/duktape.cr --warnings all | ||
|
||
[windows] | ||
build output=".build\\duktape": | ||
-mkdir {{current}}\.build | ||
{{crystal}} build -o {{output}} src\duktape.cr --warnings all | ||
|
||
[unix] | ||
clean: | ||
-rm -rf {{current}}/.build | ||
-rm -rf {{current}}/.crystal | ||
|
||
[windows] | ||
clean: | ||
-rmdir /q /s {{current}}\.build | ||
-rmdir /q /s {{current}}\.crystal | ||
|
||
cleanlib: | ||
@just -f {{current}}/ext/justfile clean | ||
make -C {{current}}/ext -f Makefile.internal clean | ||
|
||
libduktape: | ||
cd ext | ||
@just -f ext/justfile build | ||
|
||
update: | ||
make -C {{current}}/ext -f Makefile.internal update-duktape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,11 @@ authors: | |
- Jesse Doyle <[email protected]> | ||
|
||
scripts: | ||
postinstall: "make -C ext clean libduktape" | ||
postinstall: make -C clean libduktape | ||
|
||
development_dependencies: | ||
ameba: | ||
github: veelenga/ameba | ||
github: crystal-ameba/ameba | ||
version: '~> 1.4' | ||
|
||
crystal: '>= 0.35.1' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
-C
flag changes the directory to the provided argument (ext
) before running the targets.As it currently stands, this may break the seamless
postinstall
for folks on non-windows platforms. Is there a way we can detect the environment from this shell command?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.
Ah right, yeah that should be
make -C ext ...
.Unfortunately there isn't, this is part of what makes Windows support difficult because Shards itself doesn't really have a concept of platform-specific script management. Some people have tried to work around this by having
postinstall
execute a Crystal file which handles platform-specific logic/configuration, but that may not be ideal here.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.
I'm going to have to get a VM running Windows to test this - can we invoke a shell script here instead of
make
directly? If so, what type of shell does it run on in Windows?i.e.
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.
Windows' shell would be command prompt (
cmd
) but that can't run shell scripts. The (Git) Bash interpreter also does not ship with Windows by default, so there would be no way to execute the postinstall script on Windows.