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

commandLine fixes PG 0.70.0 #567

Merged
merged 9 commits into from
Aug 21, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,4 @@ commandLine/.vs/commandLine/xs
commandLine/.vs/
commandLine/bin
commandLine/dll
commandLine/icon.aps
4 changes: 2 additions & 2 deletions commandLine/src/defines.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define OFPROJECTGENERATOR_MAJOR_VERSION 0
#define OFPROJECTGENERATOR_MINOR_VERSION 67
#define OFPROJECTGENERATOR_MINOR_VERSION 70
#define OFPROJECTGENERATOR_PATCH_VERSION 0

#define PG_VERSION "69"
#define PG_VERSION "0.70.0"
12 changes: 7 additions & 5 deletions commandLine/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ constexpr option::Descriptor usage[] = {
{ LISTTEMPLATES, 0, "l", "listtemplates", option::Arg::None, " --listtemplates, -l \tlist templates available for the specified or current platform(s)" },
{ PLATFORMS, 0, "p", "platforms", option::Arg::Optional, " --platforms, -p \tplatform list (such as osx, ios, winvs)" },
{ ADDONS, 0, "a", "addons", option::Arg::Optional, " --addons, -a \taddon list (such as ofxOpenCv, ofxGui, ofxXmlSettings)" },
{ ADDONS, 0, "a", "addons", option::Arg::Optional, " --addons, -a \taddon list (such as ofxOpenCv, ofxGui, ofxXmlSettings)" },
{ OFPATH, 0, "o", "ofPath", option::Arg::Optional, " --ofPath, -o \tpath to openframeworks (relative or absolute). This *must* be set, or you can also alternatively use an environment variable PG_OF_PATH and if this isn't set, it will use that value instead" },
{ VERBOSE, 0, "v", "verbose", option::Arg::None, " --verbose, -v \trun verbose" },
{ TEMPLATE, 0, "t", "template", option::Arg::Optional, " --template, -t \tproject template" },
Expand Down Expand Up @@ -444,6 +443,8 @@ int main(int argc, char ** argv) {

if (options[BACKUP_PROJECT_FILES].count() > 0) {
bBackup = true;
backupProjectFiles = bBackup;
ofLogVerbose() << "Backup project files: true";
}

// templates:
Expand Down Expand Up @@ -538,8 +539,8 @@ int main(int argc, char ** argv) {

#ifndef DEBUG_NO_OPTIONS
if (options[HELP] || argc == 0) {
messageError("No arguments");
printHelp();
messageError("No arguments");
return EXIT_OK;
}
#endif
Expand All @@ -566,9 +567,9 @@ int main(int argc, char ** argv) {


if (projectName == "") {
messageError("Missing project path");
printHelp();
consoleSpace();
messageError("Missing project path");
return EXIT_USAGE;
}

Expand Down Expand Up @@ -633,10 +634,11 @@ int main(int argc, char ** argv) {
if (bListTemplates) {
auto ret = printTemplates();
consoleSpace();
if (ret) {

if (ret) {
messageReturn("status", "EXIT_OK");
return EXIT_OK;
} else {
messageError("printTemplates data error");
return EXIT_DATAERR;
}
}
Expand Down
12 changes: 11 additions & 1 deletion commandLine/src/projects/VSCodeProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ std::string VSCodeProject::LOG_NAME = "VSCodeProject";

bool VSCodeProject::createProjectFile(){

if (backupProjectFiles) {
createBackup({ projectDir / ".vscode" / "c_cpp_properties.json" }, projectDir);
createBackup({ projectDir / ".vscode" / "extensions.json" }, projectDir);
createBackup({ projectDir / ".vscode" / "launch.json" }, projectDir);
createBackup({ projectDir / ".vscode" / "tasks.json" }, projectDir);
createBackup({ projectDir / (projectName + ".code-workspace") }, projectDir);
createBackup({ projectDir / "addons.make" }, projectDir);
createBackup({ projectDir / "config.make" }, projectDir);
createBackup({ projectDir / "Makefile" }, projectDir);
}

#if defined(__MINGW32__) || defined(__MINGW64__)
try {
fs::remove_all(projectDir / ".vscode");
Expand All @@ -78,7 +89,6 @@ bool VSCodeProject::createProjectFile(){
}
#endif

createBackup(projectDir / ".vscode");
try {
fs::copy(templatePath / ".vscode", projectDir / ".vscode", fs::copy_options::update_existing | fs::copy_options::recursive);
} catch(fs::filesystem_error& e) {
Expand Down
12 changes: 9 additions & 3 deletions commandLine/src/projects/visualStudioProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ bool visualStudioProject::createProjectFile(){

ensureDllDirectoriesExist();
solution = projectDir / (projectName + ".sln");
createBackup(solution);
if (backupProjectFiles) {
createBackup(solution, projectDir);
createBackup({ projectDir / "addons.make" }, projectDir);
createBackup({ projectDir / "config.make" }, projectDir);
createBackup({ projectDir / "Makefile" }, projectDir);
createBackup({ projectDir / (projectName + ".vcxproj") }, projectDir);
}

std::pair <string, string> replacementsForward, replacementsBack;
if (!fs::equivalent(getOFRoot(), fs::path{ "../../.." })) {
Expand Down Expand Up @@ -508,9 +514,9 @@ void visualStudioProject::addDefine(string define, LibType libType) {
}

void visualStudioProject::ensureDllDirectoriesExist() {
std::vector<fs::path> dirs { "dll\\x64", "dll\\ARM64", "dll\\ARM64EC" };
std::vector<fs::path> dirs { { "dll/x64" }, { "dll/ARM64" }, { "dll/ARM64EC" } };
for (const auto & dir : dirs) {
fs::path dirPath = projectDir / dir;
fs::path dirPath = { projectDir / dir };
dirPath = normalizePath(dirPath);
if (!fs::exists(dirPath)) {
ofLogVerbose() << "adding dll folder: [" << dirPath.string() << "]";
Expand Down
11 changes: 11 additions & 0 deletions commandLine/src/projects/xcodeProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,23 @@ bool xcodeProject::createProjectFile(){
}
}

if (backupProjectFiles) {
createBackup({ xcodeProject / "project.pbxproj" }, projectDir);
createBackup({ projectDir / "openFrameworks-Info.plist" }, projectDir);
createBackup({ projectDir / "Project.xcconfig" }, projectDir);
createBackup({ projectDir / "of.entitlements" }, projectDir);
createBackup({ projectDir / "addons.make" }, projectDir);
createBackup({ projectDir / "config.make" }, projectDir);
createBackup({ projectDir / "Makefile" }, projectDir);
}

saveScheme();

if(target == "osx" || target == "macos"){
saveMakefile();
}



// Execute all file copy and replacements, including ones in saveScheme, saveMakefile
for (auto & c : copyTemplateFiles) {
Expand Down
14 changes: 11 additions & 3 deletions commandLine/src/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,16 @@ bool ofIsPathInPath(const fs::path & path, const fs::path & base) {
}


void createBackup(const fs::path &path) {
void createBackup(const fs::path & path, const fs::path & backupPath) {
if(fs::exists(path)) {
fs::path backupDir = path.parent_path();
fs::path backupFile = backupDir / (path.filename().string() + ".bak");
std::string datetimeStr = ofGetTimestampString("%Y-%m-%d");

fs::path backupDir = { backupPath / "backups" / datetimeStr };
if (fs::exists(backupDir)) {
std::string hour = ofGetTimestampString("%H-%M");
backupDir = { backupPath / "backups" / (datetimeStr + "_" + hour) };
}
fs::path backupFile = backupDir / (path.filename().string());
if (!fs::exists(backupDir)) {
fs::create_directories(backupDir);
}
Expand Down Expand Up @@ -651,3 +657,5 @@ fs::path ofRelativeToOFPATH(const fs::path& path) {
}
}



4 changes: 3 additions & 1 deletion commandLine/src/utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ using std::vector;
using std::cout;
using std::endl;

static bool backupProjectFiles = false;

static std::map <ofTargetPlatform, std::string> platformsToString {
{ OF_TARGET_ANDROID, "android" },
// { OF_TARGET_EMSCRIPTEN, "" },
Expand Down Expand Up @@ -108,7 +110,7 @@ std::string getPGVersion();
fs::path makeRelative(const fs::path& from, const fs::path& to);

bool ofIsPathInPath(const fs::path & path, const fs::path & base);
void createBackup(const fs::path &path);
void createBackup(const fs::path & path, const fs::path & backupPath);

std::string normalizePath(const std::string& path);

Expand Down
50 changes: 25 additions & 25 deletions frontend/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 45 additions & 18 deletions scripts/vs/test_cmdline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,84 @@ SCRIPT_DIR="$( cd "$( dirname "${CURRENT_DIR}"/../../ )" && pwd )"
PG_DIR="$( cd "$( dirname "${SCRIPT_DIR}"/../../ )" && pwd )"

CMD_DIR="${PG_DIR}/commandLine"
EXE_FILE="projectGenerator.exe"

echo "CURRENT_DIR: ${CURRENT_DIR}"
echo "SCRIPT_DIR: ${SCRIPT_DIR}"
echo "PG_DIR: ${PG_DIR}"
echo "CMD_DIR: ${CMD_DIR}"

echo "====== ${CMD_DIR}"
# Compile commandline tool

cd "${CMD_DIR}/bin"
echo "Testing projectGenerator: [vs]";
chmod +x projectGenerator
./projectGenerator --recursive -pvs -o../../../../ ../../../../examples/
pwd
ls
if [[ -f "${EXE_FILE}" ]]; then
echo "File ${EXE_FILE} exists."
else
echo "File ${EXE_FILE} does not exist. trying commandLine.exe"
EXE_FILE="commandLine.exe"
if [[ -f "${EXE_FILE}" ]]; then
echo "File ${EXE_FILE} exists."
else
echo "No commandLine.exe either! Fail! exiting"
exit 1
fi
fi
echo "Executable File: ${EXE_FILE}"
echo "Testing projectGenerator: [vs]"


chmod +x "${EXE_FILE}"

# Run the project generator executable
./"${EXE_FILE}" --recursive -pvs -b -o../../../../ ../../../../examples/
errorcode=$?
if [[ $errorcode -ne 0 ]]; then
exit $errorcode
exit $errorcode
fi

echo "test out of folder -o [vs]";
echo "Test out of folder -o [vs]"
rm -rf ../../../../../pg2
mkdir -p ../../../../../pg2
mkdir -p ../../../../../pg2

if ! command -v rsync &> /dev/null
then
cp -a ./projectGenerator ../../../../../pg2
cp -a ./"${EXE_FILE}" ../../../../../pg2
else
rsync -azp ./projectGenerator ../../../../../pg2
rsync -azp ./"${EXE_FILE}" ../../../../../pg2
fi

cd ../../../../../pg2
ls -a
pwd
./projectGenerator --recursive -pvs -o"./../openFrameworks" ./../openFrameworks/examples/

# Run the project generator executable again in the new directory
./"${EXE_FILE}" --recursive -pvs -b -o"./../openFrameworks" ./../openFrameworks/examples/
errorcode=$?
if [[ $errorcode -ne 0 ]]; then
exit $errorcode
exit $errorcode
fi

echo "Test generate new just name"
./projectGenerator -o"../openFrameworks" -p"vs" "testingGenerate"
./"${EXE_FILE}" -o"../openFrameworks" -p"vs" "testingGenerate"
errorcode=$?
if [[ $errorcode -ne 0 ]]; then
exit $errorcode
exit $errorcode
fi

echo "Test generate new / update full path"
./projectGenerator -o"../openFrameworks" -p"vs" "../openFrameworks/apps/myApps/testingGenerate"
./"${EXE_FILE}" -o"../openFrameworks" -p"vs" "../openFrameworks/apps/myApps/testingGenerate"
errorcode=$?
if [[ $errorcode -ne 0 ]]; then
exit $errorcode
exit $errorcode
fi

echo "Test generate full path"
./projectGenerator -o"../openFrameworks" -p"vs" "../openFrameworks/apps/myApps/testingGenerate2"
./"${EXE_FILE}" -o"../openFrameworks" -p"vs" "../openFrameworks/apps/myApps/testingGenerate2"
errorcode=$?
if [[ $errorcode -ne 0 ]]; then
exit $errorcode
exit $errorcode
fi
echo "Successful projectGenerator tests for [vs]";

echo "Successful projectGenerator tests for [vs]"