-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import a subset of libbase, build an AAR.
It's still quite a lot for just CHECK, LOG, and DISALLOW_COPY_AND_ASSIGN. The strings stuff is only needed because r26 is too old to have the stdlib string split/starts_with/etc. Maybe I'll end up wanting more later and this is a worthwhile start?
- Loading branch information
Showing
12 changed files
with
1,127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
plugins { | ||
id("ndksamples.android.library") | ||
} | ||
|
||
android { | ||
namespace = "com.android.ndk.samples.base" | ||
|
||
externalNativeBuild { | ||
cmake { | ||
path = file("src/main/cpp/CMakeLists.txt") | ||
} | ||
} | ||
|
||
buildFeatures { | ||
prefabPublishing = true | ||
} | ||
|
||
prefab { | ||
create("base") { | ||
headers = "src/main/cpp/include" | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(libs.appcompat) | ||
implementation(libs.material) | ||
testImplementation(libs.junit) | ||
androidTestImplementation(libs.ext.junit) | ||
androidTestImplementation(libs.espresso.core) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.22.1) | ||
project(Base LANGUAGES CXX) | ||
|
||
add_compile_options(-Wall -Werror -Wextra) | ||
|
||
add_library(base | ||
STATIC | ||
logging.cpp | ||
) | ||
|
||
target_compile_features(base PRIVATE cxx_std_23) | ||
target_compile_options(base PRIVATE -Wno-vla-cxx-extension) | ||
target_include_directories(base PUBLIC include) | ||
target_link_libraries(base PUBLIC log) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2020 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <errno.h> | ||
|
||
namespace ndksamples::base { | ||
|
||
class ErrnoRestorer { | ||
public: | ||
ErrnoRestorer() : saved_errno_(errno) {} | ||
ErrnoRestorer(const ErrnoRestorer&) = delete; | ||
|
||
~ErrnoRestorer() { errno = saved_errno_; } | ||
|
||
ErrnoRestorer& operator=(const ErrnoRestorer&) = delete; | ||
|
||
// Allow this object to be used as part of && operation. | ||
explicit operator bool() const { return true; } | ||
|
||
private: | ||
const int saved_errno_; | ||
}; | ||
|
||
} // namespace ndksamples::base |
Oops, something went wrong.