Skip to content

Commit

Permalink
Setup ci build
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Sep 21, 2024
1 parent 16ff712 commit 68809c1
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 13,682 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
matrix-build:

strategy:
matrix:
java: [22]
os: ['ubuntu-latest']
runs-on: ${{ matrix.os }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-os-${{ matrix.os }}-java-${{ matrix.java }}
cancel-in-progress: true
name: "Build on ${{ matrix.os }} with Java ${{ matrix.java }}"
env:
DEFAULT_JAVA: 22
DEFAULT_OS: 'ubuntu-latest'
permissions:
contents: read

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
cache: gradle
distribution: temurin
java-version: ${{ matrix.java }}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Java ${{ matrix.java }}
run: ./gradlew build --info --warning-mode=all -PjavaVersion=${{ matrix.java }}
- name: Sonar analysis
if: ${{ env.DEFAULT_JAVA == matrix.java && env.DEFAULT_OS == matrix.os && env.SONAR_TOKEN != null }}
run: |
./gradlew sonarqube -Dsonar.token=$SONAR_TOKEN --info --warning-mode=all -PjavaVersion=${{ matrix.java }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Archive native lib
uses: actions/upload-artifact@v4
with:
name: native-lib-${{ matrix.os }}
path: build/lua-libs/
if-no-files-found: error
retention-days: 5

build:
needs: matrix-build
runs-on: ubuntu-latest
steps:
- run: echo "Build successful"

45 changes: 45 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "CodeQL"

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ['java']

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 22

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
69 changes: 53 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,27 @@ testing {
}
}

OperatingSystem currentOs = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem
task downloadJextract(type: DownloadTask) {
OperatingSystem currentOs = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem
def os = ""
if(currentOs.isMacOsX()){
os="macos"
} else if(currentOs.isLinux()) {
os="linux"
def getOs = {
if(currentOs.isMacOsX()) {
return "macos"
}
if(currentOs.isLinux()) {
return "linux"
}
throw new IllegalStateException("Unsupported operating system: ${currentOs}")
}
def getArch = {
def arch = System.getProperty("os.arch")
switch(arch) {
case "amd64":
return "x64"
default:
throw new IllegalStateException("Unsupported architecture: ${arch}")
}
}
def arch = "x64"
sourceUrl = "https://download.java.net/java/early_access/jextract/22/5/openjdk-22-jextract+5-33_${os}-${arch}_bin.tar.gz"
sourceUrl = "https://download.java.net/java/early_access/jextract/22/5/openjdk-22-jextract+5-33_${getOs()}-${getArch()}_bin.tar.gz"
target = file("${project.buildDir}/jextract.tar.gz")
}

Expand All @@ -56,27 +67,53 @@ task unpackJextract(type: Copy, dependsOn: [tasks.downloadJextract]) {
}

task buildLua(type: Exec) {
def luaSrc = "${projectDir}/lua"
def installDir = "${project.buildDir}/lua-install"
def getMakeGoal = {
if(currentOs.isLinux()) {
return "so"
}
if(currentOs.isMacOsX()) {
return "dylib"
}
throw new IllegalStateException("Unsupported operating system: ${currentOs}")
}
def luaSrc = "${projectDir}/lua/src"
def installDir = "${project.buildDir}/lua-libs"
workingDir luaSrc
commandLine 'make', 'all', 'install', "INSTALL_TOP=$installDir"
commandLine 'make', getMakeGoal()
inputs.dir(luaSrc)
outputs.dir(installDir)
doLast {
copy {
from luaSrc
into installDir
include "liblua.*"
}
}
}

task cleanLua(type: Exec) {
workingDir "${projectDir}/lua/src"
commandLine 'make', 'clean'
}

task generateNativeInterface(type: Exec, dependsOn: [tasks.buildLua, tasks.unpackJextract]) {
clean.dependsOn(tasks.cleanLua)

task generateNativeInterface(type: Exec, dependsOn: [tasks.unpackJextract]) {
def jextractBinary = "${tasks.unpackJextract.outputs.files[0]}/jextract-22/bin/jextract"
def installDir = tasks.buildLua.outputs.files[0]
def includeDir = "${project.rootDir}/lua/src"
def generatedSrc = "${project.buildDir}/generated/sources/jextract/"
commandLine jextractBinary,
'--include-dir', "$installDir/include",
'--include-dir', includeDir,
'--output', generatedSrc,
'--target-package', 'org.itsallcode.jlua.ffi',
'--library', 'lua',
'--header-class-name', 'Lua',
"$projectDir/lua/src/all_lua.h"
inputs.dir(installDir)
"$includeDir/all_lua.h"
inputs.dir(includeDir)
outputs.dir(generatedSrc)
doLast {

}
}

compileJava {
Expand Down
106 changes: 0 additions & 106 deletions lua/Makefile

This file was deleted.

6 changes: 0 additions & 6 deletions lua/README

This file was deleted.

Binary file removed lua/doc/OSIApproved_100X125.png
Binary file not shown.
Loading

0 comments on commit 68809c1

Please sign in to comment.