cxfeng1 closed pull request #1554: [iOS] Generate build time and time stamp 
when build.
URL: https://github.com/apache/incubator-weex/pull/1554
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj 
b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
index 9caf17bc13..8afa19735d 100644
--- a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
+++ b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
@@ -307,6 +307,10 @@
                B85ED3032126715100EBEC11 /* WXRecyclerComponent.h in Headers */ 
= {isa = PBXBuildFile; fileRef = 745B2D601E5A8E1E0092D38A /* 
WXRecyclerComponent.h */; };
                B863DF322107308000EA887D /* WXBridgeContext.m in Sources */ = 
{isa = PBXBuildFile; fileRef = B863DF312107307F00EA887D /* WXBridgeContext.m 
*/; };
                B863DF332107313400EA887D /* WXBridgeContext.m in Sources */ = 
{isa = PBXBuildFile; fileRef = B863DF312107307F00EA887D /* WXBridgeContext.m 
*/; };
+               B87B9E7D21539B3300B6DC61 /* WXVersion.h in Headers */ = {isa = 
PBXBuildFile; fileRef = B87B9E7B21539B3300B6DC61 /* WXVersion.h */; };
+               B87B9E7E21539B3300B6DC61 /* WXVersion.h in Headers */ = {isa = 
PBXBuildFile; fileRef = B87B9E7B21539B3300B6DC61 /* WXVersion.h */; };
+               B87B9E7F21539B3300B6DC61 /* WXVersion.m in Sources */ = {isa = 
PBXBuildFile; fileRef = B87B9E7C21539B3300B6DC61 /* WXVersion.m */; };
+               B87B9E8021539B3300B6DC61 /* WXVersion.m in Sources */ = {isa = 
PBXBuildFile; fileRef = B87B9E7C21539B3300B6DC61 /* WXVersion.m */; };
                B89543F320EB18B5006EAD63 /* WXCoreBridge.mm in Sources */ = 
{isa = PBXBuildFile; fileRef = B89543ED20EB18B4006EAD63 /* WXCoreBridge.mm */; 
};
                B89543F420EB18B5006EAD63 /* WXCoreBridge.mm in Sources */ = 
{isa = PBXBuildFile; fileRef = B89543ED20EB18B4006EAD63 /* WXCoreBridge.mm */; 
};
                B89543F520EB18B5006EAD63 /* WXJSCoreBridge.mm in Sources */ = 
{isa = PBXBuildFile; fileRef = B89543EE20EB18B4006EAD63 /* WXJSCoreBridge.mm 
*/; };
@@ -1280,6 +1284,8 @@
                B8394F3521468AF100CA1EFF /* render_action_trigger_vsync.h */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; 
path = render_action_trigger_vsync.h; sourceTree = "<group>"; };
                B8394F3621468AF100CA1EFF /* render_action_trigger_vsync.cpp */ 
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.cpp.cpp; path = render_action_trigger_vsync.cpp; sourceTree = 
"<group>"; };
                B863DF312107307F00EA887D /* WXBridgeContext.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= WXBridgeContext.m; sourceTree = "<group>"; };
+               B87B9E7B21539B3300B6DC61 /* WXVersion.h */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WXVersion.h; 
sourceTree = "<group>"; };
+               B87B9E7C21539B3300B6DC61 /* WXVersion.m */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WXVersion.m; 
sourceTree = "<group>"; };
                B89543ED20EB18B4006EAD63 /* WXCoreBridge.mm */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; 
path = WXCoreBridge.mm; sourceTree = "<group>"; };
                B89543EE20EB18B4006EAD63 /* WXJSCoreBridge.mm */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; 
path = WXJSCoreBridge.mm; sourceTree = "<group>"; };
                B89543EF20EB18B4006EAD63 /* WXCoreBridge.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
WXCoreBridge.h; sourceTree = "<group>"; };
@@ -2015,6 +2021,8 @@
                                77D161601C02ED790010B15B /* WXLog.h */,
                                77D161611C02ED790010B15B /* WXLog.m */,
                                775BEE4D1C16F993008D1629 /* WXDefine.h */,
+                               B87B9E7B21539B3300B6DC61 /* WXVersion.h */,
+                               B87B9E7C21539B3300B6DC61 /* WXVersion.m */,
                                742389991C3174EB00D748CA /* 
WXWeakObjectWrapper.h */,
                                7423899A1C3174EB00D748CA /* 
WXWeakObjectWrapper.m */,
                                7423899D1C32733800D748CA /* WXType.h */,
@@ -2723,6 +2731,7 @@
                                B8D66CB521255730003960BD /* ViewUtils.h in 
Headers */,
                                77E659DA1C07F594008B8775 /* WXDomModule.h in 
Headers */,
                                74EF31AD1DE58BE200667A07 /* 
WXURLRewriteDefaultImpl.h in Headers */,
+                               B87B9E7D21539B3300B6DC61 /* WXVersion.h in 
Headers */,
                                746B923B1F46BE36009AE86B /* 
WXCellSlotComponent.h in Headers */,
                                744D61101E49979000B624B3 /* WXFooterComponent.h 
in Headers */,
                                744D61141E4AF23E00B624B3 /* WXDiffUtil.h in 
Headers */,
@@ -3065,6 +3074,7 @@
                                DCA4461E1EFA5AAF00D0CFA8 /* 
WXComponentFactory.h in Headers */,
                                B8D66CB621255730003960BD /* ViewUtils.h in 
Headers */,
                                DCA445F41EFA5A2800D0CFA8 /* 
WXNavigationDefaultImpl.h in Headers */,
+                               B87B9E7E21539B3300B6DC61 /* WXVersion.h in 
Headers */,
                                B8D66C9421255730003960BD /* dom_wson.h in 
Headers */,
                                DCA445E51EFA59E100D0CFA8 /* WXDivComponent.h in 
Headers */,
                                DCA446211EFA5ABA00D0CFA8 /* 
WXSDKInstance_private.h in Headers */,
@@ -3341,7 +3351,7 @@
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = ". 
\"${PROJECT_DIR}/buildScripts.sh\"\n\ngenerateSDKHeader 'WeexSDK'\n";
+                       shellScript = ". 
\"${PROJECT_DIR}/buildScripts.sh\"\n\ngenerateSDKHeader 
'WeexSDK'\ngenerateBuildTime 
\"${PROJECT_DIR}/WeexSDK/Sources/Utility/WXVersion.m\"\n";
                };
                DCA445C81EFA584000D0CFA8 /* Generate WeexSDK.h */ = {
                        isa = PBXShellScriptBuildPhase;
@@ -3356,7 +3366,7 @@
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                        shellPath = /bin/sh;
-                       shellScript = ". 
\"${PROJECT_DIR}/buildScripts.sh\"\n\ngenerateSDKHeader 'WeexSDK'";
+                       shellScript = ". 
\"${PROJECT_DIR}/buildScripts.sh\"\n\ngenerateSDKHeader 
'WeexSDK'\ngenerateBuildTime 
\"${PROJECT_DIR}/WeexSDK/Sources/Utility/WXVersion.m\"\n";
                };
 /* End PBXShellScriptBuildPhase section */
 
@@ -3491,6 +3501,7 @@
                                74862F7E1E03A0F300B7A041 /* WXModuleMethod.m in 
Sources */,
                                B8D66C4D21255730003960BD /* 
render_action_move_element.cpp in Sources */,
                                742AD7341DF98C45007DC46C /* 
WXResourceResponse.m in Sources */,
+                               B87B9E7F21539B3300B6DC61 /* WXVersion.m in 
Sources */,
                                77E65A161C155EB5008B8775 /* WXTextComponent.mm 
in Sources */,
                                C4D872261E5DDF7500E39BC1 /* WXBoxShadow.m in 
Sources */,
                                B8D66BB32125572F003960BD /* parser.cc in 
Sources */,
@@ -3755,6 +3766,7 @@
                                DCA445751EFA55B300D0CFA8 /* WXUtility.m in 
Sources */,
                                74B81AEA1F73C3E900D3A61D /* 
WXRecycleListUpdateManager.m in Sources */,
                                74B81AF01F73C3E900D3A61D /* 
WXComponent+DataBinding.mm in Sources */,
+                               B87B9E8021539B3300B6DC61 /* WXVersion.m in 
Sources */,
                                DCA445761EFA55B300D0CFA8 /* WXLog.m in Sources 
*/,
                                DCA445771EFA55B300D0CFA8 /* 
WXWeakObjectWrapper.m in Sources */,
                                B8D66C9621255730003960BD /* dom_wson.cpp in 
Sources */,
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXDefine.h 
b/ios/sdk/WeexSDK/Sources/Utility/WXDefine.h
index 56043f47ef..332cfe168f 100644
--- a/ios/sdk/WeexSDK/Sources/Utility/WXDefine.h
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXDefine.h
@@ -183,3 +183,11 @@ return;\
 #endif
 
 #endif
+
+WX_EXTERN_C_BEGIN
+
+NSString* GetWeexSDKVersion(void);
+NSString* GetWeexSDKBuildTime(void);
+unsigned long GetWeexSDKBuildTimestamp(void);
+
+WX_EXTERN_C_END
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXVersion.h 
b/ios/sdk/WeexSDK/Sources/Utility/WXVersion.h
new file mode 100644
index 0000000000..cb84a42fa4
--- /dev/null
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXVersion.h
@@ -0,0 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+#import <Foundation/Foundation.h>
diff --git a/ios/sdk/WeexSDK/Sources/Utility/WXVersion.m 
b/ios/sdk/WeexSDK/Sources/Utility/WXVersion.m
new file mode 100644
index 0000000000..aef6efc273
--- /dev/null
+++ b/ios/sdk/WeexSDK/Sources/Utility/WXVersion.m
@@ -0,0 +1,40 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one 
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you 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.
+ */
+
+#import "WXVersion.h"
+#import "WXDefine.h"
+
+static const char* WeexSDKBuildTime = "2018-09-20 09:52:40 UTC";
+static const unsigned long WeexSDKBuildTimestamp = 1537437160;
+
+NSString* GetWeexSDKVersion(void)
+{
+    return WX_SDK_VERSION;
+}
+
+NSString* GetWeexSDKBuildTime(void)
+{
+    return [NSString stringWithUTF8String:WeexSDKBuildTime];
+}
+
+unsigned long GetWeexSDKBuildTimestamp(void)
+{
+    return WeexSDKBuildTimestamp;
+}
+
diff --git a/ios/sdk/buildScripts.sh b/ios/sdk/buildScripts.sh
index 57d0048646..905dbbe696 100644
--- a/ios/sdk/buildScripts.sh
+++ b/ios/sdk/buildScripts.sh
@@ -115,3 +115,54 @@ function generateSDKHeader() {
        fi
        generateHeader "${PROJECT_DIR}/${PROJECT_NAME}.xcodeproj" 
"${publicHeaderFilePath}" 'Public' $sdkName
 }
+
+# generateBuildTime
+# param 1: file
+function generateBuildTime() {
+       file=$1
+       if [ -f "$file" ]; then
+               now="`date -u "+%Y-%m-%d %H:%M:%S"`";
+               nowStamp="`date +%s`";
+
+               echo '/*' > $file
+               echo '* Licensed to the Apache Software Foundation (ASF) under 
one 
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you 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.' >> $file
+               echo ' */' >> $file
+               echo '' >> $file
+               echo "#import \"WXVersion.h\"
+#import \"WXDefine.h\"
+
+static const char* WeexSDKBuildTime = \"$now UTC\";
+static const unsigned long WeexSDKBuildTimestamp = $nowStamp;
+
+NSString* GetWeexSDKVersion(void)
+{
+    return WX_SDK_VERSION;
+}
+
+NSString* GetWeexSDKBuildTime(void)
+{
+    return [NSString stringWithUTF8String:WeexSDKBuildTime];
+}
+
+unsigned long GetWeexSDKBuildTimestamp(void)
+{
+    return WeexSDKBuildTimestamp;
+}
+" >> $file
+       fi
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to