forked from fvarrui/universalJavaApplicationStub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request fvarrui#1 from maths22/native-code-script
Native code script
- Loading branch information
Showing
6 changed files
with
698 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build on push | ||
|
||
on: push | ||
|
||
jobs: | ||
compile: | ||
name: Compile the stubs | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install shc via HomeBrew | ||
run: | | ||
brew install shc | ||
shc -h | ||
- name: Compile universalJavaApplicationStub | ||
run: | | ||
echo "Running shc..." | ||
shc -r -f src/universalJavaApplicationStub | ||
- name: Build universalJavaApplicationStub x86_64 | ||
run: | | ||
echo "Running clang for universalJavaApplicationStub.x86_64" | ||
clang -o universalJavaApplicationStub.x86_64 -target x86_64-apple-macos10.10 src/universalJavaApplicationStub.x.c | ||
strip universalJavaApplicationStub.x86_64 | ||
- name: Build universalJavaApplicationStub arm64 | ||
run: | | ||
echo "Running clang for universalJavaApplicationStub.arm64" | ||
clang -o universalJavaApplicationStub.arm64 -target arm64-apple-macos11 src/universalJavaApplicationStub.x.c | ||
strip universalJavaApplicationStub.arm64 | ||
- name: Build universal universalJavaApplicationStub | ||
run: | | ||
echo "Runnning lipo" | ||
lipo -create -output universalJavaApplicationStub universalJavaApplicationStub.x86_64 universalJavaApplicationStub.arm64 | ||
strip universalJavaApplicationStub | ||
chmod ug=rwx,o=rx universalJavaApplicationStub | ||
- name: Build nativeJavaApplicationStub | ||
run: | | ||
make universal | ||
- name: Archive production artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: universalJavaApplicationStub | ||
retention-days: 7 | ||
path: | | ||
./src/universalJavaApplicationStub | ||
./universalJavaApplicationStub.x86_64 | ||
./universalJavaApplicationStub.arm64 | ||
./universalJavaApplicationStub | ||
- name: Archive production artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: nativeJavaApplicationStub | ||
retention-days: 7 | ||
path: | | ||
./build/x86_64/nativeJavaApplicationStub | ||
./build/arm64/nativeJavaApplicationStub | ||
./build/universal/nativeJavaApplicationStub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
|
||
# shc compiler | ||
*.x | ||
*.x.c | ||
*.x.c | ||
|
||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
CC = clang | ||
|
||
CFLAGS = -Wall -Werror -g | ||
CFLAGS_ARM64 = -target arm64-apple-macos11 | ||
CFLAGS_X86_64 = -target x86_64-apple-macos10.12 | ||
LIBS = -lobjc -framework Foundation -framework AppKit | ||
INCLUDES = | ||
|
||
SRCS = src/nativeStub.m | ||
OBJS = $(SRCS:src/%.m=build/%.o) | ||
OBJS_ARM64 = $(SRCS:src/%.m=build/arm64/%.o) | ||
OBJS_X86_64 = $(SRCS:src/%.m=build/x86_64/%.o) | ||
|
||
# define the executable file | ||
APP_NAME = nativeJavaApplicationStub | ||
MAIN = build/$(APP_NAME) | ||
MAIN_ARM64 = build/arm64/$(APP_NAME) | ||
MAIN_X86_64 = build/x86_64/$(APP_NAME) | ||
MAIN_UNIVERSAL = build/universal/$(APP_NAME) | ||
|
||
.PHONY: depend clean | ||
|
||
default: $(MAIN) | ||
universal: $(MAIN_UNIVERSAL) | ||
|
||
$(MAIN): $(OBJS) | ||
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $^ $(LFLAGS) $(LIBS) | ||
|
||
$(MAIN_ARM64): $(OBJS_ARM64) | ||
$(CC) $(CFLAGS) $(CFLAGS_ARM64) $(INCLUDES) -o $@ $^ $(LFLAGS) $(LIBS) | ||
|
||
$(MAIN_X86_64): $(OBJS_X86_64) | ||
$(CC) $(CFLAGS) $(CFLAGS_X86_64) $(INCLUDES) -o $@ $^ $(LFLAGS) $(LIBS) | ||
|
||
$(MAIN_UNIVERSAL): $(MAIN_ARM64) $(MAIN_X86_64) | ||
@mkdir -p build/universal | ||
lipo -create -output $@ $^ | ||
|
||
build/%.o: src/%.m | ||
@mkdir -p build | ||
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ | ||
|
||
build/arm64/%.o: src/%.m | ||
@mkdir -p build/arm64 | ||
$(CC) $(CFLAGS) $(INCLUDES) $(CFLAGS_ARM64) -c $< -o $@ | ||
|
||
build/x86_64/%.o: src/%.m | ||
@mkdir -p build/x86_64 | ||
$(CC) $(CFLAGS) $(INCLUDES) $(CFLAGS_X86_64) -c $< -o $@ | ||
|
||
clean: | ||
rm -rf build/ | ||
|
||
depend: $(SRCS) | ||
makedepend $(INCLUDES) $^ | ||
|
||
# DO NOT DELETE THIS LINE -- make depend needs it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
@interface JVMMetadata : NSObject | ||
@property(strong) NSString *path; | ||
@property(strong) NSString *version; | ||
@end | ||
|
||
NSString *resolvePlaceholders(NSString *src, NSString *javaFolder); | ||
NSString *execute(NSString *command, NSArray *args); | ||
NSString *fetchJavaVersion(NSString *path); | ||
NSString *normalizeJavaVersion(NSString *version); | ||
BOOL isValidRequirement(NSString *version); | ||
BOOL versionMeetsConstraint(NSString *version, NSString *constraint, BOOL hasMax); | ||
BOOL versionMeetsMaxConstraint(NSString *version, NSString *constraint); | ||
|
Oops, something went wrong.