Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow multiple aws_sdkutils_library_init() calls #7

Merged
merged 3 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ env:

jobs:
linux-compat:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04 # latest
strategy:
fail-fast: false
matrix:
Expand All @@ -39,7 +39,7 @@ jobs:
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }} downstream

linux-compiler-compat:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04 # latest
strategy:
matrix:
compiler:
Expand All @@ -62,7 +62,7 @@ jobs:
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --compiler=${{ matrix.compiler }} --spec downstream

clang-sanitizers:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04 # latest
strategy:
matrix:
sanitizers: [",thread", ",address,undefined"]
Expand All @@ -74,7 +74,7 @@ jobs:
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --compiler=clang-11 --cmake-extra=-DENABLE_SANITIZERS=ON --cmake-extra=-DSANITIZERS="${{ matrix.sanitizers }}"

linux-shared-libs:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04 # latest
steps:
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
- name: Build ${{ env.PACKAGE_NAME }}
Expand All @@ -83,15 +83,15 @@ jobs:
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBUILD_SHARED_LIBS=ON

windows:
runs-on: windows-latest
runs-on: windows-2022 # latest
steps:
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
python builder.pyz build -p ${{ env.PACKAGE_NAME }}

windows-vc14:
runs-on: windows-latest
runs-on: windows-2019 # windows-2019 is last env with Visual Studio 2015 (v14.0)
strategy:
matrix:
arch: [x86, x64]
Expand All @@ -102,15 +102,15 @@ jobs:
python builder.pyz build -p ${{ env.PACKAGE_NAME }} --target windows-${{ matrix.arch }} --compiler msvc-14

windows-shared-libs:
runs-on: windows-latest
runs-on: windows-2022 # latest
steps:
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
python builder.pyz build -p ${{ env.PACKAGE_NAME }} --cmake-extra=-DBUILD_SHARED_LIBS=ON

osx:
runs-on: macos-latest
runs-on: macos-11 # latest
steps:
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
Expand Down
10 changes: 10 additions & 0 deletions source/sdkutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,24 @@ static struct aws_log_subject_info_list s_sdkutils_log_subjects = {
.count = AWS_ARRAY_SIZE(s_log_subject_infos),
};

static int s_library_init_count = 0;

void aws_sdkutils_library_init(struct aws_allocator *allocator) {
if (s_library_init_count++ != 0) {
return;
}

aws_common_library_init(allocator);

aws_register_error_info(&s_sdkutils_error_info);
aws_register_log_subject_info_list(&s_sdkutils_log_subjects);
}

void aws_sdkutils_library_clean_up(void) {
if (--s_library_init_count != 0) {
return;
}

aws_unregister_log_subject_info_list(&s_sdkutils_log_subjects);
aws_unregister_error_info(&s_sdkutils_error_info);

Expand Down