Skip to content

Commit

Permalink
Add test libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
ekharkunov committed Jan 9, 2025
1 parent 2bcb457 commit 7e07cec
Show file tree
Hide file tree
Showing 87 changed files with 126 additions and 72 deletions.
31 changes: 11 additions & 20 deletions server/src/test/java/com/defold/extender/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ public static List<TestConfiguration> data() {
// new DefoldVersion("a", new Version(0, 0, 0), new String[] {"armv7-android", "x86_64-win32"} ),

// // ??????? https://github.com/defold/defold/releases/tag/1.8.0
// new DefoldVersion("9141d9d3605e3f5d51c71293116d769da2613d39", new Version(1, 8, 0), new String[] {"armv7-android", "x86_64-linux", "x86_64-win32", "js-web", "wasm-web"}),
new DefoldVersion("9141d9d3605e3f5d51c71293116d769da2613d39", new Version(1, 8, 0), new String[] {"armv7-android", "x86_64-linux", "x86_64-win32", "js-web", "wasm-web"}),

// // // 2024-06-25 https://github.com/defold/defold/releases/tag/1.9.0
// new DefoldVersion("d6882f432beca85d460ec42497888157c356d058", new Version(1, 9, 0), new String[] {"armv7-android", "x86_64-linux", "x86_64-win32", "js-web", "wasm-web"}),
// // 2024-06-25 https://github.com/defold/defold/releases/tag/1.9.0
new DefoldVersion("d6882f432beca85d460ec42497888157c356d058", new Version(1, 9, 0), new String[] {"armv7-android", "x86_64-linux", "x86_64-win32", "js-web", "wasm-web"}),

// // 2024-10-29 https://github.com/defold/defold/releases/tag/1.9.4
new DefoldVersion("edfdbe31830c1f8aa4d96644569ae87a8ea32672", new Version(1, 9, 4), new String[] {"armv7-android", "x86_64-linux", "x86_64-win32", "js-web", "wasm-web"}),
Expand Down Expand Up @@ -185,10 +185,10 @@ public static void beforeClass() throws IOException, InterruptedException {

@AfterAll
public static void afterClass() throws IOException, InterruptedException {
// ProcessExecutor processExecutor = new ProcessExecutor();
// processExecutor.putEnv("APPLICATION", "extender-test");
// processExecutor.execute("scripts/stop-test-server.sh");
// System.out.println(processExecutor.getOutput());
ProcessExecutor processExecutor = new ProcessExecutor();
processExecutor.putEnv("APPLICATION", "extender-test");
processExecutor.execute("scripts/stop-test-server.sh");
System.out.println(processExecutor.getOutput());
}

private String[] getEngineNames(String platform) {
Expand Down Expand Up @@ -523,30 +523,21 @@ public void buildEngineWithError(TestConfiguration configuration) throws IOExcep
@ParameterizedTest(name = "[{index}] {displayName} {arguments}")
@MethodSource("data")
public void buildEngineWithDynamicLibs(TestConfiguration configuration) throws IOException, ExtenderClientException {
String[] platformParts = configuration.platform.split("-");
List<ExtenderResource> sourceFiles = Lists.newArrayList(
new FileExtenderResource("test-data/ext_dyn_libs/ext.manifest"),
new FileExtenderResource("test-data/ext_dyn_libs/src/test_ext.cpp"),
new FileExtenderResource(String.format("test-data/ext_dyn_libs/lib/%s/%s", configuration.platform, getDynamicLibName(configuration.platform, "specific"))),
new FileExtenderResource(String.format("test-data/ext_dyn_libs/lib/%s/%s", platformParts[1], getDynamicLibName(configuration.platform, "common-test"))),
new FileExtenderResource(String.format("test-data/ext_dyn_libs/lib/%s/%s", configuration.platform, getDynamicLibName(configuration.platform, "dynamic_specific1"))),
new FileExtenderResource("test-data/ext_dyn_libs2/ext.manifest"),
new FileExtenderResource("test-data/ext_dyn_libs2/src/extension.cpp"),
new FileExtenderResource(String.format("test-data/ext_dyn_libs2/lib/%s/%s", configuration.platform, getDynamicLibName(configuration.platform, "specific2"))),
new FileExtenderResource(String.format("test-data/ext_dyn_libs2/lib/%s/%s", configuration.platform, getDynamicLibName(configuration.platform, "dynamic_specific2"))),
new FileExtenderResource("test-data/AndroidManifest.xml", "AndroidManifest.xml")
);

File destination = doBuild(sourceFiles, configuration);

try (ZipFile zipFile = new ZipFile(destination)) {
final Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
final ZipEntry entry = entries.nextElement();
String name = entry.getName();
System.out.println(name);
}
assertNotNull(zipFile.getEntry(getDynamicLibName(configuration.platform, "specific")));
assertNotNull(zipFile.getEntry(getDynamicLibName(configuration.platform, "common-test")));
assertNotNull(zipFile.getEntry(getDynamicLibName(configuration.platform, "specific2")));
assertNotNull(zipFile.getEntry(getDynamicLibName(configuration.platform, "dynamic_specific1")));
assertNotNull(zipFile.getEntry(getDynamicLibName(configuration.platform, "dynamic_specific2")));
}
}
}
22 changes: 15 additions & 7 deletions server/test-data/build-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ source ./compile.sh
function CompileLibsToExtension {
local dir=$1
local extension=$2
local lib_type=$3

for file in $dir/*.cpp
do
local name=$(basename $file)
name="${name%.*}"
echo $name $file
Compile $name $file $extension
echo $name $file $lib_type
if [ "$lib_type" == "dynamic" ]; then
CompileDynamic $name $file $extension
else
Compile $name $file $extension
fi
done
}

Expand All @@ -29,7 +34,7 @@ function Copy {
}


CompileLibsToExtension enginelibs engineext/lib
CompileLibsToExtension enginelibs engineext/lib static

# copy these into the "a" sdk
mkdir -p sdk/a/defoldsdk/lib
Expand All @@ -46,10 +51,13 @@ mv sdk/a/defoldsdk/lib/x86-linux sdk/a/defoldsdk/lib/linux
mkdir -p sdk/a/defoldsdk/ext/lib/darwin
mkdir -p sdk/a/defoldsdk/ext/lib/x86_64-macos

CompileLibsToExtension alib ext/lib
CompileLibsToExtension alib ext2/lib
CompileLibsToExtension blib ext2/lib
CompileLibsToExtension stdlib ext_std/lib
CompileLibsToExtension alib ext/lib static
CompileLibsToExtension alib ext2/lib static
CompileLibsToExtension blib ext2/lib static
CompileLibsToExtension stdlib ext_std/lib static

CompileLibsToExtension dynamic_specific1 ext_dyn_libs/lib dynamic
CompileLibsToExtension dynamic_specific2 ext_dyn_libs2/lib dynamic

(cd testproject_appmanifest && ./build.sh)

109 changes: 86 additions & 23 deletions server/test-data/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,20 @@ function CompileAndroid {
local name=$1
local src=$2
local targetdir=$3
local lib_type=$4

archs=("armv7" "arm64")
for arch in "${archs[@]}"
do
local archname=$arch-android
local target=$targetdir/$archname/lib$name.a
echo "Compiling ${name} for ${archname}"
local target=""
if [ "$lib_type" == "static" ]; then
target=$targetdir/$archname/lib$name.a
elif [ "$lib_type" == "dynamic" ]; then
target=$targetdir/$archname/lib$name.so
fi

echo "Compiling ${name} for ${archname} type ${lib_type}"

RemoveTarget $target
mkdir -p $(dirname $target)
Expand All @@ -70,9 +77,14 @@ function CompileAndroid {
GCC=${ANDROID_GCC}aarch64-linux-android${ANDROID_64_NDK_API_VERSION}-clang++
fi

$GCC -c -gdwarf-2 $CFLAGS -I${ANDROID_INCLUDE_ARCH} -isysroot=${ANDROID_SYS_ROOT} $src -c -o /tmp/$name-$archname.o

$ANDROID_AR rcs $target /tmp/$name-$archname.o
$GCC -gdwarf-2 $CFLAGS -I${ANDROID_INCLUDE_ARCH} -isysroot=${ANDROID_SYS_ROOT} $src -c -o /tmp/$name-$archname.o
if [ "$lib_type" == "static" ]; then
$ANDROID_AR rcs $target /tmp/$name-$archname.o
elif [ "$lib_type" == "dynamic" ]; then
$GCC -shared -isysroot=${ANDROID_SYS_ROOT} -o $target /tmp/$name-$archname.o
fi

echo Wrote $target
done
}
Expand All @@ -82,19 +94,30 @@ function CompileiOS {
local name=$1
local src=$2
local targetdir=$3
local lib_type=$4

archs=("arm64")
for arch in "${archs[@]}"
do
local archname=$arch-ios
local target=$targetdir/$archname/lib$name.a
local target=""
if [ "$lib_type" == "static" ]; then
target=$targetdir/$archname/lib$name.a
elif [ "$lib_type" == "dynamic" ]; then
target=$targetdir/$archname/lib$name.so
fi

echo "Compiling ${name} for ${archname}"

RemoveTarget $target
mkdir -p $(dirname $target)

$IOS_GCC -arch $arch -stdlib=libc++ -fno-strict-aliasing -fno-exceptions -miphoneos-version-min=${IOS_MIN_VERSION} -isysroot ${IOS_SYS_ROOT} $src -c -o /tmp/$name-$archname.o
$IOS_AR rcs $target /tmp/$name-$archname.o
if [ "$lib_type" == "static" ]; then
$IOS_AR rcs $target /tmp/$name-$archname.o
elif [ "$lib_type" == "dynamic" ]; then
$IOS_GCC -arch $arch -shared -isysroot ${IOS_SYS_ROOT} -o $target /tmp/$name-$archname.o
fi

echo Wrote $target
done
Expand All @@ -110,14 +133,24 @@ function CompileOSX {
for arch in "${archs[@]}"
do
local archname=$arch-osx
local target=$targetdir/$archname/lib$name.a
echo "Compiling ${name} for ${archname}"
local target=""
if [ "$lib_type" == "static" ]; then
target=$targetdir/$archname/lib$name.a
elif [ "$lib_type" == "dynamic" ]; then
target=$targetdir/$archname/lib$name.dylib
fi

echo "Compiling ${name} for ${archname} type ${lib_type}"

RemoveTarget $target
mkdir -p $(dirname $target)

$OSX_GCC -arch $arch -stdlib=libc++ -fomit-frame-pointer -fno-strict-aliasing -fno-exceptions -mmacosx-version-min=${OSX_MIN_VERSION} -isysroot ${OSX_SYS_ROOT} $src -c -o /tmp/$name-$archname.o
$OSX_AR rcs $target /tmp/$name-$archname.o
if [ "$lib_type" == "static" ]; then
$OSX_AR rcs $target /tmp/$name-$archname.o
elif [ "$lib_type" == "dynamic" ]; then
$OSX_GCC -arch $arch -shared -isysroot ${OSX_SYS_ROOT} -o $target /tmp/$name-$archname.o
fi

echo Wrote $target
done
Expand All @@ -127,19 +160,29 @@ function CompileHTML5 {
local name=$1
local src=$2
local targetdir=$3
local lib_type=$4

archs=("js" "wasm")
for arch in "${archs[@]}"
do
local archname=$arch-web
local target=$targetdir/$archname/lib$name.a
echo "Compiling ${name} for ${archname}"
echo "Compiling ${name} for ${archname} type ${lib_type}"
local target=""
if [ "$lib_type" == "static" ]; then
target=$targetdir/$archname/lib$name.a
elif [ "$lib_type" == "dynamic" ]; then
target=$targetdir/$archname/lib$name.so
fi

RemoveTarget $target
mkdir -p $(dirname $target)

$EMCC $src -c -o /tmp/$name-$archname.o
$EMAR rcs $target /tmp/$name-$archname.o
if [ "$lib_type" == "static" ]; then
$EMAR rcs $target /tmp/$name-$archname.o
elif [ "$lib_type" == "dynamic" ]; then
$EMCC -sSIDE_MODULE=1 -o $target /tmp/$name-$archname.o
fi

echo Wrote $target
done
Expand All @@ -149,13 +192,19 @@ function CompileWindowsOnDarwin {
local name=$1
local src=$2
local targetdir=$3
local lib_type=$4

archs=( "x86" "x86_64")
for arch in "${archs[@]}"
do
local archname=$arch-win32
local target=$targetdir/$archname/$name.lib
echo "Compiling ${name} for ${archname}"
echo "Compiling ${name} for ${archname} type ${lib_type}"
local target=""
if [ "$lib_type" == "static" ]; then
target=$targetdir/$archname/$name.lib
elif [ "$lib_type" == "dynamic" ]; then
target=$targetdir/$archname/$name.dll
fi

RemoveTarget $target
mkdir -p $(dirname $target)
Expand All @@ -176,7 +225,12 @@ function CompileWindowsOnDarwin {

echo $WIN32_GCC $ARCH_FLAGS $FLAGS $LIBPATHS $INCLUDES $LIB_PATHS $src -c -o /tmp/$name-$archname.o
$WIN32_GCC $ARCH_FLAGS $FLAGS $LIBPATHS $INCLUDES $LIB_PATHS $src -c -o /tmp/$name-$archname.o
$WIN32_AR rcs $target /tmp/$name-$archname.o
if [ "$lib_type" == "static" ]; then
$WIN32_AR rcs $target /tmp/$name-$archname.o
elif [ "$lib_type" == "dynamic" ]; then
echo "Create dummy .dll file with text content. Enough for testing."
echo "$target" > $target
fi

echo Wrote $target
done
Expand Down Expand Up @@ -221,20 +275,29 @@ function CompileLinux {
local name=$1
local src=$2
local targetdir=$3
local lib_type=$4

archs=("x86_64")
for arch in "${archs[@]}"
do
local archname=$arch-linux

local target=$targetdir/$archname/lib$name.a
echo "Compiling ${name} for ${archname}"
local target=""
if [ "$lib_type" == "static" ]; then
target=$targetdir/$archname/lib$name.a
elif [ "$lib_type" == "dynamic" ]; then
target=$targetdir/$archname/lib$name.so
fi
echo "Compiling ${name} for ${archname} type ${lib_type}"

RemoveTarget $target
mkdir -p $(dirname $target)

$LINUX_GCC -fPIC -fomit-frame-pointer -fno-strict-aliasing -fno-exceptions $src -c -o /tmp/$name-$archname.o
$LINUX_AR rcs $target /tmp/$name-$archname.o
if [ "$lib_type" == "static" ]; then
$LINUX_AR rcs $target /tmp/$name-$archname.o
elif [ "$lib_type" == "dynamic" ]; then
$LINUX_GCC -shared -o $target /tmp/$name-$archname.o
fi

echo Wrote $target
done
Expand All @@ -257,7 +320,7 @@ function Compile {
CompileWindows $name $src $targetdir
fi
if [ "$(uname)" == "Linux" ]; then
CompileLinux $name $src $targetdir false
CompileLinux $name $src $targetdir static
fi
set +e
}
Expand All @@ -278,9 +341,9 @@ function CompileDynamic {
# if [ "$(uname)" == "MINGW32_NT-6.2" ]; then
# CompileWindows $name $src $targetdir
# fi
# if [ "$(uname)" == "Linux" ]; then
# CompileLinux $name $src $targetdir
# fi
if [ "$(uname)" == "Linux" ]; then
CompileLinux $name $src $targetdir dynamic
fi
set +e
}

5 changes: 5 additions & 0 deletions server/test-data/dynamic_specific1/dynamic_specific1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

extern "C" int SpecificSymbol(int a, int b)
{
return a + b;
}
5 changes: 5 additions & 0 deletions server/test-data/dynamic_specific2/dynamic_specific2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

extern "C" int SpecificSymbol2(int a, int b)
{
return a - b;
}
Binary file modified server/test-data/ext/lib/arm64-ios/libalib.a
Binary file not shown.
Binary file modified server/test-data/ext/lib/arm64-osx/libalib.a
Binary file not shown.
Binary file modified server/test-data/ext/lib/x86-win32/alib.lib
Binary file not shown.
Binary file modified server/test-data/ext/lib/x86_64-osx/libalib.a
Binary file not shown.
Binary file modified server/test-data/ext/lib/x86_64-win32/alib.lib
Binary file not shown.
Binary file modified server/test-data/ext2/lib/arm64-ios/libalib.a
Binary file not shown.
Binary file modified server/test-data/ext2/lib/arm64-ios/libblib.a
Binary file not shown.
Binary file modified server/test-data/ext2/lib/arm64-osx/libalib.a
Binary file not shown.
Binary file modified server/test-data/ext2/lib/arm64-osx/libblib.a
Binary file not shown.
Binary file modified server/test-data/ext2/lib/x86-win32/alib.lib
Binary file not shown.
Binary file modified server/test-data/ext2/lib/x86-win32/blib.lib
Binary file not shown.
Binary file modified server/test-data/ext2/lib/x86_64-osx/libalib.a
Binary file not shown.
Binary file modified server/test-data/ext2/lib/x86_64-osx/libblib.a
Binary file not shown.
Binary file modified server/test-data/ext2/lib/x86_64-win32/alib.lib
Binary file not shown.
Binary file modified server/test-data/ext2/lib/x86_64-win32/blib.lib
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

1 change: 0 additions & 1 deletion server/test-data/ext_dyn_libs/lib/ios/libcommon-test.dylib

This file was deleted.

Binary file not shown.
1 change: 0 additions & 1 deletion server/test-data/ext_dyn_libs/lib/js-web/libspecific.so

This file was deleted.

1 change: 0 additions & 1 deletion server/test-data/ext_dyn_libs/lib/linux/libcommon-test.so

This file was deleted.

1 change: 0 additions & 1 deletion server/test-data/ext_dyn_libs/lib/osx/libcommon-test.dylib

This file was deleted.

Binary file not shown.
1 change: 0 additions & 1 deletion server/test-data/ext_dyn_libs/lib/wasm-web/libspecific.so

This file was deleted.

1 change: 0 additions & 1 deletion server/test-data/ext_dyn_libs/lib/web/libcommon-test.so

This file was deleted.

1 change: 0 additions & 1 deletion server/test-data/ext_dyn_libs/lib/win32/common-test.dll

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ext_dyn_libs/lib/x86-win32/dynamic_specific1.dll
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ext_dyn_libs/lib/x86_64-win32/dynamic_specific1.dll

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
1 change: 0 additions & 1 deletion server/test-data/ext_dyn_libs2/lib/js-web/libspecific2.so

This file was deleted.

Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ext_dyn_libs2/lib/x86-win32/dynamic_specific2.dll
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ext_dyn_libs2/lib/x86_64-win32/dynamic_specific2.dll
Loading

0 comments on commit 7e07cec

Please sign in to comment.