Skip to content

Commit

Permalink
Fixes for build scripts
Browse files Browse the repository at this point in the history
Since the build scripts will from now on be used in a CI/CD pipeline
they need to be strictly correct, not have bugs and not require manual
intervention. Therefore...

Fixes:
- The Windows build scripts did not incorporate Peter's fix, i.e. creating
  the 'config.h' file as a pre-cursor to the actual build.
  This is now fixed. (compare to build scripts for MacOS and Linux)
- The Windows build script did not include headers from '..\build'
  when compiling. They therefore did not work. This is now fixed.
  (this is a consequence of the JNI headers having been removed from
   source control in commit f395ace;
   the change was correctly implemented at the time in build scripts
   for Linux and MacOS but for some reason never in build scripts for
   Windows)
- The Windows build scripts will now stop on first error. (checks for
  exit code and abends immediately). The Linux and MacOS scripts do not
  need the same logic as such script can simply be executed with
  'bash -x <script>'.
- The content of the 'config.h' file is now echoed to the console
  as part of the build. This file is crucial to understand the fix
  for the bug reported in NETBEANS-1428.
- Since we will be creating 32-bit binaries on 64-bit platforms
  (because we can no longer find 32-bit hosts to build on):
  The Linux 32-bit script did not create a 32-bit binary for the
  'config' application, hence it produced an incorrect 'config.h' file.
- The Windows build scripts could not handle path names with spaces
  in them as is typical in Windows world. Hence the script did not
  work when executed from a GitHub Action workflow. This is now fixed.
  (too lazy to fix the same problem in the MacOS and Linux scripts;
   on those platforms the problem never manifests itself)
- MacOS script: was hardwired to use the installed JDK rather
  than using the JDK_HOME environment variable. This is now fixed.
- MacOS script: added comments and transparency about how the Universal
  Library mechanism works. (the result of the mechanism is that
  binaries for legacy platforms PowerPC and i386 architectures
  still exist in the bundle but do not receive bug fixes .. meaning
  they'll not as an example receive bug fix for NETBEANS-1428)
- The Windows build scripts used Unix line endings. Although Windows
  doesn't mind this when executing such script it has now been corrected.
  • Loading branch information
lbruun committed Jan 21, 2021
1 parent 05191e4 commit 504d66f
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 106 deletions.
6 changes: 5 additions & 1 deletion profiler/lib.profiler/native/scripts/buildnative-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ SOURCES="../src-jdk15/class_file_cache.c \
../src-jdk15/Stacks.c \
../src-jdk15/common_functions.c"
DEST="../../release/lib/deployed/jdk16/linux/"
cc $CPPFLAGS -o ../build/config ../src-jdk15/config.c && ../build/config > ../build/config.h
cc $CPPFLAGS -m32 -o ../build/config ../src-jdk15/config.c && ../build/config > ../build/config.h

echo "Content of config.h :"
cat ../build/config.h

cc $CFLAGS -o $DEST/libprofilerinterface.so \
$SOURCES
6 changes: 5 additions & 1 deletion profiler/lib.profiler/native/scripts/buildnative-linux64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ SOURCES="../src-jdk15/class_file_cache.c \
../src-jdk15/Stacks.c \
../src-jdk15/common_functions.c"
DEST="../../release/lib/deployed/jdk16/linux-amd64/"
cc $CPPFLAGS -o ../build/config ../src-jdk15/config.c && ../build/config > ../build/config.h
cc $CPPFLAGS -m64 -o ../build/config ../src-jdk15/config.c && ../build/config > ../build/config.h

echo "Content of config.h :"
cat ../build/config.h

cc $CFLAGS -o $DEST/libprofilerinterface.so \
$SOURCES
56 changes: 54 additions & 2 deletions profiler/lib.profiler/native/scripts/buildnative-mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@
# specific language governing permissions and limitations
# under the License.

jdk_home="$(/usr/libexec/java_home)"
if [ -z "$JDK_HOME" ]; then
jdk_home="$(/usr/libexec/java_home)"
else
echo "JDK_HOME variable was set prior to invoking this script. It will be used."
jdk_home="$JDK_HOME"
fi


echo "Value of jdk_home : $jdk_home"


CPPFLAGS="-I $jdk_home/include -I $jdk_home/include/darwin -I../build -DLINUX "
CFLAGS="$CPPFLAGS -mmacosx-version-min=10.4 -fpic -shared -O2"

Expand All @@ -33,8 +43,50 @@ SOURCES="../src-jdk15/class_file_cache.c \

DEST="../../release/lib/deployed/jdk16/mac/"

UNILIB="$DEST/libprofilerinterface.jnilib"

if [ ! -f "$UNILIB" ]; then
echo "Error: This script expects Universal Library $UNILIB to exist."
exit 1
fi


cc $CPPFLAGS ../src-jdk15/config.c -o ../build/config && ../build/config > ../build/config.h

echo "Content of config.h :"
cat ../build/config.h

cc $CFLAGS $SOURCES -o ../build/libprofilerinterface.x86_64.dylib

lipo $DEST/libprofilerinterface.jnilib -replace x86_64 ../build/libprofilerinterface.x86_64.dylib -output $DEST/libprofilerinterface.jnilib

# Now we have a library specific to 'x86_64'. However what we use in lib.profiler
# is a so-called Universal Library (one library file which contains embedded libraries for
# multiple architectures .. this is an Apple speciality .. also known as a 'fat library').
#
# At some point in the history of NetBeans someone has created a Universal Library file
# for the Profiler Interface which as of Jan 2021 contains libraries for the following platforms:
# ppc
# ppc64
# i386
# x86_64
# Nowadays, Jan 2021, only 'x86_64' is relevant. Apple has abandonned the PowerPC architecture.
# Coming up is the Apple Sillicon architecture which is named 'arm64' in short form. No attempt
# is made here to support that, yet.
#
# We re-use the existing Universal Library file and simply replace its contents but only
# for the 'x86_64' architecture. This means that libraries for other architectures will
# continue to exist in the bundle, albeit in the older form (meaning they'll not receive bug fixes)
#



# List architecture of the produced ".dylib" file
# (just to be sure .. we expect it to be 'x86_64')
lipo ../build/libprofilerinterface.x86_64.dylib -info

# List content of existing universal library
lipo "$UNILIB" -info

# Update the existing universal library so that the content for x86_64 is replaced
# with our recent build
lipo "$UNILIB" -replace x86_64 ../build/libprofilerinterface.x86_64.dylib -output "$UNILIB"
116 changes: 65 additions & 51 deletions profiler/lib.profiler/native/scripts/buildnative-windows-16.bat
Original file line number Diff line number Diff line change
@@ -1,52 +1,66 @@
rem Licensed to the Apache Software Foundation (ASF) under one
rem or more contributor license agreements. See the NOTICE file
rem distributed with this work for additional information
rem regarding copyright ownership. The ASF licenses this file
rem to you under the Apache License, Version 2.0 (the
rem "License"); you may not use this file except in compliance
rem with the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing,
rem software distributed under the License is distributed on an
rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
rem KIND, either express or implied. See the License for the
rem specific language governing permissions and limitations
rem under the License.

rem Edit the following line to set the JDK location (for JNI headers)
rem or leave if you have JDK_HOME set.
SET BUILD_JDK=%JDK_HOME%
rem Edit the following line to affect the deployment directory.
rem Should not need to be changed as JNI is compatible for all versions
rem after 1.6.
SET JDK_DEPLOY=jdk16
SET PLATFORM=windows

rem Do not alter below this line
SET BUILD_SRC_15=..\src-jdk15
SET BUILD_SRC=..\src
SET BUILD_DEPLOY=..\..\release\lib

mkdir %BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%

rc /Fo .\version.res %BUILD_SRC_15%\windows\version.rc

cl /I%BUILD_JDK%\include /I%BUILD_JDK%\include\win32 ^
%BUILD_SRC_15%\class_file_cache.c ^
%BUILD_SRC_15%\attach.c ^
%BUILD_SRC_15%\Classes.c ^
%BUILD_SRC_15%\HeapDump.c ^
%BUILD_SRC_15%\Timers.c ^
%BUILD_SRC_15%\GC.c ^
%BUILD_SRC_15%\Threads.c ^
%BUILD_SRC_15%\Stacks.c ^
%BUILD_SRC_15%\common_functions.c ^
version.res ^
/D WIN32 /D NDEBUG /LD /MD /O2 ^
/Fe:%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%\profilerinterface.dll ^
/Fm:%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%\profilerinterface.map ^
/link /DYNAMICBASE

rem Licensed to the Apache Software Foundation (ASF) under one
rem or more contributor license agreements. See the NOTICE file
rem distributed with this work for additional information
rem regarding copyright ownership. The ASF licenses this file
rem to you under the Apache License, Version 2.0 (the
rem "License"); you may not use this file except in compliance
rem with the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing,
rem software distributed under the License is distributed on an
rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
rem KIND, either express or implied. See the License for the
rem specific language governing permissions and limitations
rem under the License.

rem Edit the following line to set the JDK location (for JNI headers)
rem or leave if you have JDK_HOME set.
SET BUILD_JDK=%JDK_HOME%
rem Edit the following line to affect the deployment directory.
rem Should not need to be changed as JNI is compatible for all versions
rem after 1.6.
SET JDK_DEPLOY=jdk16
SET PLATFORM=windows

rem Do not alter below this line
SET BUILD_SRC_15=..\src-jdk15
SET BUILD_SRC=..\src
SET BUILD_DEPLOY=..\..\release\lib

if not exist "%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%" mkdir "%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%"

echo on

rem Generate 'config.h' file
cl /I"%BUILD_JDK%\include" /I"%BUILD_JDK%\include\win32" ^
..\src-jdk15\config.c /link /out:..\build\config.exe && ^
..\build\config.exe > ..\build\config.h || ^
exit /b 1

echo Content of config.h :
type ..\build\config.h



rc /Fo .\version.res "%BUILD_SRC_15%\windows\version.rc"

cl /I"%BUILD_JDK%\include" /I"%BUILD_JDK%\include\win32" /I..\build ^
"%BUILD_SRC_15%\class_file_cache.c" ^
"%BUILD_SRC_15%\attach.c" ^
"%BUILD_SRC_15%\Classes.c" ^
"%BUILD_SRC_15%\HeapDump.c" ^
"%BUILD_SRC_15%\Timers.c" ^
"%BUILD_SRC_15%\GC.c" ^
"%BUILD_SRC_15%\Threads.c" ^
"%BUILD_SRC_15%\Stacks.c" ^
"%BUILD_SRC_15%\common_functions.c" ^
version.res ^
/D WIN32 /D NDEBUG /LD /MD /O2 ^
/Fe:"%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%\profilerinterface.dll" ^
/Fm:"%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%\profilerinterface.map" ^
/link /DYNAMICBASE || ^
exit /b 1

del version.res
116 changes: 65 additions & 51 deletions profiler/lib.profiler/native/scripts/buildnative-windows64-16.bat
Original file line number Diff line number Diff line change
@@ -1,52 +1,66 @@
rem Licensed to the Apache Software Foundation (ASF) under one
rem or more contributor license agreements. See the NOTICE file
rem distributed with this work for additional information
rem regarding copyright ownership. The ASF licenses this file
rem to you under the Apache License, Version 2.0 (the
rem "License"); you may not use this file except in compliance
rem with the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing,
rem software distributed under the License is distributed on an
rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
rem KIND, either express or implied. See the License for the
rem specific language governing permissions and limitations
rem under the License.

rem Edit the following line to set the JDK location (for JNI headers)
rem or leave if you have JDK_HOME set.
SET BUILD_JDK=%JDK_HOME%
rem Edit the following line to affect the deployment directory.
rem Should not need to be changed as JNI is compatible for all versions
rem after 1.6.
SET JDK_DEPLOY=jdk16
SET PLATFORM=windows-amd64

rem Do not alter below this line
SET BUILD_SRC_15=..\src-jdk15
SET BUILD_SRC=..\src
SET BUILD_DEPLOY=..\..\release\lib

mkdir %BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%

rc /Fo .\version.res %BUILD_SRC_15%\windows\version.rc

cl /I%BUILD_JDK%\include /I%BUILD_JDK%\include\win32 ^
%BUILD_SRC_15%\class_file_cache.c ^
%BUILD_SRC_15%\attach.c ^
%BUILD_SRC_15%\Classes.c ^
%BUILD_SRC_15%\HeapDump.c ^
%BUILD_SRC_15%\Timers.c ^
%BUILD_SRC_15%\GC.c ^
%BUILD_SRC_15%\Threads.c ^
%BUILD_SRC_15%\Stacks.c ^
%BUILD_SRC_15%\common_functions.c ^
version.res ^
/D WIN32 /D NDEBUG /LD /MD /O2 ^
/Fe:%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%\profilerinterface.dll ^
/Fm:%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%\profilerinterface.map ^
/link /DYNAMICBASE

rem Licensed to the Apache Software Foundation (ASF) under one
rem or more contributor license agreements. See the NOTICE file
rem distributed with this work for additional information
rem regarding copyright ownership. The ASF licenses this file
rem to you under the Apache License, Version 2.0 (the
rem "License"); you may not use this file except in compliance
rem with the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing,
rem software distributed under the License is distributed on an
rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
rem KIND, either express or implied. See the License for the
rem specific language governing permissions and limitations
rem under the License.

rem Edit the following line to set the JDK location (for JNI headers)
rem or leave if you have JDK_HOME set.
SET BUILD_JDK=%JDK_HOME%
rem Edit the following line to affect the deployment directory.
rem Should not need to be changed as JNI is compatible for all versions
rem after 1.6.
SET JDK_DEPLOY=jdk16
SET PLATFORM=windows-amd64

rem Do not alter below this line
SET BUILD_SRC_15=..\src-jdk15
SET BUILD_SRC=..\src
SET BUILD_DEPLOY=..\..\release\lib

if not exist "%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%" mkdir "%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%"

echo on

rem Generate 'config.h' file
cl /I"%BUILD_JDK%\include" /I"%BUILD_JDK%\include\win32" ^
..\src-jdk15\config.c /link /out:..\build\config.exe && ^
..\build\config.exe > ..\build\config.h || ^
exit /b 1

echo Content of config.h :
type ..\build\config.h



rc /Fo .\version.res "%BUILD_SRC_15%\windows\version.rc"

cl /I"%BUILD_JDK%\include" /I"%BUILD_JDK%\include\win32" /I..\build ^
"%BUILD_SRC_15%\class_file_cache.c" ^
"%BUILD_SRC_15%\attach.c" ^
"%BUILD_SRC_15%\Classes.c" ^
"%BUILD_SRC_15%\HeapDump.c" ^
"%BUILD_SRC_15%\Timers.c" ^
"%BUILD_SRC_15%\GC.c" ^
"%BUILD_SRC_15%\Threads.c" ^
"%BUILD_SRC_15%\Stacks.c" ^
"%BUILD_SRC_15%\common_functions.c" ^
version.res ^
/D WIN32 /D NDEBUG /LD /MD /O2 ^
/Fe:"%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%\profilerinterface.dll" ^
/Fm:"%BUILD_DEPLOY%\deployed\%JDK_DEPLOY%\%PLATFORM%\profilerinterface.map" ^
/link /DYNAMICBASE || ^
exit /b 1

del version.res

0 comments on commit 504d66f

Please sign in to comment.