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

Add a xcode-gen tool to genenrate ios demo. #31

Merged
merged 1 commit into from
Nov 13, 2023
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
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ if (HasParent)
set(TGFX_SHARED_LIBS ${TGFX_SHARED_LIBS} PARENT_SCOPE)
endif ()

foreach (FILE_PATH ${TGFX_FILES})
get_filename_component(FILE_NAME "${FILE_PATH}" NAME_WE)
if (NOT FILE_NAME)
list(APPEND TGFX_EXCLUDE_FILES ${FILE_PATH})
endif ()
endforeach ()

if (TGFX_EXCLUDE_FILES)
list(REMOVE_ITEM TGFX_FILES ${TGFX_EXCLUDE_FILES})
endif ()
Expand Down Expand Up @@ -405,6 +412,13 @@ if (TGFX_BUILD_TESTS)
list(APPEND TGFX_TEST_LINK_OPTIONS "-ld_classic")
endif ()

foreach (FILE_PATH ${TGFX_TEST_FILES})
get_filename_component(FILE_NAME "${FILE_PATH}" NAME_WE)
if (NOT FILE_NAME)
list(APPEND TGFX_TEST_EXCLUDE_FILES ${FILE_PATH})
endif ()
endforeach ()

if (TGFX_TEST_EXCLUDE_FILES)
list(REMOVE_ITEM TGFX_TEST_FILES ${TGFX_TEST_EXCLUDE_FILES})
endif ()
Expand Down
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"common": [
{
"url": "${PAG_GROUP}/vendor_tools.git",
"commit": "5192001eb4789b114f381e035c840af9bfeb69a6",
"commit": "ad29d0cc25f95c5c53f66676dd66a42dcd35d05e",
"dir": "third_party/vendor_tools"
},
{
Expand Down
10 changes: 6 additions & 4 deletions ios/Hello2D.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
E61EC8222AF1FCB000C82F9E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E61EC8212AF1FCB000C82F9E /* Assets.xcassets */; };
E61EC8252AF1FCB000C82F9E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E61EC8232AF1FCB000C82F9E /* LaunchScreen.storyboard */; };
E61EC8282AF1FCB000C82F9E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E61EC8272AF1FCB000C82F9E /* main.m */; };
F20A4C162AFEA367004CDE2A /* tgfx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F20A4C152AFEA367004CDE2A /* tgfx.a */; };
F2272B672AF87D96004DEF8D /* tgfx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F2272B662AF87D96004DEF8D /* tgfx.a */; };
F25AD0712AF90ECD0017339D /* bridge.jpg in Resources */ = {isa = PBXBuildFile; fileRef = F25AD0702AF90ECD0017339D /* bridge.jpg */; };
F276A9802AF8D42200E482B7 /* TGFXView.mm in Sources */ = {isa = PBXBuildFile; fileRef = F276A97F2AF8D42200E482B7 /* TGFXView.mm */; };
/* End PBXBuildFile section */
Expand All @@ -32,7 +32,7 @@
E61EC8242AF1FCB000C82F9E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
E61EC8262AF1FCB000C82F9E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E61EC8272AF1FCB000C82F9E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
F20A4C152AFEA367004CDE2A /* tgfx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; name = tgfx.a; path = "tgfx/Debug-iphoneos/tgfx.a"; sourceTree = "<group>"; };
F2272B662AF87D96004DEF8D /* tgfx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = tgfx.a; sourceTree = BUILT_PRODUCTS_DIR; };
F25AD0702AF90ECD0017339D /* bridge.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bridge.jpg; sourceTree = "<group>"; };
F276A97E2AF8D3EB00E482B7 /* TGFXView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGFXView.h; sourceTree = "<group>"; };
F276A97F2AF8D42200E482B7 /* TGFXView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TGFXView.mm; sourceTree = "<group>"; };
Expand All @@ -43,7 +43,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F20A4C162AFEA367004CDE2A /* tgfx.a in Frameworks */,
F2272B672AF87D96004DEF8D /* tgfx.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -91,7 +91,7 @@
E61EC82E2AF1FEAE00C82F9E /* Frameworks */ = {
isa = PBXGroup;
children = (
F20A4C152AFEA367004CDE2A /* tgfx.a */,
F2272B662AF87D96004DEF8D /* tgfx.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -354,6 +354,7 @@
);
LIBRARY_SEARCH_PATHS = "tgfx/**";
MARKETING_VERSION = 1.0;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.tgfx.hello2d;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -391,6 +392,7 @@
);
LIBRARY_SEARCH_PATHS = "tgfx/**";
MARKETING_VERSION = 1.0;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = org.tgfx.hello2d;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
19 changes: 10 additions & 9 deletions ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@ A minimal project that demonstrates how to integrate the tgfx library into your
## Prerequisites

Before you begin building the demo project, please make sure to carefully follow the instructions
provided in the [README.md](../README.md) file located in the root directory. That documentation will guide
provided in the [README.md](../README.md) file located in the root directory. That documentation
will guide
you through the necessary steps to configure your development environment.

## Build & Run

Run the following command in the ios/ directory:

```
./gen_project [-a arm64|x64|arm64-simulator] [-Dcmake_variable=value]...
./gen [-p ios|simulator] [-a arm64|x64] [-Dcmake_variable=value]...
```

The `-a` option is used to specify the project architecture. It accepts one of the following values:
`arm64`, `x64`, `arm64-simulator`. The `x64` and `arm64-simulator` arches are intended for building
simulators. If no architecture is specified, the script will default to `arm64`. Additionally, you
can pass cmake options using the `-D` option. For example, if you want to generate a project with
webp encoding support for the arm64 simulator, you can execute the following command:
The `-a` option is used to specify the project architecture that accepts either `arm64` or `x64`.
The `-a x64` option is valid only with `-p simulator`. If no platform is specified, the script
will default to `ios`. Additionally, you can pass cmake options using the `-D` option. For example,
if you want to generate a project with webp encoding support for the arm64 simulator, you can
execute the following command:

```
./gen_project -a arm64-simulator -DTGFX_USE_WEBP_ENCODE=ON
./gen -p simulator -a arm64 -DTGFX_USE_WEBP_ENCODE=ON
```

And then, launch XCode and open the ios/Hello2D.xcworkspace. Once you've done that, you'll be all
And then, launch XCode and open the ios/Hello2D.xcworkspace. Once you've done that, you'll be all
set and ready to go!

15 changes: 15 additions & 0 deletions ios/gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env node
// run 'gen -h" to print help message
const path = require('path');

process.argv.push(path.resolve(__dirname, "../"));
let args = process.argv.slice(2);
if (args.indexOf("-p") === -1 && args.indexOf("--platform") === -1) {
process.argv.push("-p");
process.argv.push("ios");
}
if (args.indexOf("-o") === -1 && args.indexOf("--output") === -1) {
process.argv.push("-o");
process.argv.push(__dirname);
}
require("../third_party/vendor_tools/xcode-gen");
7 changes: 0 additions & 7 deletions ios/gen_project

This file was deleted.