diff --git a/.gitignore b/.gitignore index c38447d0..a51df113 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ DerivedData/ .netrc coverage.txt TODO.md -template.swiftinterface +.ag_template/ diff --git a/Package.resolved b/Package.resolved index 3f04d995..990a2545 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "18d337464a9504496064f43500ecb94e8a9dde167a757ab1aeb3948247e257c0", + "originHash" : "33172a013ea78db9fbfb2be84e0c38eb0aa2efdaf6e752b088afb5349346644a", "pins" : [ { "identity" : "darwinprivateframeworks", @@ -7,7 +7,7 @@ "location" : "https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git", "state" : { "branch" : "main", - "revision" : "eaf7097192194bbd2473dcbc3d9152e3a6d428e0" + "revision" : "8628888442c0bc214a86e887d53315981c2888d2" } }, { diff --git a/Package.swift b/Package.swift index 7ea8ae7c..29f4c244 100644 --- a/Package.swift +++ b/Package.swift @@ -107,7 +107,7 @@ if swiftToolchainSupported { // MARK: - [env] OPENGRAPH_TARGET_RELEASE let releaseVersion = Context.environment["OPENGRAPH_TARGET_RELEASE"].flatMap { Int($0) } ?? 2024 -sharedCSettings.append(.define("OPENGRAPH_RELEASE", to: "\(releaseVersion)")) +//sharedCSettings.append(.define("OPENGRAPH_RELEASE", to: "\(releaseVersion)")) sharedSwiftSettings.append(.define("OPENGRAPH_RELEASE_\(releaseVersion)")) if releaseVersion >= 2021 { for year in 2021 ... releaseVersion { diff --git a/Scripts/gen_ag_interface_template.sh b/Scripts/gen_ag_interface_template.sh deleted file mode 100755 index 68a816e7..00000000 --- a/Scripts/gen_ag_interface_template.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/zsh - -# A `realpath` alternative using the default C implementation. -filepath() { - [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" -} - -OPENGRAPH_ROOT="$(dirname $(dirname $(filepath $0)))" - -cd $OPENGRAPH_ROOT - -swift build -c release -Xswiftc -emit-module-interface -Xswiftc -enable-library-evolution -Xswiftc -no-verify-emitted-module-interface -Xswiftc -package-name -Xswiftc OpenGraph -Xswiftc -Osize - -cp .build/release/Modules/OpenGraph.swiftinterface ./template.swiftinterface - -sed -i '' '1,4d' ./template.swiftinterface -sed -i '' 's/@_exported public import OpenGraphCxx/@_exported public import AttributeGraph/g' ./template.swiftinterface -sed -i '' 's/OpenGraphCxx\.//g' ./template.swiftinterface -sed -i '' 's/OpenGraph/AttributeGraph/g' ./template.swiftinterface -sed -i '' 's/OG/AG/g' ./template.swiftinterface - -echo "Generated template.swiftinterface successfully" - diff --git a/Scripts/gen_ag_template.sh b/Scripts/gen_ag_template.sh new file mode 100755 index 00000000..f9cc77a0 --- /dev/null +++ b/Scripts/gen_ag_template.sh @@ -0,0 +1,56 @@ +#!/bin/zsh + +# A `realpath` alternative using the default C implementation. +filepath() { + [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" +} + +gen_interface() { + swift build -c release -Xswiftc -emit-module-interface -Xswiftc -enable-library-evolution -Xswiftc -no-verify-emitted-module-interface -Xswiftc -package-name -Xswiftc OpenGraph -Xswiftc -Osize + + mkdir -p .ag_template + cp .build/release/Modules/OpenGraph.swiftinterface .ag_template/template.swiftinterface + + sed -i '' '1,4d' .ag_template/template.swiftinterface + sed -i '' 's/@_exported public import OpenGraphCxx/@_exported public import AttributeGraph/g' .ag_template/template.swiftinterface + sed -i '' 's/OpenGraphCxx\.//g' .ag_template/template.swiftinterface + sed -i '' 's/OpenGraph/AttributeGraph/g' .ag_template/template.swiftinterface + sed -i '' 's/OPENGRAPH/ATTRIBUTEGRAPH/g' .ag_template/template.swiftinterface + sed -i '' 's/OG/AG/g' .ag_template/template.swiftinterface + + echo "Generated template.swiftinterface successfully" +} + +gen_header() { + mkdir -p .ag_template/Headers + + cp -r Sources/OpenGraphCxx/include/OpenGraph/* .ag_template/Headers/ + + # Rename files from OGxx to AGxx and OpenGraphxx to AttributeGraphxx + find .ag_template/Headers -name "OG*" -type f | while read file; do + new_name=$(echo "$file" | sed 's/OG/AG/g') + mv "$file" "$new_name" + done + + find .ag_template/Headers -name "OpenGraph*" -type f | while read file; do + new_name=$(echo "$file" | sed 's/OpenGraph/AttributeGraph/g') + mv "$file" "$new_name" + done + + # Update content in all header files + find .ag_template/Headers -name "*.h" -type f | while read file; do + sed -i '' 's/OpenGraphCxx/AttributeGraph/g' "$file" + sed -i '' 's/OpenGraph/AttributeGraph/g' "$file" + sed -i '' 's/OPENGRAPH/ATTRIBUTEGRAPH/g' "$file" + sed -i '' 's/OG/AG/g' "$file" + done + + echo "Generated template headers successfully" +} + +OPENGRAPH_ROOT="$(dirname $(dirname $(filepath $0)))" + +cd $OPENGRAPH_ROOT + +gen_interface +gen_header diff --git a/Sources/OpenGraph/Export.swift b/Sources/OpenGraph/Export.swift index bd56c5fb..a926fe77 100644 --- a/Sources/OpenGraph/Export.swift +++ b/Sources/OpenGraph/Export.swift @@ -1,8 +1,5 @@ -@_exported public import OpenGraphCxx +// +// Export.swift +// OpenGraph -// Align the constant define behavior -#if OPENGRAPH_RELEASE_2024 -public let OPENGRAPH_RELEASE: Int32 = 2024 -#elseif OPENGRAPH_RELEASE_2021 -public let OPENGRAPH_RELEASE: Int32 = 2021 -#endif +@_exported public import OpenGraphCxx diff --git a/Sources/OpenGraphCxx/Attribute/AttributeType.cpp b/Sources/OpenGraphCxx/Attribute/AttributeType.cpp index bd808761..2b44b10d 100644 --- a/Sources/OpenGraphCxx/Attribute/AttributeType.cpp +++ b/Sources/OpenGraphCxx/Attribute/AttributeType.cpp @@ -1,8 +1,5 @@ // // OGAttributeType.cpp -// -// -// Created by Kyle on 2024/2/17. -// +// OpenGraphCxx #include diff --git a/Sources/OpenGraphCxx/Attribute/OGAttribute.cpp b/Sources/OpenGraphCxx/Attribute/OGAttribute.cpp index 64103d79..ef8217e9 100644 --- a/Sources/OpenGraphCxx/Attribute/OGAttribute.cpp +++ b/Sources/OpenGraphCxx/Attribute/OGAttribute.cpp @@ -1,9 +1,6 @@ // // OGAttribute.cpp -// -// -// Created by Kyle on 2024/2/16. -// +// OpenGraphCxx #include #include diff --git a/Sources/OpenGraphCxx/Attribute/OGWeakAttribute.cpp b/Sources/OpenGraphCxx/Attribute/OGWeakAttribute.cpp index 403b6260..f140e43b 100644 --- a/Sources/OpenGraphCxx/Attribute/OGWeakAttribute.cpp +++ b/Sources/OpenGraphCxx/Attribute/OGWeakAttribute.cpp @@ -1,9 +1,6 @@ // // OGWeakAttribute.cpp -// -// -// Created by Kyle on 2024/2/27. -// +// OpenGraphCxx #include diff --git a/Sources/OpenGraphCxx/Data/ClosureFunction.cpp b/Sources/OpenGraphCxx/Data/ClosureFunction.cpp index 7c4a02e0..253e14cb 100644 --- a/Sources/OpenGraphCxx/Data/ClosureFunction.cpp +++ b/Sources/OpenGraphCxx/Data/ClosureFunction.cpp @@ -1,8 +1,5 @@ // // ClosureFunction.cpp -// -// -// Created by Kyle on 2024/3/6. -// +// OpenGraphCxx #include diff --git a/Sources/OpenGraphCxx/DebugServer/OGDebugServer.cpp b/Sources/OpenGraphCxx/DebugServer/OGDebugServer.cpp index af2e71d7..080e45dd 100644 --- a/Sources/OpenGraphCxx/DebugServer/OGDebugServer.cpp +++ b/Sources/OpenGraphCxx/DebugServer/OGDebugServer.cpp @@ -1,9 +1,6 @@ // // OGDebugServer.cpp -// -// -// Created by Kyle on 2024/2/17. -// +// OpenGraphCxx #include #include diff --git a/Sources/OpenGraphCxx/DebugServer/og-debug-server.mm b/Sources/OpenGraphCxx/DebugServer/og-debug-server.mm index 03934eb5..fcb9eefd 100644 --- a/Sources/OpenGraphCxx/DebugServer/og-debug-server.mm +++ b/Sources/OpenGraphCxx/DebugServer/og-debug-server.mm @@ -1,8 +1,7 @@ // // og-debug-server.mm -// OpenGraph +// OpenGraphCxx // -// Created by Kyle on 2024/1/11. // Audited for 2021 Release #include diff --git a/Sources/OpenGraphCxx/Graph/GraphContext.cpp b/Sources/OpenGraphCxx/Graph/GraphContext.cpp index a2a191cb..50d70e33 100644 --- a/Sources/OpenGraphCxx/Graph/GraphContext.cpp +++ b/Sources/OpenGraphCxx/Graph/GraphContext.cpp @@ -1,9 +1,6 @@ // // GraphContext.cpp -// -// -// Created by Kyle on 2024/2/16. -// +// OpenGraphCxx #include #include diff --git a/Sources/OpenGraphCxx/Graph/OGGraph.cpp b/Sources/OpenGraphCxx/Graph/OGGraph.cpp index b2d6de1e..ffbd3fd2 100644 --- a/Sources/OpenGraphCxx/Graph/OGGraph.cpp +++ b/Sources/OpenGraphCxx/Graph/OGGraph.cpp @@ -1,9 +1,6 @@ // // OGGraph.cpp -// -// -// Created by Kyle on 2024/2/15. -// +// OpenGraphCxx #include #include diff --git a/Sources/OpenGraphCxx/Graph/OGGraphContext.cpp b/Sources/OpenGraphCxx/Graph/OGGraphContext.cpp index 6fc9245a..4cd4fed6 100644 --- a/Sources/OpenGraphCxx/Graph/OGGraphContext.cpp +++ b/Sources/OpenGraphCxx/Graph/OGGraphContext.cpp @@ -1,9 +1,6 @@ // // OGGraphContext.cpp -// -// -// Created by Kyle on 2024/2/16. -// +// OpenGraphCxx #include #include diff --git a/Sources/OpenGraphCxx/Graph/OGSubgraph.cpp b/Sources/OpenGraphCxx/Graph/OGSubgraph.cpp index 898fb80c..530db225 100644 --- a/Sources/OpenGraphCxx/Graph/OGSubgraph.cpp +++ b/Sources/OpenGraphCxx/Graph/OGSubgraph.cpp @@ -1,9 +1,6 @@ // // OGSubgraph.cpp -// -// -// Created by Kyle on 2024/2/15. -// +// OpenGraphCxx #include #include diff --git a/Sources/OpenGraphCxx/Graph/Subgraph.cpp b/Sources/OpenGraphCxx/Graph/Subgraph.cpp index 015615a4..00fba29d 100644 --- a/Sources/OpenGraphCxx/Graph/Subgraph.cpp +++ b/Sources/OpenGraphCxx/Graph/Subgraph.cpp @@ -1,9 +1,6 @@ // // Subgraph.cpp -// -// -// Created by Kyle on 2024/2/15. -// +// OpenGraphCxx #include #include diff --git a/Sources/OpenGraphCxx/Graph/Subgraph.hpp b/Sources/OpenGraphCxx/Graph/Subgraph.hpp index 9f196391..dbf3944e 100644 --- a/Sources/OpenGraphCxx/Graph/Subgraph.hpp +++ b/Sources/OpenGraphCxx/Graph/Subgraph.hpp @@ -1,9 +1,6 @@ // // Subgraph.hpp -// -// -// Created by Kyle on 2024/2/15. -// +// OpenGraphCxx #ifndef Subgraph_hpp #define Subgraph_hpp diff --git a/Sources/OpenGraphCxx/Util/assert.cpp b/Sources/OpenGraphCxx/Util/assert.cpp index 21cbccc3..7d85df66 100644 --- a/Sources/OpenGraphCxx/Util/assert.cpp +++ b/Sources/OpenGraphCxx/Util/assert.cpp @@ -1,9 +1,6 @@ // // assert.cpp -// -// -// Created by Kyle on 2024/1/21. -// +// OpenGraphCxx #include #include diff --git a/Sources/OpenGraphCxx/Util/log.cpp b/Sources/OpenGraphCxx/Util/log.cpp index 80428465..b7c4a9f4 100644 --- a/Sources/OpenGraphCxx/Util/log.cpp +++ b/Sources/OpenGraphCxx/Util/log.cpp @@ -1,8 +1,7 @@ // // OGLog.cpp -// OpenGraph +// OpenGraphCxx // -// Created by Kyle on 2024/1/12. // Audited for 2021 Release #include diff --git a/Sources/OpenGraphCxx/Util/realloc_vector.cpp b/Sources/OpenGraphCxx/Util/realloc_vector.cpp index be8b1daa..7d073a78 100644 --- a/Sources/OpenGraphCxx/Util/realloc_vector.cpp +++ b/Sources/OpenGraphCxx/Util/realloc_vector.cpp @@ -1,9 +1,6 @@ // // realloc_vector.cpp -// -// -// Created by Kyle on 2024/1/17. -// +// OpenGraphCxx #include #include diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeInfo.h b/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeInfo.h index fda95fc5..be401467 100644 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeInfo.h +++ b/Sources/OpenGraphCxx/include/OpenGraph/OGAttributeInfo.h @@ -1,9 +1,6 @@ // // OGAttributeInfo.h -// -// -// Created by Kyle on 2024/2/17. -// +// OpenGraphCxx #ifndef OGAttributeInfo_h #define OGAttributeInfo_h diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGUniqueID.h b/Sources/OpenGraphCxx/include/OpenGraph/OGUniqueID.h index bec0f32b..c57eeb47 100644 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGUniqueID.h +++ b/Sources/OpenGraphCxx/include/OpenGraph/OGUniqueID.h @@ -1,12 +1,12 @@ // -// OGMakeUniqueID.h +// OGUniqueID.h // OpenGraphCxx // // Audited for iOS 18.0 // Status: Complete -#ifndef OGMakeUniqueID_h -#define OGMakeUniqueID_h +#ifndef OGUniqueID_h +#define OGUniqueID_h #include typedef long OGUniqueID; @@ -17,4 +17,4 @@ OG_REFINED_FOR_SWIFT OGUniqueID OGMakeUniqueID(void) OG_SWIFT_NAME(makeUniqueID()); OG_EXTERN_C_END -#endif /* OGMakeUniqueID_h */ +#endif /* OGUniqueID_h */ diff --git a/Sources/OpenGraphCxx/include/OpenGraph/OGVersion.h b/Sources/OpenGraphCxx/include/OpenGraph/OGVersion.h index d72cf048..05c1d781 100644 --- a/Sources/OpenGraphCxx/include/OpenGraph/OGVersion.h +++ b/Sources/OpenGraphCxx/include/OpenGraph/OGVersion.h @@ -7,6 +7,8 @@ #include +#define OPENGRAPH_RELEASE 2024 + #define OPENGRAPH_RELEASE_2021 2021 #define OPENGRAPH_RELEASE_2024 2024 diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Attribute/AttributeID.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Attribute/AttributeID.hpp index 29e83e07..a67e6f0e 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Attribute/AttributeID.hpp +++ b/Sources/OpenGraphCxx/include/OpenGraphCxx/Attribute/AttributeID.hpp @@ -1,9 +1,6 @@ // // AttributeID.hpp -// -// -// Created by Kyle on 2024/2/16. -// +// OpenGraphCxx #ifndef AttributeID_hpp #define AttributeID_hpp diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/ClosureFunction.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/ClosureFunction.hpp index be5de90a..08c6e949 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/ClosureFunction.hpp +++ b/Sources/OpenGraphCxx/include/OpenGraphCxx/Data/ClosureFunction.hpp @@ -1,9 +1,6 @@ // // ClosureFunction.hpp -// -// -// Created by Kyle on 2024/3/6. -// +// OpenGraphCxx #ifndef ClosureFunction_hpp #define ClosureFunction_hpp diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/DebugServer/og-debug-server.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/DebugServer/og-debug-server.hpp index f3c76f32..53e9970d 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/DebugServer/og-debug-server.hpp +++ b/Sources/OpenGraphCxx/include/OpenGraphCxx/DebugServer/og-debug-server.hpp @@ -1,8 +1,7 @@ // // og-debug-server.hpp +// OpenGraphCxx // -// -// Created by Kyle on 2024/1/11. // Audited for 2021 Release #ifndef og_debug_server_hpp diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Graph/Subgraph.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Graph/Subgraph.hpp index b1a54b27..9a657d27 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Graph/Subgraph.hpp +++ b/Sources/OpenGraphCxx/include/OpenGraphCxx/Graph/Subgraph.hpp @@ -1,9 +1,6 @@ // // Subgraph.hpp -// -// -// Created by Kyle on 2024/2/15. -// +// OpenGraphCxx #ifndef Subgraph_hpp #define Subgraph_hpp diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/env.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/env.hpp index 29b539b4..826efd89 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/env.hpp +++ b/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/env.hpp @@ -1,9 +1,6 @@ // // env.hpp -// -// -// Created by Kyle on 2024/4/4. -// +// OpenGraphCxx #ifndef env_hpp #define env_hpp diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/log.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/log.hpp index affa31d3..4094182c 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/log.hpp +++ b/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/log.hpp @@ -1,8 +1,7 @@ // // log.hpp +// OpenGraphCxx // -// -// Created by Kyle on 2024/1/12. // Audited for 2021 Release #ifndef log_hpp diff --git a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/realloc_vector.hpp b/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/realloc_vector.hpp index 89f64c92..8caea6d9 100644 --- a/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/realloc_vector.hpp +++ b/Sources/OpenGraphCxx/include/OpenGraphCxx/Util/realloc_vector.hpp @@ -1,9 +1,6 @@ // // realloc_vector.hpp -// -// -// Created by Kyle on 2024/1/17. -// +// OpenGraphCxx #ifndef realloc_vector_hpp #define realloc_vector_hpp