wip
Some checks failed
on-push / build-and-test (push) Failing after 7s

This commit is contained in:
RYAN 2024-09-02 01:43:44 +02:00
commit 67a74bb7bb
Signed by: RYAN
GPG Key ID: 3BD93EABD1407B82
24 changed files with 392 additions and 0 deletions

19
.gitattributes vendored Normal file
View File

@ -0,0 +1,19 @@
# This is a good default: files that are auto-detected by git to be text are
# converted to the platform-native line ending (LF on Unix, CRLF on Windows)
# in the working tree and to LF in the repository.
#
* text=auto
# Use `eol=crlf` for files that should have the CRLF line ending both in the
# working tree (even on Unix) and in the repository.
#
#*.bat text eol=crlf
# Use `eol=lf` for files that should have the LF line ending both in the
# working tree (even on Windows) and in the repository.
#
#*.sh text eol=lf
# Use `binary` to make sure certain files are never auto-detected as text.
#
#*.png binary

View File

@ -0,0 +1,16 @@
name: on-push
on: [push]
jobs:
build-and-test:
runs-on: linux
container: code.helloryan.se/infra/buildenv/cxx-amd64-fedora-40:latest
volumes:
- /build
steps:
- name: Init
run: bpkg create -d /build cc config.cxx=g++
- name: Build
run: cd /build && bpkg build $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git##$GITHUB_SHA
- name: Test
run: cd /build && bpkg test

31
.gitignore vendored Normal file
View File

@ -0,0 +1,31 @@
.bdep/
# Local default options files.
#
.build2/local/
# Compiler/linker output.
#
*.d
*.t
*.i
*.i.*
*.ii
*.ii.*
*.o
*.obj
*.gcm
*.pcm
*.ifc
*.so
*.dylib
*.dll
*.a
*.lib
*.exp
*.pdb
*.ilk
*.exe
*.exe.dlls/
*.exe.manifest
*.pc

41
README.md Normal file
View File

@ -0,0 +1,41 @@
# libcopy-test - A C++ library
The `libcopy-test` C++ library provides <SUMMARY-OF-FUNCTIONALITY>.
## Usage
To start using `libcopy-test` in your project, add the following `depends`
value to your `manifest`, adjusting the version constraint as appropriate:
```
depends: libcopy-test ^<VERSION>
```
Then import the library in your `buildfile`:
```
import libs = libcopy-test%lib{<TARGET>}
```
## Importable targets
This package provides the following importable targets:
```
lib{<TARGET>}
```
<DESCRIPTION-OF-IMPORTABLE-TARGETS>
## Configuration variables
This package provides the following configuration variables:
```
[bool] config.libcopy_test.<VARIABLE> ?= false
```
<DESCRIPTION-OF-CONFIG-VARIABLES>

4
build/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/config.build
/root/
/bootstrap/
build/

7
build/bootstrap.build Normal file
View File

@ -0,0 +1,7 @@
project = libcopy-test
using version
using config
using test
using install
using dist

6
build/export.build Normal file
View File

@ -0,0 +1,6 @@
$out_root/
{
include libcopy-test/
}
export $out_root/libcopy-test/$import.target

16
build/root.build Normal file
View File

@ -0,0 +1,16 @@
# Uncomment to suppress warnings coming from external libraries.
#
#cxx.internal.scope = current
cxx.std = latest
using cxx
hxx{*}: extension = hxx
ixx{*}: extension = ixx
txx{*}: extension = txx
cxx{*}: extension = cxx
# The test target for cross-testing (running tests under Wine, etc).
#
test.target = $cxx.target

5
buildfile Normal file
View File

@ -0,0 +1,5 @@
./: {*/ -build/} doc{README.md} manifest
# Don't install tests.
#
tests/: install = false

3
libcopy-test/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Generated version header.
#
version.hxx

43
libcopy-test/buildfile Normal file
View File

@ -0,0 +1,43 @@
intf_libs = # Interface dependencies.
impl_libs = # Implementation dependencies.
#import xxxx_libs += libhello%lib{hello}
lib{copy-test}: {hxx ixx txx cxx}{** -version} hxx{version} $impl_libs $intf_libs
hxx{version}: in{version} $src_root/manifest
# Build options.
#
cxx.poptions =+ "-I$out_root" "-I$src_root"
obja{*}: cxx.poptions += -DLIBCOPY_TEST_STATIC_BUILD
objs{*}: cxx.poptions += -DLIBCOPY_TEST_SHARED_BUILD
# Export options.
#
lib{copy-test}:
{
cxx.export.poptions = "-I$out_root" "-I$src_root"
cxx.export.libs = $intf_libs
}
liba{copy-test}: cxx.export.poptions += -DLIBCOPY_TEST_STATIC
libs{copy-test}: cxx.export.poptions += -DLIBCOPY_TEST_SHARED
# For pre-releases use the complete version to make sure they cannot
# be used in place of another pre-release or the final version. See
# the version module for details on the version.* variable values.
#
if $version.pre_release
lib{copy-test}: bin.lib.version = "-$version.project_id"
else
lib{copy-test}: bin.lib.version = "-$version.major.$version.minor"
# Install into the libcopy-test/ subdirectory of, say, /usr/include/
# recreating subdirectories.
#
{hxx ixx txx}{*}:
{
install = include/libcopy-test/
install.subdirs = true
}

View File

@ -0,0 +1,17 @@
#include <libcopy-test/copy-test.hxx>
#include <ostream>
#include <stdexcept>
using namespace std;
namespace copy_test
{
void say_hello (ostream& o, const string& n)
{
if (n.empty ())
throw invalid_argument ("empty name");
o << "Hello, " << n << '!' << endl;
}
}

View File

@ -0,0 +1,15 @@
#pragma once
#include <iosfwd>
#include <string>
#include <libcopy-test/export.hxx>
namespace copy_test
{
// Print a greeting for the specified name into the specified
// stream. Throw std::invalid_argument if the name is empty.
//
LIBCOPY_TEST_SYMEXPORT void
say_hello (std::ostream&, const std::string& name);
}

39
libcopy-test/export.hxx Normal file
View File

@ -0,0 +1,39 @@
#pragma once
// Normally we don't export class templates (but do complete specializations),
// inline functions, and classes with only inline member functions. Exporting
// classes that inherit from non-exported/imported bases (e.g., std::string)
// will end up badly. The only known workarounds are to not inherit or to not
// export. Also, MinGW GCC doesn't like seeing non-exported functions being
// used before their inline definition. The workaround is to reorder code. In
// the end it's all trial and error.
#if defined(LIBCOPY_TEST_STATIC) // Using static.
# define LIBCOPY_TEST_SYMEXPORT
#elif defined(LIBCOPY_TEST_STATIC_BUILD) // Building static.
# define LIBCOPY_TEST_SYMEXPORT
#elif defined(LIBCOPY_TEST_SHARED) // Using shared.
# ifdef _WIN32
# define LIBCOPY_TEST_SYMEXPORT __declspec(dllimport)
# else
# define LIBCOPY_TEST_SYMEXPORT
# endif
#elif defined(LIBCOPY_TEST_SHARED_BUILD) // Building shared.
# ifdef _WIN32
# define LIBCOPY_TEST_SYMEXPORT __declspec(dllexport)
# else
# define LIBCOPY_TEST_SYMEXPORT
# endif
#else
// If none of the above macros are defined, then we assume we are being used
// by some third-party build system that cannot/doesn't signal the library
// type. Note that this fallback works for both static and shared libraries
// provided the library only exports functions (in other words, no global
// exported data) and for the shared case the result will be sub-optimal
// compared to having dllimport. If, however, your library does export data,
// then you will probably want to replace the fallback with the (commented
// out) error since it won't work for the shared case.
//
# define LIBCOPY_TEST_SYMEXPORT // Using static or shared.
//# error define LIBCOPY_TEST_STATIC or LIBCOPY_TEST_SHARED preprocessor macro to signal libcopy-test library type being linked
#endif

View File

@ -0,0 +1,34 @@
#pragma once
// The numeric version format is AAAAABBBBBCCCCCDDDE where:
//
// AAAAA - major version number
// BBBBB - minor version number
// CCCCC - bugfix version number
// DDD - alpha / beta (DDD + 500) version number
// E - final (0) / snapshot (1)
//
// When DDDE is not 0, 1 is subtracted from AAAAABBBBBCCCCC. For example:
//
// Version AAAAABBBBBCCCCCDDDE
//
// 0.1.0 0000000001000000000
// 0.1.2 0000000001000020000
// 1.2.3 0000100002000030000
// 2.2.0-a.1 0000200001999990010
// 3.0.0-b.2 0000299999999995020
// 2.2.0-a.1.z 0000200001999990011
//
#define LIBCOPY_TEST_VERSION $libcopy_test.version.project_number$ULL
#define LIBCOPY_TEST_VERSION_STR "$libcopy_test.version.project$"
#define LIBCOPY_TEST_VERSION_ID "$libcopy_test.version.project_id$"
#define LIBCOPY_TEST_VERSION_FULL "$libcopy_test.version$"
#define LIBCOPY_TEST_VERSION_MAJOR $libcopy_test.version.major$
#define LIBCOPY_TEST_VERSION_MINOR $libcopy_test.version.minor$
#define LIBCOPY_TEST_VERSION_PATCH $libcopy_test.version.patch$
#define LIBCOPY_TEST_PRE_RELEASE $libcopy_test.version.pre_release$
#define LIBCOPY_TEST_SNAPSHOT_SN $libcopy_test.version.snapshot_sn$ULL
#define LIBCOPY_TEST_SNAPSHOT_ID "$libcopy_test.version.snapshot_id$"

13
manifest Normal file
View File

@ -0,0 +1,13 @@
: 1
name: libcopy-test
version: 0.1.0-a.0.z
language: c++
summary: copy-test C++ library
license: other: proprietary ; Not free/open source.
description-file: README.md
url: https://example.org/libcopy-test
email: ryan@helloryan.se
#build-error-email: ryan@helloryan.se
depends: * build2 >= 0.16.0
depends: * bpkg >= 0.16.0
#depends: libhello ^1.0.0

11
repositories.manifest Normal file
View File

@ -0,0 +1,11 @@
: 1
summary: libcopy-test project repository
#:
#role: prerequisite
#location: https://pkg.cppget.org/1/stable
#trust: ...
#:
#role: prerequisite
#location: https://git.build2.org/hello/libhello.git

8
tests/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Test executables.
#
driver
# Testscript output directories (can be symlinks).
#
test
test-*

3
tests/basics/buildfile Normal file
View File

@ -0,0 +1,3 @@
import libs = libcopy-test%lib{copy-test}
exe{driver}: {hxx ixx txx cxx}{**} $libs testscript{**}

35
tests/basics/driver.cxx Normal file
View File

@ -0,0 +1,35 @@
#include <sstream>
#include <stdexcept>
#include <libcopy-test/version.hxx>
#include <libcopy-test/copy-test.hxx>
#undef NDEBUG
#include <cassert>
int main ()
{
using namespace std;
using namespace copy_test;
// Basics.
//
{
ostringstream o;
say_hello (o, "World");
assert (o.str () == "Hello, World!\n");
}
// Empty name.
//
try
{
ostringstream o;
say_hello (o, "");
assert (false);
}
catch (const invalid_argument& e)
{
assert (e.what () == string ("empty name"));
}
}

4
tests/build/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/config.build
/root/
/bootstrap/
build/

View File

@ -0,0 +1,5 @@
project = # Unnamed tests subproject.
using config
using test
using dist

16
tests/build/root.build Normal file
View File

@ -0,0 +1,16 @@
cxx.std = latest
using cxx
hxx{*}: extension = hxx
ixx{*}: extension = ixx
txx{*}: extension = txx
cxx{*}: extension = cxx
# Every exe{} in this subproject is by default a test.
#
exe{*}: test = true
# The test target for cross-testing (running tests under Wine, etc).
#
test.target = $cxx.target

1
tests/buildfile Normal file
View File

@ -0,0 +1 @@
./: {*/ -build/}