Skip to content

Commit

Permalink
Merge branch '10-upgrade-test-dependency-objectbox-clib-0-14-0-21' in…
Browse files Browse the repository at this point in the history
…to 'dev'

Resolve "Upgrade test dependency objectbox-clib 0.14 -> 0.21+"

Closes #10

See merge request objectbox/objectbox-generator!12
  • Loading branch information
dan-obx committed Mar 4, 2024
2 parents 2b9ef44 + 52887c5 commit 503210c
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 12 deletions.
8 changes: 4 additions & 4 deletions test/build/c-compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ func CanCompileObjectBoxCCpp(t *testing.T, repoRoot string, cpp, required bool)

// check objectbox lib
if cpp {
err = cmake.LibraryExists("objectbox", []string{"objectbox.hpp"}, includeDirs, libDirs)
err = cmake.LibraryExists("objectbox", []string{"objectbox.hpp"}, includeDirs, libDirs, []string{"OBX_CPP_FILE"})
} else {
err = cmake.LibraryExists("objectbox", []string{"objectbox.h"}, includeDirs, libDirs)
err = cmake.LibraryExists("objectbox", []string{"objectbox.h"}, includeDirs, libDirs, nil)
}
assert.NoErr(t, err)

// check flatbuffers library availability
if cpp {
// Note: we don't need flatbuffers library explicitly, it's part of objectbox at the moment.
err = cmake.LibraryExists("", []string{"flatbuffers/flatbuffers.h"}, includeDirs, libDirs)
err = cmake.LibraryExists("", []string{"flatbuffers/flatbuffers.h"}, includeDirs, libDirs, nil)
} else {
err = cmake.LibraryExists("flatccrt", []string{"stddef.h", "flatcc/flatcc.h", "flatcc/flatcc_builder.h"}, includeDirs, libDirs)
err = cmake.LibraryExists("flatccrt", []string{"stddef.h", "flatcc/flatcc.h", "flatcc/flatcc_builder.h"}, includeDirs, libDirs, nil)
}

if required {
Expand Down
7 changes: 6 additions & 1 deletion test/cmake/libcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

// LibraryExists tries to compile a simple program linking to the given library
func LibraryExists(name string, includeFiles, includeDirs, linkDirs []string) error {
func LibraryExists(name string, includeFiles, includeDirs, linkDirs, predefines []string) error {
build := Cmake{
Name: "check-" + name,
IsCpp: true,
Expand All @@ -51,6 +51,11 @@ func LibraryExists(name string, includeFiles, includeDirs, linkDirs []string) er
{ // write main.cpp
mainPath := filepath.Join(build.ConfDir, build.Files[0])
var mainSrc string
if len(predefines) > 0 {
for _, predefine := range predefines {
mainSrc = mainSrc + "#define " + predefine + "\n"
}
}
if len(includeFiles) > 0 {
for _, inc := range includeFiles {
mainSrc = mainSrc + "#include <" + inc + ">\n"
Expand Down
8 changes: 4 additions & 4 deletions test/cmake/libcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ func TestLibExists(t *testing.T) {
t.SkipNow()
}

err := cmake.LibraryExists("nonsense", nil, nil, nil)
err := cmake.LibraryExists("nonsense", nil, nil, nil, nil)
assert.Err(t, err)

err = cmake.LibraryExists("", []string{"non-existent-lib/include.h"}, nil, nil)
err = cmake.LibraryExists("", []string{"non-existent-lib/include.h"}, nil, nil, nil)
assert.Err(t, err)

if runtime.GOOS == "windows" {
err = cmake.LibraryExists("", []string{"array"}, nil, nil)
err = cmake.LibraryExists("", []string{"array"}, nil, nil, nil)
} else {
err = cmake.LibraryExists("stdc++", []string{"array"}, nil, nil)
err = cmake.LibraryExists("stdc++", []string{"array"}, nil, nil, nil)
}
assert.NoErr(t, err)
}
1 change: 1 addition & 0 deletions test/comparison/c-helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func (h cTestHelper) build(t *testing.T, conf testSpec, dir string, expectedErro
{ // write main.c/cpp to the conf dir - a simple one, just include all sources
var mainSrc = ""
if cmak.IsCpp {
mainSrc = mainSrc + "#define OBX_CPP_FILE\n"
mainSrc = mainSrc + "#include \"objectbox.hpp\"\n"
} else {
mainSrc = mainSrc + "#include \"objectbox.h\"\n"
Expand Down
2 changes: 2 additions & 0 deletions test/integration/optional/cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define CATCH_CONFIG_MAIN

#define OBX_CPP_FILE

#include <type_traits>

#include "c-ptr.obx.h"
Expand Down
2 changes: 2 additions & 0 deletions test/integration/property-clear/cpp/step-1.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define CATCH_CONFIG_MAIN

#define OBX_CPP_FILE

#include "catch2/catch.hpp"
#include "objectbox.hpp"
#include "schema.obx.hpp"
Expand Down
2 changes: 2 additions & 0 deletions test/integration/property-clear/cpp/step-2.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define CATCH_CONFIG_MAIN

#define OBX_CPP_FILE

#include "catch2/catch.hpp"
#include "objectbox.hpp"
#include "schema.obx.hpp"
Expand Down
2 changes: 2 additions & 0 deletions test/integration/removes/cpp/step-1.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define CATCH_CONFIG_MAIN

#define OBX_CPP_FILE

#include "catch2/catch.hpp"
#include "objectbox.hpp"
#include "schema.obx.hpp"
Expand Down
2 changes: 2 additions & 0 deletions test/integration/removes/cpp/step-2.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define CATCH_CONFIG_MAIN

#define OBX_CPP_FILE

#include "catch2/catch.hpp"
#include "objectbox.hpp"
#include "schema.obx.hpp"
Expand Down
2 changes: 2 additions & 0 deletions test/integration/renames/cpp/step-1.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define CATCH_CONFIG_MAIN

#define OBX_CPP_FILE

#include "catch2/catch.hpp"
#include "objectbox.hpp"
#include "schema.obx.hpp"
Expand Down
2 changes: 2 additions & 0 deletions test/integration/renames/cpp/step-2.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define CATCH_CONFIG_MAIN

#define OBX_CPP_FILE

#include "catch2/catch.hpp"
#include "objectbox.hpp"
#include "schema.obx.hpp"
Expand Down
7 changes: 5 additions & 2 deletions test/integration/shared/store-init.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ obx::Store testStore(bool removeBeforeOpening, const char* dbDir = nullptr) {
if (!dbDir) throw std::invalid_argument("dbDir environment variable not given");
}
if (removeBeforeOpening) obx_remove_db_files(dbDir);
obx::Store::Options options(create_obx_model());
options.directory(dbDir);
obx::Options options;
options
.model(create_obx_model())
.directory(dbDir)
;
return obx::Store(options);
}
2 changes: 2 additions & 0 deletions test/integration/sync/cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define CATCH_CONFIG_MAIN

#define OBX_CPP_FILE

#include "catch2/catch.hpp"
#include "objectbox.hpp"
#include "objectbox-model.h"
Expand Down
2 changes: 2 additions & 0 deletions test/integration/typeful/cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define CATCH_CONFIG_MAIN

#define OBX_CPP_FILE

#include "annotated.obx.hpp"
#include "catch2/catch.hpp"
#include "objectbox.hpp"
Expand Down
2 changes: 1 addition & 1 deletion third_party/objectbox-c/get-objectbox-c.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

cVersion=0.14.0
cVersion=0.21.0

scriptDir=$(dirname "${BASH_SOURCE[0]}")

Expand Down

0 comments on commit 503210c

Please sign in to comment.