Skip to content

Commit

Permalink
o
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 committed Aug 1, 2021
1 parent 6e8edaa commit fb9cb87
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,39 @@ jobs:
matrix:
# 10.x, 12.x,
node-version: [ 12.x]
operating-system: [ubuntu-latest, windows-latest, macos-latest,'windows-7']
operating-system: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: jiro4989/setup-nim-action@v1
with:
nim-version: '1.4.8' # default is
- name: Install nim deps
uses: jiro4989/setup-nim-action@v1
run: nimble install -d -y
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install node deps
run: |
yarn global add node-gyp
npm install -g node-gyp
yarn install --ignore-scripts
working-directory: test
- name: test
run: nimble test

- name: Check if Git tag exists
run: echo "::set-env name=HEAD_TAG::$(git tag --points-at HEAD)"
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: build
run: yarn build
if: env.HEAD_TAG != ''
working-directory: test
- name: publish
if: env.HEAD_TAG != ''
working-directory: test
env:
PREBUILD_TOKEN: ${{ secrets.PREBUILD_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
!**/
!*.*
test/build
test/prebuilds
binding.gyp
yarn.lock
node_modules
Expand Down
9 changes: 4 additions & 5 deletions napibindings.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ skipDirs = @["test", ".git"]
bin = @["napibuild"]

requires "docopt"

import os
task test,"test":
withDir "test":
exec "yarn install --ignore-scripts"
exec "nim c -r src/napibuild.nim test/main.nim"
exec "node test/index.js"
exec findExe("yarn") & " install --ignore-scripts --cwd test"
selfExec "c -r " & "src" / "napibuild.nim" & " -r " & "test" / "main.nim"
exec findExe("node") & " " & "test" / "index.js"
7 changes: 4 additions & 3 deletions src/napibuild.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ var


if not args["-C"]:
var releaseFlag = if args["-r"]: "-d:release " else: "--embedsrc "
let r = execCmdEx "nim c --nimcache:" & nimcache & " " & releaseFlag & "--compileOnly --noMain " & projectfile
let releaseFlag = if args["-r"]: "-d:release " else: "--embedsrc "
let vccFlag = when defined(windows): " --cc:vcc " else: ""
let r = execCmdEx "nim c " & vccFlag & " --nimcache:" & nimcache & " " & releaseFlag & "--compileOnly --noMain " & projectfile
doAssert r.exitCode == 0, r.output


Expand All @@ -46,5 +47,5 @@ writeFile(project.dir / "binding.gyp", gyp.pretty)
var gypflags = "--directory=" & project.dir
if not args["-r"]: gypflags.add(" --debug")

let gypRebuild = execCmdEx "node-gyp rebuild " & gypflags
let gypRebuild = execCmdEx findExe("node-gyp") & " rebuild " & gypflags
doAssert gypRebuild.exitCode == 0, gypRebuild.output
20 changes: 19 additions & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,31 @@
"version": "0.0.0",
"description": "nim napi test",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/bung87/napibindings.git"
},
"scripts": {
"install": "prebuild-install",
"build": "prebuild -r node",
"build": "prebuild",
"test": "echo \"Error: no test specified\" && exit 1"
},
"binary": {
"napi_versions": [
1,
2,
3,
4,
5,
6,
7
]
},
"author": "",
"license": "ISC",
"devDependencies": {
"prebuild": "^10.0.1"
},
"dependencies": {
"bindings": "^1.5.0",
"prebuild-install": "^6.0.0"
Expand Down

0 comments on commit fb9cb87

Please sign in to comment.