Skip to content

Commit

Permalink
arm: do not use CI to try to build arm and create some manual scripts…
Browse files Browse the repository at this point in the history
… files
  • Loading branch information
JCMais committed May 25, 2019
1 parent 0625984 commit 15425f9
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ orbs:
condition: <<parameters.node-version>>
steps:
- run: |
[ -f /usr/local/bin/node<<parameters.node-version>> ] && ln -s /usr/local/bin/node<<parameters.node-version>> /usr/local/bin/node || true
if [ -x "$(command -v nvm)" ]; then
nvm use <<parameters.node-version>>
else
[ -f /usr/local/bin/node<<parameters.node-version>> ] && ln -s /usr/local/bin/node<<parameters.node-version>> /usr/local/bin/node || true
fi
- run:
name: Setup Environment Variables
command: |
Expand Down
9 changes: 8 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
.idea/
.nyc_output/
.vscode/
api/
build/
cache/
coverage/
debug/
deps/
dist/
docs/
examples/
lib/binding/node_libcurl.node
node_modules/
tsconfig.tsbuildinfo
website/
docs/
yarn-error.log
4 changes: 4 additions & 0 deletions cache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This directory is used for cache of deps of dockerfiles used for
# Some custom builds done manually
*
!.gitignore
5 changes: 5 additions & 0 deletions scripts/arm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## ARM Prebuilt Binaries

Those are scripts to create prebuilt binaries for the addon on ARM architecture.

They were built to be run from Windows (hence the powershell script).
6 changes: 6 additions & 0 deletions scripts/arm/armv7.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM jonathancardoso/ci-arm32v7

# docker run --rm --name node-libcurl-arm32v7 -it -v E:\\jc\\node-libcurl:/home/circleci/node-libcurl -v /home/circleci/node-libcurl/node_modules/ -v E:\\jc\\.cache\\electron:/home/circleci/.cache/electron -v E:\\jc\\node-libcurl\\debug\\image-deps-arm32v7:/home/circleci/deps/ node-libcurl-arm32v7
# cd ~/node-libcurl && sudo chown circleci:circleci -R ./ && sudo chown circleci:circleci -R ~/.cache
# PUBLISH_BINARY=false GIT_TAG="" GIT_COMMIT="" TARGET_ARCH="armv7" ./scripts/ci/build.sh
ENTRYPOINT [ "/bin/bash" ]
29 changes: 29 additions & 0 deletions scripts/arm/publish-binary.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
param (
[ValidateSet('armv7')][string]$arch = "armv7",
[string]$libcurl = "7.64.1",
[string]$token = $env:GITHUB_RELEASE_TOKEN,
[string]$node = "10"
)

$currentDir = Get-Location
$imageName = "node-libcurl-$arch"

Write-Host $arch
Write-Host $token
Write-Host $currentDir
Write-Host $imageName

docker build -t $imageName -f "${currentDir}/scripts/arm/${arch}.dockerfile" .

docker run --rm --name $imageName -it `
-v "${currentDir}:/home/circleci/node-libcurl/" `
-v "/home/circleci/node-libcurl/node_modules/" `
-v "/home/circleci/node-libcurl/debug/" `
-v "${currentDir}/cache/image-deps-${arch}:/home/circleci/deps/" `
-e PUBLISH_BINARY=true `
-e TARGET_ARCH=$arch `
-e LIBCURL_RELEASE=$libcurl `
-e LATEST_LIBCURL_RELEASE=$libcurl `
--entrypoint "/bin/bash" `
$imageName `
-c "source ~/.bashrc && nvm use $node && ~/node-libcurl/scripts/arm/publish-binary.sh"
10 changes: 10 additions & 0 deletions scripts/arm/publish-binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

cd ~/node-libcurl

user=$(whoami)

# fix permissions for directories created when mounting volumes from Windows
sudo chown $user:$user -R ./ && sudo chown $user:$user -R ~/.cache

./scripts/ci/build.sh
6 changes: 4 additions & 2 deletions scripts/ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ ls -al $OPENLDAP_BUILD_FOLDER/lib
# Build libcurl
###################
LIBCURL_ORIGINAL_RELEASE=${LIBCURL_RELEASE:-LATEST}
LATEST_LIBCURL_RELEASE=$(./scripts/ci/get-latest-libcurl-version.sh)
LATEST_LIBCURL_RELEASE=${LATEST_LIBCURL_RELEASE:-$(./scripts/ci/get-latest-libcurl-version.sh)}
LIBCURL_RELEASE=$LIBCURL_ORIGINAL_RELEASE
if [[ $LIBCURL_RELEASE == "LATEST" ]]; then
LIBCURL_RELEASE=$LATEST_LIBCURL_RELEASE
Expand Down Expand Up @@ -289,6 +289,8 @@ else
fi

target=`echo $target | sed 's/^v//'`
# ia32, x64, armv7, etc
target_arch=${TARGET_ARCH:-"x64"}

# Build Addon
export npm_config_curl_config_bin="$LIBCURL_DEST_FOLDER/build/$LIBCURL_RELEASE/bin/curl-config"
Expand All @@ -297,7 +299,7 @@ export npm_config_build_from_source="true"
export npm_config_runtime="$runtime"
export npm_config_dist_url="$dist_url"
export npm_config_target="$target"
export npm_config_target_arch="x64"
export npm_config_target_arch="$target_arch"

yarn install --frozen-lockfile

Expand Down

0 comments on commit 15425f9

Please sign in to comment.