Skip to content

Commit

Permalink
Add Web profile (gluonhq#995)
Browse files Browse the repository at this point in the history
* Add Web Profile

* Remove debug file

* Extract files from META-INF/substrate/web

* Add nativerun goal

* Use release version of webscheduler

Co-authored-by: jose.pereda <[email protected]>
  • Loading branch information
José Pereda and jperedadnr authored Sep 2, 2021
1 parent 0a366f2 commit bd07ffb
Show file tree
Hide file tree
Showing 7 changed files with 558 additions and 4 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
implementation 'com.googlecode.plist:dd-plist:1.22'
implementation 'org.bouncycastle:bcpkix-jdk15on:1.49'
implementation 'org.graalvm.nativeimage:svm:21.1.0'
implementation 'org.apidesign.bck2brwsr:aot:0.51'

testImplementation gradleTestKit()
testImplementation "org.junit.jupiter:junit-jupiter-api:$jUnitVersion"
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/gluonhq/substrate/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class Constants {
public static final String VENDOR_APPLE = "apple";
public static final String VENDOR_LINUX = "linux";
public static final String VENDOR_MICROSOFT = "microsoft";
public static final String VENDOR_WEB = "web";

/**
* Triplet OS
Expand All @@ -57,6 +58,7 @@ public class Constants {
public static final String OS_LINUX = "linux";
public static final String OS_WINDOWS = "windows";
public static final String OS_ANDROID = "android";
public static final String OS_WEB = "web";

/**
* Predefined Profiles
Expand All @@ -68,7 +70,8 @@ public enum Profile {
WINDOWS, // (x86_64-windows-windows)
IOS, // (aarch64-apple-ios)
IOS_SIM, // (x86_64-apple-ios)
ANDROID // (aarch64-linux-android);
ANDROID, // (aarch64-linux-android);
WEB // (x86_64-web-web)
};

/**
Expand Down Expand Up @@ -100,6 +103,7 @@ public enum Profile {
public static final String PROFILE_IOS_SIM = "ios-sim";
public static final String PROFILE_ANDROID = "android";
public static final String PROFILE_LINUX_AARCH64 = "linux-aarch64";
public static final String PROFILE_WEB = "web";

public static final String DEFAULT_JAVA_STATIC_SDK_VERSION = "11-ea+10";
public static final String DEFAULT_JAVAFX_STATIC_SDK_VERSION = "17-ea+14";
Expand Down Expand Up @@ -150,6 +154,12 @@ public enum Profile {
public static final String ANDROID_NATIVE_FOLDER = "/native/android/";
public static final String ANDROID_PROJECT_NAME = "android_project";

public static final String META_INF_SUBSTRATE_WEB = "META-INF/substrate/web/";
public static final String WEB_NATIVE_FOLDER = "/native/web/";
public static final String WEB_AOT_CLASSIFIER = "bck2brwsr";
public static final String WEB_AOT_VERSION = "0.51";
public static final String WEB_INDEX_HTML = "index.html";

public static final String META_INF_SUBSTRATE_CONFIG = "META-INF/substrate/config/";
public static final String USER_INIT_BUILD_TIME_FILE = "initbuildtime";
public static final String USER_INIT_BUILD_TIME_ARCHOS_FILE = "initbuildtime-${archOs}";
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/gluonhq/substrate/SubstrateDispatcher.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Gluon
* Copyright (c) 2019, 2021, Gluon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -35,6 +35,7 @@
import com.gluonhq.substrate.target.IosTargetConfiguration;
import com.gluonhq.substrate.target.LinuxTargetConfiguration;
import com.gluonhq.substrate.target.TargetConfiguration;
import com.gluonhq.substrate.target.WebTargetConfiguration;
import com.gluonhq.substrate.target.WindowsTargetConfiguration;
import com.gluonhq.substrate.util.Logger;
import com.gluonhq.substrate.util.ProcessRunner;
Expand Down Expand Up @@ -385,7 +386,7 @@ public SubstrateDispatcher(Path buildRoot, ProjectConfiguration config) throws I
}

private TargetConfiguration getTargetConfiguration(Triplet targetTriplet) throws IOException {
if (!config.getHostTriplet().canCompileTo(targetTriplet)) {
if (!Constants.OS_WEB.equals(targetTriplet.getOs()) && !config.getHostTriplet().canCompileTo(targetTriplet)) {
throw new IllegalArgumentException("We currently can't compile to " + targetTriplet + " when running on " + config.getHostTriplet());
}
switch (targetTriplet.getOs()) {
Expand All @@ -394,6 +395,7 @@ private TargetConfiguration getTargetConfiguration(Triplet targetTriplet) throws
case Constants.OS_WINDOWS: return new WindowsTargetConfiguration(paths, config);
case Constants.OS_IOS : return new IosTargetConfiguration(paths, config);
case Constants.OS_ANDROID: return new AndroidTargetConfiguration(paths, config);
case Constants.OS_WEB : return new WebTargetConfiguration(paths, config);
default : return null;
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/gluonhq/substrate/model/Triplet.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Gluon
* Copyright (c) 2019, 2021, Gluon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -125,6 +125,11 @@ public Triplet(Constants.Profile profile) {
this.vendor = VENDOR_LINUX;
this.os = OS_ANDROID;
break;
case WEB:
this.arch = ARCH_AMD64;
this.vendor = VENDOR_WEB;
this.os = OS_WEB;
break;
default:
throw new IllegalArgumentException("Triplet for profile "+profile+" is not supported yet");
}
Expand Down
Loading

0 comments on commit bd07ffb

Please sign in to comment.