我编写了一个小型命令行工具,其中包含一些 GPL 代码。一切都进行得很顺利。使用操作系统 10.6。
使用的外部代码有一个config.h头文件,是通过调用autoconf创建的。我想将该工具部署到不同的操作系统版本。因此 config.h 可能看起来像
// config.h
#if MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_4
// autoconf created config.h content for 10.4 comes here
#elif MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_5
// autoconf created config.h content for 10.5 comes here
#elif MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_6
// autoconf created config.h content for 10.6 comes here
#else
#error "muahahaha"
#endif
Run Code Online (Sandbox Code Playgroud)
在生成 config.h 时告诉 autoconf 使用 /Developer/SDKs/MacOSX10.XXXX.sdk/usr/ 的方法是什么?
为了测试它我已经跑了
#!/bin/bash
# for 10.6
export CC="/usr/bin/gcc-4.2"
export CXX="/usr/bin/g++-4.2"
export MACOSX_DEPLOYMENT_TARGET="10.6"
export OSX_SDK="/Developer/SDKs/MacOSX10.6.sdk"
export OSX_CFLAGS="-isysroot $OSX_SDK -arch x86_64 -arch i386"
export …
Run Code Online (Sandbox Code Playgroud) 我必须更改XML的"未知"内容.结构和内容本身是有效的.原版的
<blabla foo="bar">
<aa>asas</aa>
<ff>
<cc>
<dd />
</cc>
</ff>
<gg attr2="2">
</gg>
...
...
</blabla>
Run Code Online (Sandbox Code Playgroud)
变
<blabla foo="bar">
<magic>
<aa>asas</aa>
<ff>
<cc>
<dd />
</cc>
</ff>
<gg attr2="2">
</gg>
...
...
</magic>
</blabla>
Run Code Online (Sandbox Code Playgroud)
因此,在文档根节点(document.documentElement)下直接添加子项并在其下"推送""原始"子项.这里必须用普通的javascript(ecmascript)来完成.
现在的想法是
// Get the root node
RootNode = mymagicdoc.documentElement;
// Create new magic element (that will contain contents of original root node)
var magicContainer = mymagicdoc.createElement("magic");
// Copy all root node children (and their sub tree - deep copy) to magic node
/* ????? here …
Run Code Online (Sandbox Code Playgroud)