-
Notifications
You must be signed in to change notification settings - Fork 38
fix: Replicates SPM default behavior for publicHeadersPath: If this is nil, the directory is set to include #1429
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
a22ed30
a9fe850
0eb849b
c66dc7d
5b2ad2e
745c67b
9e85019
7583f75
57498e3
4662b0d
2a58117
a20242c
f63fde0
b226d96
0b68a78
3338533
cbdf598
3f574e5
a361928
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,13 @@ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" | |
bazel="${BIT_BAZEL_BINARY:-bazel}" | ||
|
||
assert_match() { | ||
local pattern=${1} | ||
local expected=${1} | ||
local actual="${2}" | ||
local err_msg="Expected to match. pattern: ${pattern}, actual: ${actual}" | ||
[[ "${actual}" =~ ${pattern} ]] || (echo >&2 "${err_msg}" && exit 1) | ||
local err_msg="Expected to match. expected: ${expected}, actual: ${actual}" | ||
if [[ "${expected}" != "${actual}" ]]; then | ||
echo >&2 "${err_msg}" | ||
exit 1 | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all tests were passed even when they didn't match. Just add a small fix and improve the clarity There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the pattern check was failing, we should understand why it was failing. The test is using Bash regex. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have context on that. The other tests in this file aren't running regex match asserts, they use full strings, so I thought the best decision was to keep things simple. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have put up #1458 to fix the existing issues with the test. Please revert your changes, removing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice!!! Let me revert my changes |
||
} | ||
|
||
# Generate Swift external deps and update build files | ||
|
@@ -23,7 +26,9 @@ assert_match() { | |
|
||
# Run MyExecutable target | ||
output="$("${bazel}" run //Sources/MyExecutable)" | ||
assert_match "Good morning, World!" "${output}" | ||
assert_match "Good morning, World! | ||
Hello, my name is Olivia and I'm 30 years old. | ||
Goodbye" "${output}" | ||
|
||
# Run old-style executable in my_local_package | ||
output="$("${bazel}" run @swiftpkg_my_local_package//:print-greeting)" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
name: //Sources/MyExecutable | ||
kind: swift_binary | ||
imports: | ||
- ArgumentParser | ||
- FarewellFramework | ||
- GreetingsFramework | ||
- MyLibrary | ||
- NotThatAmazingModule | ||
local_resolution: | ||
- module: MyLibrary | ||
label: //Sources/MyLibrary | ||
external_resolution: | ||
modules: | ||
- ArgumentParser | ||
- FarewellFramework | ||
- GreetingsFramework | ||
- NotThatAmazingModule | ||
products: | ||
- identity: my_local_package | ||
name: FarewellFramework | ||
label: '@swiftpkg_my_local_package//:FarewellFramework' | ||
- identity: my_local_package | ||
name: GreetingsFramework | ||
label: '@swiftpkg_my_local_package//:GreetingsFramework' | ||
- identity: notthatamazingmodule | ||
name: NotThatAmazingModule | ||
label: '@swiftpkg_notthatamazingmodule//:NotThatAmazingModule' | ||
- identity: swift-argument-parser | ||
name: ArgumentParser | ||
label: '@swiftpkg_swift_argument_parser//:ArgumentParser' | ||
unresolved: [] | ||
deps: | ||
- //Sources/MyLibrary | ||
- '@swiftpkg_my_local_package//:FarewellFramework' | ||
- '@swiftpkg_my_local_package//:GreetingsFramework' | ||
- '@swiftpkg_notthatamazingmodule//:NotThatAmazingModule' | ||
- '@swiftpkg_swift_argument_parser//:ArgumentParser' | ||
--- | ||
name: //Sources/MyLibrary | ||
kind: swift_library | ||
imports: | ||
- GreetingsFramework | ||
external_resolution: | ||
modules: | ||
- GreetingsFramework | ||
products: | ||
- identity: my_local_package | ||
name: GreetingsFramework | ||
label: '@swiftpkg_my_local_package//:GreetingsFramework' | ||
unresolved: [] | ||
deps: | ||
- '@swiftpkg_my_local_package//:GreetingsFramework' | ||
--- | ||
name: //Tests/MyLibraryTests | ||
kind: swift_test | ||
imports: | ||
- MyLibrary | ||
- XCTest | ||
builtins: | ||
- XCTest | ||
local_resolution: | ||
- module: MyLibrary | ||
label: //Sources/MyLibrary | ||
external_resolution: | ||
modules: | ||
- XCTest | ||
products: [] | ||
unresolved: | ||
- XCTest | ||
deps: | ||
- //Sources/MyLibrary |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#ifndef MYCLANG_LIBRARY_API_H | ||
#define MYCLANG_LIBRARY_API_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* Version information */ | ||
#define MYCLANG_VERSION_MAJOR 1 | ||
#define MYCLANG_VERSION_MINOR 0 | ||
#define MYCLANG_VERSION_PATCH 0 | ||
|
||
/* Maximum buffer sizes */ | ||
#define MYCLANG_MAX_NAME_LENGTH 256 | ||
#define MYCLANG_MAX_BUFFER_SIZE 4096 | ||
|
||
/* Status codes */ | ||
typedef enum { | ||
MYCLANG_SUCCESS = 0, | ||
MYCLANG_ERROR_INVALID_ARGUMENT = -1, | ||
MYCLANG_ERROR_BUFFER_OVERFLOW = -2, | ||
MYCLANG_ERROR_NOT_INITIALIZED = -3 | ||
} MyclangStatus; | ||
|
||
/* Farewell message types */ | ||
typedef enum { | ||
MYCLANG_FAREWELL_GOODBYE = 0, | ||
MYCLANG_FAREWELL_PARTING = 1, | ||
MYCLANG_FAREWELL_SEE_YOU_LATER = 2, | ||
MYCLANG_FAREWELL_TAKE_CARE = 3, | ||
MYCLANG_FAREWELL_ADIEU = 4, | ||
MYCLANG_FAREWELL_DEPARTURE = 5 | ||
} MyclangFarewellType; | ||
|
||
/* Data structures */ | ||
typedef struct { | ||
char name[MYCLANG_MAX_NAME_LENGTH]; | ||
unsigned int id; | ||
double value; | ||
} MyclangObject; | ||
|
||
/* Function declarations */ | ||
MyclangStatus myclang_initialize(void); | ||
MyclangStatus myclang_cleanup(void); | ||
|
||
MyclangStatus myclang_create_object(MyclangObject* obj, | ||
const char* name, | ||
unsigned int id, | ||
double value); | ||
|
||
MyclangStatus myclang_process_object(const MyclangObject* obj); | ||
|
||
const char* myclang_get_version_string(void); | ||
|
||
/* Farewell function */ | ||
const char* myclang_get_farewell_message(MyclangFarewellType type); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* MYCLANG_LIBRARY_API_H */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include <string.h> | ||
#include <stdio.h> | ||
#include "MyClangLibrary/API.h" | ||
|
||
static int g_initialized = 0; | ||
|
||
MyclangStatus myclang_initialize(void) { | ||
if (g_initialized) { | ||
return MYCLANG_ERROR_INVALID_ARGUMENT; | ||
} | ||
g_initialized = 1; | ||
return MYCLANG_SUCCESS; | ||
} | ||
|
||
MyclangStatus myclang_cleanup(void) { | ||
if (!g_initialized) { | ||
return MYCLANG_ERROR_NOT_INITIALIZED; | ||
} | ||
g_initialized = 0; | ||
return MYCLANG_SUCCESS; | ||
} | ||
|
||
MyclangStatus myclang_create_object(MyclangObject* obj, | ||
const char* name, | ||
unsigned int id, | ||
double value) { | ||
if (!g_initialized) { | ||
return MYCLANG_ERROR_NOT_INITIALIZED; | ||
} | ||
|
||
if (!obj || !name) { | ||
return MYCLANG_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
if (strlen(name) >= MYCLANG_MAX_NAME_LENGTH) { | ||
return MYCLANG_ERROR_BUFFER_OVERFLOW; | ||
} | ||
|
||
strncpy(obj->name, name, MYCLANG_MAX_NAME_LENGTH - 1); | ||
obj->name[MYCLANG_MAX_NAME_LENGTH - 1] = '\0'; | ||
obj->id = id; | ||
obj->value = value; | ||
|
||
return MYCLANG_SUCCESS; | ||
} | ||
|
||
MyclangStatus myclang_process_object(const MyclangObject* obj) { | ||
if (!g_initialized) { | ||
return MYCLANG_ERROR_NOT_INITIALIZED; | ||
} | ||
|
||
if (!obj) { | ||
return MYCLANG_ERROR_INVALID_ARGUMENT; | ||
} | ||
|
||
// Example processing - in real implementation, this would do something useful | ||
return MYCLANG_SUCCESS; | ||
} | ||
|
||
const char* myclang_get_version_string(void) { | ||
static char version[32]; | ||
snprintf(version, sizeof(version), "%d.%d.%d", | ||
MYCLANG_VERSION_MAJOR, | ||
MYCLANG_VERSION_MINOR, | ||
MYCLANG_VERSION_PATCH); | ||
return version; | ||
} | ||
|
||
const char* myclang_get_farewell_message(MyclangFarewellType type) { | ||
switch (type) { | ||
case MYCLANG_FAREWELL_GOODBYE: | ||
return "Goodbye"; | ||
case MYCLANG_FAREWELL_PARTING: | ||
return "Parting"; | ||
case MYCLANG_FAREWELL_SEE_YOU_LATER: | ||
return "See you later"; | ||
case MYCLANG_FAREWELL_TAKE_CARE: | ||
return "Take care"; | ||
case MYCLANG_FAREWELL_ADIEU: | ||
return "Adieu"; | ||
case MYCLANG_FAREWELL_DEPARTURE: | ||
return "Departure"; | ||
default: | ||
return "Goodbye"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import FarewellFramework | ||
|
||
let message = FarewellFramework.myclang_get_farewell_message(MYCLANG_FAREWELL_SEE_YOU_LATER) | ||
|
||
let swiftString = String(cString: message!) | ||
|
||
print(swiftString) |
Uh oh!
There was an error while loading. Please reload this page.