Skip to content

Commit

Permalink
Merge pull request #6513 from neilcsmith-net/nativeexec-workflow
Browse files Browse the repository at this point in the history
Native Execution Binaries workflow and changes for macOS Arm.
  • Loading branch information
neilcsmith-net authored Oct 3, 2023
2 parents 7747055 + c525351 commit eb9e96d
Show file tree
Hide file tree
Showing 11 changed files with 346 additions and 11 deletions.
268 changes: 268 additions & 0 deletions .github/workflows/native-binary-build-dlight.nativeexecution.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# ----------------------
#
# This workflow builds the native binaries for dlight.nativeexecution.
#
# The following builds are made:
# - On a Linux X64 host :
# - Linux X64 binary
# - On a MacOS X64 host :
# - MacOS X64 binary
# - MacOS ARM64 binary
# - On a Windows Server X64 host (TODO) :
# - Windows X64 binary
#
# ..meaning we build 32-bit binaries on 64-bit hosts.
#
# The result of the build are files 'nativeexecution-external-sources.zip'
# and 'nativeexecution-external-binaries.zip' which can be downloaded from
# the GitHub Actions UI and prepared for release to be used by the Ant build
# scripts for the NetBeans distribution.
#
# ----------------------


name: NetBeans Native Execution Libraries


on:
# Triggers the workflow on push or pull request events but only for
# relevant paths
push:
paths:
- .github/workflows/native-binary-build-dlight.nativeexecution.y*
- ide/dlight.nativeexecution/**

pull_request:
paths:
- .github/workflows/native-binary-build-dlight.nativeexecution.y*
- ide/dlight.nativeexecution/**

# Allows you to run this workflow manually from the Actions tab in GitHub UI
workflow_dispatch:

# cancel other PR workflow run in the same head-base group if it exists (e.g. during PR syncs)
# if this is not a PR run (no github.head_ref and github.base_ref defined), use an UID as group
concurrency:
group: dlight-${{ github.head_ref || github.run_id }}-${{ github.base_ref }}
cancel-in-progress: true

jobs:

source:

name: Build Source Zip
runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: false
show-progress: false

- name: Generate source bundle
run: |
SOURCES="ide/dlight.nativeexecution/build/sources"
mkdir -p ${SOURCES}/ide/dlight.nativeexecution
cp -r ide/dlight.nativeexecution/tools/ ${SOURCES}/ide/dlight.nativeexecution/
cp -r ide/dlight.nativeexecution/release/ ${SOURCES}/ide/dlight.nativeexecution/
cp LICENSE ${SOURCES}/LICENSE
cp NOTICE ${SOURCES}/NOTICE
ls -l -R ${SOURCES}
- name: Upload native sources
uses: actions/upload-artifact@v3
with:
name: nativeexecution-external-sources
path: ide/dlight.nativeexecution/build/sources/
if-no-files-found: error


build-linux:

name: Build on Linux
runs-on: ubuntu-latest
needs: source

steps:

- name: Download sources
uses: actions/download-artifact@v3
with:
name: nativeexecution-external-sources

- name: Build native lib (64-bit)
run: |
echo "Building 64-bit binary"
rm -rf ../release/bin/nativeexecution/Linux-x86_64/*
rm -rf buildall/*
chmod +x buildjob.sh
./buildjob.sh Linux x86_64
ls -l -R buildall/
echo "done"
working-directory: ide/dlight.nativeexecution/tools

- name: Upload artifact Linux 64 bit
uses: actions/upload-artifact@v3
with:
name: Linux-x86_64
path: ide/dlight.nativeexecution/tools/buildall/
if-no-files-found: error



# TODO : configure cygwin
# build-windows:
#
# name: Build on Windows
# runs-on: windows-latest
# needs: source
#
# steps:
#
# - name: Download sources
# uses: actions/download-artifact@v3
# with:
# name: nativeexecution-external-sources
#
# - name: Build native lib (64-bit)
# run: |
# echo "Building 64-bit binary"
# rm -f ../release/bin/nativeexecution/Windows-x86_64/*
# sh ./buildall.sh
# ls -l -R ../release/bin/nativeexecution/Windows-x86_64
# echo "done"
# shell: bash
# working-directory: ide/dlight.nativeexecution/tools
# - name: Upload artifact Windows 64 bit
# uses: actions/upload-artifact@v3
# with:
# name: Windows-x86_64
# path: ide/dlight.nativeexecution/tools/buildall/
# if-no-files-found: error
#

build-macos-x64:

name: Build on MacOS x86_64
runs-on: macos-latest
needs: source

steps:

- name: Download sources
uses: actions/download-artifact@v3
with:
name: nativeexecution-external-sources

- name: Build native lib (x86_64)
run: |
rm -rf ../release/bin/nativeexecution/Linux-MacOSX*/*
rm -rf buildall/*
chmod +x buildjob.sh
./buildjob.sh MacOSX x86_64
ls -l -R buildall/
working-directory: ide/dlight.nativeexecution/tools

- name: Upload artifact macOS x86_64
uses: actions/upload-artifact@v3
with:
name: MacOSX-x86_64
path: ide/dlight.nativeexecution/tools/buildall/
if-no-files-found: error

build-macos-arm:

name: Build on MacOS arm64
runs-on: macos-latest
needs: source

steps:

- name: Download sources
uses: actions/download-artifact@v3
with:
name: nativeexecution-external-sources

- name: Build native lib (arm64)
run: |
rm -rf ../release/bin/nativeexecution/Linux-MacOSX*/*
rm -rf buildall/*
chmod +x buildjob.sh
./buildjob.sh MacOSX arm
ls -l -R buildall/
working-directory: ide/dlight.nativeexecution/tools

- name: Upload artifact macOS arm64
uses: actions/upload-artifact@v3
with:
name: MacOSX-arm_64
path: ide/dlight.nativeexecution/tools/buildall/
if-no-files-found: error


build-zip-with-build-artifacts:

name: Package Native Execution Libraries
runs-on: ubuntu-latest

# Only run when the platform specific builds are finished
needs: [build-linux, build-macos-x64, build-macos-arm]

steps:

- name: Create dir structure
run: mkdir -p myfiles/

- name: Download artifacts from predecessor jobs
uses: actions/download-artifact@v3
with:
path: myfiles/

- name: Tidy up and display artifacts
run: |
rm -rf myfiles/*sources*
ls -l -R
- name: Create BUILDINFO
run: |
BUILDINFO="myfiles/BUILDINFO.txt"
touch "$BUILDINFO"
echo "Apache NetBeans" >> "$BUILDINFO"
echo "" >> "$BUILDINFO"
echo "Binaries in this ZIP are..." >> "$BUILDINFO"
echo "Build by GitHub Actions Workflow: ${GITHUB_WORKFLOW}" >> "$BUILDINFO"
echo "" >> "$BUILDINFO"
echo "Build from:" >> "$BUILDINFO"
echo " Git repo : ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" >> "$BUILDINFO"
echo " Git commit SHA : ${GITHUB_SHA}" >> "$BUILDINFO"
echo " Git ref : ${GITHUB_REF}" >> "$BUILDINFO"
echo "" >> "$BUILDINFO"
echo "Build time UTC : $(date --rfc-3339=seconds --utc)" >> "$BUILDINFO"
echo "" >> "$BUILDINFO"
- name: Upload bundle
uses: actions/upload-artifact@v3
with:
name: nativeexecution-external-binaries
path: myfiles/
if-no-files-found: error
4 changes: 4 additions & 0 deletions ide/dlight.nativeexecution/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
buildall/
build/
dist/
release/bin/nativeexecution/*/*
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ CPUFAMILY=`(echo ${CPUTYPE} | egrep "^i|x86_64|athlon|Intel" >/dev/null && echo
if [ "${CPUFAMILY}" = "sparc64" ]; then
CPUFAMILY="sparc"
fi
# New check if ARM64 then return ARM so Java code will stop returning “UNKNOWN”
if [ "${CPUFAMILY}" = "arm64" ]; then
CPUFAMILY="arm"
fi

USERDIRBASE=${HOME}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static CpuFamily toCpuFamily(String cpuFamilyStr) {
try {
return CpuFamily.valueOf(cpuFamilyStr.toUpperCase()); // NOI18N
} catch (IllegalArgumentException ex) {
if (cpuFamilyStr.startsWith("armv")) { //NOI18N
if (cpuFamilyStr.startsWith("arm")) { //NOI18N
return CpuFamily.ARM;
}
return CpuFamily.UNKNOWN;
Expand Down
4 changes: 2 additions & 2 deletions ide/dlight.nativeexecution/tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ CF_Linux-x86_64 = -DLINUX -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -m64
CF_Linux-sparc_64 = -DLINUX -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -m64
CF_Linux-arm = -DLINUX -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -std=c99
CF_Linux-aarch64 = -DLINUX -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -std=c99
CF_MacOSX-x86 = -DMAXOSX -D_DARWIN_C_SOURCE -m32
CF_MacOSX-x86_64 = -DMAXOSX -D_DARWIN_C_SOURCE -m64
CF_MacOSX-arm = -DMAXOSX -D_DARWIN_C_SOURCE -target arm64-apple-macos
CF_MacOSX-x86_64 = -DMAXOSX -D_DARWIN_C_SOURCE -target x86_64-apple-macos
CF_SunOS-sparc_64 = -DSOLARIS -D__EXTENSIONS__ -m64
CF_SunOS-x86 = -DSOLARIS -m32
CF_SunOS-x86_64 = -DSOLARIS -m64
Expand Down
2 changes: 1 addition & 1 deletion ide/dlight.nativeexecution/tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ OSFAMILY=\${OSFAMILY:-\`test "\$OS" = "Linux" && echo Linux\`}
OSFAMILY=\${OSFAMILY:-\${OS}}
CPUFAMILY=\`echo \${CPUTYPE} | egrep "^i|x86_64|athlon|Intel" >/dev/null && echo x86\`
CPUFAMILY=\${CPUFAMILY:-\`echo \${CPUTYPE} | egrep "armv" > /dev/null && echo arm\`}
CPUFAMILY=\${CPUFAMILY:-\`echo \${CPUTYPE} | egrep "arm" > /dev/null && echo arm\`}
CPUFAMILY=\${CPUFAMILY:-\`echo \${CPUTYPE} | egrep "sparc" > /dev/null && echo sparc\`} # sparc or sparc64
CPUFAMILY=\${CPUFAMILY:-\${CPUTYPE}}
Expand Down
55 changes: 55 additions & 0 deletions ide/dlight.nativeexecution/tools/buildjob.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#! /bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

if [ -z $1 ]; then
echo "No platform specified"
exit 1
fi

if [ -z $2 ]; then
echo "No CPU specified"
exit 2
fi

OSFAMILY=$1
CPUFAMILY=$2
PLATFORM=${OSFAMILY}-${CPUFAMILY}

echo "Platform : ${PLATFORM}"

SOURCES=". pty killall unbuffer"

MAKE=`which gmake || which make`

for dir in $SOURCES; do
(
cd $dir
$MAKE CONF=${PLATFORM} OSFAMILY=${OSFAMILY}
cd -
)
done

build_all_dir="buildall"

mkdir -p "$build_all_dir"

find "../release/bin/nativeexecution/" "unbuffer/dist/" "pty/dist" "killall/dist" -not -name "*.sh" -type f -exec cp {} $build_all_dir \;

echo "================================================"
find "$build_all_dir" -exec file {} +

4 changes: 2 additions & 2 deletions ide/dlight.nativeexecution/tools/killall/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ EXEC=$(DIST_DIR)/$(PNAME)

CF_Linux-x86 = $(CF_COMMON) -DLINUX -m32
CF_Linux-arm = $(CF_COMMON) -DLINUX -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -std=c99
CF_MacOSX-x86 = $(CF_COMMON) -DMACOSX -D_DARWIN_C_SOURCE -m32
CF_SunOS-x86 = $(CF_COMMON) -DSOLARIS -D__EXTENSIONS__ -m32
CF_Windows-x86 = $(CF_COMMON) -DWINDOWS -m32

CF_Linux-x86_64 = $(CF_COMMON) -DLINUX -m64
CF_Linux-aarch64 = $(CF_COMMON) -DLINUX -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -std=c99
CF_Linux-sparc_64 = $(CF_COMMON) -DLINUX -D_GNU_SOURCE -D_XOPEN_SOURCE=700 -m64
CF_MacOSX-x86_64 = $(CF_COMMON) -DMACOSX -m64
CF_MacOSX-arm = $(CF_COMMON) -DMACOSX -target arm64-apple-macos
CF_MacOSX-x86_64 = $(CF_COMMON) -DMACOSX -target x86_64-apple-macos
CF_SunOS-sparc_64 = $(CF_COMMON) -DSOLARIS -D__EXTENSIONS__ -m64
CF_SunOS-x86_64 = $(CF_COMMON) -DSOLARIS -D__EXTENSIONS__ -m64
CF_Windows-x86_64 = $(CF_COMMON) -DWINDOWS -m32
Expand Down
4 changes: 4 additions & 0 deletions ide/dlight.nativeexecution/tools/process_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include <stropts.h>
#endif

#if defined(TIOCSCTTY)
#include <sys/ioctl.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Expand Down
Loading

0 comments on commit eb9e96d

Please sign in to comment.