Compile For ARM
Some checks failed
ScriptCraft/pipeline/head There was a failure building this commit
Some checks failed
ScriptCraft/pipeline/head There was a failure building this commit
This commit is contained in:
parent
8fd4fdd51e
commit
35e1157df9
@ -1,4 +1,9 @@
|
||||
FROM alpine:latest
|
||||
FROM ubuntu:bionic
|
||||
|
||||
RUN apt-get update && apt-get install --no-install-recommends -y curl openjdk-11-jdk-headless cmake make gcc gcc-multilib-i686-linux-gnu gcc-multilib-arm-linux-gnueabihf gcc-aarch64-linux-gnu clang lld mingw-w64 lsb-release
|
||||
|
||||
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install --no-install-recommends -y nodejs
|
||||
|
||||
RUN apt-get clean
|
||||
|
||||
RUN apk add --no-cache curl openjdk8 npm cmake make clang binutils mingw-w64-gcc
|
||||
RUN npm install -g typescript typedoc
|
24
build.gradle
24
build.gradle
@ -10,20 +10,25 @@ class JNIPlatform {
|
||||
String[] cmakeArgs
|
||||
String libExtension
|
||||
|
||||
JNIPlatform(String name, String[] cmakeArgs, String libExtension) {
|
||||
JNIPlatform(String name, String libExtension, File rootDir) {
|
||||
this.name = name
|
||||
this.cmakeArgs = cmakeArgs
|
||||
this.cmakeArgs = ["-DCMAKE_TOOLCHAIN_FILE=${rootDir.absolutePath}/cmake/${name}-toolchain.cmake"] as String[]
|
||||
this.libExtension = libExtension
|
||||
}
|
||||
}
|
||||
|
||||
JNIPlatform[] jniPlatforms = [
|
||||
new JNIPlatform("linux-x86_64", [] as String[], ".so"),
|
||||
new JNIPlatform("linux-i686", ["-DCMAKE_TOOLCHAIN_FILE=${rootDir.absolutePath}/cmake/linux_i686_toolchain.cmake"] as String[], ".so"),
|
||||
new JNIPlatform("windows-x86_64", ["-DCMAKE_TOOLCHAIN_FILE=${rootDir.absolutePath}/cmake/windows_x86_64_toolchain.cmake"] as String[], ".dll"),
|
||||
new JNIPlatform("windows-i686", ["-DCMAKE_TOOLCHAIN_FILE=${rootDir.absolutePath}/cmake/windows_i686_toolchain.cmake"] as String[], ".dll")
|
||||
new JNIPlatform("linux-x86_64", ".so", rootDir),
|
||||
new JNIPlatform("linux-x86", ".so", rootDir),
|
||||
new JNIPlatform("linux-armhf", ".so", rootDir),
|
||||
new JNIPlatform("linux-arm64", ".so", rootDir),
|
||||
new JNIPlatform("windows-x86_64", ".dll", rootDir),
|
||||
new JNIPlatform("windows-x86", ".dll", rootDir)
|
||||
]
|
||||
|
||||
task cleanJNI {}
|
||||
task compileJNI {}
|
||||
|
||||
for (JNIPlatform platform : jniPlatforms) {
|
||||
def buildDir = new File(cDir, "build-${platform.name}")
|
||||
if (!buildDir.exists()) {
|
||||
@ -45,15 +50,18 @@ for (JNIPlatform platform : jniPlatforms) {
|
||||
dependsOn tasks.getByName("cmake-${platform.name}")
|
||||
}
|
||||
|
||||
processResources.dependsOn tasks.getByName("compileJNI-${platform.name}")
|
||||
compileJNI.dependsOn tasks.getByName("compileJNI-${platform.name}")
|
||||
|
||||
tasks.create(name: "cleanJNI-${platform.name}", type: Delete) {
|
||||
delete buildDir.absolutePath
|
||||
}
|
||||
|
||||
clean.dependsOn tasks.getByName("cleanJNI-${platform.name}")
|
||||
cleanJNI.dependsOn tasks.getByName("cleanJNI-${platform.name}")
|
||||
}
|
||||
|
||||
clean.dependsOn cleanJNI
|
||||
processResources.dependsOn compileJNI
|
||||
|
||||
compileJava {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
12
cmake/linux-arm64-toolchain.cmake
Normal file
12
cmake/linux-arm64-toolchain.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||
|
||||
set(BUILD_TARGET "aarch64-linux-gnu")
|
||||
|
||||
set(CMAKE_SYSROOT "/usr/${BUILD_TARGET}")
|
||||
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
|
||||
add_compile_options(-target ${BUILD_TARGET})
|
||||
|
||||
add_link_options(-fuse-ld=lld -target ${BUILD_TARGET})
|
12
cmake/linux-armhf-toolchain.cmake
Normal file
12
cmake/linux-armhf-toolchain.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
set(BUILD_TARGET "arm-linux-gnueabihf")
|
||||
|
||||
set(CMAKE_SYSROOT "/usr/${BUILD_TARGET}")
|
||||
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
|
||||
add_compile_options(-target ${BUILD_TARGET})
|
||||
|
||||
add_link_options(-fuse-ld=lld -target ${BUILD_TARGET})
|
12
cmake/linux-x86-toolchain.cmake
Normal file
12
cmake/linux-x86-toolchain.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR i686)
|
||||
|
||||
set(BUILD_TARGET "i686-linux-gnu")
|
||||
|
||||
set(CMAKE_SYSROOT "/usr/${BUILD_TARGET}")
|
||||
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
|
||||
add_compile_options(-target ${BUILD_TARGET})
|
||||
|
||||
add_link_options(-fuse-ld=lld -target ${BUILD_TARGET})
|
10
cmake/linux-x86_64-toolchain.cmake
Normal file
10
cmake/linux-x86_64-toolchain.cmake
Normal file
@ -0,0 +1,10 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
|
||||
message(FATAL_ERROR "Host System is not x86_64")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
|
||||
add_link_options(-fuse-ld=lld)
|
@ -1,7 +0,0 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR i686)
|
||||
|
||||
set(CMAKE_C_FLAGS "-m32 -march=i686")
|
||||
set(CMAKE_CXX_FLAGS "-m32 -march=i686")
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-m32 -march=i686")
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(scriptcraft C)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast")
|
||||
add_compile_options(-Wall -Werror -Wno-implicit-int-float-conversion -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-sign-compare -Wno-missing-field-initializers -Wundef -Wuninitialized -Wunused -Wno-unused-parameter -Wwrite-strings -Wchar-subscripts -funsigned-char)
|
||||
|
||||
add_library(
|
||||
scriptcraft
|
||||
|
@ -11,13 +11,13 @@
|
||||
|
||||
static JavaVM *jvm;
|
||||
|
||||
static void *get_pointer(JNIEnv *env, jobject obj, char *name) {
|
||||
static void *get_pointer(JNIEnv *env, jobject obj, const char *name) {
|
||||
jclass clazz = (*env)->FindClass(env, "com/thebrokenrail/scriptcraft/quickjs/QuickJS");
|
||||
jfieldID field = (*env)->GetFieldID(env, clazz, name, "J");
|
||||
return (void *) (long) (*env)->GetLongField(env, obj, field);
|
||||
}
|
||||
|
||||
static void set_pointer(JNIEnv *env, jobject obj, char *name, void *value) {
|
||||
static void set_pointer(JNIEnv *env, jobject obj, const char *name, void *value) {
|
||||
jclass clazz = (*env)->FindClass(env, "com/thebrokenrail/scriptcraft/quickjs/QuickJS");
|
||||
jfieldID field = (*env)->GetFieldID(env, clazz, name, "J");
|
||||
(*env)->SetLongField(env, obj, field, (jlong) (long) value);
|
||||
@ -163,7 +163,7 @@ static JSModuleDef *js_module_loader(JSContext *ctx, const char *module_name, vo
|
||||
return m;
|
||||
}
|
||||
|
||||
static void throw_exception(JNIEnv *env, char *message) {
|
||||
static void throw_exception(JNIEnv *env, const char *message) {
|
||||
jclass exception_clazz = (*env)->FindClass(env, "com/thebrokenrail/scriptcraft/quickjs/JSException");
|
||||
(*env)->ThrowNew(env, exception_clazz, message);
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ static JSValue js_print_internal(JSContext *ctx, JSValueConst this_val, int argc
|
||||
int i;
|
||||
char *out;
|
||||
if (prepend_throw) {
|
||||
out = "Throw: ";
|
||||
out = (char *) "Throw: ";
|
||||
} else {
|
||||
out = "";
|
||||
out = (char *) "";
|
||||
}
|
||||
const char *str;
|
||||
|
||||
@ -53,7 +53,7 @@ static JSValue js_assert(JSContext *ctx, JSValueConst this_val, int argc, JSValu
|
||||
}
|
||||
|
||||
if (!bool_val) {
|
||||
char *out = "Assertion failed";
|
||||
char *out = (char *) "Assertion failed";
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (i != 1) {
|
||||
asprintf(&out, "%s ", out);
|
||||
|
@ -21,14 +21,26 @@ public class OSUtil {
|
||||
String arch;
|
||||
switch (raw) {
|
||||
case "x86":
|
||||
case "i386":
|
||||
case "i686": {
|
||||
arch = "i686";
|
||||
arch = "x86";
|
||||
break;
|
||||
}
|
||||
case "amd64": {
|
||||
arch = "x86_64";
|
||||
break;
|
||||
}
|
||||
case "arm": {
|
||||
arch = "armhf";
|
||||
break;
|
||||
}
|
||||
case "aarch64_be":
|
||||
case "armv8b":
|
||||
case "armv8l":
|
||||
case "aarch64": {
|
||||
arch = "arm64";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
arch = "other";
|
||||
break;
|
||||
|
Reference in New Issue
Block a user