Skip to content

Commit 282bbc0

Browse files
Merge pull request #8408 from matthiasblaesing/enhance_launcher
Enhance launcher
2 parents d77e0b1 + d30154c commit 282bbc0

File tree

15 files changed

+164
-87
lines changed

15 files changed

+164
-87
lines changed

harness/apisupport.harness/release/etc/app.conf

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,23 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
# ${HOME} will be replaced by user home directory according to platform.
1918
#
2019
# Default locations of userdir and cachedir:
2120
# (http://wiki.netbeans.org/FaqWhatIsUserdir)
2221
#
22+
# The following variables can be used for these options:
23+
# - default_userdir
24+
# - default_cachedir
25+
# - default_options
26+
# - jdkhome
27+
#
2328
# On Windows ${DEFAULT_USERDIR_ROOT} will be replaced by the launcher
24-
# with <AppData>\<AppName>, where <AppData> is the value of
25-
# "AppData" key in Windows Registry under
29+
# with "<AppData>\<AppName>", where <AppData> is users value of "AppData" key
30+
# in Windows Registry under
2631
# "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
2732
# and ${DEFAULT_CACHEDIR_ROOT} will be replaced by the launcher
2833
# with the value of "<LocalAppData>\<AppName>\Cache" where "LocalAppData"
29-
# is a key in Windows Registry under
34+
# is a key in Windows Registry under
3035
# "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders".
3136
# <AppName> is the the executable's filename without the extension.
3237
#
@@ -36,22 +41,21 @@
3641
# where <AppName> is the launcher script's name.
3742
#
3843
# On other systems ${DEFAULT_USERDIR_ROOT} will be replaced by the launcher
39-
# with "${HOME}/.<AppName>" and ${DEFAULT_CACHEDIR_ROOT} with
44+
# with "${HOME}/.<AppName>" and ${DEFAULT_CACHEDIR_ROOT} with
4045
# "${HOME}/.cache/<AppName>".
4146
#
4247
# You can also use ${HOME} variable which will be replaced with
4348
# user.home JVM system property value.
4449
#
45-
# The above location variables are valid only in the default_userdir and
46-
# default_cachedir properties.
47-
#
4850
# NOTE: If you specify a non-default userdir path on command line
4951
# (--userdir option) and don't specify a cachedir path (--cachedir option),
5052
# cachedir will be in "<userdir>/var/cache".
5153
#
5254
# Cachedir must be different from userdir. The same cachedir and userdir
5355
# would cause problems.
5456
#
57+
# ${BASEDIR} is replaced with the base directory of the NetBeans installation
58+
#
5559

5660
default_userdir="${DEFAULT_USERDIR_ROOT}/dev"
5761
default_cachedir="${DEFAULT_CACHEDIR_ROOT}/dev"

harness/apisupport.harness/release/launchers/app.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ while [ -h "$PRG" ]; do
3434
done
3535

3636
progdir=`dirname "$PRG"`
37+
old=`pwd`
38+
cd "$progdir"/..
39+
basedir=`pwd`
40+
cd "$old"
41+
3742
APPNAME=`basename "$PRG"`
3843
if [ -z "$APP_DOCK_NAME" ] ; then
3944
APP_DOCK_NAME="$APPNAME"
@@ -52,8 +57,11 @@ case "`uname`" in
5257
;;
5358
esac
5459

55-
if [ -f "$progdir/../etc/$APPNAME".conf ] ; then
56-
. "$progdir/../etc/$APPNAME".conf
60+
# $HOME can be used as it is present on mac OS and linux
61+
BASEDIR=$basedir
62+
63+
if [ -f "$basedir/etc/$APPNAME".conf ] ; then
64+
. "$basedir/etc/$APPNAME".conf
5765
fi
5866

5967
# XXX does not correctly deal with spaces in non-userdir params

harness/apisupport.harness/windows-launcher-src/app.exe.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
-->
2222
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
23-
<assemblyIdentity version="101.1.0.0"
23+
<assemblyIdentity version="101.3.0.0"
2424
processorArchitecture="x86"
2525
name="app.exe"
2626
type="win32"/>

nb/ide.launcher/netbeans.conf

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
1718
#
1819
# Default locations of userdir and cachedir:
1920
# (http://wiki.netbeans.org/FaqWhatIsUserdir)
2021
#
22+
# The following variables can be used for these options:
23+
# - netbeans_default_userdir
24+
# - netbeans_default_cachedir
25+
# - netbeans_default_options
26+
# - netbeans_jdkhome
27+
#
2128
# On Windows ${DEFAULT_USERDIR_ROOT} will be replaced by the launcher
22-
# with "<AppData>\NetBeans" where <AppData> is user's
23-
# value of "AppData" key in Windows Registry under
29+
# with "<AppData>\NetBeans", where <AppData> is users value of "AppData" key
30+
# in Windows Registry under
2431
# "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
2532
# and ${DEFAULT_CACHEDIR_ROOT} will be replaced by the launcher
2633
# with "<Local AppData>\NetBeans\Cache" where <Local AppData> is user's
@@ -32,11 +39,11 @@
3239
# ${DEFAULT_CACHEDIR_ROOT} with "~/Library/Caches/NetBeans"
3340
#
3441
# On other systems ${DEFAULT_USERDIR_ROOT} will be replaced by the launcher
35-
# with "~/.netbeans" and ${DEFAULT_CACHEDIR_ROOT} with "~/.cache/netbeans"
42+
# with "${HOME}/.netbeans" and ${DEFAULT_CACHEDIR_ROOT} with
43+
# "${HOME}/.cache/netbeans".
3644
#
3745
# You can also use ${HOME} variable which will be replaced with
38-
# user.home JVM system property value. This variable is valid only in
39-
# netbeans_default_userdir and netbeans_default_cachedir properties.
46+
# user.home JVM system property value.
4047
#
4148
# NOTE: If you specify a non-default userdir path on command line
4249
# (--userdir option) and don't specify a cachedir path (--cachedir option),
@@ -45,6 +52,9 @@
4552
# Cachedir must be different from userdir. The same cachedir and userdir
4653
# would cause problems.
4754
#
55+
# ${BASEDIR} is replaced with the base directory of the NetBeans installation
56+
#
57+
4858
netbeans_default_userdir="${DEFAULT_USERDIR_ROOT}/@@metabuild.RawVersion@@"
4959
netbeans_default_cachedir="${DEFAULT_CACHEDIR_ROOT}/@@metabuild.RawVersion@@"
5060

nb/ide.launcher/unix/netbeans

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ case "`uname`" in
5151
;;
5252
esac
5353

54+
# $HOME can be used as it is present on mac OS and
55+
BASEDIR=$basedir
5456

5557
if [ -f "$basedir"/etc/netbeans.conf ] ; then
5658
. "$basedir"/etc/netbeans.conf

nb/ide.launcher/windows/nblauncher.cpp

Lines changed: 59 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const char *NbLauncher::ENV_USER_PROFILE = "USERPROFILE";
4343
const char *NbLauncher::HOME_TOKEN = "${HOME}";
4444
const char *NbLauncher::DEFAULT_USERDIR_ROOT_TOKEN = "${DEFAULT_USERDIR_ROOT}";
4545
const char *NbLauncher::DEFAULT_CACHEDIR_ROOT_TOKEN = "${DEFAULT_CACHEDIR_ROOT}";
46+
const char *NbLauncher::BASEDIR_TOKEN = "${BASEDIR}";
4647
const char *NbLauncher::NETBEANS_DIRECTORY = "\\NetBeans\\";
4748
const char *NbLauncher::NETBEANS_CACHES_DIRECTORY = "\\NetBeans\\Cache\\";
4849

@@ -214,6 +215,11 @@ bool NbLauncher::initBaseNames() {
214215
baseDir = path;
215216

216217
logMsg("Base dir: %s", baseDir.c_str());
218+
219+
getDefaultUserDirRoot();
220+
getDefaultCacheDirRoot();
221+
getUserHome();
222+
217223
return true;
218224
}
219225

@@ -365,83 +371,77 @@ bool NbLauncher::parseArgs(int argc, char *argv[]) {
365371
}
366372

367373
bool NbLauncher::findUserDir(const char *str) {
368-
logMsg("NbLauncher::findUserDir()");
369-
if (strncmp(str, HOME_TOKEN, strlen(HOME_TOKEN)) == 0) {
370-
if (userHome.empty()) {
371-
char *userProfile = getenv(ENV_USER_PROFILE);
372-
if (userProfile) {
373-
userHome = userProfile;
374-
} else {
375-
TCHAR userHomeChar[MAX_PATH];
376-
if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, userHomeChar))) {
377-
return false;
378-
}
379-
userHome = userHomeChar;
380-
userHome.erase(userHome.rfind('\\'));
381-
}
382-
logMsg("User home: %s", userHome.c_str());
383-
}
384-
userDir = userHome + (str + strlen(HOME_TOKEN));
385-
} else if (strncmp(str, DEFAULT_USERDIR_ROOT_TOKEN, strlen(DEFAULT_USERDIR_ROOT_TOKEN)) == 0) {
386-
std::string s = std::string("Replacing ") + DEFAULT_USERDIR_ROOT_TOKEN;
387-
logMsg(s.c_str());
388-
userDir = getDefaultUserDirRoot() + (str + strlen(DEFAULT_USERDIR_ROOT_TOKEN));
389-
} else {
390-
getDefaultUserDirRoot();
391-
userDir = str;
392-
}
374+
logMsg("NbLauncher::findUserDir(%s)", str);
375+
userDir = str;
376+
replaceToken(userDir);
377+
logMsg("NbLauncher::findUserDir: %s", userDir.c_str());
393378
return true;
394379
}
395380

396381
bool NbLauncher::findCacheDir(const char *str) {
397-
logMsg("NbLauncher::findCacheDir()");
398-
if (strncmp(str, HOME_TOKEN, strlen(HOME_TOKEN)) == 0) {
399-
if (userHome.empty()) {
400-
char *userProfile = getenv(ENV_USER_PROFILE);
401-
if (userProfile) {
402-
userHome = userProfile;
403-
} else {
404-
TCHAR userHomeChar[MAX_PATH];
405-
if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, userHomeChar))) {
406-
return false;
407-
}
408-
userHome = userHomeChar;
409-
userHome.erase(userHome.rfind('\\'));
410-
}
411-
logMsg("User home: %s", userHome.c_str());
412-
}
413-
cacheDir = userHome + (str + strlen(HOME_TOKEN));
414-
} else if (strncmp(str, DEFAULT_CACHEDIR_ROOT_TOKEN, strlen(DEFAULT_CACHEDIR_ROOT_TOKEN)) == 0) {
415-
std::string s = std::string("Replacing ") + DEFAULT_CACHEDIR_ROOT_TOKEN;
416-
logMsg(s.c_str());
417-
cacheDir = getDefaultCacheDirRoot() + (str + strlen(DEFAULT_CACHEDIR_ROOT_TOKEN));
418-
} else {
419-
getDefaultCacheDirRoot();
420-
cacheDir = str;
421-
}
382+
logMsg("NbLauncher::findCacheDir(%s)", str);
383+
cacheDir = str;
384+
replaceToken(cacheDir);
385+
logMsg("NbLauncher::findCacheDir: %s", cacheDir.c_str());
422386
return true;
423387
}
424388

425-
string NbLauncher::getDefaultUserDirRoot() {
389+
void NbLauncher::replaceToken(std::string& str) {
390+
// Replace the allowed tokens in configuration options
391+
replaceString(str, HOME_TOKEN, userHome);
392+
replaceString(str, DEFAULT_CACHEDIR_ROOT_TOKEN, defCacheDirRoot);
393+
replaceString(str, DEFAULT_USERDIR_ROOT_TOKEN, defUserDirRoot);
394+
replaceString(str, BASEDIR_TOKEN, baseDir);
395+
}
396+
397+
void NbLauncher::replaceString(std::string& str, const std::string& from, const std::string& to) {
398+
if(from.empty()) {
399+
return;
400+
}
401+
// Loop over all occurrences of the search string in the input string and
402+
// replace them all
403+
size_t start_pos = 0;
404+
while((start_pos = str.find(from, start_pos)) != std::string::npos) {
405+
str.replace(start_pos, from.length(), to);
406+
// Skip over the replacement
407+
start_pos += to.length();
408+
}
409+
}
410+
411+
void NbLauncher::getDefaultUserDirRoot() {
426412
TCHAR defUserDirRootChar[MAX_PATH];
427413
if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, defUserDirRootChar))) {
428-
return std::string();
414+
defUserDirRoot = std::string();
429415
}
430416
defUserDirRoot = constructApplicationDir((string) defUserDirRootChar, false);
431417
defUserDirRoot.erase(defUserDirRoot.rfind('\\'));
432418
logMsg("Default Userdir Root: %s", defUserDirRoot.c_str());
433-
return defUserDirRoot;
434419
}
435420

436-
string NbLauncher::getDefaultCacheDirRoot() {
421+
void NbLauncher::getDefaultCacheDirRoot() {
437422
TCHAR defCacheDirRootChar[MAX_PATH];
438423
if (FAILED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, defCacheDirRootChar))) {
439-
return std::string();
424+
defCacheDirRoot = std::string();
440425
}
441426
defCacheDirRoot = constructApplicationDir((string) defCacheDirRootChar, true);
442427
defCacheDirRoot.erase(defCacheDirRoot.rfind('\\'));
443428
logMsg("Default Cachedir Root: %s", defCacheDirRoot.c_str());
444-
return defCacheDirRoot;
429+
}
430+
431+
void NbLauncher::getUserHome() {
432+
char *userProfile = getenv(ENV_USER_PROFILE);
433+
if (userProfile) {
434+
userHome = userProfile;
435+
} else {
436+
TCHAR userHomeChar[MAX_PATH];
437+
if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, userHomeChar))) {
438+
defCacheDirRoot = std::string();
439+
userHome = std::string();
440+
}
441+
userHome = userHomeChar;
442+
userHome.erase(userHome.rfind('\\'));
443+
}
444+
logMsg("User home: %s", userHome.c_str());
445445
}
446446

447447
bool NbLauncher::getOption(char *&str, const char *opt) {
@@ -492,12 +492,15 @@ bool NbLauncher::parseConfigFile(const char* path) {
492492
}
493493
str[k] = '\0';
494494
nbOptions = str;
495+
replaceToken(nbOptions);
495496
logMsg("After replacement: %s", nbOptions.c_str());
496497

497498
} else if (getOption(str, getExtraClustersOptName())) {
498499
extraClusters = str;
499500
} else if (getOption(str, getJdkHomeOptName())) {
500501
jdkHome = str;
502+
replaceToken(jdkHome);
503+
logMsg("jdkHome: %s", jdkHome.c_str());
501504
}
502505
}
503506
bool ok = ferror(file) == 0;

nb/ide.launcher/windows/nblauncher.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class NbLauncher {
5050
static const char *REG_DEFAULT_USERDIR_ROOT;
5151
static const char *REG_DEFAULT_CACHEDIR_ROOT;
5252
static const char* staticOptions[];
53+
static const char *BASEDIR_TOKEN;
54+
static const char *USERDIR_TOKEN;
5355

5456
typedef int (*StartPlatform)(int argc, char *argv[]);
5557

@@ -82,8 +84,11 @@ class NbLauncher {
8284
bool getOption(char *&str, const char *opt);
8385
void addCluster(const char *cl);
8486
void addExtraClusters();
85-
std::string getDefaultUserDirRoot();
86-
std::string getDefaultCacheDirRoot();
87+
void getDefaultUserDirRoot();
88+
void getDefaultCacheDirRoot();
89+
void getUserHome();
90+
void replaceToken(std::string& str);
91+
void replaceString(std::string& str, const std::string& from, const std::string& to);
8792

8893
protected:
8994
std::string baseDir;

nb/ide.launcher/windows/netbeans.exe.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
-->
2222
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
23-
<assemblyIdentity version="101.2.0.0"
23+
<assemblyIdentity version="101.3.0.0"
2424
processorArchitecture="x86"
2525
name="netbeans.exe"
2626
type="win32"/>

nb/ide.launcher/windows/netbeans64.exe.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
2323
<!-- Use processorArchitecture="x86", which is the value used by the 64-bit
2424
javaw.exe on Java 10.0.2 and Java 11ea. -->
25-
<assemblyIdentity version="101.2.0.0"
25+
<assemblyIdentity version="101.3.0.0"
2626
processorArchitecture="x86"
2727
name="netbeans64.exe"
2828
type="win32"/>

nb/ide.launcher/windows/version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
#define COMPANY ""
2121
#define COMPONENT "Apache NetBeans IDE Launcher"
22-
#define VER "101.2.0.0"
23-
#define FVER 101,2,0,0
24-
#define BUILD_ID "101200"
22+
#define VER "101.3.0.0"
23+
#define FVER 101,3,0,0
24+
#define BUILD_ID "101300"
2525
#define INTERNAL_NAME "netbeans"
2626
#define COPYRIGHT "Based on Apache NetBeans from the Apache Software Foundation and is licensed under Apache License Version 2.0"
2727
#define NAME "Apache NetBeans IDE Launcher"

platform/o.n.bootstrap/launcher/windows/Makefile.mingw

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ nbexec64.res: nbexec.rc
3131
x86_64-w64-mingw32-windres -o$(TMPFLD)nbexec64.res -Ocoff nbexec.rc
3232

3333
nbexec64.dll: include/jni.h include/jni_types.h jvmlauncher.cpp nbexec.cpp platformlauncher.cpp utilsfuncs.cpp nbexec64.res
34-
x86_64-w64-mingw32-gcc -s -shared -m64 -o $(OFLD)nbexec64.dll -I include jvmlauncher.cpp nbexec.cpp platformlauncher.cpp utilsfuncs.cpp $(TMPFLD)nbexec64.res -Wl,--no-insert-timestamp -static -lstdc++ -static-libstdc++ -static-libgcc
34+
x86_64-w64-mingw32-gcc -s -shared -m64 -o $(OFLD)nbexec64.dll -I include jvmlauncher.cpp nbexec.cpp platformlauncher.cpp utilsfuncs.cpp $(TMPFLD)nbexec64.res -Wl,--no-insert-timestamp -static -lstdc++ -lshlwapi -static-libstdc++ -static-libgcc
3535

3636
nbexec_exe64.res: nbexec_exe.rc nbexec.exe.manifest
3737
x86_64-w64-mingw32-windres -o$(TMPFLD)nbexec_exe64.res -Ocoff -DMANIFEST_FILE=nbexec.exe.manifest nbexec_exe.rc
3838

3939
nbexec64.exe: nbexecexe.cpp utilsfuncs.cpp nbexec_exe64.res
40-
x86_64-w64-mingw32-gcc -s -DNBEXEC_DLL='"nbexec64.dll"' -DARCHITECTURE=64 -Wl,--nxcompat -Wl,--dynamicbase -Wl,--no-seh -Wl,--no-insert-timestamp -mwindows nbexecexe.cpp utilsfuncs.cpp $(TMPFLD)nbexec_exe64.res -o$(OFLD)nbexec64.exe -static -lstdc++ -static-libstdc++ -static-libgcc
40+
x86_64-w64-mingw32-gcc -s -DNBEXEC_DLL='"nbexec64.dll"' -DARCHITECTURE=64 -Wl,--nxcompat -Wl,--dynamicbase -Wl,--no-seh -Wl,--no-insert-timestamp -mwindows nbexecexe.cpp utilsfuncs.cpp $(TMPFLD)nbexec_exe64.res -o$(OFLD)nbexec64.exe -static -lstdc++ -lshlwapi -static-libstdc++ -static-libgcc
4141

4242
nbexec.res: nbexec.rc
4343
i686-w64-mingw32-windres -o$(TMPFLD)nbexec.res -Ocoff nbexec.rc
4444

4545
nbexec.dll: include/jni.h include/jni_types.h jvmlauncher.cpp nbexec.cpp platformlauncher.cpp utilsfuncs.cpp nbexec.res
46-
i686-w64-mingw32-gcc -s -shared -o $(OFLD)nbexec.dll -I include jvmlauncher.cpp nbexec.cpp platformlauncher.cpp utilsfuncs.cpp $(TMPFLD)nbexec.res -static -Wl,--no-insert-timestamp -lstdc++ -static-libstdc++ -static-libgcc
46+
i686-w64-mingw32-gcc -s -shared -o $(OFLD)nbexec.dll -I include jvmlauncher.cpp nbexec.cpp platformlauncher.cpp utilsfuncs.cpp $(TMPFLD)nbexec.res -static -Wl,--no-insert-timestamp -lstdc++ -lshlwapi -static-libstdc++ -static-libgcc
4747

4848
nbexec_exe.res: nbexec_exe.rc nbexec.exe.manifest
4949
i686-w64-mingw32-windres -o$(TMPFLD)nbexec_exe.res -Ocoff -DMANIFEST_FILE=nbexec.exe.manifest nbexec_exe.rc
5050

5151
nbexec.exe: nbexecexe.cpp utilsfuncs.cpp nbexec_exe.res
52-
i686-w64-mingw32-gcc -s -DNBEXEC_DLL='"nbexec.dll"' -DARCHITECTURE=32 -Wl,--nxcompat -Wl,--dynamicbase -Wl,--no-seh -Wl,--no-insert-timestamp -mwindows nbexecexe.cpp utilsfuncs.cpp $(TMPFLD)nbexec_exe.res -o$(OFLD)nbexec.exe -static -lstdc++ -static-libstdc++ -static-libgcc
52+
i686-w64-mingw32-gcc -s -DNBEXEC_DLL='"nbexec.dll"' -DARCHITECTURE=32 -Wl,--nxcompat -Wl,--dynamicbase -Wl,--no-seh -Wl,--no-insert-timestamp -mwindows nbexecexe.cpp utilsfuncs.cpp $(TMPFLD)nbexec_exe.res -o$(OFLD)nbexec.exe -static -lstdc++ -lshlwapi -static-libstdc++ -static-libgcc

0 commit comments

Comments
 (0)